mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 00:23:10 +00:00
- Nonpaged pool MEMORY_AREA is now initialized during nonpaged pool initialization (and it is now a static MEMORY_AREA).
- Paged pool MEMORY_AREA is now initialized during paged pool initialization. - Remaining MEMORY_AREAs (KPCR and KUSER_SHARED_DATA) are now created in MiInitSystemMemoryAreas (and they are also static) instead of MmInitVirtualMemory, since this is really what the function was doing. - The page table and hyperspace MEMORY_AREAs are still initialized the same, but are also now static. - The creation of these core/system memory areas is now done much earlier. For example, hyperspace memory area is now created before hyperspace is mapped. - Nonpaged pool, paged pool, and working set initialization is now done outside MiInitSystemMemoryAreas and roughly at the same time as before. - Removed MmInitVirtualMemory as it had become a kitchen sink of random Memory Manager initialization code. - I/O and Local APIC MEMORY_AREAs are not created anymore, since that should be done by the HAL, not the kernel. svn path=/trunk/; revision=41510
This commit is contained in:
parent
f29743948c
commit
e7b3dac46f
6 changed files with 86 additions and 110 deletions
|
@ -29,7 +29,7 @@ struct _MM_PAGEOP;
|
||||||
typedef ULONG SWAPENTRY;
|
typedef ULONG SWAPENTRY;
|
||||||
typedef ULONG PFN_TYPE, *PPFN_TYPE;
|
typedef ULONG PFN_TYPE, *PPFN_TYPE;
|
||||||
|
|
||||||
#define MI_STATIC_MEMORY_AREAS (1)
|
#define MI_STATIC_MEMORY_AREAS (6)
|
||||||
|
|
||||||
#define MEMORY_AREA_INVALID (0)
|
#define MEMORY_AREA_INVALID (0)
|
||||||
#define MEMORY_AREA_SECTION_VIEW (1)
|
#define MEMORY_AREA_SECTION_VIEW (1)
|
||||||
|
|
|
@ -1161,7 +1161,7 @@ MiInitPageDirectoryMap(VOID)
|
||||||
BoundaryAddressMultiple.QuadPart = 0;
|
BoundaryAddressMultiple.QuadPart = 0;
|
||||||
BaseAddress = (PVOID)PAGETABLE_MAP;
|
BaseAddress = (PVOID)PAGETABLE_MAP;
|
||||||
Status = MmCreateMemoryArea(MmGetKernelAddressSpace(),
|
Status = MmCreateMemoryArea(MmGetKernelAddressSpace(),
|
||||||
MEMORY_AREA_SYSTEM,
|
MEMORY_AREA_SYSTEM | MEMORY_AREA_STATIC,
|
||||||
&BaseAddress,
|
&BaseAddress,
|
||||||
0x400000,
|
0x400000,
|
||||||
PAGE_READWRITE,
|
PAGE_READWRITE,
|
||||||
|
@ -1175,7 +1175,7 @@ MiInitPageDirectoryMap(VOID)
|
||||||
}
|
}
|
||||||
BaseAddress = (PVOID)HYPERSPACE;
|
BaseAddress = (PVOID)HYPERSPACE;
|
||||||
Status = MmCreateMemoryArea(MmGetKernelAddressSpace(),
|
Status = MmCreateMemoryArea(MmGetKernelAddressSpace(),
|
||||||
MEMORY_AREA_SYSTEM,
|
MEMORY_AREA_SYSTEM | MEMORY_AREA_STATIC,
|
||||||
&BaseAddress,
|
&BaseAddress,
|
||||||
0x400000,
|
0x400000,
|
||||||
PAGE_READWRITE,
|
PAGE_READWRITE,
|
||||||
|
|
|
@ -293,7 +293,8 @@ MmNotPresentFault(KPROCESSOR_MODE Mode,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MEMORY_AREA_SHARED_DATA:
|
case MEMORY_AREA_SHARED_DATA:
|
||||||
Pfn = MmSharedDataPagePhysicalAddress.LowPart >> PAGE_SHIFT;
|
Pfn = MmGetPhysicalAddress((PVOID)PCR).LowPart >> PAGE_SHIFT;
|
||||||
|
Pfn++;
|
||||||
Status =
|
Status =
|
||||||
MmCreateVirtualMapping(PsGetCurrentProcess(),
|
MmCreateVirtualMapping(PsGetCurrentProcess(),
|
||||||
(PVOID)PAGE_ROUND_DOWN(Address),
|
(PVOID)PAGE_ROUND_DOWN(Address),
|
||||||
|
|
|
@ -47,7 +47,6 @@ MemType[] =
|
||||||
|
|
||||||
BOOLEAN IsThisAnNtAsSystem = FALSE;
|
BOOLEAN IsThisAnNtAsSystem = FALSE;
|
||||||
MM_SYSTEMSIZE MmSystemSize = MmSmallSystem;
|
MM_SYSTEMSIZE MmSystemSize = MmSmallSystem;
|
||||||
PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress;
|
|
||||||
PVOID MiNonPagedPoolStart;
|
PVOID MiNonPagedPoolStart;
|
||||||
ULONG MiNonPagedPoolLength;
|
ULONG MiNonPagedPoolLength;
|
||||||
ULONG MmBootImageSize;
|
ULONG MmBootImageSize;
|
||||||
|
@ -107,110 +106,45 @@ MiShutdownMemoryManager(VOID)
|
||||||
VOID
|
VOID
|
||||||
INIT_FUNCTION
|
INIT_FUNCTION
|
||||||
NTAPI
|
NTAPI
|
||||||
MmInitVirtualMemory()
|
MiInitSystemMemoryAreas()
|
||||||
{
|
{
|
||||||
PVOID BaseAddress;
|
PVOID BaseAddress;
|
||||||
ULONG Length;
|
PHYSICAL_ADDRESS BoundaryAddressMultiple;
|
||||||
NTSTATUS Status;
|
PMEMORY_AREA MArea;
|
||||||
PHYSICAL_ADDRESS BoundaryAddressMultiple;
|
BoundaryAddressMultiple.QuadPart = 0;
|
||||||
PMEMORY_AREA MArea;
|
|
||||||
|
|
||||||
BoundaryAddressMultiple.QuadPart = 0;
|
//
|
||||||
|
// First initialize the page table and hyperspace memory areas
|
||||||
|
//
|
||||||
|
MiInitPageDirectoryMap();
|
||||||
|
|
||||||
DPRINT("NonPagedPool %x - %x, PagedPool %x - %x\n", MiNonPagedPoolStart, (ULONG_PTR)MiNonPagedPoolStart + MiNonPagedPoolLength - 1,
|
//
|
||||||
MmPagedPoolBase, (ULONG_PTR)MmPagedPoolBase + MmPagedPoolSize - 1);
|
// Next, the KPCR
|
||||||
|
//
|
||||||
|
BaseAddress = (PVOID)PCR;
|
||||||
|
MmCreateMemoryArea(MmGetKernelAddressSpace(),
|
||||||
|
MEMORY_AREA_SYSTEM | MEMORY_AREA_STATIC,
|
||||||
|
&BaseAddress,
|
||||||
|
PAGE_SIZE * KeNumberProcessors,
|
||||||
|
PAGE_READWRITE,
|
||||||
|
&MArea,
|
||||||
|
TRUE,
|
||||||
|
0,
|
||||||
|
BoundaryAddressMultiple);
|
||||||
|
|
||||||
MiInitializeNonPagedPool();
|
//
|
||||||
|
// Now the KUSER_SHARED_DATA
|
||||||
/*
|
//
|
||||||
* Setup the system area descriptor list
|
BaseAddress = (PVOID)KI_USER_SHARED_DATA;
|
||||||
*/
|
MmCreateMemoryArea(MmGetKernelAddressSpace(),
|
||||||
MiInitPageDirectoryMap();
|
MEMORY_AREA_SYSTEM | MEMORY_AREA_STATIC,
|
||||||
|
&BaseAddress,
|
||||||
BaseAddress = (PVOID)PCR;
|
PAGE_SIZE,
|
||||||
MmCreateMemoryArea(MmGetKernelAddressSpace(),
|
PAGE_READWRITE,
|
||||||
MEMORY_AREA_SYSTEM,
|
&MArea,
|
||||||
&BaseAddress,
|
TRUE,
|
||||||
PAGE_SIZE * KeNumberProcessors,
|
0,
|
||||||
PAGE_READWRITE,
|
BoundaryAddressMultiple);
|
||||||
&MArea,
|
|
||||||
TRUE,
|
|
||||||
0,
|
|
||||||
BoundaryAddressMultiple);
|
|
||||||
|
|
||||||
#if defined(_M_IX86)
|
|
||||||
/* Local APIC base */
|
|
||||||
BaseAddress = (PVOID)0xFEE00000;
|
|
||||||
MmCreateMemoryArea(MmGetKernelAddressSpace(),
|
|
||||||
MEMORY_AREA_SYSTEM,
|
|
||||||
&BaseAddress,
|
|
||||||
PAGE_SIZE,
|
|
||||||
PAGE_READWRITE,
|
|
||||||
&MArea,
|
|
||||||
TRUE,
|
|
||||||
0,
|
|
||||||
BoundaryAddressMultiple);
|
|
||||||
|
|
||||||
/* i/o APIC base */
|
|
||||||
BaseAddress = (PVOID)0xFEC00000;
|
|
||||||
MmCreateMemoryArea(MmGetKernelAddressSpace(),
|
|
||||||
MEMORY_AREA_SYSTEM,
|
|
||||||
&BaseAddress,
|
|
||||||
PAGE_SIZE,
|
|
||||||
PAGE_READWRITE,
|
|
||||||
&MArea,
|
|
||||||
TRUE,
|
|
||||||
0,
|
|
||||||
BoundaryAddressMultiple);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
BaseAddress = MiNonPagedPoolStart;
|
|
||||||
MmCreateMemoryArea(MmGetKernelAddressSpace(),
|
|
||||||
MEMORY_AREA_SYSTEM,
|
|
||||||
&BaseAddress,
|
|
||||||
MiNonPagedPoolLength,
|
|
||||||
PAGE_READWRITE,
|
|
||||||
&MArea,
|
|
||||||
TRUE,
|
|
||||||
0,
|
|
||||||
BoundaryAddressMultiple);
|
|
||||||
|
|
||||||
BaseAddress = MmPagedPoolBase;
|
|
||||||
Status = MmCreateMemoryArea(MmGetKernelAddressSpace(),
|
|
||||||
MEMORY_AREA_PAGED_POOL,
|
|
||||||
&BaseAddress,
|
|
||||||
MmPagedPoolSize,
|
|
||||||
PAGE_READWRITE,
|
|
||||||
&MArea,
|
|
||||||
TRUE,
|
|
||||||
0,
|
|
||||||
BoundaryAddressMultiple);
|
|
||||||
|
|
||||||
MmInitializePagedPool();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Create the kernel mapping of the user/kernel shared memory.
|
|
||||||
*/
|
|
||||||
BaseAddress = (PVOID)KI_USER_SHARED_DATA;
|
|
||||||
Length = PAGE_SIZE;
|
|
||||||
MmCreateMemoryArea(MmGetKernelAddressSpace(),
|
|
||||||
MEMORY_AREA_SYSTEM,
|
|
||||||
&BaseAddress,
|
|
||||||
Length,
|
|
||||||
PAGE_READWRITE,
|
|
||||||
&MArea,
|
|
||||||
TRUE,
|
|
||||||
0,
|
|
||||||
BoundaryAddressMultiple);
|
|
||||||
|
|
||||||
/* Shared data are always located the next page after PCR */
|
|
||||||
MmSharedDataPagePhysicalAddress = MmGetPhysicalAddress((PVOID)PCR);
|
|
||||||
MmSharedDataPagePhysicalAddress.QuadPart += PAGE_SIZE;
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
MmInitializeMemoryConsumer(MC_USER, MmTrimUserMemory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
@ -433,6 +367,9 @@ MmInit1(VOID)
|
||||||
/* Dump kernel memory layout */
|
/* Dump kernel memory layout */
|
||||||
MiDbgKernelLayout();
|
MiDbgKernelLayout();
|
||||||
|
|
||||||
|
/* Intialize system memory areas */
|
||||||
|
MiInitSystemMemoryAreas();
|
||||||
|
|
||||||
/* Initialize hyperspace */
|
/* Initialize hyperspace */
|
||||||
MiInitHyperSpace();
|
MiInitHyperSpace();
|
||||||
|
|
||||||
|
@ -442,11 +379,17 @@ MmInit1(VOID)
|
||||||
/* Unmap low memory */
|
/* Unmap low memory */
|
||||||
MmDeletePageTable(NULL, 0);
|
MmDeletePageTable(NULL, 0);
|
||||||
|
|
||||||
/* Intialize memory areas */
|
/* Initialize nonpaged pool */
|
||||||
MmInitVirtualMemory();
|
MiInitializeNonPagedPool();
|
||||||
|
|
||||||
|
/* Initialize paged pool */
|
||||||
|
MmInitializePagedPool();
|
||||||
|
|
||||||
/* Initialize MDLs */
|
/* Initialize MDLs */
|
||||||
MmInitializeMdlImplementation();
|
MmInitializeMdlImplementation();
|
||||||
|
|
||||||
|
/* Initialize working sets */
|
||||||
|
MmInitializeMemoryConsumer(MC_USER, MmTrimUserMemory);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
|
|
|
@ -1699,6 +1699,22 @@ MiInitializeNonPagedPool(VOID)
|
||||||
PVOID Address;
|
PVOID Address;
|
||||||
HDR_USED* used;
|
HDR_USED* used;
|
||||||
HDR_FREE* free;
|
HDR_FREE* free;
|
||||||
|
PVOID BaseAddress;
|
||||||
|
PHYSICAL_ADDRESS BoundaryAddressMultiple;
|
||||||
|
PMEMORY_AREA MArea;
|
||||||
|
BoundaryAddressMultiple.QuadPart = 0;
|
||||||
|
|
||||||
|
BaseAddress = MiNonPagedPoolStart;
|
||||||
|
MmCreateMemoryArea(MmGetKernelAddressSpace(),
|
||||||
|
MEMORY_AREA_SYSTEM | MEMORY_AREA_STATIC,
|
||||||
|
&BaseAddress,
|
||||||
|
MiNonPagedPoolLength,
|
||||||
|
PAGE_READWRITE,
|
||||||
|
&MArea,
|
||||||
|
TRUE,
|
||||||
|
0,
|
||||||
|
BoundaryAddressMultiple);
|
||||||
|
|
||||||
#ifdef TAG_STATISTICS_TRACKING
|
#ifdef TAG_STATISTICS_TRACKING
|
||||||
|
|
||||||
for (i = 0; i < TAG_HASH_TABLE_SIZE; i++)
|
for (i = 0; i < TAG_HASH_TABLE_SIZE; i++)
|
||||||
|
|
|
@ -52,6 +52,22 @@ INIT_FUNCTION
|
||||||
NTAPI
|
NTAPI
|
||||||
MmInitializePagedPool(VOID)
|
MmInitializePagedPool(VOID)
|
||||||
{
|
{
|
||||||
|
PVOID BaseAddress;
|
||||||
|
PHYSICAL_ADDRESS BoundaryAddressMultiple;
|
||||||
|
PMEMORY_AREA MArea;
|
||||||
|
BoundaryAddressMultiple.QuadPart = 0;
|
||||||
|
|
||||||
|
BaseAddress = MmPagedPoolBase;
|
||||||
|
MmCreateMemoryArea(MmGetKernelAddressSpace(),
|
||||||
|
MEMORY_AREA_PAGED_POOL,
|
||||||
|
&BaseAddress,
|
||||||
|
MmPagedPoolSize,
|
||||||
|
PAGE_READWRITE,
|
||||||
|
&MArea,
|
||||||
|
TRUE,
|
||||||
|
0,
|
||||||
|
BoundaryAddressMultiple);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We are still at a high IRQL level at this point so explicitly commit
|
* We are still at a high IRQL level at this point so explicitly commit
|
||||||
* the first page of the paged pool before writing the first block header.
|
* the first page of the paged pool before writing the first block header.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue