mirror of
https://github.com/reactos/reactos.git
synced 2024-10-01 06:57:08 +00:00
[FORMATTING] Remove dead code (#if 0) and re-organize the file to match kernel standard layout/style.
Get rid of old debugging hacks introduced by ion (rmapready, pageopready, pagingready). svn path=/trunk/; revision=32352
This commit is contained in:
parent
7c1fea060f
commit
44baeebd8a
|
@ -1,81 +1,71 @@
|
|||
/* $Id$
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top directory
|
||||
* PROJECT: ReactOS kernel
|
||||
/*
|
||||
* PROJECT: ReactOS Kernel
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: ntoskrnl/mm/mminit.c
|
||||
* PURPOSE: Kernel memory managment initialization functions
|
||||
*
|
||||
* PROGRAMMERS: David Welch (welch@cwcom.net)
|
||||
* PURPOSE: Memory Manager Initialization
|
||||
* PROGRAMMERS:
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <ntoskrnl.h>
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* GLOBALS *****************************************************************/
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
/*
|
||||
* Compiler defined symbols
|
||||
*/
|
||||
#if 0
|
||||
extern unsigned int _image_base__;
|
||||
extern unsigned int _text_start__;
|
||||
extern unsigned int _text_end__;
|
||||
PCHAR
|
||||
MemType[] =
|
||||
{
|
||||
"ExceptionBlock ",
|
||||
"SystemBlock ",
|
||||
"Free ",
|
||||
"Bad ",
|
||||
"LoadedProgram ",
|
||||
"FirmwareTemporary ",
|
||||
"FirmwarePermanent ",
|
||||
"OsloaderHeap ",
|
||||
"OsloaderStack ",
|
||||
"SystemCode ",
|
||||
"HalCode ",
|
||||
"BootDriver ",
|
||||
"ConsoleInDriver ",
|
||||
"ConsoleOutDriver ",
|
||||
"StartupDpcStack ",
|
||||
"StartupKernelStack",
|
||||
"StartupPanicStack ",
|
||||
"StartupPcrPage ",
|
||||
"StartupPdrPage ",
|
||||
"RegistryData ",
|
||||
"MemoryData ",
|
||||
"NlsData ",
|
||||
"SpecialMemory ",
|
||||
"BBTMemory ",
|
||||
"LoaderReserve "
|
||||
};
|
||||
|
||||
extern unsigned int _init_start__;
|
||||
extern unsigned int _init_end__;
|
||||
|
||||
extern unsigned int _bss_end__;
|
||||
#endif
|
||||
|
||||
static BOOLEAN IsThisAnNtAsSystem = FALSE;
|
||||
BOOLEAN IsThisAnNtAsSystem = FALSE;
|
||||
MM_SYSTEMSIZE MmSystemSize = MmSmallSystem;
|
||||
|
||||
PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress;
|
||||
|
||||
PVOID MiNonPagedPoolStart;
|
||||
ULONG MiNonPagedPoolLength;
|
||||
|
||||
ULONG MmNumberOfPhysicalPages;
|
||||
extern KMUTANT MmSystemLoadLock;
|
||||
|
||||
VOID INIT_FUNCTION NTAPI MmInitVirtualMemory(ULONG_PTR LastKernelAddress, ULONG KernelLength);
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
BOOLEAN STDCALL MmIsThisAnNtAsSystem(VOID)
|
||||
{
|
||||
return(IsThisAnNtAsSystem);
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
MM_SYSTEMSIZE STDCALL MmQuerySystemSize(VOID)
|
||||
{
|
||||
return(MmSystemSize);
|
||||
}
|
||||
/* PRIVATE FUNCTIONS *********************************************************/
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
MiShutdownMemoryManager(VOID)
|
||||
{}
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
VOID
|
||||
INIT_FUNCTION
|
||||
NTAPI
|
||||
MmInitVirtualMemory(ULONG_PTR LastKernelAddress,
|
||||
ULONG KernelLength)
|
||||
/*
|
||||
* FUNCTION: Intialize the memory areas list
|
||||
* ARGUMENTS:
|
||||
* bp = Pointer to the boot parameters
|
||||
* kernel_len = Length of the kernel
|
||||
*/
|
||||
{
|
||||
PVOID BaseAddress;
|
||||
ULONG Length;
|
||||
|
@ -234,35 +224,6 @@ MiCountFreePagesInLoaderBlock(PLOADER_PARAMETER_BLOCK LoaderBlock)
|
|||
return TotalPages;
|
||||
}
|
||||
|
||||
PCHAR
|
||||
MemType[] = {
|
||||
"ExceptionBlock ", // ?
|
||||
"SystemBlock ", // ?
|
||||
"Free ",
|
||||
"Bad ", // used
|
||||
"LoadedProgram ", // == Free
|
||||
"FirmwareTemporary ", // == Free
|
||||
"FirmwarePermanent ", // == Bad
|
||||
"OsloaderHeap ", // used
|
||||
"OsloaderStack ", // == Free
|
||||
"SystemCode ",
|
||||
"HalCode ",
|
||||
"BootDriver ", // not used
|
||||
"ConsoleInDriver ", // ?
|
||||
"ConsoleOutDriver ", // ?
|
||||
"StartupDpcStack ", // ?
|
||||
"StartupKernelStack", // ?
|
||||
"StartupPanicStack ", // ?
|
||||
"StartupPcrPage ", // ?
|
||||
"StartupPdrPage ", // ?
|
||||
"RegistryData ", // used
|
||||
"MemoryData ", // not used
|
||||
"NlsData ", // used
|
||||
"SpecialMemory ", // == Bad
|
||||
"BBTMemory ",
|
||||
"LoaderReserve "// == Bad
|
||||
};
|
||||
|
||||
VOID
|
||||
INIT_FUNCTION
|
||||
NTAPI
|
||||
|
@ -413,24 +374,7 @@ MmInit1(ULONG_PTR FirstKrnlPhysAddr,
|
|||
/*
|
||||
* Unmap low memory
|
||||
*/
|
||||
#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.
|
||||
We unmap all pages except page 2 and 3. */
|
||||
for (MappingAddress = 0;
|
||||
MappingAddress < 1024 * PAGE_SIZE;
|
||||
MappingAddress += PAGE_SIZE)
|
||||
{
|
||||
if (MappingAddress != 2 * PAGE_SIZE &&
|
||||
MappingAddress != 3 * PAGE_SIZE)
|
||||
{
|
||||
MmRawDeleteVirtualMapping((PVOID)MappingAddress);
|
||||
}
|
||||
}
|
||||
#else
|
||||
MmDeletePageTable(NULL, 0);
|
||||
#endif
|
||||
|
||||
DPRINT("Invalidating between %x and %x\n",
|
||||
LastKernelAddress, KSEG0_BASE + 0x00600000);
|
||||
|
@ -450,9 +394,6 @@ MmInit1(ULONG_PTR FirstKrnlPhysAddr,
|
|||
MmInitializeMdlImplementation();
|
||||
}
|
||||
|
||||
BOOLEAN RmapReady, PageOpReady, SectionsReady, PagingReady;
|
||||
extern KMUTANT MmSystemLoadLock;
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
MmInitSystem(IN ULONG Phase,
|
||||
|
@ -483,13 +424,9 @@ MmInitSystem(IN ULONG Phase,
|
|||
else if (Phase == 1)
|
||||
{
|
||||
MmInitializeRmapList();
|
||||
RmapReady = TRUE;
|
||||
MmInitializePageOp();
|
||||
PageOpReady = TRUE;
|
||||
MmInitSectionImplementation();
|
||||
SectionsReady = TRUE;
|
||||
MmInitPagingFile();
|
||||
PagingReady = TRUE;
|
||||
MmCreatePhysicalMemorySection();
|
||||
|
||||
/* Setup shared user data settings that NT does as well */
|
||||
|
@ -521,29 +458,25 @@ MmInitSystem(IN ULONG Phase,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
VOID static
|
||||
MiFreeInitMemoryPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address,
|
||||
PFN_TYPE Page, SWAPENTRY SwapEntry,
|
||||
BOOLEAN Dirty)
|
||||
{
|
||||
ASSERT(SwapEntry == 0);
|
||||
if (Page != 0)
|
||||
{
|
||||
MmReleasePageMemoryConsumer(MC_NPPOOL, Page);
|
||||
}
|
||||
}
|
||||
/* PUBLIC FUNCTIONS **********************************************************/
|
||||
|
||||
VOID
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
MiFreeInitMemory(VOID)
|
||||
MmIsThisAnNtAsSystem(VOID)
|
||||
{
|
||||
MmLockAddressSpace(MmGetKernelAddressSpace());
|
||||
MmFreeMemoryAreaByPtr(MmGetKernelAddressSpace(),
|
||||
(PVOID)&_init_start__,
|
||||
MiFreeInitMemoryPage,
|
||||
NULL);
|
||||
MmUnlockAddressSpace(MmGetKernelAddressSpace());
|
||||
return IsThisAnNtAsSystem;
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
MM_SYSTEMSIZE
|
||||
NTAPI
|
||||
MmQuerySystemSize(VOID)
|
||||
{
|
||||
return MmSystemSize;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -322,8 +322,6 @@ MmReadFromSwapPage(SWAPENTRY SwapEntry, PFN_TYPE Page)
|
|||
return(Status);
|
||||
}
|
||||
|
||||
extern BOOLEAN PagingReady;
|
||||
|
||||
VOID
|
||||
INIT_FUNCTION
|
||||
NTAPI
|
||||
|
@ -367,11 +365,6 @@ MmReserveSwapPages(ULONG Nr)
|
|||
KIRQL oldIrql;
|
||||
ULONG MiAvailSwapPages;
|
||||
|
||||
if (!PagingReady)
|
||||
{
|
||||
DPRINT1("PAGING USED TOO SOON!!!\n");
|
||||
while (TRUE);
|
||||
}
|
||||
KeAcquireSpinLock(&PagingFileListLock, &oldIrql);
|
||||
MiAvailSwapPages =
|
||||
(MiFreeSwapPages * MM_PAGEFILE_COMMIT_RATIO) + MM_PAGEFILE_COMMIT_GRACE;
|
||||
|
@ -391,11 +384,6 @@ MmDereserveSwapPages(ULONG Nr)
|
|||
{
|
||||
KIRQL oldIrql;
|
||||
|
||||
if (!PagingReady)
|
||||
{
|
||||
DPRINT1("PAGING USED TOO SOON!!!\n");
|
||||
while (TRUE);
|
||||
}
|
||||
KeAcquireSpinLock(&PagingFileListLock, &oldIrql);
|
||||
MiReservedSwapPages = MiReservedSwapPages - Nr;
|
||||
KeReleaseSpinLock(&PagingFileListLock, oldIrql);
|
||||
|
@ -407,11 +395,6 @@ MiAllocPageFromPagingFile(PPAGINGFILE PagingFile)
|
|||
KIRQL oldIrql;
|
||||
ULONG i, j;
|
||||
|
||||
if (!PagingReady)
|
||||
{
|
||||
DPRINT1("PAGING USED TOO SOON!!!\n");
|
||||
while (TRUE);
|
||||
}
|
||||
KeAcquireSpinLock(&PagingFile->AllocMapLock, &oldIrql);
|
||||
|
||||
for (i = 0; i < PagingFile->AllocMapSize; i++)
|
||||
|
@ -441,11 +424,6 @@ MmFreeSwapPage(SWAPENTRY Entry)
|
|||
ULONG off;
|
||||
KIRQL oldIrql;
|
||||
|
||||
if (!PagingReady)
|
||||
{
|
||||
DPRINT1("PAGING USED TOO SOON!!!\n");
|
||||
while (TRUE);
|
||||
}
|
||||
i = FILE_FROM_ENTRY(Entry);
|
||||
off = OFFSET_FROM_ENTRY(Entry);
|
||||
|
||||
|
@ -490,11 +468,6 @@ MmAllocSwapPage(VOID)
|
|||
ULONG off;
|
||||
SWAPENTRY entry;
|
||||
|
||||
if (!PagingReady)
|
||||
{
|
||||
DPRINT1("PAGING USED TOO SOON!!!\n");
|
||||
while (TRUE);
|
||||
}
|
||||
KeAcquireSpinLock(&PagingFileListLock, &oldIrql);
|
||||
|
||||
if (MiFreeSwapPages == 0)
|
||||
|
|
|
@ -133,8 +133,6 @@ MmCheckForPageOp(PMEMORY_AREA MArea, HANDLE Pid, PVOID Address,
|
|||
return(NULL);
|
||||
}
|
||||
|
||||
extern BOOLEAN RmapReady, PageOpReady, SectionsReady, PagingReady;
|
||||
|
||||
PMM_PAGEOP
|
||||
NTAPI
|
||||
MmGetPageOp(PMEMORY_AREA MArea, HANDLE Pid, PVOID Address,
|
||||
|
@ -149,12 +147,6 @@ MmGetPageOp(PMEMORY_AREA MArea, HANDLE Pid, PVOID Address,
|
|||
KIRQL oldIrql;
|
||||
PMM_PAGEOP PageOp;
|
||||
|
||||
if (!PageOpReady)
|
||||
{
|
||||
DPRINT1("PAGEOPS USED TOO SOON!!!\n");
|
||||
while (TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Calcuate the hash value for pageop structure
|
||||
*/
|
||||
|
|
|
@ -379,8 +379,6 @@ MmIsDirtyPageRmap(PFN_TYPE Page)
|
|||
return(FALSE);
|
||||
}
|
||||
|
||||
extern BOOLEAN RmapReady, PageOpReady, SectionsReady, PagingReady;
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
MmInsertRmap(PFN_TYPE Page, PEPROCESS Process,
|
||||
|
@ -390,12 +388,6 @@ MmInsertRmap(PFN_TYPE Page, PEPROCESS Process,
|
|||
PMM_RMAP_ENTRY new_entry;
|
||||
ULONG PrevSize;
|
||||
|
||||
if (!RmapReady)
|
||||
{
|
||||
DPRINT1("RMAPS USED TOO SOON!!!\n");
|
||||
while (TRUE);
|
||||
}
|
||||
|
||||
Address = (PVOID)PAGE_ROUND_DOWN(Address);
|
||||
|
||||
new_entry = ExAllocateFromNPagedLookasideList(&RmapLookasideList);
|
||||
|
@ -467,12 +459,6 @@ MmDeleteAllRmaps(PFN_TYPE Page, PVOID Context,
|
|||
PMM_RMAP_ENTRY previous_entry;
|
||||
PEPROCESS Process;
|
||||
|
||||
if (!RmapReady)
|
||||
{
|
||||
DPRINT1("RMAPS USED TOO SOON!!!\n");
|
||||
while (TRUE);
|
||||
}
|
||||
|
||||
ExAcquireFastMutex(&RmapListLock);
|
||||
current_entry = MmGetRmapListHeadPage(Page);
|
||||
if (current_entry == NULL)
|
||||
|
@ -511,12 +497,6 @@ MmDeleteRmap(PFN_TYPE Page, PEPROCESS Process,
|
|||
{
|
||||
PMM_RMAP_ENTRY current_entry, previous_entry;
|
||||
|
||||
if (!RmapReady)
|
||||
{
|
||||
DPRINT1("RMAPS USED TOO SOON!!!\n");
|
||||
while (TRUE);
|
||||
}
|
||||
|
||||
ExAcquireFastMutex(&RmapListLock);
|
||||
previous_entry = NULL;
|
||||
current_entry = MmGetRmapListHeadPage(Page);
|
||||
|
|
Loading…
Reference in a new issue