- Update NDK to remove zwfuncs.h and place the native functions in their respective...
[reactos.git] / reactos / include / ndk / mmtypes.h
1 /*++ NDK Version: 0095
2
3 Copyright (c) Alex Ionescu. All rights reserved.
4
5 Header Name:
6
7 mmtypes.h
8
9 Abstract:
10
11 Type definitions for the Memory Manager
12
13 Author:
14
15 Alex Ionescu (alex.ionescu@reactos.com) 06-Oct-2004
16
17 --*/
18
19 #ifndef _MMTYPES_H
20 #define _MMTYPES_H
21
22 //
23 // Dependencies
24 //
25 #include <umtypes.h>
26 #include <arch/mmtypes.h>
27
28 //
29 // Page-Rounding Macros
30 //
31 #define PAGE_ROUND_DOWN(x) (((ULONG)x)&(~(PAGE_SIZE-1)))
32 #define PAGE_ROUND_UP(x) \
33 ( (((ULONG)x)%PAGE_SIZE) ? ((((ULONG)x)&(~(PAGE_SIZE-1)))+PAGE_SIZE) : ((ULONG)x) )
34
35 //
36 // Macro for generating pool tags
37 //
38 #define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24))
39
40 #ifdef NTOS_MODE_USER
41
42 //
43 // Section Flags for NtCreateSection
44 //
45 #define SEC_BASED 0x00200000
46 #define SEC_NO_CHANGE 0x00400000
47
48 //
49 // Section Inherit Flags for NtCreateSection
50 //
51 typedef enum _SECTION_INHERIT
52 {
53 ViewShare = 1,
54 ViewUnmap = 2
55 } SECTION_INHERIT;
56
57 //
58 // Pool Types
59 //
60 typedef enum _POOL_TYPE
61 {
62 NonPagedPool,
63 PagedPool,
64 NonPagedPoolMustSucceed,
65 DontUseThisType,
66 NonPagedPoolCacheAligned,
67 PagedPoolCacheAligned,
68 NonPagedPoolCacheAlignedMustS,
69 MaxPoolType,
70 NonPagedPoolSession = 32,
71 PagedPoolSession,
72 NonPagedPoolMustSucceedSession,
73 DontUseThisTypeSession,
74 NonPagedPoolCacheAlignedSession,
75 PagedPoolCacheAlignedSession,
76 NonPagedPoolCacheAlignedMustSSession
77 } POOL_TYPE;
78 #endif
79
80 //
81 // Per Processor Non Paged Lookaside List IDs
82 //
83 typedef enum _PP_NPAGED_LOOKASIDE_NUMBER
84 {
85 LookasideSmallIrpList = 0,
86 LookasideLargeIrpList = 1,
87 LookasideMdlList = 2,
88 LookasideCreateInfoList = 3,
89 LookasideNameBufferList = 4,
90 LookasideTwilightList = 5,
91 LookasideCompletionList = 6,
92 LookasideMaximumList = 7
93 } PP_NPAGED_LOOKASIDE_NUMBER;
94
95 //
96 // Memory Information Classes for NtQueryVirtualMemory
97 //
98 typedef enum _MEMORY_INFORMATION_CLASS
99 {
100 MemoryBasicInformation,
101 MemoryWorkingSetList,
102 MemorySectionName,
103 MemoryBasicVlmInformation
104 } MEMORY_INFORMATION_CLASS;
105
106 //
107 // Section Information Clasess for NtQuerySection
108 //
109 typedef enum _SECTION_INFORMATION_CLASS
110 {
111 SectionBasicInformation,
112 SectionImageInformation,
113 } SECTION_INFORMATION_CLASS;
114
115 #ifdef NTOS_MODE_USER
116
117 //
118 // Virtual Memory Counters
119 //
120 typedef struct _VM_COUNTERS
121 {
122 SIZE_T PeakVirtualSize;
123 SIZE_T VirtualSize;
124 ULONG PageFaultCount;
125 SIZE_T PeakWorkingSetSize;
126 SIZE_T WorkingSetSize;
127 SIZE_T QuotaPeakPagedPoolUsage;
128 SIZE_T QuotaPagedPoolUsage;
129 SIZE_T QuotaPeakNonPagedPoolUsage;
130 SIZE_T QuotaNonPagedPoolUsage;
131 SIZE_T PagefileUsage;
132 SIZE_T PeakPagefileUsage;
133 } VM_COUNTERS, *PVM_COUNTERS;
134
135 typedef struct _VM_COUNTERS_EX
136 {
137 SIZE_T PeakVirtualSize;
138 SIZE_T VirtualSize;
139 ULONG PageFaultCount;
140 SIZE_T PeakWorkingSetSize;
141 SIZE_T WorkingSetSize;
142 SIZE_T QuotaPeakPagedPoolUsage;
143 SIZE_T QuotaPagedPoolUsage;
144 SIZE_T QuotaPeakNonPagedPoolUsage;
145 SIZE_T QuotaNonPagedPoolUsage;
146 SIZE_T PagefileUsage;
147 SIZE_T PeakPagefileUsage;
148 SIZE_T PrivateUsage;
149 } VM_COUNTERS_EX, *PVM_COUNTERS_EX;
150 #endif
151
152 //
153 // List of Working Sets
154 //
155 typedef struct _MEMORY_WORKING_SET_LIST
156 {
157 ULONG NumberOfPages;
158 ULONG WorkingSetList[1];
159 } MEMORY_WORKING_SET_LIST, *PMEMORY_WORKING_SET_LIST;
160
161 //
162 // Memory Information Structures for NtQueryVirtualMemory
163 //
164 typedef struct
165 {
166 UNICODE_STRING SectionFileName;
167 WCHAR NameBuffer[ANYSIZE_ARRAY];
168 } MEMORY_SECTION_NAME, *PMEMORY_SECTION_NAME;
169
170 //
171 // Section Information Structures for NtQuerySection
172 //
173 typedef struct _SECTION_BASIC_INFORMATION
174 {
175 PVOID BaseAddress;
176 ULONG Attributes;
177 LARGE_INTEGER Size;
178 } SECTION_BASIC_INFORMATION, *PSECTION_BASIC_INFORMATION;
179
180 typedef struct _SECTION_IMAGE_INFORMATION
181 {
182 PVOID TransferAddress;
183 ULONG ZeroBits;
184 ULONG MaximumStackSize;
185 ULONG CommittedStackSize;
186 ULONG SubsystemType;
187 USHORT SubSystemMinorVersion;
188 USHORT SubSystemMajorVersion;
189 ULONG GpValue;
190 USHORT ImageCharacteristics;
191 USHORT DllChracteristics;
192 USHORT Machine;
193 UCHAR ImageContainsCode;
194 UCHAR Spare1;
195 ULONG LoaderFlags;
196 ULONG ImageFileSIze;
197 ULONG Reserved[1];
198 } SECTION_IMAGE_INFORMATION, *PSECTION_IMAGE_INFORMATION;
199
200 #ifndef NTOS_MODE_USER
201
202 //
203 // FIXME: REACTOS SPECIFIC HACK IN EPROCESS
204 //
205 typedef struct _MADDRESS_SPACE
206 {
207 struct _MEMORY_AREA *MemoryAreaRoot;
208 FAST_MUTEX Lock;
209 PVOID LowestAddress;
210 struct _EPROCESS* Process;
211 PUSHORT PageTableRefCountTable;
212 ULONG PageTableRefCountTableSize;
213 } MADDRESS_SPACE, *PMADDRESS_SPACE;
214
215 //
216 // Generic Address Range Structure
217 //
218 typedef struct _ADDRESS_RANGE
219 {
220 ULONG BaseAddrLow;
221 ULONG BaseAddrHigh;
222 ULONG LengthLow;
223 ULONG LengthHigh;
224 ULONG Type;
225 } ADDRESS_RANGE, *PADDRESS_RANGE;
226
227 //
228 // Node in Memory Manager's AVL Table
229 //
230 typedef struct _MMADDRESS_NODE
231 {
232 union
233 {
234 ULONG Balance:2;
235 struct _MMADDRESS_NODE *Parent;
236 } u1;
237 struct _MMADDRESS_NODE *LeftChild;
238 struct _MMADDRESS_NODE *RightChild;
239 ULONG StartingVpn;
240 ULONG EndingVpn;
241 } MMADDRESS_NODE, *PMMADDRESS_NODE;
242
243 //
244 // Memory Manager AVL Table for VADs and other descriptors
245 //
246 typedef struct _MM_AVL_TABLE
247 {
248 MMADDRESS_NODE BalancedRoot;
249 ULONG DepthOfTree:5;
250 ULONG Unused:3;
251 ULONG NumberGenericTableElements:24;
252 PVOID NodeHint;
253 PVOID NodeFreeHint;
254 } MM_AVL_TABLE, *PMM_AVL_TABLE;
255
256 //
257 // Memory Manager Working Set Structures
258 //
259 typedef struct _MMWSLENTRY
260 {
261 ULONG Valid:1;
262 ULONG LockedInWs:1;
263 ULONG LockedInMemory:1;
264 ULONG Protection:5;
265 ULONG Hashed:1;
266 ULONG Direct:1;
267 ULONG Age:2;
268 ULONG VirtualPageNumber:14;
269 } MMWSLENTRY, *PMMWSLENTRY;
270
271 typedef struct _MMWSLE
272 {
273 union
274 {
275 PVOID VirtualAddress;
276 ULONG Long;
277 MMWSLENTRY e1;
278 };
279 } MMWSLE, *PMMWSLE;
280
281 typedef struct _MMWSLE_HASH
282 {
283 PVOID Key;
284 ULONG Index;
285 } MMWSLE_HASH, *PMMWSLE_HASH;
286
287 typedef struct _MMWSL
288 {
289 ULONG FirstFree;
290 ULONG FirstDynamic;
291 ULONG LastEntry;
292 ULONG NextSlot;
293 PMMWSLE Wsle;
294 ULONG LastInitializedWsle;
295 ULONG NonDirectcout;
296 PMMWSLE_HASH HashTable;
297 ULONG HashTableSize;
298 ULONG NumberOfCommittedPageTables;
299 PVOID HashTableStart;
300 PVOID HighestPermittedHashAddress;
301 ULONG NumberOfImageWaiters;
302 ULONG VadBitMapHint;
303 USHORT UsedPageTableEntries[768];
304 ULONG CommittedPageTables[24];
305 } MMWSL, *PMMWSL;
306
307 //
308 // Flags for Memory Support Structure
309 //
310 typedef struct _MMSUPPORT_FLAGS
311 {
312 ULONG SessionSpace:1;
313 ULONG BeingTrimmed:1;
314 ULONG SessionLeader:1;
315 ULONG TrimHard:1;
316 ULONG WorkingSetHard:1;
317 ULONG AddressSpaceBeingDeleted :1;
318 ULONG Available:10;
319 ULONG AllowWorkingSetAdjustment:8;
320 ULONG MemoryPriority:8;
321 } MMSUPPORT_FLAGS, *PMMSUPPORT_FLAGS;
322
323 //
324 // Per-Process Memory Manager Data
325 //
326 typedef struct _MMSUPPORT
327 {
328 LARGE_INTEGER LastTrimTime;
329 MMSUPPORT_FLAGS Flags;
330 ULONG PageFaultCount;
331 ULONG PeakWorkingSetSize;
332 ULONG WorkingSetSize;
333 ULONG MinimumWorkingSetSize;
334 ULONG MaximumWorkingSetSize;
335 PMMWSL MmWorkingSetList;
336 LIST_ENTRY WorkingSetExpansionLinks;
337 ULONG Claim;
338 ULONG NextEstimationSlot;
339 ULONG NextAgingSlot;
340 ULONG EstimatedAvailable;
341 ULONG GrowthSinceLastEstimate;
342 } MMSUPPORT, *PMMSUPPORT;
343
344 #endif // !NTOS_MODE_USER
345
346 #endif // _MMTYPES_H