[NTOS]: Kill some debug spew.
[reactos.git] / reactos / ntoskrnl / mm / ARM3 / pool.c
index bd2f826..37cb2e5 100644 (file)
@@ -26,6 +26,8 @@ KGUARDED_MUTEX MmPagedPoolMutex;
 MM_PAGED_POOL_INFO MmPagedPoolInfo;
 SIZE_T MmAllocatedNonPagedPool;
 ULONG MmSpecialPoolTag;
+ULONG MmConsumedPoolPercentage;
+BOOLEAN MmProtectFreedNonPagedPool;
 
 /* PRIVATE FUNCTIONS **********************************************************/
 
@@ -262,6 +264,7 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
             // Get the page bit count
             //
             i = ((SizeInPages - 1) / 1024) + 1;
+            DPRINT1("Paged pool expansion: %d %x\n", i, SizeInPages);
             
             //
             // Check if there is enougn paged pool expansion space left
@@ -323,21 +326,25 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
                 //
                 ASSERT(PointerPte->u.Hard.Valid == 0);
                 
-                //
-                // Request a paged pool page and write the PFN for it
-                //
-                PageFrameNumber = MmAllocPage(MC_PPOOL);
+                /* Request a page */
+                PageFrameNumber = MiRemoveAnyPage(0);
                 TempPte.u.Hard.PageFrameNumber = PageFrameNumber;
                 
                 //
                 // Save it into our double-buffered system page directory
                 //
+                /* This seems to be making the assumption that one PDE is one page long */
+                C_ASSERT(PAGE_SIZE == (PD_COUNT * (sizeof(MMPTE) * PDE_COUNT)));
                 MmSystemPagePtes[(ULONG_PTR)PointerPte & (PAGE_SIZE - 1) /
                                  sizeof(MMPTE)] = TempPte;
                             
-                //
-                // Write the actual PTE now
-                //
+                /* Initialize the PFN */
+                MiInitializePfnForOtherProcess(PageFrameNumber,
+                                               PointerPte,
+                                               MmSystemPageDirectory[(PointerPte - (PMMPTE)PDE_BASE) / PDE_COUNT]);
+                             
+                /* Write the actual PTE now */
+                ASSERT(TempPte.u.Hard.Valid == 1);
                 *PointerPte++ = TempPte;
                 
                 //
@@ -414,11 +421,8 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
         //
         KeFlushEntireTb(TRUE, TRUE);
         
-        //
-        // Setup a demand-zero writable PTE
-        //
-        TempPte.u.Long = 0;
-        MI_MAKE_WRITE_PAGE(&TempPte);
+        /* Setup a demand-zero writable PTE */
+        MI_MAKE_SOFTWARE_PTE(&TempPte, MM_READWRITE);
         
         //
         // Find the first and last PTE, then loop them all
@@ -430,6 +434,7 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
             //
             // Write the demand zero PTE and keep going
             //
+            ASSERT(PointerPte->u.Hard.Valid == 0);
             *PointerPte++ = TempPte;
         } while (PointerPte < StartPte);
         
@@ -586,19 +591,18 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType,
     TempPte = ValidKernelPte;
     do
     {
-        //
-        // Allocate a page
-        //
-        PageFrameNumber = MmAllocPage(MC_NPPOOL);
+        /* Allocate a page */
+        PageFrameNumber = MiRemoveAnyPage(0);
         
-        //
-        // Get the PFN entry for it
-        //
+        /* Get the PFN entry for it and fill it out */
         Pfn1 = MiGetPfnEntry(PageFrameNumber);
+        Pfn1->u3.e2.ReferenceCount = 1;
+        Pfn1->u2.ShareCount = 1;
+        Pfn1->PteAddress = PointerPte;
+        Pfn1->u3.e1.PageLocation = ActiveAndValid;
+        Pfn1->u4.VerifierAllocation = 0;
         
-        //
-        // Write the PTE for it
-        //
+        /* Write the PTE for it */
         TempPte.u.Hard.PageFrameNumber = PageFrameNumber;
         ASSERT(PointerPte->u.Hard.Valid == 0);
         ASSERT(TempPte.u.Hard.Valid == 1);
@@ -662,6 +666,11 @@ MiFreePoolPages(IN PVOID StartingVa)
         //
         NumberOfPages = End - i + 1;
         
+        /* Delete the actual pages */
+        PointerPte = MmPagedPoolInfo.FirstPteForPagedPool + i;
+        FreePages = MiDeleteSystemPageableVm(PointerPte, NumberOfPages, 0, NULL);
+        ASSERT(FreePages == NumberOfPages);
+        
         //
         // Acquire the paged pool lock
         //