Fix layout issues for printed version
This commit is contained in:
parent
15997d5849
commit
e25b74ca80
7 changed files with 55 additions and 57 deletions
35
vm.c
35
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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue