[NTOS]: Clean up Mm initialization, there is now no-more RosMM stuff done in Phase 0 of MmInit, only ARM3 runs. The kernel address space and memory areas are only initialized in Phase 1, because that's where sections are started up, and they're the only thing other than VM which still use memory-areas.

svn path=/trunk/; revision=49200
This commit is contained in:
Sir Richard 2010-10-18 23:07:09 +00:00
parent 619ab27e1d
commit 609dce9faf
5 changed files with 150 additions and 151 deletions

View file

@ -14,6 +14,14 @@
#include <debug.h>
#include "ntstrsafe.h"
/* Temporary hack */
BOOLEAN
NTAPI
MmArmInitSystem(
IN ULONG Phase,
IN PLOADER_PARAMETER_BLOCK LoaderBlock
);
typedef struct _INIT_BUFFER
{
WCHAR DebugBuffer[256];
@ -1045,7 +1053,7 @@ ExpInitializeExecutive(IN ULONG Cpu,
if (!ExInitSystem()) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
/* Initialize the memory manager at phase 0 */
if (!MmInitSystem(0, LoaderBlock)) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
if (!MmArmInitSystem(0, LoaderBlock)) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
/* Load boot symbols */
ExpLoadBootSymbols(LoaderBlock);
@ -1577,7 +1585,7 @@ Phase1InitializationDiscard(IN PVOID Context)
if (!MmInitSystem(1, LoaderBlock)) KeBugCheck(MEMORY1_INITIALIZATION_FAILED);
/* Create NLS section */
ExpInitNls(KeLoaderBlock);
ExpInitNls(LoaderBlock);
/* Initialize Cache Views */
if (!CcInitializeCacheManager()) KeBugCheck(CACHE_INITIALIZATION_FAILED);
@ -1862,8 +1870,8 @@ Phase1InitializationDiscard(IN PVOID Context)
NtClose(OptionHandle);
}
/* Unmap Low memory, and initialize the MPW and Balancer Thread */
MmInitSystem(2, LoaderBlock);
/* FIXME: This doesn't do anything for now */
MmArmInitSystem(2, LoaderBlock);
/* Update progress bar */
InbvUpdateProgressBar(80);

View file

@ -832,7 +832,7 @@ MiUnlockWorkingSet(IN PETHREAD Thread,
KeLeaveGuardedRegion();
}
NTSTATUS
BOOLEAN
NTAPI
MmArmInitSystem(
IN ULONG Phase,

View file

@ -353,6 +353,14 @@ SIZE_T MmAllocationFragment;
SIZE_T MmTotalCommitLimit;
SIZE_T MmTotalCommitLimitMaximum;
/* Internal setting used for debugging memory descriptors */
BOOLEAN MiDbgEnableMdDump =
#ifdef _ARM_
TRUE;
#else
FALSE;
#endif
/* PRIVATE FUNCTIONS **********************************************************/
PFN_NUMBER
@ -1654,7 +1662,58 @@ MiBuildPagedPool(VOID)
MiInitializeSystemSpaceMap(NULL);
}
NTSTATUS
VOID
NTAPI
MiDbgDumpMemoryDescriptors(VOID)
{
PLIST_ENTRY NextEntry;
PMEMORY_ALLOCATION_DESCRIPTOR Md;
ULONG TotalPages = 0;
PCHAR
MemType[] =
{
"ExceptionBlock ",
"SystemBlock ",
"Free ",
"Bad ",
"LoadedProgram ",
"FirmwareTemporary ",
"FirmwarePermanent ",
"OsloaderHeap ",
"OsloaderStack ",
"SystemCode ",
"HalCode ",
"BootDriver ",
"ConsoleInDriver ",
"ConsoleOutDriver ",
"StartupDpcStack ",
"StartupKernelStack",
"StartupPanicStack ",
"StartupPcrPage ",
"StartupPdrPage ",
"RegistryData ",
"MemoryData ",
"NlsData ",
"SpecialMemory ",
"BBTMemory ",
"LoaderReserve ",
"LoaderXIPRom "
};
DPRINT1("Base\t\tLength\t\tType\n");
for (NextEntry = KeLoaderBlock->MemoryDescriptorListHead.Flink;
NextEntry != &KeLoaderBlock->MemoryDescriptorListHead;
NextEntry = NextEntry->Flink)
{
Md = CONTAINING_RECORD(NextEntry, MEMORY_ALLOCATION_DESCRIPTOR, ListEntry);
DPRINT1("%08lX\t%08lX\t%s\n", Md->BasePage, Md->PageCount, MemType[Md->MemoryType]);
TotalPages += Md->PageCount;
}
DPRINT1("Total: %08lX (%d MB)\n", TotalPages, (TotalPages * PAGE_SIZE) / 1024 / 1024);
}
BOOLEAN
NTAPI
MmArmInitSystem(IN ULONG Phase,
IN PLOADER_PARAMETER_BLOCK LoaderBlock)
@ -1665,6 +1724,9 @@ MmArmInitSystem(IN ULONG Phase,
PPHYSICAL_MEMORY_RUN Run;
PFN_NUMBER PageCount;
/* Dump memory descriptors */
if (MiDbgEnableMdDump) MiDbgDumpMemoryDescriptors();
//
// Instantiate memory that we don't consider RAM/usable
// We use the same exclusions that Windows does, in order to try to be
@ -2065,7 +2127,7 @@ MmArmInitSystem(IN ULONG Phase,
//
// Always return success for now
//
return STATUS_SUCCESS;
return TRUE;
}
/* EOF */

View file

@ -199,7 +199,7 @@ MmAccessFault(IN BOOLEAN StoreInstruction,
IN KPROCESSOR_MODE Mode,
IN PVOID TrapInformation)
{
PMEMORY_AREA MemoryArea;
PMEMORY_AREA MemoryArea = NULL;
/* Cute little hack for ROS */
if ((ULONG_PTR)Address >= (ULONG_PTR)MmSystemRangeStart)
@ -214,27 +214,24 @@ MmAccessFault(IN BOOLEAN StoreInstruction,
#endif
}
/*
* Check if this is an ARM3 memory area or if there's no memory area at all.
* The latter can happen early in the boot cycle when ARM3 paged pool is in
* use before having defined the memory areas proper.
* A proper fix would be to define memory areas in the ARM3 code, but we want
* to avoid adding this ReactOS-specific construct to ARM3 code.
* Either way, in the future, as ReactOS-paged pool is eliminated, this hack
* can go away.
*/
/* Is there a ReactOS address space yet? */
if (MmGetKernelAddressSpace())
{
/* Check if this is an ARM3 memory area */
MemoryArea = MmLocateMemoryAreaByAddress(MmGetKernelAddressSpace(), Address);
if (!(MemoryArea) && (Address <= MM_HIGHEST_USER_ADDRESS))
{
/* Could this be a VAD fault from user-mode? */
MemoryArea = MmLocateMemoryAreaByAddress(MmGetCurrentAddressSpace(), Address);
}
if ((!(MemoryArea) && ((ULONG_PTR)Address >= (ULONG_PTR)MmPagedPoolStart)) ||
((MemoryArea) && (MemoryArea->Type == MEMORY_AREA_OWNED_BY_ARM3)))
}
/* Is this an ARM3 memory area, or is there no address space yet? */
if (((MemoryArea) && (MemoryArea->Type == MEMORY_AREA_OWNED_BY_ARM3)) ||
(!(MemoryArea) && ((ULONG_PTR)Address >= (ULONG_PTR)MmPagedPoolStart)) ||
(!MmGetKernelAddressSpace()))
{
//
// Hand it off to more competent hands...
//
/* This is an ARM3 fault */
DPRINT("ARM3 fault %p\n", MemoryArea);
return MmArmAccessFault(StoreInstruction, Address, Mode, TrapInformation);
}

View file

@ -19,37 +19,6 @@
VOID NTAPI MiInitializeUserPfnBitmap(VOID);
PCHAR
MemType[] =
{
"ExceptionBlock ",
"SystemBlock ",
"Free ",
"Bad ",
"LoadedProgram ",
"FirmwareTemporary ",
"FirmwarePermanent ",
"OsloaderHeap ",
"OsloaderStack ",
"SystemCode ",
"HalCode ",
"BootDriver ",
"ConsoleInDriver ",
"ConsoleOutDriver ",
"StartupDpcStack ",
"StartupKernelStack",
"StartupPanicStack ",
"StartupPcrPage ",
"StartupPdrPage ",
"RegistryData ",
"MemoryData ",
"NlsData ",
"SpecialMemory ",
"BBTMemory ",
"LoaderReserve ",
"LoaderXIPRom "
};
HANDLE MpwThreadHandle;
KEVENT MpwThreadEvent;
@ -61,12 +30,6 @@ ULONG MmReadClusterSize;
UCHAR MmDisablePagingExecutive = 1; // Forced to off
PMMPTE MmSharedUserDataPte;
PMMSUPPORT MmKernelAddressSpace;
BOOLEAN MiDbgEnableMdDump =
#ifdef _ARM_
TRUE;
#else
FALSE;
#endif
/* PRIVATE FUNCTIONS *********************************************************/
@ -314,27 +277,6 @@ MiDbgDumpAddressSpace(VOID)
"Non Paged Pool Expansion PTE Space");
}
VOID
NTAPI
MiDbgDumpMemoryDescriptors(VOID)
{
PLIST_ENTRY NextEntry;
PMEMORY_ALLOCATION_DESCRIPTOR Md;
ULONG TotalPages = 0;
DPRINT1("Base\t\tLength\t\tType\n");
for (NextEntry = KeLoaderBlock->MemoryDescriptorListHead.Flink;
NextEntry != &KeLoaderBlock->MemoryDescriptorListHead;
NextEntry = NextEntry->Flink)
{
Md = CONTAINING_RECORD(NextEntry, MEMORY_ALLOCATION_DESCRIPTOR, ListEntry);
DPRINT1("%08lX\t%08lX\t%s\n", Md->BasePage, Md->PageCount, MemType[Md->MemoryType]);
TotalPages += Md->PageCount;
}
DPRINT1("Total: %08lX (%d MB)\n", TotalPages, (TotalPages * PAGE_SIZE) / 1024 / 1024);
}
NTSTATUS NTAPI
MmMpwThreadMain(PVOID Ignored)
{
@ -428,27 +370,18 @@ MmInitSystem(IN ULONG Phase,
MMPTE TempPte = ValidKernelPte;
PFN_NUMBER PageFrameNumber;
if (Phase == 0)
{
/* Initialize the kernel address space */
KeInitializeGuardedMutex(&PsGetCurrentProcess()->AddressCreationLock);
MmKernelAddressSpace = MmGetCurrentAddressSpace();
MmInitGlobalKernelPageDirectory();
/* Dump memory descriptors */
if (MiDbgEnableMdDump) MiDbgDumpMemoryDescriptors();
/* Initialize ARM³ in phase 0 */
MmArmInitSystem(0, KeLoaderBlock);
ASSERT(Phase == 1);
KeInitializeGuardedMutex(&PsIdleProcess->AddressCreationLock);
MmKernelAddressSpace = &PsIdleProcess->Vm;
/* Intialize system memory areas */
MiInitSystemMemoryAreas();
/* Dump the address space */
MiDbgDumpAddressSpace();
}
else if (Phase == 1)
{
MmInitGlobalKernelPageDirectory();
MiInitializeUserPfnBitmap();
MmInitializeMemoryConsumer(MC_USER, MmTrimUserMemory);
MmInitializeRmapList();
@ -496,7 +429,6 @@ MmInitSystem(IN ULONG Phase,
/* Initialize the balance set manager */
MmInitBsmThread();
}
return TRUE;
}