// figure out the most appropriate values.
//
ULONG MmMaximumNonPagedPoolPercent;
-ULONG MmSizeOfNonPagedPoolInBytes;
-ULONG MmMaximumNonPagedPoolInBytes;
+SIZE_T MmSizeOfNonPagedPoolInBytes;
+SIZE_T MmMaximumNonPagedPoolInBytes;
/* Some of the same values, in pages */
PFN_NUMBER MmMaximumNonPagedPoolInPages;
// They are described on http://support.microsoft.com/default.aspx/kb/126402/ja
// along with the algorithm that uses them, which is implemented later below.
//
-ULONG MmMinimumNonPagedPoolSize = 256 * 1024;
+SIZE_T MmMinimumNonPagedPoolSize = 256 * 1024;
ULONG MmMinAdditionNonPagedPoolPerMb = 32 * 1024;
-ULONG MmDefaultMaximumNonPagedPool = 1024 * 1024;
+SIZE_T MmDefaultMaximumNonPagedPool = 1024 * 1024;
ULONG MmMaxAdditionNonPagedPoolPerMb = 400 * 1024;
//
//
// And this is its default size
//
-ULONG MmSizeOfPagedPoolInBytes = MI_MIN_INIT_PAGED_POOLSIZE;
+SIZE_T MmSizeOfPagedPoolInBytes = MI_MIN_INIT_PAGED_POOLSIZE;
PFN_NUMBER MmSizeOfPagedPoolInPages = MI_MIN_INIT_PAGED_POOLSIZE / PAGE_SIZE;
//
PVOID MiSessionPoolEnd; // 0xBE000000
PVOID MiSessionPoolStart; // 0xBD000000
PVOID MmSessionBase; // 0xBD000000
-ULONG MmSessionSize;
-ULONG MmSessionViewSize;
-ULONG MmSessionPoolSize;
-ULONG MmSessionImageSize;
+SIZE_T MmSessionSize;
+SIZE_T MmSessionViewSize;
+SIZE_T MmSessionPoolSize;
+SIZE_T MmSessionImageSize;
/*
* These are the PTE addresses of the boundaries carved out above
// By default, it is a 16MB region.
//
PVOID MiSystemViewStart;
-ULONG MmSystemViewSize;
+SIZE_T MmSystemViewSize;
//
// A copy of the system page directory (the page directory associated with the
// On systems with more than 32MB, this number is then doubled, and further
// aligned up to a PDE boundary (4MB).
//
-ULONG MmNumberOfSystemPtes;
+ULONG_PTR MmNumberOfSystemPtes;
//
// This is how many pages the PFN database will take up
// In Windows, this includes the Quark Color Table, but not in ARMĀ³
//
-ULONG MxPfnAllocation;
+PFN_NUMBER MxPfnAllocation;
//
// Unlike the old ReactOS Memory Manager, ARMĀ³ (and Windows) does not keep track
//
// This is where we keep track of the most basic physical layout markers
//
-ULONG MmNumberOfPhysicalPages, MmHighestPhysicalPage, MmLowestPhysicalPage = -1;
+PFN_NUMBER MmNumberOfPhysicalPages, MmHighestPhysicalPage, MmLowestPhysicalPage = -1;
//
// The total number of pages mapped by the boot loader, which include the kernel
//
// This number is later aligned up to a PDE boundary.
//
-ULONG MmBootImageSize;
+SIZE_T MmBootImageSize;
//
// These three variables keep track of the core separation of address space that
// exists between kernel mode and user mode.
//
-ULONG MmUserProbeAddress;
+ULONG_PTR MmUserProbeAddress;
PVOID MmHighestUserAddress;
PVOID MmSystemRangeStart;
/* FIXME: Move to cache/working set code later */
BOOLEAN MmLargeSystemCache;
+/*
+ * This value determines in how many fragments/chunks the subsection prototype
+ * PTEs should be allocated when mapping a section object. It is configurable in
+ * the registry through the MapAllocationFragment parameter.
+ *
+ * The default is 64KB on systems with more than 1GB of RAM, 32KB on systems with
+ * more than 256MB of RAM, and 16KB on systems with less than 256MB of RAM.
+ *
+ * The maximum it can be set to is 2MB, and the minimum is 4KB.
+ */
+SIZE_T MmAllocationFragment;
+
+/*
+ * These two values track how much virtual memory can be committed, and when
+ * expansion should happen.
+ */
+ // FIXME: They should be moved elsewhere since it's not an "init" setting?
+SIZE_T MmTotalCommitLimit;
+SIZE_T MmTotalCommitLimitMaximum;
+
/* PRIVATE FUNCTIONS **********************************************************/
+#ifndef _M_AMD64
//
// In Bavaria, this is probably a hate crime
//
Pde++;
}
}
+#endif
PFN_NUMBER
NTAPI
DPRINT("System PTE count has been tuned to %d (%d bytes)\n",
MmNumberOfSystemPtes, MmNumberOfSystemPtes * PAGE_SIZE);
+
+ /* Initialize the working set lock */
+ ExInitializePushLock((PULONG_PTR)&MmSystemCacheWs.WorkingSetMutex);
+
+ /* Set commit limit */
+ MmTotalCommitLimit = 2 * _1GB;
+ MmTotalCommitLimitMaximum = MmTotalCommitLimit;
+
+ /* Has the allocation fragment been setup? */
+ if (!MmAllocationFragment)
+ {
+ /* Use the default value */
+ MmAllocationFragment = MI_ALLOCATION_FRAGMENT;
+ if (PageCount < ((256 * _1MB) / PAGE_SIZE))
+ {
+ /* On memory systems with less than 256MB, divide by 4 */
+ MmAllocationFragment = MI_ALLOCATION_FRAGMENT / 4;
+ }
+ else if (PageCount < (_1GB / PAGE_SIZE))
+ {
+ /* On systems with less than 1GB, divide by 2 */
+ MmAllocationFragment = MI_ALLOCATION_FRAGMENT / 2;
+ }
+ }
+ else
+ {
+ /* Convert from 1KB fragments to pages */
+ MmAllocationFragment *= _1KB;
+ MmAllocationFragment = ROUND_TO_PAGES(MmAllocationFragment);
+
+ /* Don't let it past the maximum */
+ MmAllocationFragment = min(MmAllocationFragment,
+ MI_MAX_ALLOCATION_FRAGMENT);
+
+ /* Don't let it too small either */
+ MmAllocationFragment = max(MmAllocationFragment,
+ MI_MIN_ALLOCATION_FRAGMENT);
+ }
/* Initialize the platform-specific parts */
MiInitMachineDependent(LoaderBlock);
/* FIXME: Call out into Driver Verifier for initialization */
/* Check how many pages the system has */
- if (MmNumberOfPhysicalPages <= (13 * _1MB))
+ if (MmNumberOfPhysicalPages <= ((13 * _1MB) / PAGE_SIZE))
{
/* Set small system */
MmSystemSize = MmSmallSystem;
}
- else if (MmNumberOfPhysicalPages <= (19 * _1MB))
+ else if (MmNumberOfPhysicalPages <= ((19 * _1MB) / PAGE_SIZE))
{
/* Set small system and add 100 pages for the cache */
MmSystemSize = MmSmallSystem;
return FALSE;
}
+ /* Initialize the system cache */
+ //MiInitializeSystemCache(MmSystemCacheWsMinimum, MmAvailablePages);
+
+ /* Update the commit limit */
+ MmTotalCommitLimit = MmAvailablePages;
+ if (MmTotalCommitLimit > 1024) MmTotalCommitLimit -= 1024;
+ MmTotalCommitLimitMaximum = MmTotalCommitLimit;
+
/* Size up paged pool and build the shadow system page directory */
MiBuildPagedPool();
/* Debugger physical memory support is now ready to be used */
- MiDbgReadyForPhysical = TRUE;
+ MmDebugPte = MiAddressToPte(MiDebugMapping);
/* Initialize the loaded module list */
MiInitializeLoadedModuleList(LoaderBlock);