diff options
author | Robert Morris <[email protected]> | 2011-09-01 12:03:49 -0400 |
---|---|---|
committer | Robert Morris <[email protected]> | 2011-09-01 12:03:49 -0400 |
commit | 62e3b8a92c6f8840cec8a0db13b2bcad10192b4a (patch) | |
tree | 6186d2ac5e654ba71f8f45ae9956c560d7251dfc /vm.c | |
parent | 5a236924444db768813d726ae165d263856d8bff (diff) | |
parent | d0f3efca650eccd5179e045cd07f7d723037defc (diff) | |
download | xv6-labs-62e3b8a92c6f8840cec8a0db13b2bcad10192b4a.tar.gz xv6-labs-62e3b8a92c6f8840cec8a0db13b2bcad10192b4a.tar.bz2 xv6-labs-62e3b8a92c6f8840cec8a0db13b2bcad10192b4a.zip |
Merge branch 'master' of git+ssh://amsterdam.csail.mit.edu/home/am0/6.828/xv6
Conflicts:
vm.c
Diffstat (limited to 'vm.c')
-rw-r--r-- | vm.c | 32 |
1 files changed, 17 insertions, 15 deletions
@@ -92,19 +92,21 @@ mappages(pde_t *pgdir, void *va, uint size, uint pa, } // 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). @@ -117,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 }; @@ -137,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; |