2 * Acess2 x86_64 Architecture Code
4 * This file is published under the terms of the Acess Licence.
5 * See the file COPYING for more details
7 * vmem.h - Virtual Memory Functions & Definitions
14 #define PAGE_SIZE 0x1000
16 // === Memory Location Definitions ===
18 * Userland - Lower Half
19 * Kernel land - Upper Half
21 * START ADDRESS END ADDRESS BITS SIZE NAME
22 * 0x00000000 00000000 - 0x00007FFF FFFFFFFF 47 128 TiB User Space
23 * 0x00008000 00000000 - 0xFFFF7FFF FFFFFFFF --- SIGN EXTENSION NULL ZONE
24 * 0xFFFF8000 00000000 - 0xFFFFFFFF FFFFFFFF 47 128 TiB Kernel Range
25 * 8000 00000000 - 9000 00000000 42 16 TiB Kernel Heap
26 * 9000 00000000 - 9800 00000000 43 8 TiB Module Space
27 * 9800 00000000 - 9A00 00000000 41 2 TiB Kernel VFS
29 * A000 00000000 - B000 00000000 44 16 TiB Kernel Stacks
30 * C000 00000000 - D000 00000000 44 16 TiB Hardware Mappings
31 * D000 00000000 - D080 00000000 39 512 GiB Per-Process Data
32 * D080 00000000 - D100 00000000 39 512 GiB Kernel Supplied User Code
33 * ---- GAP ---- 15 TiB
34 * E000 00000000 - E800 00000000 43 8 TiB Physical Page Nodes (2**40 pages * 8 bytes)
35 * E800 00000000 - EC00 00000000 42 4 TiB Physical Page Reference Counts (2**40 pg * 4 bytes)
36 * EC00 00000000 - EC80 00000000 39 512 GiB Physical Page Bitmap (1 page per bit)
37 * EC80 00000000 - ED00 00000000 39 512 GiB Physical Page DblAlloc Bitmap (1 page per bit)
38 * ED00 00000000 - ED00 80000000 31 2 GiB Physical Page Super Bitmap (64 pages per bit)
40 * FE00 00000000 - FE80 00000000 39 512 GiB Fractal Mapping (PML4 508)
41 * FE80 00000000 - FF00 00000000 39 512 GiB Temp Fractal Mapping
42 * FF00 00000000 - FF80 00000000 39 512 GiB Temporary page mappings
43 * FF80 00000000 - FF80 80000000 31 2 GiB Local APIC
44 * ---- GAP ---- 506 GiB
45 * FFFF 00000000 - FFFF 80000000 31 2 GiB User Code
46 * FFFF 80000000 - FFFF FFFFFFFF 31 2 GiB Kernel code / data
49 #define MM_USER_MIN 0x00000000##00010000
50 #define USER_LIB_MAX 0x00007000##00000000
51 #define USER_STACK_PREALLOC 0x00000000##00002000 // 8 KiB
52 #define USER_STACK_SZ 0x00000000##00020000 // 64 KiB
53 #define USER_STACK_TOP 0x00008000##00000000
54 #define MM_KERNEL_RANGE 0xFFFF8000##00000000
55 #define MM_KHEAP_BASE (MM_KERNEL_RANGE|(0x8000##00000000))
56 #define MM_KHEAP_MAX (MM_KERNEL_RANGE|(0x9000##00000000))
57 #define MM_MODULE_MIN (MM_KERNEL_RANGE|(0x9000##00000000))
58 #define MM_MODULE_MAX (MM_KERNEL_RANGE|(0x9800##00000000))
59 #define MM_KERNEL_VFS (MM_KERNEL_RANGE|(0x9800##00000000))
60 #define MM_KSTACK_BASE (MM_KERNEL_RANGE|(0xA000##00000000))
61 #define MM_KSTACK_TOP (MM_KERNEL_RANGE|(0xB000##00000000))
63 #define MM_HWMAP_BASE (MM_KERNEL_RANGE|(0xC000##00000000))
64 #define MM_HWMAP_TOP (MM_KERNEL_RANGE|(0xD000##00000000))
65 #define MM_PPD_BASE (MM_KERNEL_RANGE|(0xD000##00000000))
66 #define MM_PPD_CFG MM_PPD_BASE
67 #define MM_PPD_HANDLES (MM_KERNEL_RANGE|(0xD008##00000000))
68 #define MM_USER_CODE (MM_KERNEL_RANGE|(0xD080##00000000))
70 #define MM_PAGE_NODES (MM_KERNEL_RANGE|(0xE000##00000000))
71 #define MM_PAGE_COUNTS (MM_KERNEL_RANGE|(0xE800##00000000))
72 #define MM_PAGE_BITMAP (MM_KERNEL_RANGE|(0xEC00##00000000))
73 #define MM_PAGE_DBLBMP (MM_KERNEL_RANGE|(0xEC00##00000000))
74 #define MM_PAGE_SUPBMP (MM_KERNEL_RANGE|(0xED00##00000000))
76 #define MM_FRACTAL_BASE (MM_KERNEL_RANGE|(0xFE00##00000000))
77 #define MM_TMPFRAC_BASE (MM_KERNEL_RANGE|(0xFE80##00000000))
78 #define MM_TMPMAP_BASE (MM_KERNEL_RANGE|(0xFF00##00000000))
79 #define MM_TMPMAP_END (MM_KERNEL_RANGE|(0xFF80##00000000))
80 #define MM_LOCALAPIC (MM_KERNEL_RANGE|(0xFF80##00000000))
81 #define MM_KERNEL_CODE (MM_KERNEL_RANGE|(0xFFFF##80000000))
85 void MM_FinishVirtualInit(void);
86 tVAddr MM_NewKStack(void);
87 tVAddr MM_Clone(void);
88 tVAddr MM_NewWorkerStack(void *StackData, size_t StackSize);