mirror of
https://github.com/reactos/reactos.git
synced 2025-04-27 17:10:22 +00:00
[NTOS:MM]
- Simplify MiInitSystemMemoryAreas by introducing a helper, MiCreateArm3StaticMemoryArea. Patch by Mike Nordell svn path=/trunk/; revision=68421
This commit is contained in:
parent
88fed9bfce
commit
e39f524e17
1 changed files with 56 additions and 171 deletions
|
@ -38,198 +38,83 @@ extern NTSTATUS MiRosTrimCache(ULONG Target, ULONG Priority, PULONG NrFreed);
|
||||||
|
|
||||||
/* PRIVATE FUNCTIONS *********************************************************/
|
/* PRIVATE FUNCTIONS *********************************************************/
|
||||||
|
|
||||||
|
//
|
||||||
|
// Helper function to create initial memory areas.
|
||||||
|
// The created area is always read/write.
|
||||||
|
//
|
||||||
|
VOID
|
||||||
|
INIT_FUNCTION
|
||||||
|
NTAPI
|
||||||
|
MiCreateArm3StaticMemoryArea(PVOID BaseAddress, ULONG Size, BOOLEAN Executable)
|
||||||
|
{
|
||||||
|
const ULONG Protection = Executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
|
||||||
|
PVOID pBaseAddress = BaseAddress;
|
||||||
|
PMEMORY_AREA MArea;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
Status = MmCreateMemoryArea(MmGetKernelAddressSpace(),
|
||||||
|
MEMORY_AREA_OWNED_BY_ARM3 | MEMORY_AREA_STATIC,
|
||||||
|
&pBaseAddress,
|
||||||
|
Size,
|
||||||
|
Protection,
|
||||||
|
&MArea,
|
||||||
|
0,
|
||||||
|
PAGE_SIZE);
|
||||||
|
ASSERT(Status == STATUS_SUCCESS);
|
||||||
|
// TODO: Perhaps it would be prudent to bugcheck here, not only assert?
|
||||||
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
INIT_FUNCTION
|
INIT_FUNCTION
|
||||||
NTAPI
|
NTAPI
|
||||||
MiInitSystemMemoryAreas()
|
MiInitSystemMemoryAreas()
|
||||||
{
|
{
|
||||||
PVOID BaseAddress;
|
//
|
||||||
PMEMORY_AREA MArea;
|
// Create all the static memory areas.
|
||||||
NTSTATUS Status;
|
//
|
||||||
|
|
||||||
//
|
// The loader mappings. The only Executable area.
|
||||||
// Create the memory area to define the loader mappings
|
MiCreateArm3StaticMemoryArea((PVOID)KSEG0_BASE, MmBootImageSize, TRUE);
|
||||||
//
|
|
||||||
BaseAddress = (PVOID)KSEG0_BASE;
|
|
||||||
Status = MmCreateMemoryArea(MmGetKernelAddressSpace(),
|
|
||||||
MEMORY_AREA_OWNED_BY_ARM3 | MEMORY_AREA_STATIC,
|
|
||||||
&BaseAddress,
|
|
||||||
MmBootImageSize,
|
|
||||||
PAGE_EXECUTE_READWRITE,
|
|
||||||
&MArea,
|
|
||||||
0,
|
|
||||||
PAGE_SIZE);
|
|
||||||
ASSERT(Status == STATUS_SUCCESS);
|
|
||||||
|
|
||||||
//
|
// The PTE base
|
||||||
// Create the memory area to define the PTE base
|
MiCreateArm3StaticMemoryArea((PVOID)PTE_BASE, PTE_TOP - PTE_BASE + 1, FALSE);
|
||||||
//
|
|
||||||
BaseAddress = (PVOID)PTE_BASE;
|
|
||||||
Status = MmCreateMemoryArea(MmGetKernelAddressSpace(),
|
|
||||||
MEMORY_AREA_OWNED_BY_ARM3 | MEMORY_AREA_STATIC,
|
|
||||||
&BaseAddress,
|
|
||||||
PTE_TOP - PTE_BASE + 1,
|
|
||||||
PAGE_READWRITE,
|
|
||||||
&MArea,
|
|
||||||
0,
|
|
||||||
PAGE_SIZE);
|
|
||||||
ASSERT(Status == STATUS_SUCCESS);
|
|
||||||
|
|
||||||
//
|
// Hyperspace
|
||||||
// Create the memory area to define Hyperspace
|
MiCreateArm3StaticMemoryArea((PVOID)HYPER_SPACE, HYPER_SPACE_END - HYPER_SPACE + 1, FALSE);
|
||||||
//
|
|
||||||
BaseAddress = (PVOID)HYPER_SPACE;
|
|
||||||
Status = MmCreateMemoryArea(MmGetKernelAddressSpace(),
|
|
||||||
MEMORY_AREA_OWNED_BY_ARM3 | MEMORY_AREA_STATIC,
|
|
||||||
&BaseAddress,
|
|
||||||
HYPER_SPACE_END - HYPER_SPACE + 1,
|
|
||||||
PAGE_READWRITE,
|
|
||||||
&MArea,
|
|
||||||
0,
|
|
||||||
PAGE_SIZE);
|
|
||||||
ASSERT(Status == STATUS_SUCCESS);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Protect the PFN database
|
// Protect the PFN database
|
||||||
//
|
MiCreateArm3StaticMemoryArea(MmPfnDatabase, (MxPfnAllocation << PAGE_SHIFT), FALSE);
|
||||||
BaseAddress = MmPfnDatabase;
|
|
||||||
Status = MmCreateMemoryArea(MmGetKernelAddressSpace(),
|
|
||||||
MEMORY_AREA_OWNED_BY_ARM3 | MEMORY_AREA_STATIC,
|
|
||||||
&BaseAddress,
|
|
||||||
(MxPfnAllocation << PAGE_SHIFT),
|
|
||||||
PAGE_READWRITE,
|
|
||||||
&MArea,
|
|
||||||
0,
|
|
||||||
PAGE_SIZE);
|
|
||||||
ASSERT(Status == STATUS_SUCCESS);
|
|
||||||
|
|
||||||
//
|
|
||||||
// ReactOS requires a memory area to keep the initial NP area off-bounds
|
// ReactOS requires a memory area to keep the initial NP area off-bounds
|
||||||
//
|
MiCreateArm3StaticMemoryArea(MmNonPagedPoolStart, MmSizeOfNonPagedPoolInBytes, FALSE);
|
||||||
BaseAddress = MmNonPagedPoolStart;
|
|
||||||
Status = MmCreateMemoryArea(MmGetKernelAddressSpace(),
|
|
||||||
MEMORY_AREA_OWNED_BY_ARM3 | MEMORY_AREA_STATIC,
|
|
||||||
&BaseAddress,
|
|
||||||
MmSizeOfNonPagedPoolInBytes,
|
|
||||||
PAGE_READWRITE,
|
|
||||||
&MArea,
|
|
||||||
0,
|
|
||||||
PAGE_SIZE);
|
|
||||||
ASSERT(Status == STATUS_SUCCESS);
|
|
||||||
|
|
||||||
//
|
// System NP
|
||||||
// And we need one more for the system NP
|
MiCreateArm3StaticMemoryArea(MmNonPagedSystemStart, MiNonPagedSystemSize, FALSE);
|
||||||
//
|
|
||||||
BaseAddress = MmNonPagedSystemStart;
|
|
||||||
Status = MmCreateMemoryArea(MmGetKernelAddressSpace(),
|
|
||||||
MEMORY_AREA_OWNED_BY_ARM3 | MEMORY_AREA_STATIC,
|
|
||||||
&BaseAddress,
|
|
||||||
MiNonPagedSystemSize,
|
|
||||||
PAGE_READWRITE,
|
|
||||||
&MArea,
|
|
||||||
0,
|
|
||||||
PAGE_SIZE);
|
|
||||||
ASSERT(Status == STATUS_SUCCESS);
|
|
||||||
|
|
||||||
//
|
// System view space
|
||||||
// We also need one for system view space
|
MiCreateArm3StaticMemoryArea(MiSystemViewStart, MmSystemViewSize, FALSE);
|
||||||
//
|
|
||||||
BaseAddress = MiSystemViewStart;
|
|
||||||
Status = MmCreateMemoryArea(MmGetKernelAddressSpace(),
|
|
||||||
MEMORY_AREA_OWNED_BY_ARM3 | MEMORY_AREA_STATIC,
|
|
||||||
&BaseAddress,
|
|
||||||
MmSystemViewSize,
|
|
||||||
PAGE_READWRITE,
|
|
||||||
&MArea,
|
|
||||||
0,
|
|
||||||
PAGE_SIZE);
|
|
||||||
ASSERT(Status == STATUS_SUCCESS);
|
|
||||||
|
|
||||||
//
|
// Session space
|
||||||
// And another for session space
|
MiCreateArm3StaticMemoryArea(MmSessionBase, (ULONG_PTR)MiSessionSpaceEnd - (ULONG_PTR)MmSessionBase, FALSE);
|
||||||
//
|
|
||||||
BaseAddress = MmSessionBase;
|
// Paged pool
|
||||||
Status = MmCreateMemoryArea(MmGetKernelAddressSpace(),
|
MiCreateArm3StaticMemoryArea(MmPagedPoolStart, MmSizeOfPagedPoolInBytes, FALSE);
|
||||||
MEMORY_AREA_OWNED_BY_ARM3 | MEMORY_AREA_STATIC,
|
|
||||||
&BaseAddress,
|
|
||||||
(ULONG_PTR)MiSessionSpaceEnd -
|
|
||||||
(ULONG_PTR)MmSessionBase,
|
|
||||||
PAGE_READWRITE,
|
|
||||||
&MArea,
|
|
||||||
0,
|
|
||||||
PAGE_SIZE);
|
|
||||||
ASSERT(Status == STATUS_SUCCESS);
|
|
||||||
|
|
||||||
//
|
|
||||||
// One more for ARM paged pool
|
|
||||||
//
|
|
||||||
BaseAddress = MmPagedPoolStart;
|
|
||||||
Status = MmCreateMemoryArea(MmGetKernelAddressSpace(),
|
|
||||||
MEMORY_AREA_OWNED_BY_ARM3 | MEMORY_AREA_STATIC,
|
|
||||||
&BaseAddress,
|
|
||||||
MmSizeOfPagedPoolInBytes,
|
|
||||||
PAGE_READWRITE,
|
|
||||||
&MArea,
|
|
||||||
0,
|
|
||||||
PAGE_SIZE);
|
|
||||||
ASSERT(Status == STATUS_SUCCESS);
|
|
||||||
#ifndef _M_AMD64
|
#ifndef _M_AMD64
|
||||||
//
|
// KPCR, one page per CPU. Only for 32-bit kernel.
|
||||||
// Next, the KPCR
|
MiCreateArm3StaticMemoryArea(PCR, PAGE_SIZE * KeNumberProcessors, FALSE);
|
||||||
//
|
|
||||||
BaseAddress = (PVOID)PCR;
|
|
||||||
Status = MmCreateMemoryArea(MmGetKernelAddressSpace(),
|
|
||||||
MEMORY_AREA_OWNED_BY_ARM3 | MEMORY_AREA_STATIC,
|
|
||||||
&BaseAddress,
|
|
||||||
PAGE_SIZE * KeNumberProcessors,
|
|
||||||
PAGE_READWRITE,
|
|
||||||
&MArea,
|
|
||||||
0,
|
|
||||||
PAGE_SIZE);
|
|
||||||
ASSERT(Status == STATUS_SUCCESS);
|
|
||||||
#endif
|
#endif
|
||||||
//
|
|
||||||
// Now the KUSER_SHARED_DATA
|
|
||||||
//
|
|
||||||
BaseAddress = (PVOID)KI_USER_SHARED_DATA;
|
|
||||||
Status = MmCreateMemoryArea(MmGetKernelAddressSpace(),
|
|
||||||
MEMORY_AREA_OWNED_BY_ARM3 | MEMORY_AREA_STATIC,
|
|
||||||
&BaseAddress,
|
|
||||||
PAGE_SIZE,
|
|
||||||
PAGE_READWRITE,
|
|
||||||
&MArea,
|
|
||||||
0,
|
|
||||||
PAGE_SIZE);
|
|
||||||
ASSERT(Status == STATUS_SUCCESS);
|
|
||||||
|
|
||||||
//
|
// KUSER_SHARED_DATA
|
||||||
// And the debugger mapping
|
MiCreateArm3StaticMemoryArea((PVOID)KI_USER_SHARED_DATA, PAGE_SIZE, FALSE);
|
||||||
//
|
|
||||||
BaseAddress = MI_DEBUG_MAPPING;
|
// Debugger mapping
|
||||||
Status = MmCreateMemoryArea(MmGetKernelAddressSpace(),
|
MiCreateArm3StaticMemoryArea(MI_DEBUG_MAPPING, PAGE_SIZE, FALSE);
|
||||||
MEMORY_AREA_OWNED_BY_ARM3 | MEMORY_AREA_STATIC,
|
|
||||||
&BaseAddress,
|
|
||||||
PAGE_SIZE,
|
|
||||||
PAGE_READWRITE,
|
|
||||||
&MArea,
|
|
||||||
0,
|
|
||||||
PAGE_SIZE);
|
|
||||||
ASSERT(Status == STATUS_SUCCESS);
|
|
||||||
|
|
||||||
#if defined(_X86_)
|
#if defined(_X86_)
|
||||||
//
|
// Reserve the 2 pages we currently make use of for HAL mappings.
|
||||||
// Finally, reserve the 2 pages we currently make use of for HAL mappings
|
// TODO: Remove hard-coded constant and replace with a define.
|
||||||
//
|
MiCreateArm3StaticMemoryArea((PVOID)0xFFC00000, PAGE_SIZE * 2, FALSE);
|
||||||
BaseAddress = (PVOID)0xFFC00000;
|
|
||||||
Status = MmCreateMemoryArea(MmGetKernelAddressSpace(),
|
|
||||||
MEMORY_AREA_OWNED_BY_ARM3 | MEMORY_AREA_STATIC,
|
|
||||||
&BaseAddress,
|
|
||||||
PAGE_SIZE * 2,
|
|
||||||
PAGE_READWRITE,
|
|
||||||
&MArea,
|
|
||||||
0,
|
|
||||||
PAGE_SIZE);
|
|
||||||
ASSERT(Status == STATUS_SUCCESS);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue