diff options
author | Frans Kaashoek <[email protected]> | 2011-08-16 15:47:22 -0400 |
---|---|---|
committer | Frans Kaashoek <[email protected]> | 2011-08-16 15:47:22 -0400 |
commit | c3dcf479663bc1bc9144c39ba2dd7607ea9c1c52 (patch) | |
tree | f3c00fcd2a86748a615edb8f01ed56c45dd9f474 /mmu.h | |
parent | 427958cb71e485cec4e7c68b280b506e555dd8e0 (diff) | |
download | xv6-labs-c3dcf479663bc1bc9144c39ba2dd7607ea9c1c52.tar.gz xv6-labs-c3dcf479663bc1bc9144c39ba2dd7607ea9c1c52.tar.bz2 xv6-labs-c3dcf479663bc1bc9144c39ba2dd7607ea9c1c52.zip |
Clean up memlayout.h
Get rid of last instances of linear address and "la"
Get ready for detecting physical memory dynamically
Diffstat (limited to 'mmu.h')
-rw-r--r-- | mmu.h | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -100,32 +100,34 @@ struct segdesc { #define STS_IG32 0xE // 32-bit Interrupt Gate #define STS_TG32 0xF // 32-bit Trap Gate -// A linear address 'la' has a three-part structure as follows: +// A virtual address 'la' has a three-part structure as follows: // // +--------10------+-------10-------+---------12----------+ // | Page Directory | Page Table | Offset within Page | // | Index | Index | | // +----------------+----------------+---------------------+ -// \--- PDX(la) --/ \--- PTX(la) --/ +// \--- PDX(va) --/ \--- PTX(va) --/ // page directory index -#define PDX(la) (((uint)(la) >> PDXSHIFT) & 0x3FF) +#define PDX(va) (((uint)(va) >> PDXSHIFT) & 0x3FF) // page table index -#define PTX(la) (((uint)(la) >> PTXSHIFT) & 0x3FF) +#define PTX(va) (((uint)(va) >> PTXSHIFT) & 0x3FF) -// construct linear address from indexes and offset +// construct virtual address from indexes and offset #define PGADDR(d, t, o) ((uint)((d) << PDXSHIFT | (t) << PTXSHIFT | (o))) // Page directory and page table constants. #define NPDENTRIES 1024 // page directory entries per page directory #define NPTENTRIES 1024 // page table entries per page table +#define PGSIZE 4096 // bytes mapped by a page +#define PGSHIFT 12 // log2(PGSIZE) #define PTXSHIFT 12 // offset of PTX in a linear address #define PDXSHIFT 22 // offset of PDX in a linear address #define PGROUNDUP(sz) (((sz)+PGSIZE-1) & ~(PGSIZE-1)) -#define PGROUNDDOWN(a) ((char*)((((unsigned int)(a)) & ~(PGSIZE-1)))) +#define PGROUNDDOWN(a) (((a)) & ~(PGSIZE-1)) // Page table/directory entry flags. #define PTE_P 0x001 // Present |