From 8abb673efbc4cccda9ed564eeebe4660a879647e Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Tue, 2 Feb 2010 07:28:10 +0100 Subject: Reinitialize paging. --- kernel/entry.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'kernel/entry.c') 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( -- cgit v1.2.3