- Implement MmGetPfnForProcess, MmIsPageSwapEntry.
authorReactOS Portable Systems Group <ros-arm-bringup@svn.reactos.org>
Tue, 24 Jun 2008 14:16:06 +0000 (14:16 +0000)
committerReactOS Portable Systems Group <ros-arm-bringup@svn.reactos.org>
Tue, 24 Jun 2008 14:16:06 +0000 (14:16 +0000)
- Fix a bug in MmDeletePageTable.
- Use MmCreateVirtualMappingForKernel when we are already in the right process context, and allow it to be used for addresses < KSEG0_BASE as well.
- We now have full memory mapped file support, and get all the way to CmInitSystem1.

svn path=/trunk/; revision=34072

reactos/ntoskrnl/mm/arm/stubs.c

index bafad58..652c880 100644 (file)
@@ -162,36 +162,51 @@ MmDeletePageTable(IN PEPROCESS Process,
     ASSERT(PointerPde->u.Hard.L1.Fault.Type == FaultPte);
     
     //
-    // Check if this is a kernel PDE
+    // Invalidate the TLB entry
     //
-    if ((PointerPde >= (PMMPTE)PTE_BASE) && (PointerPde < (PMMPTE)PTE_BASE + (1024 * 1024)))
+    KiFlushSingleTb(TRUE, Address);
+}
+
+PFN_TYPE
+NTAPI
+MmGetPfnForProcess(IN PEPROCESS Process,
+                   IN PVOID Address)
+{
+    PMMPTE Pte;
+    
+    //
+    // Check if this is for a different process
+    //
+    if ((Process) && (Process != PsGetCurrentProcess()))
     {
         //
-        // Invalidate the TLB entry
+        // TODO
         //
-        KiFlushSingleTb(TRUE, Address);
+        UNIMPLEMENTED;
+        return 0;
     }
-    else
+    
+    //
+    // Get the PDE
+    //
+    Pte = MiGetPdeAddress(Address);
+    if (Pte->u.Hard.L1.Fault.Type != FaultPte)
     {
         //
-        // Process PDE, unmap it from hyperspace (will also invalidate TLB entry)
+        // Get the PTE
         //
-        MmDeleteHyperspaceMapping((PVOID)PAGE_ROUND_DOWN(PointerPde));
+        Pte = MiGetPteAddress(Address);
     }
-}
-
-PFN_TYPE
-NTAPI
-MmGetPfnForProcess(IN PEPROCESS Process,
-                   IN PVOID Address)
-{
-    PFN_TYPE Pfn = {0};
     
     //
-    // TODO
+    // If PTE is invalid, return 0
     //
-    UNIMPLEMENTED;
-    return Pfn;
+    if (Pte->u.Hard.L2.Fault.Type == FaultPte) return 0;
+    
+    //
+    // Return PFN
+    //
+    return Pte->u.Hard.L2.Small.BaseAddress;
 }
 
 VOID
@@ -323,8 +338,6 @@ MmIsPagePresent(IN PEPROCESS Process,
     // Return whether or not it's valid
     //
     return (Pte->u.Hard.L1.Fault.Type != FaultPte);
-    
-    
 }
 
 BOOLEAN
@@ -332,11 +345,36 @@ NTAPI
 MmIsPageSwapEntry(IN PEPROCESS Process,
                   IN PVOID Address)
 {
+    PMMPTE Pte;
+    
     //
-    // TODO
+    // Check if this is for a different process
     //
-    UNIMPLEMENTED;
-    return 0;
+    if ((Process) && (Process != PsGetCurrentProcess()))
+    {
+        //
+        // TODO
+        //
+        UNIMPLEMENTED;
+        return 0;
+    }
+    
+    //
+    // Get the PDE
+    //
+    Pte = MiGetPdeAddress(Address);
+    if (Pte->u.Hard.L1.Fault.Type != FaultPte)
+    {
+        //
+        // Get the PTE
+        //
+        Pte = MiGetPteAddress(Address);
+    }
+    
+    //
+    // Return whether or not it's valid
+    //
+    return ((Pte->u.Hard.L2.Fault.Type == FaultPte) && (Pte->u.Hard.AsUlong));
 }
 
 NTSTATUS
@@ -351,7 +389,7 @@ MmCreateVirtualMappingForKernel(IN PVOID Address,
     NTSTATUS Status;
     PFN_NUMBER Pfn;
     DPRINT1("[KMAP]: %p %d\n", Address, PageCount);
-    ASSERT(Address >= MmSystemRangeStart);
+    //ASSERT(Address >= MmSystemRangeStart);
 
     //
     // Get our templates
@@ -468,7 +506,7 @@ MmCreateVirtualMappingUnsafe(IN PEPROCESS Process,
     //
     // Are we only handling the kernel?
     //
-    if (!Process)
+    if (!(Process) || (Process == PsGetCurrentProcess()))
     {
         //
         // Call the kernel version
@@ -675,7 +713,6 @@ MmDeleteHyperspaceMapping(IN PVOID Address)
     //
     KiFlushSingleTb(TRUE, Address);
     return Pfn;
-    
 }
 
 VOID