ReactOS  0.4.15-dev-1070-ge1a01de
page.c File Reference
#include <ntoskrnl.h>
#include <ppcmmu/mmu.h>
#include <debug.h>
Include dependency graph for page.c:

Go to the source code of this file.

Macros

#define HYPERSPACE_PAGEDIR_PTR   ((PVOID)0xc0000000)
 
#define PA_PRESENT   (1ll<<63)
 
#define PA_USER   (1ll<<62)
 
#define PA_ACCESSED   0x200
 
#define PA_DIRTY   0x100
 
#define PA_WT   0x20
 
#define PA_CD   0x10
 
#define PA_READWRITE   3
 
#define HYPERSPACE   (0xc0400000)
 
#define IS_HYPERSPACE(v)   (((ULONG)(v) >= HYPERSPACE && (ULONG)(v) < HYPERSPACE + 0x400000))
 
#define PTE_TO_PFN(X)   ((X) >> PAGE_SHIFT)
 
#define PFN_TO_PTE(X)   ((X) << PAGE_SHIFT)
 

Functions

__inline LARGE_INTEGER PTE_TO_PAGE (ULONG npage)
 
VOID NTAPI MiFlushTlbIpiRoutine (PVOID Address)
 
VOID MiFlushTlb (PULONG Pt, PVOID Address)
 
static ULONG ProtectToFlags (ULONG flProtect)
 
NTSTATUS NTAPI MmCopyMmInfo (PEPROCESS Src, PEPROCESS Dest, PPHYSICAL_ADDRESS DirectoryTableBase)
 
BOOLEAN NTAPI MmCreateProcessAddressSpace (IN ULONG MinWs, IN PEPROCESS Process, IN PLARGE_INTEGER DirectoryTableBase)
 
VOID NTAPI MmDeletePageTable (PEPROCESS Process, PVOID Address)
 
VOID NTAPI MmFreePageTable (PEPROCESS Process, PVOID Address)
 
PVOID NTAPI MmGetPhysicalAddressProcess (PEPROCESS Process, PVOID Addr)
 
PFN_NUMBER NTAPI MmGetPfnForProcess (PEPROCESS Process, PVOID Address)
 
VOID NTAPI MmDeleteVirtualMapping (PEPROCESS Process, PVOID Address, BOOLEAN *WasDirty, PPFN_NUMBER Page)
 
VOID NTAPI MmDeletePageFileMapping (PEPROCESS Process, PVOID Address, SWAPENTRY *SwapEntry)
 
BOOLEAN NTAPI MmIsDirtyPage (PEPROCESS Process, PVOID Address)
 
VOID NTAPI MmSetCleanPage (PEPROCESS Process, PVOID Address)
 
VOID NTAPI MmSetDirtyPage (PEPROCESS Process, PVOID Address)
 
BOOLEAN NTAPI MmIsPagePresent (PEPROCESS Process, PVOID Address)
 
ULONGLONG MmGetPageEntryForProcess (PEPROCESS Process, PVOID Address)
 
BOOLEAN NTAPI MmIsPageSwapEntry (PEPROCESS Process, PVOID Address)
 
NTSTATUS NTAPI MmCreatePageFileMapping (PEPROCESS Process, PVOID Address, SWAPENTRY SwapEntry)
 
NTSTATUS NTAPI MmCreateVirtualMappingUnsafe (PEPROCESS Process, PVOID Address, ULONG flProtect, PPFN_NUMBER Pages, ULONG PageCount)
 
NTSTATUS NTAPI MmCreateVirtualMapping (PEPROCESS Process, PVOID Address, ULONG flProtect, PPFN_NUMBER Pages, ULONG PageCount)
 
ULONG NTAPI MmGetPageProtect (PEPROCESS Process, PVOID Address)
 
VOID NTAPI MmSetPageProtect (PEPROCESS Process, PVOID Address, ULONG flProtect)
 
INIT_FUNCTION VOID NTAPI MmInitGlobalKernelPageDirectory (VOID)
 
NTSTATUS MmPPCCreatePrimitiveMapping (ULONG_PTR PageAddr)
 
PFN_NUMBER MmPPCPrimitiveAllocPage ()
 

Macro Definition Documentation

◆ HYPERSPACE

#define HYPERSPACE   (0xc0400000)

Definition at line 34 of file page.c.

◆ HYPERSPACE_PAGEDIR_PTR

#define HYPERSPACE_PAGEDIR_PTR   ((PVOID)0xc0000000)

Definition at line 24 of file page.c.

◆ IS_HYPERSPACE

#define IS_HYPERSPACE (   v)    (((ULONG)(v) >= HYPERSPACE && (ULONG)(v) < HYPERSPACE + 0x400000))

Definition at line 35 of file page.c.

◆ PA_ACCESSED

#define PA_ACCESSED   0x200

Definition at line 28 of file page.c.

◆ PA_CD

#define PA_CD   0x10

Definition at line 31 of file page.c.

◆ PA_DIRTY

#define PA_DIRTY   0x100

Definition at line 29 of file page.c.

◆ PA_PRESENT

#define PA_PRESENT   (1ll<<63)

Definition at line 26 of file page.c.

◆ PA_READWRITE

#define PA_READWRITE   3

Definition at line 32 of file page.c.

◆ PA_USER

#define PA_USER   (1ll<<62)

Definition at line 27 of file page.c.

◆ PA_WT

#define PA_WT   0x20

Definition at line 30 of file page.c.

◆ PFN_TO_PTE

#define PFN_TO_PTE (   X)    ((X) << PAGE_SHIFT)

Definition at line 38 of file page.c.

◆ PTE_TO_PFN

#define PTE_TO_PFN (   X)    ((X) >> PAGE_SHIFT)

Definition at line 37 of file page.c.

Function Documentation

◆ MiFlushTlb()

VOID MiFlushTlb ( PULONG  Pt,
PVOID  Address 
)

Definition at line 72 of file page.c.

73 {
74  __asm__("tlbi %0" : "=r" (Address));
75 }
__asm__("\t.globl GetPhys\n" "GetPhys:\t\n" "mflr 0\n\t" "stwu 0,-16(1)\n\t" "mfmsr 5\n\t" "andi. 6,5,0xffef\n\t" "mtmsr 6\n\t" "isync\n\t" "sync\n\t" "lwz 3,0(3)\n\t" "mtmsr 5\n\t" "isync\n\t" "sync\n\t" "lwz 0,0(1)\n\t" "addi 1,1,16\n\t" "mtlr 0\n\t" "blr")
static WCHAR Address[46]
Definition: ping.c:68

◆ MiFlushTlbIpiRoutine()

VOID NTAPI MiFlushTlbIpiRoutine ( PVOID  Address)

Definition at line 55 of file page.c.

56 {
57  if (Address == (PVOID)0xffffffff)
58  {
59  __asm__("tlbsync");
60  }
61  else if (Address == (PVOID)0xfffffffe)
62  {
63  __asm__("tlbsync");
64  }
65  else
66  {
67  __asm__("tlbi %0" : "=r" (Address));
68  }
69 }
__asm__("\t.globl GetPhys\n" "GetPhys:\t\n" "mflr 0\n\t" "stwu 0,-16(1)\n\t" "mfmsr 5\n\t" "andi. 6,5,0xffef\n\t" "mtmsr 6\n\t" "isync\n\t" "sync\n\t" "lwz 3,0(3)\n\t" "mtmsr 5\n\t" "isync\n\t" "sync\n\t" "lwz 0,0(1)\n\t" "addi 1,1,16\n\t" "mtlr 0\n\t" "blr")
static WCHAR Address[46]
Definition: ping.c:68

◆ MmCopyMmInfo()

NTSTATUS NTAPI MmCopyMmInfo ( PEPROCESS  Src,
PEPROCESS  Dest,
PPHYSICAL_ADDRESS  DirectoryTableBase 
)

Definition at line 85 of file page.c.

88 {
89  DPRINT("MmCopyMmInfo(Src %x, Dest %x)\n", Src, Dest);
90 
91  ASSERT(FALSE);
92 
93  return(STATUS_SUCCESS);
94 }
#define FALSE
Definition: types.h:117
void DPRINT(...)
Definition: polytest.cpp:61
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
return STATUS_SUCCESS
Definition: btrfs.c:3014

◆ MmCreatePageFileMapping()

NTSTATUS NTAPI MmCreatePageFileMapping ( PEPROCESS  Process,
PVOID  Address,
SWAPENTRY  SwapEntry 
)

Definition at line 271 of file page.c.

274 {
276  {
277  DPRINT1("No process\n");
278  ASSERT(FALSE);
279  }
280  if (Process != NULL && Address >= MmSystemRangeStart)
281  {
282  DPRINT1("Setting kernel address with process context\n");
283  ASSERT(FALSE);
284  }
285  if (SwapEntry & (1 << 31))
286  {
287  ASSERT(FALSE);
288  }
289 
290  // XXX arty
291 
292  return(STATUS_SUCCESS);
293 }
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
static WCHAR Address[46]
Definition: ping.c:68
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define DPRINT1
Definition: precomp.h:8
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define MmSystemRangeStart
Definition: mm.h:32

◆ MmCreateProcessAddressSpace()

BOOLEAN NTAPI MmCreateProcessAddressSpace ( IN ULONG  MinWs,
IN PEPROCESS  Process,
IN PLARGE_INTEGER  DirectoryTableBase 
)

Definition at line 98 of file page.c.

101 {
102  ASSERT(FALSE);
103  return TRUE;
104 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)

◆ MmCreateVirtualMapping()

NTSTATUS NTAPI MmCreateVirtualMapping ( PEPROCESS  Process,
PVOID  Address,
ULONG  flProtect,
PPFN_NUMBER  Pages,
ULONG  PageCount 
)

Definition at line 372 of file page.c.

377 {
378  ULONG i;
379 
380  for (i = 0; i < PageCount; i++)
381  {
382  if (!MmIsUsablePage(Pages[i]))
383  {
384  DPRINT1("Page at address %x not usable\n", PFN_TO_PTE(Pages[i]));
385  ASSERT(FALSE);
386  }
387  }
388 
390  Address,
391  flProtect,
392  Pages,
393  PageCount));
394 }
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 FALSE
Definition: types.h:117
static WCHAR Address[46]
Definition: ping.c:68
NTSTATUS NTAPI MmCreateVirtualMappingUnsafe(PEPROCESS Process, PVOID Address, ULONG PageProtection, PPFN_NUMBER Pages, ULONG PageCount)
Definition: page.c:514
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define PFN_TO_PTE(X)
Definition: page.c:38
#define DPRINT1
Definition: precomp.h:8
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
unsigned int ULONG
Definition: retypes.h:1

◆ MmCreateVirtualMappingUnsafe()

NTSTATUS NTAPI MmCreateVirtualMappingUnsafe ( PEPROCESS  Process,
PVOID  Address,
ULONG  flProtect,
PPFN_NUMBER  Pages,
ULONG  PageCount 
)

Definition at line 298 of file page.c.

303 {
305  PVOID Addr;
306  ULONG i;
307  ppc_map_info_t info = { 0 };
308 
309  DPRINT("MmCreateVirtualMappingUnsafe(%x, %x, %x, %x (%x), %d)\n",
310  Process, Address, flProtect, Pages, *Pages, PageCount);
311 
312  if (Process == NULL)
313  {
315  {
316  DPRINT1("No process\n");
317  ASSERT(FALSE);
318  }
319  if (PageCount > 0x10000 ||
320  (ULONG_PTR) Address / PAGE_SIZE + PageCount > 0x100000)
321  {
322  DPRINT1("Page count to large\n");
323  ASSERT(FALSE);
324  }
325  }
326  else
327  {
329  {
330  DPRINT1("Setting kernel address with process context\n");
331  ASSERT(FALSE);
332  }
333  if (PageCount > (ULONG_PTR)MmSystemRangeStart / PAGE_SIZE ||
334  (ULONG_PTR) Address / PAGE_SIZE + PageCount >
336  {
337  DPRINT1("Page Count to large\n");
338  ASSERT(FALSE);
339  }
340  }
341 
342  Attributes = ProtectToFlags(flProtect);
343  Addr = Address;
344 
345  for (i = 0; i < PageCount; i++, Addr = (PVOID)((ULONG_PTR)Addr + PAGE_SIZE))
346  {
348  info.proc = ((Addr < MmSystemRangeStart) && Process) ?
349  (int)Process->UniqueProcessId : 0;
350  info.addr = (vaddr_t)Addr;
351  info.flags = Attributes;
352  MmuMapPage(&info, 1);
353  //(void)InterlockedExchangeUL(Pt, PFN_TO_PTE(Pages[i]) | Attributes);
354  if (Address < MmSystemRangeStart &&
355  ((PMADDRESS_SPACE)&Process->VadRoot)->PageTableRefCountTable != NULL &&
357  {
358 #if 0
359  PUSHORT Ptrc;
360 
361  Ptrc = ((PMADDRESS_SPACE)&Process->VadRoot)->PageTableRefCountTable;
362 
363  Ptrc[ADDR_TO_PAGE_TABLE(Addr)]++;
364 #endif
365  }
366  }
367  return(STATUS_SUCCESS);
368 }
static ULONG ProtectToFlags(ULONG flProtect)
Definition: page.c:78
uint32_t ULONG_PTR
Definition: typedefs.h:65
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 FALSE
Definition: types.h:117
unsigned long vaddr_t
Definition: mmu.h:90
#define PsGetCurrentProcess
Definition: psfuncs.h:17
smooth NULL
Definition: ftsmooth.c:416
static WCHAR Address[46]
Definition: ping.c:68
#define PA_PRESENT
Definition: page.c:26
void DPRINT(...)
Definition: polytest.cpp:61
void * PVOID
Definition: retypes.h:9
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define PAGE_SIZE
Definition: env_spec_w32.h:49
static int MmuMapPage(ppc_map_info_t *info, int count)
Definition: mmu.h:197
_Must_inspect_result_ _In_ USHORT _In_ PHIDP_PREPARSED_DATA _Out_writes_to_ LengthAttributes PHIDP_EXTENDED_ATTRIBUTES Attributes
Definition: hidpi.h:348
#define ADDR_TO_PAGE_TABLE(v)
Definition: page.c:23
#define DPRINT1
Definition: precomp.h:8
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define MmSystemRangeStart
Definition: mm.h:32
unsigned short * PUSHORT
Definition: retypes.h:2
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

◆ MmDeletePageFileMapping()

VOID NTAPI MmDeletePageFileMapping ( PEPROCESS  Process,
PVOID  Address,
SWAPENTRY SwapEntry 
)

Definition at line 194 of file page.c.

199 {
200  ppc_map_info_t info = { 0 };
201  /*
202  * Decrement the reference count for this page table.
203  */
204  if (Process != NULL &&
205  ((PMADDRESS_SPACE)&Process->VadRoot)->PageTableRefCountTable != NULL &&
207  {
208  PUSHORT Ptrc;
209 
210  Ptrc = ((PMADDRESS_SPACE)&Process->VadRoot)->PageTableRefCountTable;
212  }
213 
214  /*
215  * Return some information to the caller
216  */
217  MmuInqPage(&info, 1);
218  *SwapEntry = info.phys;
219 }
VOID NTAPI MmFreePageTable(PEPROCESS Process, PVOID Address)
Definition: page.c:138
smooth NULL
Definition: ftsmooth.c:416
static WCHAR Address[46]
Definition: ping.c:68
static void MmuInqPage(ppc_map_info_t *info, int count)
Definition: mmu.h:217
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
#define MmSystemRangeStart
Definition: mm.h:32
unsigned short * PUSHORT
Definition: retypes.h:2

◆ MmDeletePageTable()

VOID NTAPI MmDeletePageTable ( PEPROCESS  Process,
PVOID  Address 
)

Definition at line 108 of file page.c.

109 {
111 
112  DPRINT1("DeletePageTable: Process: %x CurrentProcess %x\n",
114 
115  if (Process != NULL && Process != CurrentProcess)
116  {
117  KeAttachProcess(&Process->Pcb);
118  }
119 
120  if (Process)
121  {
122  DPRINT1("Revoking VSID %d\n", (paddr_t)Process->UniqueProcessId);
123  MmuRevokeVsid((paddr_t)Process->UniqueProcessId, -1);
124  }
125  else
126  {
127  DPRINT1("No vsid to revoke\n");
128  }
129 
130  if (Process != NULL && Process != CurrentProcess)
131  {
132  KeDetachProcess();
133  }
134 }
static void MmuRevokeVsid(int vsid, int mask)
Definition: mmu.h:247
unsigned long paddr_t
Definition: mmu.h:89
#define PsGetCurrentProcess
Definition: psfuncs.h:17
smooth NULL
Definition: ftsmooth.c:416
ULONG CurrentProcess
Definition: shell.c:125
VOID NTAPI KeDetachProcess(VOID)
Definition: procobj.c:618
VOID NTAPI KeAttachProcess(IN PKPROCESS Process)
Definition: procobj.c:579
#define DPRINT1
Definition: precomp.h:8
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219

Referenced by MmFreePageTable().

◆ MmDeleteVirtualMapping()

VOID NTAPI MmDeleteVirtualMapping ( PEPROCESS  Process,
PVOID  Address,
BOOLEAN WasDirty,
PPFN_NUMBER  Page 
)

Definition at line 164 of file page.c.

169 {
170  ppc_map_info_t info = { 0 };
171 
172  DPRINT("MmDeleteVirtualMapping(%x, %x, %d, %x, %x)\n",
173  Process, Address, WasDirty, Page);
174 
175  info.proc = Process ? (int)Process->UniqueProcessId : 0;
176  info.addr = (vaddr_t)Address;
177  MmuInqPage(&info, 1);
178 
179  /*
180  * Return some information to the caller
181  */
182  if (WasDirty != NULL)
183  {
184  *WasDirty = !!(info.flags & MMU_PAGE_DIRTY);
185  }
186  if (Page != NULL)
187  {
188  *Page = info.phys >> PAGE_SHIFT;
189  }
190 }
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
unsigned long vaddr_t
Definition: mmu.h:90
#define MMU_PAGE_DIRTY
Definition: mmu.h:81
smooth NULL
Definition: ftsmooth.c:416
static WCHAR Address[46]
Definition: ping.c:68
void DPRINT(...)
Definition: polytest.cpp:61
static void MmuInqPage(ppc_map_info_t *info, int count)
Definition: mmu.h:217
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

◆ MmFreePageTable()

VOID NTAPI MmFreePageTable ( PEPROCESS  Process,
PVOID  Address 
)

Definition at line 138 of file page.c.

139 {
141 }
VOID NTAPI MmDeletePageTable(PEPROCESS Process, PVOID Address)
Definition: page.c:108
static WCHAR Address[46]
Definition: ping.c:68
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219

Referenced by MmDeletePageFileMapping().

◆ MmGetPageEntryForProcess()

ULONGLONG MmGetPageEntryForProcess ( PEPROCESS  Process,
PVOID  Address 
)

Definition at line 255 of file page.c.

256 {
257  return 0; // XXX arty
258 }

Referenced by MmIsPageSwapEntry().

◆ MmGetPageProtect()

ULONG NTAPI MmGetPageProtect ( PEPROCESS  Process,
PVOID  Address 
)

Definition at line 398 of file page.c.

399 {
400  ULONG Protect = 0;
401  ppc_map_info_t info = { 0 };
402 
403  info.proc = Process ? (int)Process->UniqueProcessId : 0;
404  info.addr = (vaddr_t)Address;
405  MmuInqPage(&info, 1);
406 
407  if (!info.phys) { return PAGE_NOACCESS; }
408  if (!(info.flags & MMU_KMASK))
409  {
410  Protect |= PAGE_SYSTEM;
411  if ((info.flags & MMU_KR) && (info.flags & MMU_KW))
413  else if (info.flags & MMU_KR)
415  }
416  else
417  {
418  if ((info.flags & MMU_UR) && (info.flags & MMU_UW))
420  else
422  }
423  return(Protect);
424 }
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T _In_ SECTION_INHERIT _In_ ULONG _In_ ULONG Protect
Definition: zwfuncs.h:214
unsigned long vaddr_t
Definition: mmu.h:90
#define PAGE_NOACCESS
Definition: nt_native.h:1302
static WCHAR Address[46]
Definition: ping.c:68
#define MMU_KMASK
Definition: mmu.h:83
#define PAGE_SYSTEM
Definition: mm.h:86
#define MMU_KR
Definition: mmu.h:71
static void MmuInqPage(ppc_map_info_t *info, int count)
Definition: mmu.h:217
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
#define MMU_UW
Definition: mmu.h:74
#define MMU_KW
Definition: mmu.h:72
unsigned int ULONG
Definition: retypes.h:1
#define PAGE_EXECUTE_READ
Definition: nt_native.h:1307
#define MMU_UR
Definition: mmu.h:73
#define PAGE_READWRITE
Definition: nt_native.h:1304
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

◆ MmGetPfnForProcess()

PFN_NUMBER NTAPI MmGetPfnForProcess ( PEPROCESS  Process,
PVOID  Address 
)

Definition at line 156 of file page.c.

158 {
160 }
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
PVOID NTAPI MmGetPhysicalAddressProcess(PEPROCESS Process, PVOID Addr)
Definition: page.c:145
ULONG PFN_NUMBER
Definition: ke.h:8
static WCHAR Address[46]
Definition: ping.c:68
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219

◆ MmGetPhysicalAddressProcess()

PVOID NTAPI MmGetPhysicalAddressProcess ( PEPROCESS  Process,
PVOID  Addr 
)

Definition at line 145 of file page.c.

146 {
147  ppc_map_info_t info = { 0 };
148  info.proc = Process ? (int)Process->UniqueProcessId : 0;
149  info.addr = (vaddr_t)Addr;
150  MmuInqPage(&info, 1);
151  return (PVOID)info.phys;
152 }
unsigned long vaddr_t
Definition: mmu.h:90
static void MmuInqPage(ppc_map_info_t *info, int count)
Definition: mmu.h:217
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by MmGetPfnForProcess().

◆ MmInitGlobalKernelPageDirectory()

INIT_FUNCTION VOID NTAPI MmInitGlobalKernelPageDirectory ( VOID  )

Definition at line 451 of file page.c.

452 {
453 }

◆ MmIsDirtyPage()

BOOLEAN NTAPI MmIsDirtyPage ( PEPROCESS  Process,
PVOID  Address 
)

Definition at line 223 of file page.c.

224 {
225  ppc_map_info_t info = { 0 };
226  info.proc = Process ? (int)Process->UniqueProcessId : 0;
227  info.addr = (vaddr_t)Address;
228  MmuInqPage(&info, 1);
229  return !!(info.flags & MMU_PAGE_DIRTY);
230 }
unsigned long vaddr_t
Definition: mmu.h:90
#define MMU_PAGE_DIRTY
Definition: mmu.h:81
static WCHAR Address[46]
Definition: ping.c:68
static void MmuInqPage(ppc_map_info_t *info, int count)
Definition: mmu.h:217
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

◆ MmIsPagePresent()

BOOLEAN NTAPI MmIsPagePresent ( PEPROCESS  Process,
PVOID  Address 
)

Definition at line 246 of file page.c.

247 {
248  ppc_map_info_t info = { 0 };
249  info.proc = Process ? (int)Process->UniqueProcessId : 0;
250  info.addr = (vaddr_t)Address;
251  MmuInqPage(&info, 1);
252  return !!info.phys;
253 }
unsigned long vaddr_t
Definition: mmu.h:90
static WCHAR Address[46]
Definition: ping.c:68
static void MmuInqPage(ppc_map_info_t *info, int count)
Definition: mmu.h:217
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

◆ MmIsPageSwapEntry()

BOOLEAN NTAPI MmIsPageSwapEntry ( PEPROCESS  Process,
PVOID  Address 
)

Definition at line 262 of file page.c.

263 {
264  ULONG Entry;
266  return !(Entry & PA_PRESENT) && Entry != 0 ? TRUE : FALSE;
267 }
struct _Entry Entry
Definition: kefuncs.h:627
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static WCHAR Address[46]
Definition: ping.c:68
#define PA_PRESENT
Definition: page.c:26
ULONGLONG MmGetPageEntryForProcess(PEPROCESS Process, PVOID Address)
Definition: page.c:255
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
unsigned int ULONG
Definition: retypes.h:1
base of all file and directory entries
Definition: entries.h:82

◆ MmPPCCreatePrimitiveMapping()

NTSTATUS MmPPCCreatePrimitiveMapping ( ULONG_PTR  PageAddr)

Definition at line 456 of file page.c.

457 {
459  ppc_map_info_t info = { 0 };
460  info.flags = MMU_KRW;
461  info.addr = (vaddr_t)PageAddr;
463  return result;
464 }
LONG NTSTATUS
Definition: precomp.h:26
unsigned long vaddr_t
Definition: mmu.h:90
static int MmuMapPage(ppc_map_info_t *info, int count)
Definition: mmu.h:197
#define MMU_KRW
Definition: mmu.h:76
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
return STATUS_SUCCESS
Definition: btrfs.c:3014
GLuint64EXT * result
Definition: glext.h:11304

◆ MmPPCPrimitiveAllocPage()

PFN_NUMBER MmPPCPrimitiveAllocPage ( )

Definition at line 467 of file page.c.

468 {
470  DbgPrint("Got Page %x\n", Result);
471  return Result / PAGE_SIZE;
472 }
#define DbgPrint
Definition: loader.c:25
unsigned long paddr_t
Definition: mmu.h:89
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
#define PAGE_SIZE
Definition: env_spec_w32.h:49
static paddr_t MmuGetPage()
Definition: mmu.h:252

◆ MmSetCleanPage()

VOID NTAPI MmSetCleanPage ( PEPROCESS  Process,
PVOID  Address 
)

Definition at line 234 of file page.c.

235 {
236 }

◆ MmSetDirtyPage()

VOID NTAPI MmSetDirtyPage ( PEPROCESS  Process,
PVOID  Address 
)

Definition at line 240 of file page.c.

241 {
242 }

◆ MmSetPageProtect()

VOID NTAPI MmSetPageProtect ( PEPROCESS  Process,
PVOID  Address,
ULONG  flProtect 
)

Definition at line 428 of file page.c.

429 {
430  //ULONG Attributes = 0;
431 
432  DPRINT("MmSetPageProtect(Process %x Address %x flProtect %x)\n",
433  Process, Address, flProtect);
434 
435 #if 0
436  Attributes = ProtectToPTE(flProtect);
437 
439  if (Pt == NULL)
440  {
441  ASSERT(FALSE);
442  }
444  MiFlushTlb(Pt, Address);
445 #endif
446 }
static ULONG ProtectToPTE(ULONG flProtect)
Definition: page.c:153
static PMMPTE MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create)
Definition: page.c:331
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
static WCHAR Address[46]
Definition: ping.c:68
void DPRINT(...)
Definition: polytest.cpp:61
#define PAGE_MASK(x)
Definition: page.c:50
VOID MiFlushTlb(PMMPTE Pte, PVOID Address)
Definition: page.c:128
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define InterlockedExchange
Definition: armddk.h:54
_Must_inspect_result_ _In_ USHORT _In_ PHIDP_PREPARSED_DATA _Out_writes_to_ LengthAttributes PHIDP_EXTENDED_ATTRIBUTES Attributes
Definition: hidpi.h:348
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
#define PA_ACCESSED
Definition: page.c:28
#define PA_DIRTY
Definition: page.c:29
signed int * PLONG
Definition: retypes.h:5

◆ ProtectToFlags()

static ULONG ProtectToFlags ( ULONG  flProtect)
static

Definition at line 78 of file page.c.

79 {
80  return MMU_ALL_RW; // XXX hack
81 }
#define MMU_ALL_RW
Definition: mmu.h:78

Referenced by MmCreateVirtualMappingUnsafe().

◆ PTE_TO_PAGE()

__inline LARGE_INTEGER PTE_TO_PAGE ( ULONG  npage)

Definition at line 43 of file page.c.

44 {
46  dummy.QuadPart = (LONGLONG)(PAGE_MASK(npage));
47  return dummy;
48 }
int64_t LONGLONG
Definition: typedefs.h:68
#define PAGE_MASK(x)
Definition: page.c:50
unsigned char dummy
Definition: maze.c:118