MMPTE TempPde, TempPte;
PVOID NonPagedPoolExpansionVa;
ULONG OldCount;
+ KIRQL OldIrql;
/* Check for kernel stack size that's too big */
if (MmLargeStackSize > (KERNEL_LARGE_STACK_SIZE / _1KB))
// then add the color tables and convert to pages
//
MxPfnAllocation = (MmHighestPhysicalPage + 1) * sizeof(MMPFN);
- MxPfnAllocation <<= 1;
+ //MxPfnAllocation <<= 1;
MxPfnAllocation += (MmSecondaryColors * sizeof(MMCOLOR_TABLES) * 2);
MxPfnAllocation >>= PAGE_SHIFT;
MmNonPagedSystemStart = (PVOID)((ULONG_PTR)MmNonPagedPoolStart -
(MmNumberOfSystemPtes + 1) * PAGE_SIZE);
MmNonPagedSystemStart = (PVOID)((ULONG_PTR)MmNonPagedSystemStart &
- ~((4 * 1024 * 1024) - 1));
+ ~(PDE_MAPPED_VA - 1));
//
// Don't let it go below the minimum
// with the old memory manager, so we'll create a "Shadow PFN Database"
// instead, and arbitrarly start it at 0xB0000000.
//
- // We actually create two PFN databases, one for ReactOS starting here,
- // and the next one used for ARM3, which starts right after. The MmPfnAllocation
- // variable actually holds the size of both (the colored tables come after
- // the ARM3 PFN database).
- //
- MmPfnDatabase[0] = (PVOID)0xB0000000;
- MmPfnDatabase[1] = &MmPfnDatabase[0][MmHighestPhysicalPage];
- ASSERT(((ULONG_PTR)MmPfnDatabase[0] & ((4 * 1024 * 1024) - 1)) == 0);
+ MmPfnDatabase = (PVOID)0xB0000000;
+ ASSERT(((ULONG_PTR)MmPfnDatabase & (PDE_MAPPED_VA - 1)) == 0);
//
// Non paged pool comes after the PFN database
//
- MmNonPagedPoolStart = (PVOID)((ULONG_PTR)MmPfnDatabase[0] +
+ MmNonPagedPoolStart = (PVOID)((ULONG_PTR)MmPfnDatabase +
(MxPfnAllocation << PAGE_SHIFT));
//
//
// Now we need pages for the page tables which will map initial NP
//
- StartPde = MiAddressToPde(MmPfnDatabase[0]);
+ StartPde = MiAddressToPde(MmPfnDatabase);
EndPde = MiAddressToPde((PVOID)((ULONG_PTR)MmNonPagedPoolStart +
MmSizeOfNonPagedPoolInBytes - 1));
while (StartPde <= EndPde)
/* Initialize the color tables */
MiInitializeColorTables();
+ /* ReactOS Stuff */
+ extern KEVENT ZeroPageThreadEvent;
+ KeInitializeEvent(&ZeroPageThreadEvent, NotificationEvent, TRUE);
+
/* Build the PFN Database */
MiInitializePfnDatabase(LoaderBlock);
+ MmInitializeBalancer(MmAvailablePages, 0);
- /* Call back into shitMM to setup the ReactOS PFN database */
- MmInitializePageList();
-
//
// Reset the descriptor back so we can create the correct memory blocks
//
//
MiInitializeSystemPtes(PointerPte, MmNumberOfSystemPtes, SystemPteSpace);
- //
- // Get the PDE For hyperspace
- //
+ /* Get the PDE For hyperspace */
StartPde = MiAddressToPde(HYPER_SPACE);
- //
- // Allocate a page for it and create it
- //
- PageFrameIndex = MmAllocPage(MC_SYSTEM);
+ /* Lock PFN database */
+ OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
+
+ /* Allocate a page for hyperspace and create it */
+ PageFrameIndex = MiRemoveAnyPage(0);
TempPde.u.Hard.PageFrameNumber = PageFrameIndex;
TempPde.u.Hard.Global = FALSE; // Hyperspace is local!
ASSERT(StartPde->u.Hard.Valid == 0);
ASSERT(TempPde.u.Hard.Valid == 1);
*StartPde = TempPde;
+ /* Flush the TLB */
+ KeFlushCurrentTb();
+
+ /* Release the lock */
+ KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql);
+
//
// Zero out the page table now
//