rewrite the device subsystem interfaces (#48)
[lunaix-os.git] / lunaix-os / arch / x86 / includes / asm / mm_defs.h
1 #ifndef __LUNAIX_MM_DEFS_H
2 #define __LUNAIX_MM_DEFS_H
3
4 #include "mempart.h"
5 #include "pagetable.h"
6
7 /*
8     Regardless architecture we need to draw the line very carefully, and must 
9     take the size of VM into account. In general, we aims to achieve 
10     "sufficiently large" of memory for kernel
11
12     In terms of x86_32:
13         * #768~1022 PTEs of PD      (0x00000000c0000000, ~1GiB)
14     
15     In light of upcomming x86_64 support (for Level 4&5 Paging):
16         * #510 entry of PML4        (0x0000ff0000000000, ~512GiB)
17         * #510 entry of PML5        (0x01fe000000000000, ~256TiB)
18     
19
20     KERNEL_RESIDENT  -  a high-mem region, kernel should be
21     KSTACK_PAGES     -  kernel stack, pages allocated to
22     KEXEC_RSVD       -  page reserved for kernel images
23 */
24
25 #ifdef CONFIG_ARCH_X86_64
26 #   define KSTACK_PAGES            4
27 #   define KEXEC_RSVD              32
28 #else
29 #   define KSTACK_PAGES            2
30 #   define KEXEC_RSVD              16
31 #endif
32
33 #define KSTACK_SIZE             (KSTACK_PAGES * PAGE_SIZE)
34
35 #define kernel_addr(addr)       ((addr) >= KERNEL_RESIDENT || (addr) < USR_EXEC)
36
37 #define to_kphysical(k_va)      ((ptr_t)(k_va) - KERNEL_IMG)
38 #define to_kvirtual(k_pa)       ((ptr_t)(k_pa) + KERNEL_IMG)
39
40 #endif /* __LUNAIX_MM_DEFS_H */