xref: /reactos/sdk/include/ndk/amd64/mmtypes.h (revision c2c66aff)
1 /*++ NDK Version: 0095
2 
3 Copyright (c) Alex Ionescu.  All rights reserved.
4 
5 Header Name:
6 
7     mmtypes.h (AMD64)
8 
9 Abstract:
10 
11     AMD64 Type definitions for the Memory Manager
12 
13 Author:
14 
15     Alex Ionescu (alex.ionescu@reactos.com)   06-Oct-2004
16     Timo Kreuzer (timo.kreuzer@reactos.com)   15-Aug-2008
17 
18 --*/
19 
20 #ifndef _AMD64_MMTYPES_H
21 #define _AMD64_MMTYPES_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 //
28 // Dependencies
29 //
30 
31 //
32 // Page-related Macros
33 //
34 #define PAGE_SIZE                         0x1000
35 #define PAGE_SHIFT                        12L
36 #define MM_ALLOCATION_GRANULARITY         0x10000
37 #define MM_ALLOCATION_GRANULARITY_SHIFT   16L
38 #define MM_PAGE_FRAME_NUMBER_SIZE         52
39 
40 //
41 // User space range limit
42 //
43 #define MI_HIGHEST_USER_ADDRESS         (PVOID)0x000007FFFFFEFFFFULL
44 
45 //
46 // Address of the shared user page
47 //
48 #define MM_SHARED_USER_DATA_VA 0x7FFE0000ULL
49 
50 //
51 // Sanity checks for Paging Macros
52 //
53 #ifdef C_ASSERT
54 C_ASSERT(PAGE_SIZE == (1 << PAGE_SHIFT));
55 C_ASSERT(MM_ALLOCATION_GRANULARITY == (1 << MM_ALLOCATION_GRANULARITY_SHIFT));
56 C_ASSERT(MM_ALLOCATION_GRANULARITY &&
57          !(MM_ALLOCATION_GRANULARITY & (MM_ALLOCATION_GRANULARITY - 1)));
58 C_ASSERT(MM_ALLOCATION_GRANULARITY >= PAGE_SIZE);
59 #endif
60 
61 //
62 // Page Table Entry Definitions
63 //
64 typedef struct _HARDWARE_PTE
65 {
66     ULONG64 Valid:1;
67     ULONG64 Write:1;
68     ULONG64 Owner:1;
69     ULONG64 WriteThrough:1;
70     ULONG64 CacheDisable:1;
71     ULONG64 Accessed:1;
72     ULONG64 Dirty:1;
73     ULONG64 LargePage:1;
74     ULONG64 Global:1;
75     ULONG64 CopyOnWrite:1;
76     ULONG64 Prototype:1;
77     ULONG64 reserved0:1;
78     ULONG64 PageFrameNumber:28;
79     ULONG64 reserved1:12;
80     ULONG64 SoftwareWsIndex:11;
81     ULONG64 NoExecute:1;
82 } HARDWARE_PTE, *PHARDWARE_PTE;
83 
84 typedef struct _MMPTE_SOFTWARE
85 {
86     ULONG64 Valid:1;
87     ULONG64 PageFileLow:4;
88     ULONG64 Protection:5;
89     ULONG64 Prototype:1;
90     ULONG64 Transition:1;
91     ULONG64 UsedPageTableEntries:10;
92     ULONG64 Reserved:10;
93     ULONG64 PageFileHigh:32;
94 } MMPTE_SOFTWARE, *PMMPTE_SOFTWARE;
95 
96 typedef struct _MMPTE_TRANSITION
97 {
98     ULONG64 Valid:1;
99     ULONG64 Write:1;
100     ULONG64 Owner:1;
101     ULONG64 WriteThrough:1;
102     ULONG64 CacheDisable:1;
103     ULONG64 Protection:5;
104     ULONG64 Prototype:1;
105     ULONG64 Transition:1;
106 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
107     ULONG64 PageFrameNumber:36;
108     ULONG64 Unused:16;
109 #else
110     ULONG64 PageFrameNumber:28;
111     ULONG64 Unused:24;
112 #endif
113 } MMPTE_TRANSITION;
114 
115 typedef struct _MMPTE_PROTOTYPE
116 {
117     ULONG64 Valid:1;
118     ULONG64 Unused0:7;
119     ULONG64 ReadOnly:1;
120     ULONG64 Unused1:1;
121     ULONG64 Prototype:1;
122     ULONG64 Protection:5;
123     LONG64 ProtoAddress:48;
124 } MMPTE_PROTOTYPE;
125 
126 typedef struct _MMPTE_SUBSECTION
127 {
128     ULONG64 Valid:1;
129     ULONG64 Unused0:4;
130     ULONG64 Protection:5;
131     ULONG64 Prototype:1;
132     ULONG64 Unused1:5;
133     LONG64 SubsectionAddress:48;
134 } MMPTE_SUBSECTION;
135 
136 typedef struct _MMPTE_LIST
137 {
138     ULONG64 Valid:1;
139     ULONG64 OneEntry:1;
140     ULONG64 filler0:3;
141     ULONG64 Protection:5;
142     ULONG64 Prototype:1;
143     ULONG64 Transition:1;
144     ULONG64 filler1:20;
145     ULONG64 NextEntry:32;
146 } MMPTE_LIST;
147 
148 typedef struct _MMPTE_HARDWARE
149 {
150     ULONG64 Valid:1;
151 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
152     ULONG64 Dirty1:1;
153 #else
154 #ifdef CONFIG_SMP
155     ULONG64 Writable:1;
156 #else
157     ULONG64 Write:1;
158 #endif
159 #endif
160     ULONG64 Owner:1;
161     ULONG64 WriteThrough:1;
162     ULONG64 CacheDisable:1;
163     ULONG64 Accessed:1;
164     ULONG64 Dirty:1;
165     ULONG64 LargePage:1;
166     ULONG64 Global:1;
167     ULONG64 CopyOnWrite:1;
168     ULONG64 Prototype:1;
169 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
170     ULONG64 Write:1;
171     ULONG64 PageFrameNumber:36;
172     ULONG64 reserved1:4;
173 #else
174 #ifdef CONFIG_SMP
175     ULONG64 Write:1;
176 #else
177     ULONG64 reserved0:1;
178 #endif
179     ULONG64 PageFrameNumber:28;
180     ULONG64 reserved1:12;
181 #endif
182     ULONG64 SoftwareWsIndex:11;
183     ULONG64 NoExecute:1;
184 } MMPTE_HARDWARE, *PMMPTE_HARDWARE;
185 
186 typedef struct _MMPTE_HARDWARE_LARGEPAGE
187 {
188     ULONG64 Valid:1;
189     ULONG64 Write:1;
190     ULONG64 Owner:1;
191     ULONG64 WriteThrough:1;
192     ULONG64 CacheDisable:1;
193     ULONG64 Accessed:1;
194     ULONG64 Dirty:1;
195     ULONG64 LargePage:1;
196     ULONG64 Global:1;
197     ULONG64 CopyOnWrite:1;
198     ULONG64 Prototype:1;
199     ULONG64 reserved0:1;
200     ULONG64 PAT:1;
201     ULONG64 reserved1:8;
202 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
203     ULONG64 PageFrameNumber:27;
204     ULONG64 reserved2:16;
205 #else
206     ULONG64 PageFrameNumber:19;
207     ULONG64 reserved2:24;
208 #endif
209 } MMPTE_HARDWARE_LARGEPAGE, *PMMPTE_HARDWARE_LARGEPAGE;
210 
211 typedef struct _MMPTE
212 {
213     union
214     {
215         ULONG_PTR Long;
216         HARDWARE_PTE Flush;
217         MMPTE_HARDWARE Hard;
218         MMPTE_PROTOTYPE Proto;
219         MMPTE_SOFTWARE Soft;
220         MMPTE_TRANSITION Trans;
221         MMPTE_SUBSECTION Subsect;
222         MMPTE_LIST List;
223     } u;
224 } MMPTE, *PMMPTE,
225   MMPDE, *PMMPDE,
226   MMPPE, *PMMPPE,
227   MMPXE, *PMMPXE;
228 
229 #ifdef __cplusplus
230 }; // extern "C"
231 #endif
232 
233 #endif // !AMD64_MMTYPES_H
234