[ros-diffs] [tkreuzer] 55505: [NTOSKRNL] - Implement amd64 version of MmDeleteProcessPageDirectory - Fix amd64 build

tkreuzer at svn.reactos.org tkreuzer at svn.reactos.org
Wed Feb 8 22:23:13 UTC 2012


Author: tkreuzer
Date: Wed Feb  8 22:23:10 2012
New Revision: 55505

URL: http://svn.reactos.org/svn/reactos?rev=55505&view=rev
Log:
[NTOSKRNL]
- Implement amd64 version of MmDeleteProcessPageDirectory
- Fix amd64 build

Modified:
    trunk/reactos/ntoskrnl/kd64/kddata.c
    trunk/reactos/ntoskrnl/mm/ARM3/mminit.c
    trunk/reactos/ntoskrnl/mm/amd64/page.c

Modified: trunk/reactos/ntoskrnl/kd64/kddata.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd64/kddata.c?rev=55505&r1=55504&r2=55505&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/kd64/kddata.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/kd64/kddata.c [iso-8859-1] Wed Feb  8 22:23:10 2012
@@ -12,6 +12,7 @@
 #define NDEBUG
 #include <debug.h>
 #include "../mm/ARM3/miarm.h"
+#undef MmSystemRangeStart
 
 VOID NTAPI RtlpBreakWithStatusInstruction(VOID);
 

Modified: trunk/reactos/ntoskrnl/mm/ARM3/mminit.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/mminit.c?rev=55505&r1=55504&r2=55505&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/mminit.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/mminit.c [iso-8859-1] Wed Feb  8 22:23:10 2012
@@ -14,6 +14,7 @@
 
 #define MODULE_INVOLVED_IN_ARM3
 #include "miarm.h"
+#undef MmSystemRangeStart
 
 /* GLOBALS ********************************************************************/
 
@@ -170,7 +171,7 @@
 //
 // This should be 0xC0C00000 -- the cache itself starts at 0xC1000000
 //
-PMMWSL MmSystemCacheWorkingSetList = MI_SYSTEM_CACHE_WS_START;
+PMMWSL MmSystemCacheWorkingSetList = (PVOID)MI_SYSTEM_CACHE_WS_START;
 
 //
 // Windows NT seems to choose between 7000, 11000 and 50000

Modified: trunk/reactos/ntoskrnl/mm/amd64/page.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/amd64/page.c?rev=55505&r1=55504&r2=55505&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/amd64/page.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/amd64/page.c [iso-8859-1] Wed Feb  8 22:23:10 2012
@@ -138,6 +138,80 @@
 }
 
 static
+VOID
+MmDeletePageTablePfn(PFN_NUMBER PageFrameNumber, ULONG Level)
+{
+    PMMPTE PageTable;
+    KIRQL OldIrql;
+    PMMPFN PfnEntry;
+    ULONG i, NumberEntries;
+
+    /* Check if this is a page table */
+    if (Level > 0)
+    {
+        NumberEntries = (Level == 4) ? MiAddressToPxi(MmHighestUserAddress)+1 : 512;
+
+        /* Map the page table in hyperspace */
+        PageTable = (PMMPTE)MmCreateHyperspaceMapping(PageFrameNumber);
+
+        /* Loop all page table entries */
+        for (i = 0; i < NumberEntries; i++)
+        {
+            /* Check if the entry is valid */
+            if (PageTable[i].u.Hard.Valid)
+            {
+                /* Recursively free the page that backs it */
+                MmDeletePageTablePfn(PageTable[i].u.Hard.PageFrameNumber, Level - 1);
+            }
+        }
+
+        /* Delete the hyperspace mapping */
+        MmDeleteHyperspaceMapping(PageTable);
+    }
+
+    /* Check if this is a legacy allocation */
+    PfnEntry = MiGetPfnEntry(PageFrameNumber);
+    if (MI_IS_ROS_PFN(PfnEntry))
+    {
+        /* Free it using the legacy API */
+        MmReleasePageMemoryConsumer(MC_SYSTEM, PageFrameNumber);
+    }
+    else
+    {
+        OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
+
+        /* Free it using the ARM3 API */
+        MI_SET_PFN_DELETED(PfnEntry);
+        MiDecrementShareCount(PfnEntry, PageFrameNumber);
+
+        KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql);
+    }
+}
+
+VOID
+NTAPI
+MmDeleteProcessPageDirectory(PEPROCESS Process)
+{
+    PFN_NUMBER TableBasePfn;
+    PMMPTE PageDir;
+
+    /* Get the page directory PFN */
+    TableBasePfn = Process->Pcb.DirectoryTableBase[0] >> PAGE_SHIFT;
+
+    /* Map the page directory in hyperspace */
+    PageDir = (PMMPTE)MmCreateHyperspaceMapping(TableBasePfn);
+
+    /* Free the hyperspace mapping page (ARM3) */
+    //MmDeletePageTablePfn(PageDir[ADDR_TO_PDE_OFFSET(HYPERSPACE)].u.Hard.PageFrameNumber, 3);
+
+    /* Delete the hyperspace mapping */
+    MmDeleteHyperspaceMapping(PageDir);
+
+    /* Recursively free the page directories */
+    MmDeletePageTablePfn(TableBasePfn, 4);
+}
+
+static
 PMMPTE
 MiGetPteForProcess(
     PEPROCESS Process,
@@ -626,44 +700,6 @@
     }
 
     return MmCreateVirtualMappingUnsafe(Process, Address, Protect, Pages, PageCount);
-}
-
-static PMMPTE
-MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create)
-{
-    __debugbreak();
-    return 0;
-}
-
-BOOLEAN MmUnmapPageTable(PMMPTE Pt)
-{
-    ASSERT(FALSE);
-    return 0;
-}
-
-static ULONG64 MmGetPageEntryForProcess(PEPROCESS Process, PVOID Address)
-{
-    MMPTE Pte, *PointerPte;
-
-    PointerPte = MmGetPageTableForProcess(Process, Address, FALSE);
-    if (PointerPte)
-    {
-        Pte = *PointerPte;
-        MmUnmapPageTable(PointerPte);
-        return Pte.u.Long;
-    }
-    return 0;
-}
-
-VOID
-NTAPI
-MmGetPageFileMapping(
-    PEPROCESS Process,
-    PVOID Address,
-    SWAPENTRY* SwapEntry)
-{
-	ULONG64 Entry = MmGetPageEntryForProcess(Process, Address);
-	*SwapEntry = Entry >> 1;
 }
 
 BOOLEAN




More information about the Ros-diffs mailing list