xref: /xv6-public/memlayout.h (revision a56c8d60)
167d4254dSFrans Kaashoek // Memory layout
267d4254dSFrans Kaashoek 
367d4254dSFrans Kaashoek #define PGSIZE          4096            // bytes mapped by a page
467d4254dSFrans Kaashoek #define PGSHIFT         12              // log2(PGSIZE)
567d4254dSFrans Kaashoek 
667d4254dSFrans Kaashoek #define KSTKSIZE        (8*PGSIZE)              // size of a kernel stack
767d4254dSFrans Kaashoek 
867d4254dSFrans Kaashoek #define IOSPACEB  0x0A0000 // begin IO space
967d4254dSFrans Kaashoek #define IOSPACEE  0x100000  // end IO space
1067d4254dSFrans Kaashoek #define PHYSTOP   0xE000000 // use phys mem up to here as free pool
1167d4254dSFrans Kaashoek 
12*a56c8d60SFrans Kaashoek // Key addresses for address space layout (see kmap in vm.c for the layout)
1367d4254dSFrans Kaashoek #define KERNBASE 0xF0000000  // First kernel virtual address
1467d4254dSFrans Kaashoek #define USERTOP  (KERNBASE-PGSIZE)  // Highest user virtual address
1567d4254dSFrans Kaashoek #define KERNLINK 0xF0100000   // Address where kernel is linked
1667d4254dSFrans Kaashoek 
1767d4254dSFrans Kaashoek #ifndef __ASSEMBLER__
1867d4254dSFrans Kaashoek 
1967d4254dSFrans Kaashoek static inline uint v2p(void *a) { return (uint) a  - KERNBASE; }
2067d4254dSFrans Kaashoek static inline void *p2v(uint a) { return (void *) a + KERNBASE; }
2167d4254dSFrans Kaashoek 
2267d4254dSFrans Kaashoek #endif
2367d4254dSFrans Kaashoek 
2467d4254dSFrans Kaashoek #define V2P(a) ((uint) a - KERNBASE)
2567d4254dSFrans Kaashoek #define P2V(a) ((void *) a + KERNBASE)
2667d4254dSFrans Kaashoek 
27*a56c8d60SFrans Kaashoek #define V2P_WO(x) ((x) - KERNBASE)    // same as V2P, but without casts
28*a56c8d60SFrans Kaashoek #define P2V_WO(x) ((x) + KERNBASE)    // same as V2P, but without casts
29