ReactOS  0.4.15-dev-2526-g0fb3c1e
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)
 
VOID NTAPI MmInitGlobalKernelPageDirectory (VOID)
 
NTSTATUS MmPPCCreatePrimitiveMapping (ULONG_PTR PageAddr)
 
PFN_NUMBER MmPPCPrimitiveAllocPage ()
 

Macro Definition Documentation

◆ HYPERSPACE

#define HYPERSPACE   (0xc0400000)

Definition at line 30 of file page.c.

◆ HYPERSPACE_PAGEDIR_PTR

#define HYPERSPACE_PAGEDIR_PTR   ((PVOID)0xc0000000)

Definition at line 20 of file page.c.

◆ IS_HYPERSPACE

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

Definition at line 31 of file page.c.

◆ PA_ACCESSED

#define PA_ACCESSED   0x200

Definition at line 24 of file page.c.

◆ PA_CD

#define PA_CD   0x10

Definition at line 27 of file page.c.

◆ PA_DIRTY

#define PA_DIRTY   0x100

Definition at line 25 of file page.c.

◆ PA_PRESENT

#define PA_PRESENT   (1ll<<63)

Definition at line 22 of file page.c.

◆ PA_READWRITE

#define PA_READWRITE   3

Definition at line 28 of file page.c.

◆ PA_USER

#define PA_USER   (1ll<<62)

Definition at line 23 of file page.c.

◆ PA_WT

#define PA_WT   0x20

Definition at line 26 of file page.c.

◆ PFN_TO_PTE

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

Definition at line 34 of file page.c.

◆ PTE_TO_PFN

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

Definition at line 33 of file page.c.

Function Documentation

◆ MiFlushTlb()

VOID MiFlushTlb ( PULONG  Pt,
PVOID  Address 
)

Definition at line 68 of file page.c.

69 {
70  __asm__("tlbi %0" : "=r" (Address));
71 }
__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 51 of file page.c.

52 {
53  if (Address == (PVOID)0xffffffff)
54  {
55  __asm__("tlbsync");
56  }
57  else if (Address == (PVOID)0xfffffffe)
58  {
59  __asm__("tlbsync");
60  }
61  else
62  {
63  __asm__("tlbi %0" : "=r" (Address));
64  }
65 }
__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 81 of file page.c.

84 {
85  DPRINT("MmCopyMmInfo(Src %x, Dest %x)\n", Src, Dest);
86 
87  ASSERT(FALSE);
88 
89  return(STATUS_SUCCESS);
90 }
#define FALSE
Definition: types.h:117
#define ASSERT(a)
Definition: mode.c:45
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71

◆ MmCreatePageFileMapping()

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

Definition at line 267 of file page.c.

270 {
272  {
273  DPRINT1("No process\n");
274  ASSERT(FALSE);
275  }
276  if (Process != NULL && Address >= MmSystemRangeStart)
277  {
278  DPRINT1("Setting kernel address with process context\n");
279  ASSERT(FALSE);
280  }
281  if (SwapEntry & (1 << 31))
282  {
283  ASSERT(FALSE);
284  }
285 
286  // XXX arty
287 
288  return(STATUS_SUCCESS);
289 }
#define FALSE
Definition: types.h:117
static WCHAR Address[46]
Definition: ping.c:68
#define ASSERT(a)
Definition: mode.c:45
#define NULL
Definition: types.h:112
#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
#define STATUS_SUCCESS
Definition: shellext.h:65
#define MmSystemRangeStart
Definition: mm.h:32

◆ MmCreateProcessAddressSpace()

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

Definition at line 94 of file page.c.

97 {
98  ASSERT(FALSE);
99  return TRUE;
100 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ASSERT(a)
Definition: mode.c:45

◆ MmCreateVirtualMapping()

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

Definition at line 368 of file page.c.

373 {
374  ULONG i;
375 
376  for (i = 0; i < PageCount; i++)
377  {
378  if (!MmIsUsablePage(Pages[i]))
379  {
380  DPRINT1("Page at address %x not usable\n", PFN_TO_PTE(Pages[i]));
381  ASSERT(FALSE);
382  }
383  }
384 
386  Address,
387  flProtect,
388  Pages,
389  PageCount));
390 }
#define FALSE
Definition: types.h:117
NTSTATUS NTAPI MmCreateVirtualMappingUnsafe(IN PEPROCESS Process, IN PVOID Address, IN ULONG Protection, IN PPFN_NUMBER Pages, IN ULONG PageCount)
Definition: page.c:146
static WCHAR Address[46]
Definition: ping.c:68
#define ASSERT(a)
Definition: mode.c:45
#define PFN_TO_PTE(X)
Definition: page.c:34
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 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 294 of file page.c.

299 {
301  PVOID Addr;
302  ULONG i;
303  ppc_map_info_t info = { 0 };
304 
305  DPRINT("MmCreateVirtualMappingUnsafe(%x, %x, %x, %x (%x), %d)\n",
306  Process, Address, flProtect, Pages, *Pages, PageCount);
307 
308  if (Process == NULL)
309  {
311  {
312  DPRINT1("No process\n");
313  ASSERT(FALSE);
314  }
315  if (PageCount > 0x10000 ||
316  (ULONG_PTR) Address / PAGE_SIZE + PageCount > 0x100000)
317  {
318  DPRINT1("Page count to large\n");
319  ASSERT(FALSE);
320  }
321  }
322  else
323  {
325  {
326  DPRINT1("Setting kernel address with process context\n");
327  ASSERT(FALSE);
328  }
329  if (PageCount > (ULONG_PTR)MmSystemRangeStart / PAGE_SIZE ||
330  (ULONG_PTR) Address / PAGE_SIZE + PageCount >
332  {
333  DPRINT1("Page Count to large\n");
334  ASSERT(FALSE);
335  }
336  }
337 
338  Attributes = ProtectToFlags(flProtect);
339  Addr = Address;
340 
341  for (i = 0; i < PageCount; i++, Addr = (PVOID)((ULONG_PTR)Addr + PAGE_SIZE))
342  {
344  info.proc = ((Addr < MmSystemRangeStart) && Process) ?
345  (int)Process->UniqueProcessId : 0;
346  info.addr = (vaddr_t)Addr;
347  info.flags = Attributes;
348  MmuMapPage(&info, 1);
349  //(void)InterlockedExchangeUL(Pt, PFN_TO_PTE(Pages[i]) | Attributes);
350  if (Address < MmSystemRangeStart &&
351  ((PMADDRESS_SPACE)&Process->VadRoot)->PageTableRefCountTable != NULL &&
353  {
354 #if 0
355  PUSHORT Ptrc;
356 
357  Ptrc = ((PMADDRESS_SPACE)&Process->VadRoot)->PageTableRefCountTable;
358 
359  Ptrc[ADDR_TO_PAGE_TABLE(Addr)]++;
360 #endif
361  }
362  }
363  return(STATUS_SUCCESS);
364 }
#define ADDR_TO_PAGE_TABLE(v)
Definition: parse.h:178
static ULONG ProtectToFlags(ULONG flProtect)
Definition: page.c:74
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define FALSE
Definition: types.h:117
unsigned long vaddr_t
Definition: mmu.h:90
#define PsGetCurrentProcess
Definition: psfuncs.h:17
static WCHAR Address[46]
Definition: ping.c:68
#define PA_PRESENT
Definition: page.c:22
void * PVOID
Definition: retypes.h:9
#define ASSERT(a)
Definition: mode.c:45
#define PAGE_SIZE
Definition: env_spec_w32.h:49
static int MmuMapPage(ppc_map_info_t *info, int count)
Definition: mmu.h:197
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 NULL
Definition: types.h:112
#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
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
#define MmSystemRangeStart
Definition: mm.h:32
unsigned short * PUSHORT
Definition: retypes.h:2
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
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 190 of file page.c.

195 {
196  ppc_map_info_t info = { 0 };
197  /*
198  * Decrement the reference count for this page table.
199  */
200  if (Process != NULL &&
201  ((PMADDRESS_SPACE)&Process->VadRoot)->PageTableRefCountTable != NULL &&
203  {
204  PUSHORT Ptrc;
205 
206  Ptrc = ((PMADDRESS_SPACE)&Process->VadRoot)->PageTableRefCountTable;
208  }
209 
210  /*
211  * Return some information to the caller
212  */
213  MmuInqPage(&info, 1);
214  *SwapEntry = info.phys;
215 }
VOID NTAPI MmFreePageTable(PEPROCESS Process, PVOID Address)
Definition: page.c:134
static WCHAR Address[46]
Definition: ping.c:68
static void MmuInqPage(ppc_map_info_t *info, int count)
Definition: mmu.h:217
#define NULL
Definition: types.h:112
_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 104 of file page.c.

105 {
107 
108  DPRINT1("DeletePageTable: Process: %x CurrentProcess %x\n",
110 
111  if (Process != NULL && Process != CurrentProcess)
112  {
113  KeAttachProcess(&Process->Pcb);
114  }
115 
116  if (Process)
117  {
118  DPRINT1("Revoking VSID %d\n", (paddr_t)Process->UniqueProcessId);
119  MmuRevokeVsid((paddr_t)Process->UniqueProcessId, -1);
120  }
121  else
122  {
123  DPRINT1("No vsid to revoke\n");
124  }
125 
126  if (Process != NULL && Process != CurrentProcess)
127  {
128  KeDetachProcess();
129  }
130 }
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
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 NULL
Definition: types.h:112
#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 160 of file page.c.

165 {
166  ppc_map_info_t info = { 0 };
167 
168  DPRINT("MmDeleteVirtualMapping(%x, %x, %d, %x, %x)\n",
169  Process, Address, WasDirty, Page);
170 
171  info.proc = Process ? (int)Process->UniqueProcessId : 0;
172  info.addr = (vaddr_t)Address;
173  MmuInqPage(&info, 1);
174 
175  /*
176  * Return some information to the caller
177  */
178  if (WasDirty != NULL)
179  {
180  *WasDirty = !!(info.flags & MMU_PAGE_DIRTY);
181  }
182  if (Page != NULL)
183  {
184  *Page = info.phys >> PAGE_SHIFT;
185  }
186 }
#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
static WCHAR Address[46]
Definition: ping.c:68
PFN_NUMBER Page
Definition: section.c:4756
static void MmuInqPage(ppc_map_info_t *info, int count)
Definition: mmu.h:217
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
#define DPRINT
Definition: sndvol32.h:71
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 134 of file page.c.

135 {
137 }
VOID NTAPI MmDeletePageTable(PEPROCESS Process, PVOID Address)
Definition: page.c:104
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 251 of file page.c.

252 {
253  return 0; // XXX arty
254 }

Referenced by MmIsPageSwapEntry().

◆ MmGetPageProtect()

ULONG NTAPI MmGetPageProtect ( PEPROCESS  Process,
PVOID  Address 
)

Definition at line 394 of file page.c.

395 {
396  ULONG Protect = 0;
397  ppc_map_info_t info = { 0 };
398 
399  info.proc = Process ? (int)Process->UniqueProcessId : 0;
400  info.addr = (vaddr_t)Address;
401  MmuInqPage(&info, 1);
402 
403  if (!info.phys) { return PAGE_NOACCESS; }
404  if (!(info.flags & MMU_KMASK))
405  {
406  Protect |= PAGE_SYSTEM;
407  if ((info.flags & MMU_KR) && (info.flags & MMU_KW))
409  else if (info.flags & MMU_KR)
411  }
412  else
413  {
414  if ((info.flags & MMU_UR) && (info.flags & MMU_UW))
416  else
418  }
419  return(Protect);
420 }
_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:92
#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 152 of file page.c.

154 {
156 }
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
PVOID NTAPI MmGetPhysicalAddressProcess(PEPROCESS Process, PVOID Addr)
Definition: page.c:141
ULONG PFN_NUMBER
Definition: ke.h:9
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 141 of file page.c.

142 {
143  ppc_map_info_t info = { 0 };
144  info.proc = Process ? (int)Process->UniqueProcessId : 0;
145  info.addr = (vaddr_t)Addr;
146  MmuInqPage(&info, 1);
147  return (PVOID)info.phys;
148 }
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()

VOID NTAPI MmInitGlobalKernelPageDirectory ( VOID  )

Definition at line 447 of file page.c.

448 {
449 }

Referenced by MmInitSystem().

◆ MmIsDirtyPage()

BOOLEAN NTAPI MmIsDirtyPage ( PEPROCESS  Process,
PVOID  Address 
)

Definition at line 219 of file page.c.

220 {
221  ppc_map_info_t info = { 0 };
222  info.proc = Process ? (int)Process->UniqueProcessId : 0;
223  info.addr = (vaddr_t)Address;
224  MmuInqPage(&info, 1);
225  return !!(info.flags & MMU_PAGE_DIRTY);
226 }
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 242 of file page.c.

243 {
244  ppc_map_info_t info = { 0 };
245  info.proc = Process ? (int)Process->UniqueProcessId : 0;
246  info.addr = (vaddr_t)Address;
247  MmuInqPage(&info, 1);
248  return !!info.phys;
249 }
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 258 of file page.c.

259 {
260  ULONG Entry;
262  return !(Entry & PA_PRESENT) && Entry != 0 ? TRUE : FALSE;
263 }
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:22
ULONGLONG MmGetPageEntryForProcess(PEPROCESS Process, PVOID Address)
Definition: page.c:251
_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 452 of file page.c.

453 {
455  ppc_map_info_t info = { 0 };
456  info.flags = MMU_KRW;
457  info.addr = (vaddr_t)PageAddr;
459  return result;
460 }
GLuint64EXT * result
Definition: glext.h:11304
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
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ MmPPCPrimitiveAllocPage()

PFN_NUMBER MmPPCPrimitiveAllocPage ( )

Definition at line 463 of file page.c.

464 {
466  DbgPrint("Got Page %x\n", Result);
467  return Result / PAGE_SIZE;
468 }
#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 230 of file page.c.

231 {
232 }

◆ MmSetDirtyPage()

VOID NTAPI MmSetDirtyPage ( PEPROCESS  Process,
PVOID  Address 
)

Definition at line 236 of file page.c.

237 {
238 }

◆ MmSetPageProtect()

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

Definition at line 424 of file page.c.

425 {
426  //ULONG Attributes = 0;
427 
428  DPRINT("MmSetPageProtect(Process %x Address %x flProtect %x)\n",
429  Process, Address, flProtect);
430 
431 #if 0
432  Attributes = ProtectToPTE(flProtect);
433 
435  if (Pt == NULL)
436  {
437  ASSERT(FALSE);
438  }
440  MiFlushTlb(Pt, Address);
441 #endif
442 }
static ULONG ProtectToPTE(ULONG flProtect)
Definition: pagepae.c:105
#define FALSE
Definition: types.h:117
static WCHAR Address[46]
Definition: ping.c:68
VOID NTAPI MiFlushTlb(IN PMMPTE PointerPte, IN PVOID Address)
Definition: page.c:128
#define ASSERT(a)
Definition: mode.c:45
static PULONG MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create)
Definition: pagepae.c:435
#define InterlockedExchange
Definition: armddk.h:54
#define PAGE_MASK
Definition: tools.h:88
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
#define DPRINT
Definition: sndvol32.h:71
#define PA_ACCESSED
Definition: page.c:24
#define PA_DIRTY
Definition: page.c:25
signed int * PLONG
Definition: retypes.h:5
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes

◆ ProtectToFlags()

static ULONG ProtectToFlags ( ULONG  flProtect)
static

Definition at line 74 of file page.c.

75 {
76  return MMU_ALL_RW; // XXX hack
77 }
#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 39 of file page.c.

40 {
42  dummy.QuadPart = (LONGLONG)(PAGE_MASK(npage));
43  return dummy;
44 }
int64_t LONGLONG
Definition: typedefs.h:68
#define PAGE_MASK
Definition: tools.h:88
unsigned char dummy
Definition: maze.c:118