Merge branch 'master' of git+ssh://amsterdam.csail.mit.edu/home/am0/6.828/xv6

Conflicts:
	vm.c
This commit is contained in:
Robert Morris 2011-09-01 12:03:49 -04:00
commit 62e3b8a92c
9 changed files with 67 additions and 57 deletions

32
vm.c
View file

@ -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;