xref: /xv6-public/memlayout.h (revision 67d4254d)
1*67d4254dSFrans Kaashoek // Memory layout
2*67d4254dSFrans Kaashoek 
3*67d4254dSFrans Kaashoek #define PGSIZE          4096            // bytes mapped by a page
4*67d4254dSFrans Kaashoek #define PGSHIFT         12              // log2(PGSIZE)
5*67d4254dSFrans Kaashoek 
6*67d4254dSFrans Kaashoek #define KSTKSIZE        (8*PGSIZE)              // size of a kernel stack
7*67d4254dSFrans Kaashoek 
8*67d4254dSFrans Kaashoek #define IOSPACEB  0x0A0000 // begin IO space
9*67d4254dSFrans Kaashoek #define IOSPACEE  0x100000  // end IO space
10*67d4254dSFrans Kaashoek #define PHYSTOP   0xE000000 // use phys mem up to here as free pool
11*67d4254dSFrans Kaashoek 
12*67d4254dSFrans Kaashoek // Key addresses for address space layout (see kmap in vm.c for the actual layout)
13*67d4254dSFrans Kaashoek #define KERNBASE 0xF0000000  // First kernel virtual address
14*67d4254dSFrans Kaashoek #define USERTOP  (KERNBASE-PGSIZE)  // Highest user virtual address
15*67d4254dSFrans Kaashoek #define KERNLINK 0xF0100000   // Address where kernel is linked
16*67d4254dSFrans Kaashoek 
17*67d4254dSFrans Kaashoek #ifndef __ASSEMBLER__
18*67d4254dSFrans Kaashoek 
19*67d4254dSFrans Kaashoek static inline uint v2p(void *a) { return (uint) a  - KERNBASE; }
20*67d4254dSFrans Kaashoek static inline void *p2v(uint a) { return (void *) a + KERNBASE; }
21*67d4254dSFrans Kaashoek 
22*67d4254dSFrans Kaashoek #endif
23*67d4254dSFrans Kaashoek 
24*67d4254dSFrans Kaashoek #define V2P(a) ((uint) a - KERNBASE)
25*67d4254dSFrans Kaashoek #define P2V(a) ((void *) a + KERNBASE)
26*67d4254dSFrans Kaashoek 
27