From ee7a31ee017700c15b8c597b34882769c9bf1558 Mon Sep 17 00:00:00 2001 From: Guanqun Lu Date: Sun, 9 Mar 2008 00:07:53 +0800 Subject: [PATCH] check_boot_pgdir() passed. one point i'm still confusing is that how to implement this: * [KSTACKTOP-PTSIZE, KSTACKTOP-KSTKSIZE) -- not backed => faults Signed-off-by: Guanqun Lu --- kern/pmap.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/kern/pmap.c b/kern/pmap.c index b16e2f6..9ce96cd 100644 --- a/kern/pmap.c +++ b/kern/pmap.c @@ -209,8 +209,7 @@ i386_vm_init(void) // - pages -- kernel RW, user NONE // - the read-only version mapped at UPAGES -- kernel R, user R // Your code goes here: - - + boot_map_segment(pgdir, UPAGES, n, PADDR(pages), PTE_U); ////////////////////////////////////////////////////////////////////// // Map the kernel stack (symbol name "bootstack"). The complete VA @@ -220,6 +219,7 @@ i386_vm_init(void) // * [KSTACKTOP-PTSIZE, KSTACKTOP-KSTKSIZE) -- not backed => faults // Permissions: kernel RW, user NONE // Your code goes here: + boot_map_segment(pgdir, KSTACKTOP-KSTKSIZE, KSTKSIZE, PADDR(bootstack), PTE_W); ////////////////////////////////////////////////////////////////////// // Map all of physical memory at KERNBASE. @@ -229,6 +229,7 @@ i386_vm_init(void) // we just set up the amapping anyway. // Permissions: kernel RW, user NONE // Your code goes here: + boot_map_segment(pgdir, KERNBASE, 0xffffffff-KERNBASE+1, 0, PTE_W); // Check that the initial page directory has been set up correctly. check_boot_pgdir(); @@ -647,9 +648,10 @@ boot_map_segment(pde_t *pgdir, uintptr_t la, size_t size, physaddr_t pa, int per pte_t *pt; int i; + perm &= 0xfff; for (i = 0; i < size; i += PGSIZE) { pt = pgdir_walk(pgdir, (void *)(la + i), 1); - *pt = PTE_ADDR(pa + i) | (perm & 0xFFF) | PTE_P; + *pt = PTE_ADDR(pa + i) | perm | PTE_P; } } -- 2.11.4.GIT