aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/idt.cc1
-rw-r--r--src/core/int.S3
-rw-r--r--src/core/paging.cc23
3 files changed, 17 insertions, 10 deletions
diff --git a/src/core/idt.cc b/src/core/idt.cc
index 25264b6..d2b7ccc 100644
--- a/src/core/idt.cc
+++ b/src/core/idt.cc
@@ -1,4 +1,5 @@
#include "idt.hpp"
+#include "boucane.hpp"
#include "core/paging.hpp"
#include "libs/string.hpp"
diff --git a/src/core/int.S b/src/core/int.S
index daf0224..861d5cc 100644
--- a/src/core/int.S
+++ b/src/core/int.S
@@ -6,7 +6,8 @@
.macro call_printk msg
mov \msg, %rdi
mov $0, %eax # Required for variadic functions
- call printk
+ mov $printk,%rcx
+ call *(%rcx)
.endm
.globl INT_DEFAULT
diff --git a/src/core/paging.cc b/src/core/paging.cc
index b21e660..b12fb4c 100644
--- a/src/core/paging.cc
+++ b/src/core/paging.cc
@@ -36,7 +36,10 @@ void paging_enable() {
// Setting up new kernel address space
for(u64 i=0;i<=0x10000000;i+=4096){
+ // Higher half mapping
PAGE_MAP(i);
+ // Allow access to RAM:
+ paging_allocate_addr(kpages[0], i, i, PAGING_OPT_P|PAGING_OPT_RW, 1);
}
// 4096 bytes stack
@@ -145,32 +148,35 @@ void paging_allocate_addr(u64* pml4_table, u64 virt, u64 phy, u16 options, char
// Solve pdp
if(pml4_table[pml4] == 0){
- pml4_table[pml4]=(u64)(useKernelTables ? paging_allocate_table() : VIRT(PAGE_ALLOCATE()));
+ pml4_table[pml4]=(u64)(useKernelTables ? paging_allocate_table() : PAGE_ALLOCATE());
pml4_table[pml4]|=options;
paging_allocate_addr(pml4_table,virt,phy,options,useKernelTables);
return;
}
// Solve pd
- u64* pdp_table=(u64*)(VIRT(PAGE(pml4_table[pml4])));
+ u64* pdp_table=(u64*)(PAGE(pml4_table[pml4]));
+ pdp_table=useKernelTables ? VIRT(pdp_table) : pdp_table;
if(pdp_table[pdp] == 0){
- pdp_table[pdp]=(u64)(useKernelTables ? paging_allocate_table() : VIRT(PAGE_ALLOCATE()));
+ pdp_table[pdp]=(u64)(useKernelTables ? paging_allocate_table() : PAGE_ALLOCATE());
pdp_table[pdp]|=options;
paging_allocate_addr(pml4_table,virt,phy,options,useKernelTables);
return;
}
// Solve pt
- u64* pd_table=(u64*)(VIRT(PAGE(pdp_table[pdp])));
+ u64* pd_table=(u64*)(PAGE(pdp_table[pdp]));
+ pd_table=useKernelTables ? VIRT(pd_table) : pd_table;
if(pd_table[pd] == 0){
- pd_table[pd]=(u64)(useKernelTables ? paging_allocate_table() : VIRT(PAGE_ALLOCATE()));
+ pd_table[pd]=(u64)(useKernelTables ? paging_allocate_table() : PAGE_ALLOCATE());
pd_table[pd]|=options;
paging_allocate_addr(pml4_table,virt,phy,options,useKernelTables);
return;
}
// Solve address
- u64* pt_table=(u64*)(VIRT(PAGE(pd_table[pd])));
+ u64* pt_table=(u64*)(PAGE(pd_table[pd]));
+ pt_table=useKernelTables ? VIRT(pt_table) : pt_table;
if(pt_table[pt] == 0){
pt_table[pt]=PAGE(phy);
pt_table[pt]|=options;
@@ -180,8 +186,7 @@ void paging_allocate_addr(u64* pml4_table, u64 virt, u64 phy, u16 options, char
}
u64* paging_create_task(int npages){
- u64 *pml4=VIRT(PAGE_ALLOCATE());
- u64 sum=(u64)pml4+kvar_kernel_vma;
- paging_allocate_addr(pml4, 0, (u64)PAGE_ALLOCATE(), PAGING_OPT_P|PAGING_OPT_RW, 0);
+ u64 *pml4=PAGE_ALLOCATE();
+ // paging_allocate_addr(pml4, 0, (u64)PAGE_ALLOCATE(), PAGING_OPT_P|PAGING_OPT_RW, 0);
return pml4;
} \ No newline at end of file