/* $Id$
*
* COPYRIGHT: See COPYING in the top directory
- * PROJECT: ReactOS kernel
+ * PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/mminit.c
* PURPOSE: Kernel memory managment initialization functions
*
static BOOLEAN IsThisAnNtAsSystem = FALSE;
static MM_SYSTEM_SIZE MmSystemSize = MmSmallSystem;
-static MEMORY_AREA* kernel_text_desc = NULL;
-static MEMORY_AREA* kernel_init_desc = NULL;
-static MEMORY_AREA* kernel_kpcr_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* kernel_mapped_vga_framebuffer_desc = NULL;
-static MEMORY_AREA* MiKernelMapDescriptor = NULL;
-static MEMORY_AREA* MiPagedPoolDescriptor = NULL;
-
PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress;
PVOID MiNonPagedPoolStart;
ULONG MiNonPagedPoolLength;
-//PVOID MiKernelMapStart;
extern ULONG init_stack;
extern ULONG init_stack_top;
return(MmSystemSize);
}
-VOID MiShutdownMemoryManager(VOID)
+VOID
+NTAPI
+MiShutdownMemoryManager(VOID)
{}
-VOID INIT_FUNCTION
+VOID
+INIT_FUNCTION
+NTAPI
MmInitVirtualMemory(ULONG_PTR LastKernelAddress,
ULONG KernelLength)
/*
NTSTATUS Status;
PHYSICAL_ADDRESS BoundaryAddressMultiple;
PFN_TYPE Pfn;
+ PMEMORY_AREA MArea;
DPRINT("MmInitVirtualMemory(%x, %x)\n",LastKernelAddress, KernelLength);
MmInitMemoryAreas();
- MiNonPagedPoolStart = (char*)LastKernelAddress + PAGE_SIZE;
+ /* Start the paged and nonpaged pool at a 4MB boundary. */
+ MiNonPagedPoolStart = (PVOID)ROUND_UP((ULONG_PTR)LastKernelAddress + PAGE_SIZE, 0x400000);
MiNonPagedPoolLength = MM_NONPAGED_POOL_SIZE;
- MmPagedPoolBase = (char*)MiNonPagedPoolStart + MiNonPagedPoolLength + PAGE_SIZE;
+ MmPagedPoolBase = (PVOID)ROUND_UP((ULONG_PTR)MiNonPagedPoolStart + MiNonPagedPoolLength + PAGE_SIZE, 0x400000);
MmPagedPoolSize = MM_PAGED_POOL_SIZE;
+ DPRINT("NonPagedPool %x - %x, PagedPool %x - %x\n", MiNonPagedPoolStart, (ULONG_PTR)MiNonPagedPoolStart + MiNonPagedPoolLength - 1,
+ MmPagedPoolBase, (ULONG_PTR)MmPagedPoolBase + MmPagedPoolSize - 1);
+
MiInitializeNonPagedPool();
/*
&BaseAddress,
PAGE_SIZE * MAXIMUM_PROCESSORS,
0,
- &kernel_kpcr_desc,
+ &MArea,
+ TRUE,
+ FALSE,
+ BoundaryAddressMultiple);
+
+ /* Local APIC base */
+ BaseAddress = (PVOID)0xFEE00000;
+ MmCreateMemoryArea(NULL,
+ MmGetKernelAddressSpace(),
+ MEMORY_AREA_SYSTEM,
+ &BaseAddress,
+ PAGE_SIZE,
+ 0,
+ &MArea,
+ TRUE,
+ FALSE,
+ BoundaryAddressMultiple);
+
+ /* i/o APIC base */
+ BaseAddress = (PVOID)0xFEC00000;
+ MmCreateMemoryArea(NULL,
+ MmGetKernelAddressSpace(),
+ MEMORY_AREA_SYSTEM,
+ &BaseAddress,
+ PAGE_SIZE,
+ 0,
+ &MArea,
TRUE,
FALSE,
BoundaryAddressMultiple);
&BaseAddress,
0x20000,
0,
- &kernel_mapped_vga_framebuffer_desc,
+ &MArea,
TRUE,
FALSE,
BoundaryAddressMultiple);
&BaseAddress,
Length,
0,
- &kernel_text_desc,
+ &MArea,
TRUE,
FALSE,
BoundaryAddressMultiple);
&BaseAddress,
Length,
0,
- &kernel_init_desc,
+ &MArea,
TRUE,
FALSE,
BoundaryAddressMultiple);
&BaseAddress,
Length,
0,
- &kernel_data_desc,
+ &MArea,
TRUE,
FALSE,
BoundaryAddressMultiple);
&BaseAddress,
Length,
0,
- &kernel_param_desc,
+ &MArea,
TRUE,
FALSE,
BoundaryAddressMultiple);
&BaseAddress,
MiNonPagedPoolLength,
0,
- &kernel_pool_desc,
+ &MArea,
TRUE,
FALSE,
BoundaryAddressMultiple);
- BaseAddress = (PVOID)MM_KERNEL_MAP_BASE;
- Status = MmCreateMemoryArea(NULL,
- MmGetKernelAddressSpace(),
- MEMORY_AREA_SYSTEM,
- &BaseAddress,
- MM_KERNEL_MAP_SIZE,
- 0,
- &MiKernelMapDescriptor,
- TRUE,
- FALSE,
- BoundaryAddressMultiple);
-
BaseAddress = MmPagedPoolBase;
Status = MmCreateMemoryArea(NULL,
MmGetKernelAddressSpace(),
&BaseAddress,
MmPagedPoolSize,
0,
- &MiPagedPoolDescriptor,
+ &MArea,
TRUE,
FALSE,
BoundaryAddressMultiple);
&BaseAddress,
Length,
0,
- &kernel_shared_data_desc,
+ &MArea,
TRUE,
FALSE,
BoundaryAddressMultiple);
MmInitializeMemoryConsumer(MC_USER, MmTrimUserMemory);
}
-VOID INIT_FUNCTION
+VOID
+INIT_FUNCTION
+NTAPI
MmInit1(ULONG_PTR FirstKrnlPhysAddr,
ULONG_PTR LastKrnlPhysAddr,
ULONG_PTR LastKernelAddress,
}
/* Set memory limits */
- MmUserProbeAddress = 0x7fff0000;
- MmHighestUserAddress = (PVOID)0x7ffeffff;
+ MmUserProbeAddress = (ULONG_PTR)MmSystemRangeStart - 0x10000;
+ MmHighestUserAddress = (PVOID)(MmUserProbeAddress - 1);
/*
* Initialize memory managment statistics
* Initialize the kernel address space
*/
MmInitializeKernelAddressSpace();
-
+
MmInitGlobalKernelPageDirectory();
-
+
DbgPrint("Used memory %dKb\n", (MmStats.NrTotalPages * PAGE_SIZE) / 1024);
DPRINT1("Kernel Stack Limits. InitTop = 0x%x, Init = 0x%x\n", init_stack_top, init_stack);
#ifdef CONFIG_SMP
/* In SMP mode we unmap the low memory pagetable in MmInit3.
The APIC needs the mapping of the first pages
- while the processors are starting up.
+ while the processors are starting up.
We unmap all pages except page 2 and 3. */
for (MappingAddress = 0;
MappingAddress < 1024 * PAGE_SIZE;
MappingAddress += PAGE_SIZE)
{
- if (MappingAddress != 2 * PAGE_SIZE &&
+ if (MappingAddress != 2 * PAGE_SIZE &&
MappingAddress != 3 * PAGE_SIZE)
{
MmRawDeleteVirtualMapping((PVOID)MappingAddress);
MmInitializeMdlImplementation();
}
-VOID INIT_FUNCTION
+VOID
+NTAPI
+INIT_FUNCTION
MmInit2(VOID)
{
MmInitializeRmapList();
MmInitPagingFile();
}
-VOID INIT_FUNCTION
+VOID
+INIT_FUNCTION
+NTAPI
MmInit3(VOID)
{
/*
}
VOID
+NTAPI
MiFreeInitMemory(VOID)
{
MmLockAddressSpace(MmGetKernelAddressSpace());