diff options
author | Frans Kaashoek <[email protected]> | 2011-08-16 20:23:17 -0400 |
---|---|---|
committer | Frans Kaashoek <[email protected]> | 2011-08-16 20:23:17 -0400 |
commit | 5f069dcf2f9d833a6c4f58ed87269d61c6abb687 (patch) | |
tree | 4756e313b7681bbbb4a4c2d1879031bee6130681 /vm.c | |
parent | c3dcf479663bc1bc9144c39ba2dd7607ea9c1c52 (diff) | |
download | xv6-labs-5f069dcf2f9d833a6c4f58ed87269d61c6abb687.tar.gz xv6-labs-5f069dcf2f9d833a6c4f58ed87269d61c6abb687.tar.bz2 xv6-labs-5f069dcf2f9d833a6c4f58ed87269d61c6abb687.zip |
Switch back to #define for PHYSTOP. Using the E820 to retrieve the memory map is too complicated (must be done in 16-bit real-mode, probably enlarged bootblock beyond 512 bytes, and a #define requires less explanation).
Diffstat (limited to 'vm.c')
-rw-r--r-- | vm.c | 16 |
1 files changed, 5 insertions, 11 deletions
@@ -8,7 +8,6 @@ #include "elf.h" extern char data[]; // defined in data.S -uint maxpa; // max physical address pde_t *kpgdir; // for use in scheduler() struct segdesc gdt[NSEGS]; @@ -103,11 +102,11 @@ mappages(pde_t *pgdir, void *va, uint size, uint pa, int perm, char* (*alloc)(vo // 0..USERTOP : 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+maxpa : mapped to end..maxpa (rw data + free memory) +// 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 (maxpa). +// between kernend and the end of physical memory (PHYSTOP). // The virtual address space of each user program includes the kernel // (which is inaccessible in user mode). The user program sits in // the bottom of the address space, and the kernel at the top at KERNBASE. @@ -119,7 +118,7 @@ static struct kmap { } 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 - { data, V2P(data), 0, PTE_W}, // kernel data, memory + { data, V2P(data), PHYSTOP, PTE_W}, // kernel data, memory { (void*)DEVSPACE, DEVSPACE, 0, PTE_W}, // more devices }; @@ -130,17 +129,12 @@ setupkvm(char* (*alloc)(void)) pde_t *pgdir; struct kmap *k; - if (kmap[2].phys_end == 0) { - maxpa = detect_memory(); - kmap[2].phys_end = maxpa; - if (p2v(maxpa) > kmap[3].virt) - panic("detect_memory: too much memory"); - - } if((pgdir = (pde_t*)alloc()) == 0) return 0; memset(pgdir, 0, PGSIZE); k = kmap; + 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) |