ReactOS  0.4.15-dev-1184-g23e04ae
page.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Kernel
3  * LICENSE: BSD - See COPYING.ARM in the top level directory
4  * FILE: ntoskrnl/mm/arm/page.c
5  * PURPOSE: Old-school Page Management
6  * PROGRAMMERS: ReactOS Portable Systems Group
7  */
8 
9 /* INCLUDES *******************************************************************/
10 
11 #include <ntoskrnl.h>
12 #define NDEBUG
13 #include <debug.h>
14 
15 #define MODULE_INVOLVED_IN_ARM3
16 #include <mm/ARM3/miarm.h>
17 
18 /* GLOBALS ********************************************************************/
19 
20 const
21 ULONG
23 {
24  //
25  // These are the base MM_ protection flags
26  //
27  0,
28  PTE_READONLY | PTE_ENABLE_CACHE,
29  PTE_EXECUTE | PTE_ENABLE_CACHE,
30  PTE_EXECUTE_READ | PTE_ENABLE_CACHE,
31  PTE_READWRITE | PTE_ENABLE_CACHE,
32  PTE_WRITECOPY | PTE_ENABLE_CACHE,
33  PTE_EXECUTE_READWRITE | PTE_ENABLE_CACHE,
34  PTE_EXECUTE_WRITECOPY | PTE_ENABLE_CACHE,
35  //
36  // These OR in the MM_NOCACHE flag
37  //
38  0,
39  PTE_READONLY | PTE_DISABLE_CACHE,
40  PTE_EXECUTE | PTE_DISABLE_CACHE,
41  PTE_EXECUTE_READ | PTE_DISABLE_CACHE,
42  PTE_READWRITE | PTE_DISABLE_CACHE,
43  PTE_WRITECOPY | PTE_DISABLE_CACHE,
44  PTE_EXECUTE_READWRITE | PTE_DISABLE_CACHE,
45  PTE_EXECUTE_WRITECOPY | PTE_DISABLE_CACHE,
46  //
47  // These OR in the MM_DECOMMIT flag, which doesn't seem supported on x86/64/ARM
48  //
49  0,
50  PTE_READONLY | PTE_ENABLE_CACHE,
51  PTE_EXECUTE | PTE_ENABLE_CACHE,
52  PTE_EXECUTE_READ | PTE_ENABLE_CACHE,
53  PTE_READWRITE | PTE_ENABLE_CACHE,
54  PTE_WRITECOPY | PTE_ENABLE_CACHE,
55  PTE_EXECUTE_READWRITE | PTE_ENABLE_CACHE,
56  PTE_EXECUTE_WRITECOPY | PTE_ENABLE_CACHE,
57  //
58  // These OR in the MM_NOACCESS flag, which seems to enable WriteCombining?
59  //
60  0,
61  PTE_READONLY | PTE_WRITECOMBINED_CACHE,
62  PTE_EXECUTE | PTE_WRITECOMBINED_CACHE,
63  PTE_EXECUTE_READ | PTE_WRITECOMBINED_CACHE,
64  PTE_READWRITE | PTE_WRITECOMBINED_CACHE,
65  PTE_WRITECOPY | PTE_WRITECOMBINED_CACHE,
66  PTE_EXECUTE_READWRITE | PTE_WRITECOMBINED_CACHE,
67  PTE_EXECUTE_WRITECOPY | PTE_WRITECOMBINED_CACHE,
68 };
69 
70 const
72 {
105 };
106 
108 
109 /* Template PTE and PDE for a kernel page */
111 MMPTE ValidKernelPte = {.u.Hard.Valid = 1, .u.Hard.Sbo = 1};
112 
113 /* Template PDE for a demand-zero page */
116 
117 /* Template PTE for prototype page */
119 
123 
124 /* PRIVATE FUNCTIONS **********************************************************/
125 
126 VOID
127 NTAPI
128 MiFlushTlb(IN PMMPTE PointerPte,
129  IN PVOID Address)
130 {
132 }
133 
134 BOOLEAN
135 NTAPI
138  IN PULONG DirectoryTableBase)
139 {
141  return FALSE;
142 }
143 
144 NTSTATUS
145 NTAPI
147  IN PVOID Address,
148  IN ULONG Protection,
149  IN PPFN_NUMBER Pages,
150  IN ULONG PageCount)
151 {
153  return STATUS_SUCCESS;
154 }
155 
156 NTSTATUS
157 NTAPI
159  IN PVOID Address,
160  IN ULONG Protection,
161  IN PPFN_NUMBER Pages,
162  IN ULONG PageCount)
163 {
165  return STATUS_SUCCESS;
166 }
167 
168 VOID
169 NTAPI
171 {
173 }
174 
175 VOID
176 NTAPI
178  IN PVOID Address,
179  OUT PBOOLEAN WasDirty,
180  OUT PPFN_NUMBER Page)
181 {
183 }
184 
185 VOID
186 NTAPI
188  IN PVOID Address,
189  IN SWAPENTRY *SwapEntry)
190 {
192 }
193 
194 NTSTATUS
195 NTAPI
197  IN PVOID Address,
198  IN SWAPENTRY SwapEntry)
199 {
201  return STATUS_NOT_IMPLEMENTED;
202 }
203 
205 NTAPI
207  IN PVOID Address)
208 {
210  return 0;
211 }
212 
213 BOOLEAN
214 NTAPI
216  IN PVOID Address)
217 {
219  return FALSE;
220 }
221 
222 VOID
223 NTAPI
225  IN PVOID Address)
226 {
228 }
229 
230 VOID
231 NTAPI
233  IN PVOID Address)
234 {
236 }
237 
238 BOOLEAN
239 NTAPI
241  IN PVOID Address)
242 {
244  return FALSE;
245 }
246 
247 BOOLEAN
248 NTAPI
250  IN PVOID Address)
251 {
253  return FALSE;
254 }
255 
256 ULONG
257 NTAPI
259  IN PVOID Address)
260 {
261  /* We don't enforce any protection on the pages -- they are all RWX */
262  return PAGE_READWRITE;
263 }
264 
265 VOID
266 NTAPI
268  IN PVOID Address,
269  IN ULONG Protection)
270 {
271  /* We don't enforce any protection on the pages -- they are all RWX */
272  return;
273 }
274 
275 VOID
276 NTAPI
278 {
279  ULONG i;
280  PULONG CurrentPageDirectory = (PULONG)PDE_BASE;
281 
282  /* Loop the 2GB of address space which belong to the kernel */
283  for (i = MiGetPdeOffset(MmSystemRangeStart); i < 2048; i++)
284  {
285  /* Check if we have an entry for this already */
286  if ((i != MiGetPdeOffset(PTE_BASE)) &&
287  (i != MiGetPdeOffset(HYPER_SPACE)) &&
289  (CurrentPageDirectory[i]))
290  {
291  /* We don't, link it in our global page directory */
292  MmGlobalKernelPageDirectory[i] = CurrentPageDirectory[i];
293  }
294  }
295 }
296 
297 VOID
298 NTAPI
301  PVOID Address,
302  SWAPENTRY* SwapEntry)
303 {
304  ASSERT(FALSE);
305 }
306 
307 BOOLEAN
308 NTAPI
310 {
311  ASSERT(FALSE);
312  return FALSE;
313 }
314 
315 INIT_FUNCTION
316 VOID
317 NTAPI
319 {
320  ASSERT(FALSE);
321 }
322 
MMPTE MmDecommittedPte
Definition: page.c:122
#define PAGE_NOCACHE
Definition: nt_native.h:1311
VOID NTAPI MmDeletePageFileMapping(PEPROCESS Process, PVOID Address, SWAPENTRY *SwapEntry)
Definition: page.c:495
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
#define IN
Definition: typedefs.h:39
BOOLEAN NTAPI MmIsPagePresent(PEPROCESS Process, PVOID Address)
Definition: page.c:302
MMPTE ValidKernelPteLocal
Definition: page.c:120
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
BOOLEAN NTAPI MmIsDisabledPage(PEPROCESS Process, PVOID Address)
Definition: page.c:311
MMPDE ValidKernelPde
Definition: page.c:110
#define PAGE_GUARD
Definition: nt_native.h:1310
MMPDE ValidKernelPdeLocal
Definition: page.c:121
VOID NTAPI MmDeleteVirtualMapping(PEPROCESS Process, PVOID Address, BOOLEAN *WasDirty, PPFN_NUMBER Page)
Definition: page.c:453
LONG NTSTATUS
Definition: precomp.h:26
#define MI_PTE_LOOKUP_NEEDED
Definition: miarm.h:247
VOID NTAPI MmSetDirtyPage(PEPROCESS Process, PVOID Address)
Definition: page.c:431
#define MM_PTE_SOFTWARE_PROTECTION_BITS
Definition: mm.h:75
BOOLEAN NTAPI MmIsDirtyPage(PEPROCESS Process, PVOID Address)
Definition: page.c:370
VOID NTAPI MmInitGlobalKernelPageDirectory(VOID)
Definition: page.c:277
INIT_FUNCTION VOID NTAPI MiInitializeSessionSpaceLayout(VOID)
Definition: page.c:318
VOID NTAPI MmSetCleanPage(PEPROCESS Process, PVOID Address)
Definition: page.c:409
MMPTE PrototypePte
Definition: page.c:118
#define MiGetPdeOffset(x)
Definition: mm.h:188
ULONG * PPFN_NUMBER
Definition: ke.h:8
union _MMPTE::@2302 u
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define PAGE_EXECUTE_WRITECOPY
Definition: nt_native.h:1309
ULONG PFN_NUMBER
Definition: ke.h:8
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
MMPTE DemandZeroPte
Definition: page.c:115
#define FALSE
Definition: types.h:117
#define PDE_BASE
Definition: winldr.c:21
NTSTATUS NTAPI MmCreatePageFileMapping(PEPROCESS Process, PVOID Address, SWAPENTRY SwapEntry)
Definition: page.c:503
BOOLEAN NTAPI MmIsPageSwapEntry(PEPROCESS Process, PVOID Address)
Definition: page.c:323
#define PAGE_NOACCESS
Definition: nt_native.h:1302
unsigned char BOOLEAN
static WCHAR Address[46]
Definition: ping.c:68
#define PAGE_EXECUTE
Definition: nt_native.h:1306
ULONG NTAPI MmGetPageProtect(PEPROCESS Process, PVOID Address)
Definition: page.c:379
NTSTATUS NTAPI MmCreateVirtualMappingUnsafe(PEPROCESS Process, PVOID Address, ULONG PageProtection, PPFN_NUMBER Pages, ULONG PageCount)
Definition: page.c:514
PFN_NUMBER NTAPI MmGetPfnForProcess(PEPROCESS Process, PVOID Address)
Definition: page.c:292
const ULONG64 MmProtectToPteMask[32]
Definition: page.c:32
ULONG64 Valid
Definition: mmtypes.h:150
VOID MiFlushTlb(PMMPTE Pte, PVOID Address)
Definition: page.c:128
VOID NTAPI MmRawDeleteVirtualMapping(IN PVOID Address)
Definition: page.c:170
MMPDE DemandZeroPde
Definition: page.c:114
MMPTE ValidKernelPte
Definition: page.c:111
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
char * PBOOLEAN
Definition: retypes.h:11
#define MM_READWRITE
Definition: inbv.c:12
#define PTE_BASE
Definition: mmx86.c:14
const ULONG MmProtectToValue[32]
Definition: page.c:81
VOID NTAPI MmSetPageProtect(PEPROCESS Process, PVOID Address, ULONG flProtect)
Definition: page.c:390
ULONG_PTR Long
Definition: mmtypes.h:215
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
#define PAGE_WRITECOMBINE
Definition: mmtypes.h:78
ULONG_PTR SWAPENTRY
Definition: mm.h:47
BOOLEAN NTAPI MmCreateProcessAddressSpace(IN ULONG MinWs, IN PEPROCESS Process, OUT PULONG_PTR DirectoryTableBase)
Definition: page.c:592
unsigned int * PULONG
Definition: retypes.h:1
VOID NTAPI MmGetPageFileMapping(PEPROCESS Process, PVOID Address, SWAPENTRY *SwapEntry)
Definition: page.c:359
#define PAGE_READONLY
Definition: compat.h:138
#define PAGE_WRITECOPY
Definition: nt_native.h:1305
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
#define OUT
Definition: typedefs.h:40
#define HYPER_SPACE
Definition: mm.h:14
unsigned int ULONG
Definition: retypes.h:1
#define PAGE_EXECUTE_READ
Definition: nt_native.h:1307
#define PAGE_EXECUTE_READWRITE
Definition: nt_native.h:1308
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define MmSystemRangeStart
Definition: mm.h:32
NTSTATUS NTAPI MmCreateVirtualMapping(PEPROCESS Process, PVOID Address, ULONG Protect, PPFN_NUMBER Pages, ULONG PageCount)
Definition: page.c:568
ULONG MmGlobalKernelPageDirectory[4096]
Definition: page.c:107
#define PAGE_READWRITE
Definition: nt_native.h:1304