[ros-diffs] [sir_richard] 47432: [NTOS]: Implement MiAllocatePfn, it is a simpler wrapper that grabs a page, sets its protection, and initializes its PFN entry. [NTOS]: Use MiAllocatePfn in MiLoadImageSection instead of MmAllocPage. Other than doing a better job at initializing the page, it creates our first caller of this function, great for testing, since this is a rather high-demand function, especially at boot. Please test.

sir_richard at svn.reactos.org sir_richard at svn.reactos.org
Sun May 30 05:02:40 CEST 2010


Author: sir_richard
Date: Sun May 30 05:02:39 2010
New Revision: 47432

URL: http://svn.reactos.org/svn/reactos?rev=47432&view=rev
Log:
[NTOS]: Implement MiAllocatePfn, it is a simpler wrapper that grabs a page, sets its protection, and initializes its PFN entry.
[NTOS]: Use MiAllocatePfn in MiLoadImageSection instead of MmAllocPage. Other than doing a better job at initializing the page, it creates our first caller of this function, great for testing, since this is a rather high-demand function, especially at boot.
Please test.

Modified:
    trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c
    trunk/reactos/ntoskrnl/mm/sysldr.c

Modified: trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c?rev=47432&r1=47431&r2=47432&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c [iso-8859-1] Sun May 30 05:02:39 2010
@@ -618,6 +618,44 @@
     Pfn1->u2.ShareCount++;
 }
 
+PFN_NUMBER
+NTAPI
+MiAllocatePfn(IN PMMPTE PointerPte,
+              IN ULONG Protection)
+{
+    KIRQL OldIrql;
+    PFN_NUMBER PageFrameIndex;
+    MMPTE TempPte;
+    
+    /* Make an empty software PTE */
+    MI_MAKE_SOFTWARE_PTE(&TempPte, MM_READWRITE);
+    
+    /* Lock the PFN database */
+    OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
+    
+    /* Check if we're running low on pages */
+    if (MmAvailablePages < 128)
+    {
+        DPRINT1("Warning, running low on memory: %d pages left\n", MmAvailablePages);
+        //MiEnsureAvailablePageOrWait(NULL, OldIrql);
+    }
+    
+    /* Grab a page */
+    PageFrameIndex = MiRemoveAnyPage(0);
+    
+    /* Write the software PTE */
+    ASSERT(PointerPte->u.Hard.Valid == 0);
+    *PointerPte = TempPte;
+    PointerPte->u.Soft.Protection |= Protection;
+    
+    /* Initialize its PFN entry */
+    MiInitializePfn(PageFrameIndex, PointerPte, TRUE);
+    
+    /* Release the PFN lock and return the page */
+    KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql);
+    return PageFrameIndex;
+}
+
 VOID
 NTAPI
 MiDecrementShareCount(IN PMMPFN Pfn1,

Modified: trunk/reactos/ntoskrnl/mm/sysldr.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/sysldr.c?rev=47432&r1=47431&r2=47432&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/sysldr.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/sysldr.c [iso-8859-1] Sun May 30 05:02:39 2010
@@ -172,7 +172,7 @@
     while (PointerPte < LastPte)
     {
         /* Allocate a page */
-        TempPte.u.Hard.PageFrameNumber = MmAllocPage(MC_NPPOOL);
+        TempPte.u.Hard.PageFrameNumber = MiAllocatePfn(PointerPte, MM_EXECUTE);
         
         /* Write it */
         ASSERT(PointerPte->u.Hard.Valid == 0);




More information about the Ros-diffs mailing list