summaryrefslogtreecommitdiff
path: root/kernel/entry.c
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2010-02-02 07:28:10 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2010-02-02 07:28:10 +0100
commit8abb673efbc4cccda9ed564eeebe4660a879647e (patch)
tree9709fd49dbc70838b77d290a338a1d230ea27f27 /kernel/entry.c
parent273967f16dad471478bbca2a14a5282faae95679 (diff)
Reinitialize paging.
Diffstat (limited to 'kernel/entry.c')
-rw-r--r--kernel/entry.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/kernel/entry.c b/kernel/entry.c
index 6058910..2ec5089 100644
--- a/kernel/entry.c
+++ b/kernel/entry.c
@@ -1,4 +1,5 @@
#include "kernel.h"
+#include "paging.h"
extern void main();
@@ -46,25 +47,27 @@ void entry_main(uint32_t mb_magic, multiboot_info_t* mb_info) {
entry_pagedir[i] = 0;
// Identity mapping of the current code.
- //entry_pagetable_low[i] = ((uint32_t)&addr_phys & 0xffc00000) | (i << 12) | 0x003;
- entry_pagetable_low[i] = ((uint32_t)&addr_phys & 0xffc00000) | (i << 12) | 0x007;
+ entry_pagetable_low[i] = ((uint32_t)&addr_phys & 0xffc00000) | (i << 12) | P1_P | P1_W;
// Map kernelspace.
if((i << 12) < ((uint32_t)&addr_virt_end & 0x003fffff)) {
- entry_pagetable_high[i] = ((uint32_t)&addr_load_virt + (i << 12)) | 0x003;
+ entry_pagetable_high[i] = ((uint32_t)&addr_load_virt + (i << 12)) | P1_P | P1_W | P1_G;
} else {
entry_pagetable_high[i] = 0;
}
}
- entry_pagetable_high[((uint32_t)&multiboot_info & 0x003ff000) >> 12] = (uint32_t)&entry_multiboot | 0x003;
+ entry_pagetable_high[((uint32_t)&multiboot_info & 0x003ff000) >> 12] = (uint32_t)&entry_multiboot | P1_P | P1_W | P1_G;
- entry_pagedir[(uint32_t)&addr_phys >> 22] = (uint32_t)&entry_pagetable_low | 0x007;
- entry_pagedir[(uint32_t)&addr_virt >> 22] = (uint32_t)&entry_pagetable_high | 0x003;
+ entry_pagedir[(uint32_t)&addr_phys >> 22] = (uint32_t)&entry_pagetable_low | P2_P | P2_W;
+ entry_pagedir[(uint32_t)&addr_virt >> 22] = (uint32_t)&entry_pagetable_high | P2_P | P2_W | P2_G;
+
+ // Map map_p1.
+ entry_pagedir[1022] = (uint32_t)&entry_pagedir | P2_P | P2_W | P2_G;
// Mapping stack to top without creating another page directory.
- entry_pagetable_high[1023] = (uint32_t)&entry_stack | 0x003;
- entry_pagedir[1023] = (uint32_t)&entry_pagetable_high | 0x003;
+ entry_pagetable_low[1023] = (uint32_t)&entry_stack | P1_P | P1_W | P1_G;
+ entry_pagedir[1023] = (uint32_t)&entry_pagetable_low | P2_P | P2_W | P2_G;
// Enable paging.
asm volatile(