3 Copyright (c) Alex Ionescu. All rights reserved.
11 Type definitions for the Memory Manager
15 Alex Ionescu (alex.ionescu@reactos.com) 06-Oct-2004
25 #include <arch/mmtypes.h>
28 // Page-Rounding Macros
30 #define PAGE_ROUND_DOWN(x) (((ULONG)x)&(~(PAGE_SIZE-1)))
31 #define PAGE_ROUND_UP(x) \
32 ( (((ULONG)x)%PAGE_SIZE) ? ((((ULONG)x)&(~(PAGE_SIZE-1)))+PAGE_SIZE) : ((ULONG)x) )
35 // Macro for generating pool tags
37 #define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24))
42 // Section Flags for NtCreateSection
44 #define SEC_BASED 0x00200000
45 #define SEC_NO_CHANGE 0x00400000
48 // Section Inherit Flags for NtCreateSection
50 typedef enum _SECTION_INHERIT
59 typedef enum _POOL_TYPE
63 NonPagedPoolMustSucceed
,
65 NonPagedPoolCacheAligned
,
66 PagedPoolCacheAligned
,
67 NonPagedPoolCacheAlignedMustS
,
69 NonPagedPoolSession
= 32,
71 NonPagedPoolMustSucceedSession
,
72 DontUseThisTypeSession
,
73 NonPagedPoolCacheAlignedSession
,
74 PagedPoolCacheAlignedSession
,
75 NonPagedPoolCacheAlignedMustSSession
80 // Per Processor Non Paged Lookaside List IDs
82 typedef enum _PP_NPAGED_LOOKASIDE_NUMBER
84 LookasideSmallIrpList
= 0,
85 LookasideLargeIrpList
= 1,
87 LookasideCreateInfoList
= 3,
88 LookasideNameBufferList
= 4,
89 LookasideTwilightList
= 5,
90 LookasideCompletionList
= 6,
91 LookasideMaximumList
= 7
92 } PP_NPAGED_LOOKASIDE_NUMBER
;
95 // Memory Information Classes for NtQueryVirtualMemory
97 typedef enum _MEMORY_INFORMATION_CLASS
99 MemoryBasicInformation
,
100 MemoryWorkingSetList
,
102 MemoryBasicVlmInformation
103 } MEMORY_INFORMATION_CLASS
;
106 // Section Information Clasess for NtQuerySection
108 typedef enum _SECTION_INFORMATION_CLASS
110 SectionBasicInformation
,
111 SectionImageInformation
,
112 } SECTION_INFORMATION_CLASS
;
114 #ifdef NTOS_MODE_USER
117 // Virtual Memory Counters
119 typedef struct _VM_COUNTERS
121 SIZE_T PeakVirtualSize
;
123 ULONG PageFaultCount
;
124 SIZE_T PeakWorkingSetSize
;
125 SIZE_T WorkingSetSize
;
126 SIZE_T QuotaPeakPagedPoolUsage
;
127 SIZE_T QuotaPagedPoolUsage
;
128 SIZE_T QuotaPeakNonPagedPoolUsage
;
129 SIZE_T QuotaNonPagedPoolUsage
;
130 SIZE_T PagefileUsage
;
131 SIZE_T PeakPagefileUsage
;
132 } VM_COUNTERS
, *PVM_COUNTERS
;
134 typedef struct _VM_COUNTERS_EX
136 SIZE_T PeakVirtualSize
;
138 ULONG PageFaultCount
;
139 SIZE_T PeakWorkingSetSize
;
140 SIZE_T WorkingSetSize
;
141 SIZE_T QuotaPeakPagedPoolUsage
;
142 SIZE_T QuotaPagedPoolUsage
;
143 SIZE_T QuotaPeakNonPagedPoolUsage
;
144 SIZE_T QuotaNonPagedPoolUsage
;
145 SIZE_T PagefileUsage
;
146 SIZE_T PeakPagefileUsage
;
148 } VM_COUNTERS_EX
, *PVM_COUNTERS_EX
;
152 // List of Working Sets
154 typedef struct _MEMORY_WORKING_SET_LIST
157 ULONG WorkingSetList
[1];
158 } MEMORY_WORKING_SET_LIST
, *PMEMORY_WORKING_SET_LIST
;
161 // Memory Information Structures for NtQueryVirtualMemory
165 UNICODE_STRING SectionFileName
;
166 WCHAR NameBuffer
[ANYSIZE_ARRAY
];
167 } MEMORY_SECTION_NAME
, *PMEMORY_SECTION_NAME
;
170 // Section Information Structures for NtQuerySection
172 typedef struct _SECTION_BASIC_INFORMATION
177 } SECTION_BASIC_INFORMATION
, *PSECTION_BASIC_INFORMATION
;
179 typedef struct _SECTION_IMAGE_INFORMATION
181 PVOID TransferAddress
;
183 ULONG MaximumStackSize
;
184 ULONG CommittedStackSize
;
186 USHORT SubSystemMinorVersion
;
187 USHORT SubSystemMajorVersion
;
189 USHORT ImageCharacteristics
;
190 USHORT DllChracteristics
;
192 UCHAR ImageContainsCode
;
197 } SECTION_IMAGE_INFORMATION
, *PSECTION_IMAGE_INFORMATION
;
199 #ifndef NTOS_MODE_USER
202 // FIXME: REACTOS SPECIFIC HACK IN EPROCESS
204 typedef struct _MADDRESS_SPACE
206 struct _MEMORY_AREA
*MemoryAreaRoot
;
209 struct _EPROCESS
* Process
;
210 PUSHORT PageTableRefCountTable
;
211 ULONG PageTableRefCountTableSize
;
212 } MADDRESS_SPACE
, *PMADDRESS_SPACE
;
215 // Generic Address Range Structure
217 typedef struct _ADDRESS_RANGE
224 } ADDRESS_RANGE
, *PADDRESS_RANGE
;
227 // Node in Memory Manager's AVL Table
229 typedef struct _MMADDRESS_NODE
234 struct _MMADDRESS_NODE
*Parent
;
236 struct _MMADDRESS_NODE
*LeftChild
;
237 struct _MMADDRESS_NODE
*RightChild
;
240 } MMADDRESS_NODE
, *PMMADDRESS_NODE
;
243 // Memory Manager AVL Table for VADs and other descriptors
245 typedef struct _MM_AVL_TABLE
247 MMADDRESS_NODE BalancedRoot
;
250 ULONG NumberGenericTableElements
:24;
253 } MM_AVL_TABLE
, *PMM_AVL_TABLE
;
256 // Memory Manager Working Set Structures
258 typedef struct _MMWSLENTRY
262 ULONG LockedInMemory
:1;
267 ULONG VirtualPageNumber
:14;
268 } MMWSLENTRY
, *PMMWSLENTRY
;
270 typedef struct _MMWSLE
274 PVOID VirtualAddress
;
280 typedef struct _MMWSLE_HASH
284 } MMWSLE_HASH
, *PMMWSLE_HASH
;
286 typedef struct _MMWSL
293 ULONG LastInitializedWsle
;
295 PMMWSLE_HASH HashTable
;
297 ULONG NumberOfCommittedPageTables
;
298 PVOID HashTableStart
;
299 PVOID HighestPermittedHashAddress
;
300 ULONG NumberOfImageWaiters
;
302 USHORT UsedPageTableEntries
[768];
303 ULONG CommittedPageTables
[24];
307 // Flags for Memory Support Structure
309 typedef struct _MMSUPPORT_FLAGS
311 ULONG SessionSpace
:1;
312 ULONG BeingTrimmed
:1;
313 ULONG SessionLeader
:1;
315 ULONG WorkingSetHard
:1;
316 ULONG AddressSpaceBeingDeleted
:1;
318 ULONG AllowWorkingSetAdjustment
:8;
319 ULONG MemoryPriority
:8;
320 } MMSUPPORT_FLAGS
, *PMMSUPPORT_FLAGS
;
323 // Per-Process Memory Manager Data
325 typedef struct _MMSUPPORT
327 LARGE_INTEGER LastTrimTime
;
328 MMSUPPORT_FLAGS Flags
;
329 ULONG PageFaultCount
;
330 ULONG PeakWorkingSetSize
;
331 ULONG WorkingSetSize
;
332 ULONG MinimumWorkingSetSize
;
333 ULONG MaximumWorkingSetSize
;
334 PMMWSL MmWorkingSetList
;
335 LIST_ENTRY WorkingSetExpansionLinks
;
337 ULONG NextEstimationSlot
;
339 ULONG EstimatedAvailable
;
340 ULONG GrowthSinceLastEstimate
;
341 } MMSUPPORT
, *PMMSUPPORT
;
343 #endif // !NTOS_MODE_USER