ReactOS  r75385
mm.h
Go to the documentation of this file.
1 /*
2  * kernel internal memory management definitions for arm
3  */
4 #pragma once
5 
6 #define _MI_PAGING_LEVELS 2
7 
8 /* Memory layout base addresses */
9 #define MI_USER_PROBE_ADDRESS (PVOID)0x7FFF0000
10 #define MI_DEFAULT_SYSTEM_RANGE_START (PVOID)0x80000000
11 #define HYPER_SPACE 0xC0500000
12 #define HYPER_SPACE_END 0xC08FFFFF
13 #define MI_SYSTEM_CACHE_WS_START (PVOID)0xC0C00000
14 #define MI_PAGED_POOL_START (PVOID)0xE1000000
15 #define MI_NONPAGED_POOL_END (PVOID)0xFFBE0000
16 #define MI_DEBUG_MAPPING (PVOID)0xFFBFF000
17 
18 #define PTE_PER_PAGE 256
19 #define PDE_PER_PAGE 4096
20 #define PPE_PER_PAGE 1
21 
22 /* Misc address definitions */
23 #define MI_SYSTEM_PTE_BASE (PVOID)MiAddressToPte(NULL)
24 #define MM_HIGHEST_VAD_ADDRESS \
25  (PVOID)((ULONG_PTR)MM_HIGHEST_USER_ADDRESS - (16 * PAGE_SIZE))
26 #define MI_MAPPING_RANGE_START ((ULONG)HYPER_SPACE)
27 #define MI_MAPPING_RANGE_END (MI_MAPPING_RANGE_START + \
28  MI_HYPERSPACE_PTES * PAGE_SIZE)
29 #define MI_DUMMY_PTE (PMMPTE)(MI_MAPPING_RANGE_END + \
30  PAGE_SIZE)
31 #define MI_VAD_BITMAP (PMMPTE)(MI_DUMMY_PTE + \
32  PAGE_SIZE)
33 #define MI_WORKING_SET_LIST (PMMPTE)(MI_VAD_BITMAP + \
34  PAGE_SIZE)
35 
36 /* Memory sizes */
37 #define MI_MIN_PAGES_FOR_NONPAGED_POOL_TUNING ((255 * _1MB) >> PAGE_SHIFT)
38 #define MI_MIN_PAGES_FOR_SYSPTE_TUNING ((19 * _1MB) >> PAGE_SHIFT)
39 #define MI_MIN_PAGES_FOR_SYSPTE_BOOST ((32 * _1MB) >> PAGE_SHIFT)
40 #define MI_MIN_PAGES_FOR_SYSPTE_BOOST_BOOST ((256 * _1MB) >> PAGE_SHIFT)
41 #define MI_MIN_INIT_PAGED_POOLSIZE (32 * _1MB)
42 #define MI_MAX_INIT_NONPAGED_POOL_SIZE (128 * _1MB)
43 #define MI_MAX_NONPAGED_POOL_SIZE (128 * _1MB)
44 #define MI_SYSTEM_VIEW_SIZE (32 * _1MB)
45 #define MI_SESSION_VIEW_SIZE (48 * _1MB)
46 #define MI_SESSION_POOL_SIZE (16 * _1MB)
47 #define MI_SESSION_IMAGE_SIZE (8 * _1MB)
48 #define MI_SESSION_WORKING_SET_SIZE (4 * _1MB)
49 #define MI_SESSION_SIZE (MI_SESSION_VIEW_SIZE + \
50  MI_SESSION_POOL_SIZE + \
51  MI_SESSION_IMAGE_SIZE + \
52  MI_SESSION_WORKING_SET_SIZE)
53 #define MI_MIN_ALLOCATION_FRAGMENT (4 * _1KB)
54 #define MI_ALLOCATION_FRAGMENT (64 * _1KB)
55 #define MI_MAX_ALLOCATION_FRAGMENT (2 * _1MB)
56 
57 /* Misc constants */
58 #define MM_PTE_SOFTWARE_PROTECTION_BITS 6
59 #define MI_MIN_SECONDARY_COLORS 8
60 #define MI_SECONDARY_COLORS 64
61 #define MI_MAX_SECONDARY_COLORS 1024
62 #define MI_MAX_FREE_PAGE_LISTS 4
63 #define MI_HYPERSPACE_PTES (256 - 1) /* Dee PDR definition */
64 #define MI_ZERO_PTES (32) /* Dee PDR definition */
65 #define MI_MAX_ZERO_BITS 21
66 #define SESSION_POOL_LOOKASIDES 26 // CHECKME
67 
68 /* MMPTE related defines */
69 #define MM_EMPTY_PTE_LIST ((ULONG)0xFFFFF)
70 #define MM_EMPTY_LIST ((ULONG_PTR)-1)
71 
72 
73 /* Easy accessing PFN in PTE */
74 #define PFN_FROM_PTE(v) ((v)->u.Hard.PageFrameNumber)
75 
76 /* Macros for portable PTE modification */
77 #define MI_MAKE_DIRTY_PAGE(x)
78 #define MI_MAKE_CLEAN_PAGE(x)
79 #define MI_MAKE_ACCESSED_PAGE(x)
80 #define MI_PAGE_DISABLE_CACHE(x) ((x)->u.Hard.Cached = 0)
81 #define MI_PAGE_WRITE_THROUGH(x) ((x)->u.Hard.Buffered = 0)
82 #define MI_PAGE_WRITE_COMBINED(x) ((x)->u.Hard.Buffered = 1)
83 #define MI_IS_PAGE_LARGE(x) FALSE
84 #define MI_IS_PAGE_WRITEABLE(x) ((x)->u.Hard.ReadOnly == 0)
85 #define MI_IS_PAGE_COPY_ON_WRITE(x)FALSE
86 #define MI_IS_PAGE_DIRTY(x) TRUE
87 #define MI_MAKE_OWNER_PAGE(x) ((x)->u.Hard.Owner = 1)
88 #define MI_MAKE_WRITE_PAGE(x) ((x)->u.Hard.ReadOnly = 0)
89 
90 /* Convert an address to a corresponding PTE */
91 #define MiAddressToPte(x) \
92  ((PMMPTE)(PTE_BASE + (((ULONG)(x) >> 12) << 2)))
93 
94 /* Convert an address to a corresponding PDE */
95 #define MiAddressToPde(x) \
96  ((PMMPDE)(PDE_BASE + (((ULONG)(x) >> 20) << 2)))
97 
98 /* Convert an address to a corresponding PTE offset/index */
99 #define MiAddressToPteOffset(x) \
100  ((((ULONG)(x)) << 12) >> 24)
101 
102 /* Convert an address to a corresponding PDE offset/index */
103 #define MiAddressToPdeOffset(x) \
104  (((ULONG)(x)) >> 20)
105 #define MiGetPdeOffset MiAddressToPdeOffset
106 
107 /* Convert a PTE/PDE into a corresponding address */
108 #define MiPteToAddress(_Pte) ((PVOID)((ULONG)(_Pte) << 10))
109 #define MiPdeToAddress(_Pde) ((PVOID)((ULONG)(_Pde) << 18))
110 
111 /* Translate between P*Es */
112 #define MiPdeToPte(_Pde) ((PMMPTE)0) /* FIXME */
113 #define MiPteToPde(_Pte) ((PMMPDE)0) /* FIXME */
114 
115 /* Check P*E boundaries */
116 #define MiIsPteOnPdeBoundary(PointerPte) \
117  ((((ULONG_PTR)PointerPte) & (PAGE_SIZE - 1)) == 0)
118 
119 //
120 // Decodes a Prototype PTE into the underlying PTE
121 //
122 #define MiProtoPteToPte(x) \
123  (PMMPTE)((ULONG_PTR)MmPagedPoolStart + \
124  (((x)->u.Proto.ProtoAddressHigh << 9) | (x)->u.Proto.ProtoAddressLow << 2))
125 
126 //
127 // Decodes a Prototype PTE into the underlying PTE
128 //
129 #define MiSubsectionPteToSubsection(x) \
130  ((x)->u.Subsect.WhichPool == PagedPool) ? \
131  (PMMPTE)((ULONG_PTR)MmSubsectionBase + \
132  (((x)->u.Subsect.SubsectionAddressHigh << 7) | \
133  (x)->u.Subsect.SubsectionAddressLow << 3)) : \
134  (PMMPTE)((ULONG_PTR)MmNonPagedPoolEnd - \
135  (((x)->u.Subsect.SubsectionAddressHigh << 7) | \
136  (x)->u.Subsect.SubsectionAddressLow << 3))
137 
138 //
139 // Number of bits corresponding to the area that a coarse page table occupies (1KB)
140 //
141 #define CPT_SHIFT 10
142 
143 /* See PDR definition */
144 #define MI_ZERO_PTE (PMMPTE)(MI_MAPPING_RANGE_END + \
145  PAGE_SIZE)
146