From e25b74ca8069e340c3f2c267d09beed6d9328250 Mon Sep 17 00:00:00 2001 From: Frans Kaashoek Date: Thu, 1 Sep 2011 10:25:20 -0400 Subject: Fix layout issues for printed version --- vm.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'vm.c') diff --git a/vm.c b/vm.c index 32775a1..c7f7315 100644 --- a/vm.c +++ b/vm.c @@ -68,7 +68,8 @@ walkpgdir(pde_t *pgdir, const void *va, char* (*alloc)(void)) // physical addresses starting at pa. va and size might not // be page-aligned. static int -mappages(pde_t *pgdir, void *va, uint size, uint pa, int perm, char* (*alloc)(void)) +mappages(pde_t *pgdir, void *va, uint size, uint pa, int perm, + char* (*alloc)(void)) { char *a, *last; pte_t *pte; @@ -91,19 +92,21 @@ mappages(pde_t *pgdir, void *va, uint size, uint pa, int perm, char* (*alloc)(vo } // The mappings from logical to virtual are one to one (i.e., -// segmentation doesn't do anything). -// There is one page table per process, plus one that's used -// when a CPU is not running any process (kpgdir). -// A user process uses the same page table as the kernel; the -// page protection bits prevent it from using anything other -// than its memory. +// segmentation doesn't do anything). There is one page table per +// process, plus one that's used when a CPU is not running any +// process (kpgdir). A user process uses the same page table as +// the kernel; the page protection bits prevent it from using +// anything other than its memory. // // setupkvm() and exec() set up every page table like this: -// 0..KERNBASE : user memory (text, data, stack, heap), mapped to some unused phys mem -// KERNBASE..KERNBASE+EXTMEM: mapped to 0..EXTMEM (below extended memory) -// KERNBASE+EXTMEM..KERNBASE+end : mapped to EXTMEM..end (mapped without write permission) -// KERNBASE+end..KERBASE+PHYSTOP : mapped to end..PHYSTOP (rw data + free memory) -// 0xfe000000..0 : mapped direct (devices such as ioapic) +// 0..KERNBASE: user memory (text+data+stack+heap), mapped to some free +// phys memory +// KERNBASE..KERNBASE+EXTMEM: mapped to 0..EXTMEM (for I/O space) +// KERNBASE+EXTMEM..KERNBASE+end: mapped to EXTMEM..end kernel, +// w. no write permission +// KERNBASE+end..KERBASE+PHYSTOP: mapped to end..PHYSTOP, +// rw data + free memory +// 0xfe000000..0: mapped direct (devices such as ioapic) // // The kernel allocates memory for its heap and for user memory // between kernend and the end of physical memory (PHYSTOP). @@ -116,8 +119,8 @@ static struct kmap { uint phys_end; int perm; } kmap[] = { - { P2V(0), 0, 1024*1024, PTE_W}, // First 1Mbyte contains BIOS and some IO devices - { (void *)KERNLINK, V2P(KERNLINK), V2P(data), 0}, // kernel text, rodata + { P2V(0), 0, 1024*1024, PTE_W}, // I/O space + { (void *)KERNLINK, V2P(KERNLINK), V2P(data), 0}, // kernel text+rodata { data, V2P(data), PHYSTOP, PTE_W}, // kernel data, memory { (void*)DEVSPACE, DEVSPACE, 0, PTE_W}, // more devices }; @@ -136,8 +139,8 @@ setupkvm(char* (*alloc)(void)) if (p2v(PHYSTOP) > (void *) DEVSPACE) panic("PHYSTOP too high"); for(k = kmap; k < &kmap[NELEM(kmap)]; k++) - if(mappages(pgdir, k->virt, k->phys_end - k->phys_start, (uint)k->phys_start, - k->perm, alloc) < 0) + if(mappages(pgdir, k->virt, k->phys_end - k->phys_start, + (uint)k->phys_start, k->perm, alloc) < 0) return 0; return pgdir; -- cgit v1.2.3