Author: tkreuzer
Date: Thu Aug 28 19:24:55 2008
New Revision: 35737
URL:
http://svn.reactos.org/svn/reactos?rev=35737&view=rev
Log:
Implement MmUpdatePageDir
Modified:
branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/amd64/mm.h
branches/ros-amd64-bringup/reactos/ntoskrnl/mm/amd64/page.c
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/amd64/mm.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/amd64/mm.h [iso-8859-1]
(original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/amd64/mm.h [iso-8859-1]
Thu Aug 28 19:24:55 2008
@@ -2,8 +2,8 @@
* Lowlevel memory managment definitions
*/
-#ifndef __NTOSKRNL_INCLUDE_INTERNAL_I386_MM_H
-#define __NTOSKRNL_INCLUDE_INTERNAL_I386_MM_H
+#ifndef __NTOSKRNL_INCLUDE_INTERNAL_AMD64_MM_H
+#define __NTOSKRNL_INCLUDE_INTERNAL_AMD64_MM_H
struct _EPROCESS;
PULONG_PTR MmGetPageDirectory(VOID);
@@ -17,15 +17,21 @@
/* Converting address to a corresponding PDE or PTE entry */
#define MiAddressToPde(x) \
- ((PMMPTE)(((((ULONG)(x)) >> 22) << 2) + PAGEDIRECTORY_MAP))
+ ((PMMPTE)(((((ULONG64)(x)) >> 22) << 2) + PAGEDIRECTORY_MAP))
#define MiAddressToPte(x) \
- ((PMMPTE)(((((ULONG)(x)) >> 12) << 2) + PAGETABLE_MAP))
+ ((PMMPTE)(((((ULONG64)(x)) >> 12) << 2) + PAGETABLE_MAP))
-#define ADDR_TO_PAGE_TABLE(v) (((ULONG)(v)) / (1024 * PAGE_SIZE))
-#define ADDR_TO_PDE_OFFSET(v) ((((ULONG)(v)) / (1024 * PAGE_SIZE)))
-#define ADDR_TO_PTE_OFFSET(v) ((((ULONG)(v)) % (1024 * PAGE_SIZE)) / PAGE_SIZE)
+//#define ADDR_TO_PAGE_TABLE(v) (((ULONG)(v)) / (1024 * PAGE_SIZE))
+//#define ADDR_TO_PDE_OFFSET(v) ((((ULONG)(v)) / (1024 * PAGE_SIZE)))
+//#define ADDR_TO_PTE_OFFSET(v) ((((ULONG)(v)) % (1024 * PAGE_SIZE)) / PAGE_SIZE)
+
+#define VAtoPXI(va) ((((ULONG64)va) >> PXI_SHIFT) & 0x1FF)
+#define VAtoPPI(va) ((((ULONG64)va) >> PPI_SHIFT) & 0x1FF)
+#define VAtoPDI(va) ((((ULONG64)va) >> PDI_SHIFT) & 0x1FF)
+#define VAtoPTI(va) ((((ULONG64)va) >> PTI_SHIFT) & 0x1FF)
+
/* Easy accessing PFN in PTE */
#define PFN_FROM_PTE(v) ((v)->u.Hard.PageFrameNumber)
-#endif /* __NTOSKRNL_INCLUDE_INTERNAL_I386_MM_H */
+#endif /* __NTOSKRNL_INCLUDE_INTERNAL_AMD64_MM_H */
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/mm/amd64/page.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/mm/amd64/page.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/mm/amd64/page.c [iso-8859-1] Thu Aug 28
19:24:55 2008
@@ -21,6 +21,7 @@
/* GLOBALS *****************************************************************/
+ULONG64 MmGlobalKernelPageDirectory[512];
/* FUNCTIONS ***************************************************************/
@@ -301,7 +302,37 @@
NTAPI
MmUpdatePageDir(PEPROCESS Process, PVOID Address, ULONG Size)
{
- UNIMPLEMENTED;
+ ULONG StartIndex, EndIndex, Index;
+ PULONG64 Pde;
+
+ /* Sanity check */
+ if (Address < MmSystemRangeStart)
+ {
+ KEBUGCHECK(0);
+ }
+
+ /* Get pointer to the page directory to update */
+ if (Process != NULL && Process != PsGetCurrentProcess())
+ {
+// Pde =
MmCreateHyperspaceMapping(PTE_TO_PFN(Process->Pcb.DirectoryTableBase[0]));
+ }
+ else
+ {
+ Pde = (PULONG64)PXE_BASE;
+ }
+
+ /* Update PML4 entries */
+ StartIndex = VAtoPXI(Address);
+ EndIndex = VAtoPXI((ULONG64)Address + Size);
+ for (Index = StartIndex; Index <= EndIndex; Index++)
+ {
+ if (Index != VAtoPXI(PXE_BASE))
+ {
+ (void)InterlockedCompareExchangePointer((PVOID*)&Pde[Index],
+ MmGlobalKernelPageDirectory[Index],
+ 0);
+ }
+ }
}
VOID