[NTOS]: Enable usage of ARM3 paged pool, up until Mm Phase 2.
[reactos.git] / reactos / ntoskrnl / mm / mminit.c
index cdaec0a..83c45f1 100644 (file)
@@ -48,7 +48,7 @@ MemType[] =
     "LoaderXIPRom      "
 };
 
-PBOOLEAN Mm64BitPhysicalAddress = FALSE;
+BOOLEAN Mm64BitPhysicalAddress = FALSE;
 ULONG MmReadClusterSize;
 //
 // 0 | 1 is on/off paging, 2 is undocumented
@@ -109,7 +109,7 @@ MiInitSystemMemoryAreas()
     //
     // Protect the PFN database
     //
-    BaseAddress = MmPfnDatabase[0];
+    BaseAddress = MmPfnDatabase;
     Status = MmCreateMemoryArea(MmGetKernelAddressSpace(),
                                 MEMORY_AREA_OWNED_BY_ARM3 | MEMORY_AREA_STATIC,
                                 &BaseAddress,
@@ -292,8 +292,8 @@ MiDbgDumpAddressSpace(VOID)
             (ULONG_PTR)MmPagedPoolBase + MmPagedPoolSize,
             "Paged Pool");
     DPRINT1("          0x%p - 0x%p\t%s\n",
-            MmPfnDatabase[0],
-            (ULONG_PTR)MmPfnDatabase[0] + (MxPfnAllocation << PAGE_SHIFT),
+            MmPfnDatabase,
+            (ULONG_PTR)MmPfnDatabase + (MxPfnAllocation << PAGE_SHIFT),
             "PFN Database");
     DPRINT1("          0x%p - 0x%p\t%s\n",
             MmNonPagedPoolStart,
@@ -371,18 +371,8 @@ MmInitSystem(IN ULONG Phase,
         /* Dump memory descriptors */
         if (MiDbgEnableMdDump) MiDbgDumpMemoryDescriptors();
         
-        //
-        // Initialize ARMĀ³ in phase 0
-        //
+        /* Initialize ARMĀ³ in phase 0 */
         MmArmInitSystem(0, KeLoaderBlock);    
-
-#if defined(_WINKD_)
-        //
-        // Everything required for the debugger to read and write
-        // physical memory is now set up
-        //
-        MiDbgReadyForPhysical = TRUE;
-#endif
         
         /* Put the paged pool after the loaded modules */
         MmPagedPoolBase = (PVOID)PAGE_ROUND_UP((ULONG_PTR)MmSystemRangeStart +
@@ -394,36 +384,12 @@ MmInitSystem(IN ULONG Phase,
 
         /* Dump the address space */
         MiDbgDumpAddressSpace();
-        
-        /* Initialize paged pool */
-        MmInitializePagedPool();
-        
-        /* Initialize working sets */
-        MiInitializeUserPfnBitmap();
-        MmInitializeMemoryConsumer(MC_USER, MmTrimUserMemory);
-
-        /* Initialize the user mode image list */
-        InitializeListHead(&MmLoadedUserImageList);
-
-        /* Initialize the Loader Lock */
-        KeInitializeMutant(&MmSystemLoadLock, FALSE);
-
-        /* Reload boot drivers */
-        MiReloadBootLoadedDrivers(LoaderBlock);
-
-        /* Initialize the loaded module list */
-        MiInitializeLoadedModuleList(LoaderBlock);
-
-        /* Setup shared user data settings that NT does as well */
-        ASSERT(SharedUserData->NumberOfPhysicalPages == 0);
-        SharedUserData->NumberOfPhysicalPages = MmNumberOfPhysicalPages;
-        SharedUserData->LargePageMinimum = 0;
-        
-        /* For now, we assume that we're always Server */
-        SharedUserData->NtProductType = NtProductServer;
     }
     else if (Phase == 1)
     {
+        MmInitializePagedPool();
+        MiInitializeUserPfnBitmap();
+        MmInitializeMemoryConsumer(MC_USER, MmTrimUserMemory);
         MmInitializeRmapList();
         MmInitializePageOp();
         MmInitSectionImplementation();
@@ -454,6 +420,9 @@ MmInitSystem(IN ULONG Phase,
         TempPte.u.Hard.PageFrameNumber = PageFrameNumber;
         *MmSharedUserDataPte = TempPte;
         
+        /* Setup the memory threshold events */
+        if (!MiInitializeMemoryEvents()) return FALSE;
+        
         /*
          * Unmap low memory
          */
@@ -469,7 +438,9 @@ MmInitSystem(IN ULONG Phase,
     }
     else if (Phase == 2)
     {
-
+        /* Enough fun for now */
+        extern BOOLEAN AllowPagedPool;
+        AllowPagedPool = FALSE;
     }
 
     return TRUE;