extern unsigned int _bss_end__;
static MEMORY_AREA* kernel_text_desc = NULL;
+static MEMORY_AREA* kernel_map_desc = NULL;
static MEMORY_AREA* kernel_data_desc = NULL;
static MEMORY_AREA* kernel_param_desc = NULL;
static MEMORY_AREA* kernel_pool_desc = NULL;
static MEMORY_AREA* kernel_shared_data_desc = NULL;
+static MEMORY_AREA* MiKernelMapDescriptor = NULL;
static MEMORY_AREA* MiPagedPoolDescriptor = NULL;
PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress;
+PVOID MiNonPagedPoolStart;
+ULONG MiNonPagedPoolLength;
+PVOID MiKernelMapStart;
+ULONG MiKernelMapLength;
+
/* FUNCTIONS ****************************************************************/
+/*
+ * @implemented
+ */
BOOLEAN STDCALL MmIsThisAnNtAsSystem(VOID)
{
return(IsThisAnNtAsSystem);
}
+/*
+ * @implemented
+ */
MM_SYSTEM_SIZE STDCALL MmQuerySystemSize(VOID)
{
return(MmSystemSize);
DPRINT("MmInitVirtualMemory(%x, %x)\n",LastKernelAddress, KernelLength);
LastKernelAddress = PAGE_ROUND_UP(LastKernelAddress);
-
+
MmInitMemoryAreas();
- ExInitNonPagedPool(LastKernelAddress + PAGE_SIZE);
+
+ /* Don't change the start of kernel map. Pte's must always exist for this region. */
+ MiKernelMapStart = (PVOID)LastKernelAddress + PAGE_SIZE;
+ MiKernelMapLength = MM_KERNEL_MAP_SIZE;
+
+ MiNonPagedPoolStart = MiKernelMapStart + MiKernelMapLength + PAGE_SIZE;
+ MiNonPagedPoolLength = MM_NONPAGED_POOL_SIZE;
+
+ MmPagedPoolBase = MiNonPagedPoolStart + MiNonPagedPoolLength + PAGE_SIZE;
+ MmPagedPoolSize = MM_PAGED_POOL_SIZE;
+
+
+ MiInitKernelMap();
+ MiInitializeNonPagedPool();
/*
* Setup the system area descriptor list
*/
+ BaseAddress = (PVOID)0xf0000000;
+ MmCreateMemoryArea(NULL,
+ MmGetKernelAddressSpace(),
+ MEMORY_AREA_SYSTEM,
+ &BaseAddress,
+ 0x400000,
+ 0,
+ &kernel_map_desc,
+ FALSE,
+ FALSE);
+
BaseAddress = (PVOID)KERNEL_BASE;
Length = PAGE_ROUND_UP(((ULONG)&_text_end__)) - KERNEL_BASE;
ParamLength = ParamLength - Length;
Length,
0,
&kernel_text_desc,
+ FALSE,
FALSE);
-
Length = PAGE_ROUND_UP(((ULONG)&_bss_end__)) -
PAGE_ROUND_UP(((ULONG)&_text_end__));
ParamLength = ParamLength - Length;
* the only thread running.
*/
MmCreateMemoryArea(NULL,
- MmGetKernelAddressSpace(),
+ MmGetKernelAddressSpace(),
MEMORY_AREA_SYSTEM,
&BaseAddress,
Length,
0,
&kernel_data_desc,
+ FALSE,
FALSE);
-
+
BaseAddress = (PVOID)PAGE_ROUND_UP(((ULONG)&_bss_end__));
-// Length = ParamLength;
Length = LastKernelAddress - (ULONG)BaseAddress;
MmCreateMemoryArea(NULL,
- MmGetKernelAddressSpace(),
+ MmGetKernelAddressSpace(),
MEMORY_AREA_SYSTEM,
&BaseAddress,
Length,
0,
&kernel_param_desc,
+ FALSE,
FALSE);
-
- BaseAddress = (PVOID)(LastKernelAddress + PAGE_SIZE);
- Length = NONPAGED_POOL_SIZE;
+
+ BaseAddress = MiNonPagedPoolStart;
MmCreateMemoryArea(NULL,
MmGetKernelAddressSpace(),
MEMORY_AREA_SYSTEM,
&BaseAddress,
- Length,
+ MiNonPagedPoolLength,
0,
&kernel_pool_desc,
+ FALSE,
FALSE);
- MmPagedPoolSize = MM_PAGED_POOL_SIZE;
- BaseAddress = (PVOID)(LastKernelAddress + PAGE_SIZE + NONPAGED_POOL_SIZE +
- PAGE_SIZE);
- MmPagedPoolBase = BaseAddress;
- Length = MM_PAGED_POOL_SIZE;
- MmCreateMemoryArea(NULL,
+ BaseAddress = MiKernelMapStart;
+ Status = MmCreateMemoryArea(NULL,
+ MmGetKernelAddressSpace(),
+ MEMORY_AREA_SYSTEM,
+ &BaseAddress,
+ MiKernelMapLength,
+ 0,
+ &MiKernelMapDescriptor,
+ FALSE,
+ FALSE);
+
+ BaseAddress = MmPagedPoolBase;
+ Status = MmCreateMemoryArea(NULL,
MmGetKernelAddressSpace(),
MEMORY_AREA_PAGED_POOL,
&BaseAddress,
- Length,
+ MmPagedPoolSize,
0,
&MiPagedPoolDescriptor,
+ FALSE,
FALSE);
+
MmInitializePagedPool();
/*
Length,
0,
&kernel_shared_data_desc,
+ FALSE,
FALSE);
Status = MmRequestPageMemoryConsumer(MC_NPPOOL, TRUE,
&MmSharedDataPagePhysicalAddress);
if (!NT_SUCCESS(Status))
{
DbgPrint("Unable to create virtual mapping\n");
- KeBugCheck(0);
+ KEBUGCHECK(0);
}
RtlZeroMemory(BaseAddress, Length);
ULONG LastKrnlPhysAddr,
ULONG LastKernelAddress,
PADDRESS_RANGE BIOSMemoryMap,
- ULONG AddressRangeCount)
+ ULONG AddressRangeCount,
+ ULONG MaxMem)
/*
* FUNCTION: Initalize memory managment
*/
LastKrnlPhysAddr,
LastKernelAddress);
+
if ((BIOSMemoryMap != NULL) && (AddressRangeCount > 0))
{
// If we have a bios memory map, recalulate the the memory size
}
}
+ if (KeLoaderBlock.MemHigher >= (MaxMem - 1) * 1024)
+ {
+ KeLoaderBlock.MemHigher = (MaxMem - 1) * 1024;
+ }
+
/*
* FIXME: Set this based on the system command line
*/
+ MmSystemRangeStart = (PVOID)KERNEL_BASE; // 0xC0000000
MmUserProbeAddress = (PVOID)0x7fff0000;
MmHighestUserAddress = (PVOID)0x7ffeffff;
+ MmInitGlobalKernelPageDirectory();
+
/*
* Initialize memory managment statistics
*/
i<(KERNEL_BASE + 2 * PAGE_TABLE_SIZE);
i=i+PAGE_SIZE)
{
- MmDeleteVirtualMapping(NULL, (PVOID)(i), FALSE, NULL, NULL);
+ MmRawDeleteVirtualMapping((PVOID)(i));
}
DPRINT("Almost done MmInit()\n");
#ifndef MP
if all processors are started. */
MmDeletePageTable(NULL, 0);
#endif
+ MmInitZeroPageThread();
MmInitPagerThread();
MmCreatePhysicalMemorySection();
MmInitializeRmapList();