[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:
ReactOS Portable Systems Group 2008-02-14 03:08:20 +00:00
parent 7c1fea060f
commit 44baeebd8a
4 changed files with 59 additions and 181 deletions

View file

@ -1,81 +1,71 @@
/* $Id$ /*
* * PROJECT: ReactOS Kernel
* COPYRIGHT: See COPYING in the top directory * LICENSE: GPL - See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/mminit.c * FILE: ntoskrnl/mm/mminit.c
* PURPOSE: Kernel memory managment initialization functions * PURPOSE: Memory Manager Initialization
* * PROGRAMMERS:
* PROGRAMMERS: David Welch (welch@cwcom.net)
*/ */
/* INCLUDES *****************************************************************/ /* INCLUDES ******************************************************************/
#include <ntoskrnl.h> #include <ntoskrnl.h>
#define NDEBUG #define NDEBUG
#include <internal/debug.h> #include <internal/debug.h>
/* GLOBALS *****************************************************************/ /* GLOBALS *******************************************************************/
/* PCHAR
* Compiler defined symbols MemType[] =
*/ {
#if 0 "ExceptionBlock ",
extern unsigned int _image_base__; "SystemBlock ",
extern unsigned int _text_start__; "Free ",
extern unsigned int _text_end__; "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__; BOOLEAN IsThisAnNtAsSystem = FALSE;
extern unsigned int _init_end__;
extern unsigned int _bss_end__;
#endif
static BOOLEAN IsThisAnNtAsSystem = FALSE;
MM_SYSTEMSIZE MmSystemSize = MmSmallSystem; MM_SYSTEMSIZE MmSystemSize = MmSmallSystem;
PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress; PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress;
PVOID MiNonPagedPoolStart; PVOID MiNonPagedPoolStart;
ULONG MiNonPagedPoolLength; ULONG MiNonPagedPoolLength;
ULONG MmNumberOfPhysicalPages; ULONG MmNumberOfPhysicalPages;
extern KMUTANT MmSystemLoadLock;
VOID INIT_FUNCTION NTAPI MmInitVirtualMemory(ULONG_PTR LastKernelAddress, ULONG KernelLength); /* PRIVATE FUNCTIONS *********************************************************/
/* FUNCTIONS ****************************************************************/
/*
* @implemented
*/
BOOLEAN STDCALL MmIsThisAnNtAsSystem(VOID)
{
return(IsThisAnNtAsSystem);
}
/*
* @implemented
*/
MM_SYSTEMSIZE STDCALL MmQuerySystemSize(VOID)
{
return(MmSystemSize);
}
VOID VOID
NTAPI NTAPI
MiShutdownMemoryManager(VOID) MiShutdownMemoryManager(VOID)
{} {
}
VOID VOID
INIT_FUNCTION INIT_FUNCTION
NTAPI NTAPI
MmInitVirtualMemory(ULONG_PTR LastKernelAddress, MmInitVirtualMemory(ULONG_PTR LastKernelAddress,
ULONG KernelLength) ULONG KernelLength)
/*
* FUNCTION: Intialize the memory areas list
* ARGUMENTS:
* bp = Pointer to the boot parameters
* kernel_len = Length of the kernel
*/
{ {
PVOID BaseAddress; PVOID BaseAddress;
ULONG Length; ULONG Length;
@ -234,35 +224,6 @@ MiCountFreePagesInLoaderBlock(PLOADER_PARAMETER_BLOCK LoaderBlock)
return TotalPages; 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 VOID
INIT_FUNCTION INIT_FUNCTION
NTAPI NTAPI
@ -413,24 +374,7 @@ MmInit1(ULONG_PTR FirstKrnlPhysAddr,
/* /*
* Unmap low memory * 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); MmDeletePageTable(NULL, 0);
#endif
DPRINT("Invalidating between %x and %x\n", DPRINT("Invalidating between %x and %x\n",
LastKernelAddress, KSEG0_BASE + 0x00600000); LastKernelAddress, KSEG0_BASE + 0x00600000);
@ -450,9 +394,6 @@ MmInit1(ULONG_PTR FirstKrnlPhysAddr,
MmInitializeMdlImplementation(); MmInitializeMdlImplementation();
} }
BOOLEAN RmapReady, PageOpReady, SectionsReady, PagingReady;
extern KMUTANT MmSystemLoadLock;
BOOLEAN BOOLEAN
NTAPI NTAPI
MmInitSystem(IN ULONG Phase, MmInitSystem(IN ULONG Phase,
@ -483,13 +424,9 @@ MmInitSystem(IN ULONG Phase,
else if (Phase == 1) else if (Phase == 1)
{ {
MmInitializeRmapList(); MmInitializeRmapList();
RmapReady = TRUE;
MmInitializePageOp(); MmInitializePageOp();
PageOpReady = TRUE;
MmInitSectionImplementation(); MmInitSectionImplementation();
SectionsReady = TRUE;
MmInitPagingFile(); MmInitPagingFile();
PagingReady = TRUE;
MmCreatePhysicalMemorySection(); MmCreatePhysicalMemorySection();
/* Setup shared user data settings that NT does as well */ /* Setup shared user data settings that NT does as well */
@ -521,29 +458,25 @@ MmInitSystem(IN ULONG Phase,
return TRUE; return TRUE;
} }
#if 0
VOID static /* PUBLIC FUNCTIONS **********************************************************/
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);
}
}
VOID /*
* @implemented
*/
BOOLEAN
NTAPI NTAPI
MiFreeInitMemory(VOID) MmIsThisAnNtAsSystem(VOID)
{ {
MmLockAddressSpace(MmGetKernelAddressSpace()); return IsThisAnNtAsSystem;
MmFreeMemoryAreaByPtr(MmGetKernelAddressSpace(), }
(PVOID)&_init_start__,
MiFreeInitMemoryPage, /*
NULL); * @implemented
MmUnlockAddressSpace(MmGetKernelAddressSpace()); */
MM_SYSTEMSIZE
NTAPI
MmQuerySystemSize(VOID)
{
return MmSystemSize;
} }
#endif

View file

@ -322,8 +322,6 @@ MmReadFromSwapPage(SWAPENTRY SwapEntry, PFN_TYPE Page)
return(Status); return(Status);
} }
extern BOOLEAN PagingReady;
VOID VOID
INIT_FUNCTION INIT_FUNCTION
NTAPI NTAPI
@ -367,11 +365,6 @@ MmReserveSwapPages(ULONG Nr)
KIRQL oldIrql; KIRQL oldIrql;
ULONG MiAvailSwapPages; ULONG MiAvailSwapPages;
if (!PagingReady)
{
DPRINT1("PAGING USED TOO SOON!!!\n");
while (TRUE);
}
KeAcquireSpinLock(&PagingFileListLock, &oldIrql); KeAcquireSpinLock(&PagingFileListLock, &oldIrql);
MiAvailSwapPages = MiAvailSwapPages =
(MiFreeSwapPages * MM_PAGEFILE_COMMIT_RATIO) + MM_PAGEFILE_COMMIT_GRACE; (MiFreeSwapPages * MM_PAGEFILE_COMMIT_RATIO) + MM_PAGEFILE_COMMIT_GRACE;
@ -391,11 +384,6 @@ MmDereserveSwapPages(ULONG Nr)
{ {
KIRQL oldIrql; KIRQL oldIrql;
if (!PagingReady)
{
DPRINT1("PAGING USED TOO SOON!!!\n");
while (TRUE);
}
KeAcquireSpinLock(&PagingFileListLock, &oldIrql); KeAcquireSpinLock(&PagingFileListLock, &oldIrql);
MiReservedSwapPages = MiReservedSwapPages - Nr; MiReservedSwapPages = MiReservedSwapPages - Nr;
KeReleaseSpinLock(&PagingFileListLock, oldIrql); KeReleaseSpinLock(&PagingFileListLock, oldIrql);
@ -407,11 +395,6 @@ MiAllocPageFromPagingFile(PPAGINGFILE PagingFile)
KIRQL oldIrql; KIRQL oldIrql;
ULONG i, j; ULONG i, j;
if (!PagingReady)
{
DPRINT1("PAGING USED TOO SOON!!!\n");
while (TRUE);
}
KeAcquireSpinLock(&PagingFile->AllocMapLock, &oldIrql); KeAcquireSpinLock(&PagingFile->AllocMapLock, &oldIrql);
for (i = 0; i < PagingFile->AllocMapSize; i++) for (i = 0; i < PagingFile->AllocMapSize; i++)
@ -441,11 +424,6 @@ MmFreeSwapPage(SWAPENTRY Entry)
ULONG off; ULONG off;
KIRQL oldIrql; KIRQL oldIrql;
if (!PagingReady)
{
DPRINT1("PAGING USED TOO SOON!!!\n");
while (TRUE);
}
i = FILE_FROM_ENTRY(Entry); i = FILE_FROM_ENTRY(Entry);
off = OFFSET_FROM_ENTRY(Entry); off = OFFSET_FROM_ENTRY(Entry);
@ -490,11 +468,6 @@ MmAllocSwapPage(VOID)
ULONG off; ULONG off;
SWAPENTRY entry; SWAPENTRY entry;
if (!PagingReady)
{
DPRINT1("PAGING USED TOO SOON!!!\n");
while (TRUE);
}
KeAcquireSpinLock(&PagingFileListLock, &oldIrql); KeAcquireSpinLock(&PagingFileListLock, &oldIrql);
if (MiFreeSwapPages == 0) if (MiFreeSwapPages == 0)

View file

@ -133,8 +133,6 @@ MmCheckForPageOp(PMEMORY_AREA MArea, HANDLE Pid, PVOID Address,
return(NULL); return(NULL);
} }
extern BOOLEAN RmapReady, PageOpReady, SectionsReady, PagingReady;
PMM_PAGEOP PMM_PAGEOP
NTAPI NTAPI
MmGetPageOp(PMEMORY_AREA MArea, HANDLE Pid, PVOID Address, MmGetPageOp(PMEMORY_AREA MArea, HANDLE Pid, PVOID Address,
@ -149,12 +147,6 @@ MmGetPageOp(PMEMORY_AREA MArea, HANDLE Pid, PVOID Address,
KIRQL oldIrql; KIRQL oldIrql;
PMM_PAGEOP PageOp; PMM_PAGEOP PageOp;
if (!PageOpReady)
{
DPRINT1("PAGEOPS USED TOO SOON!!!\n");
while (TRUE);
}
/* /*
* Calcuate the hash value for pageop structure * Calcuate the hash value for pageop structure
*/ */

View file

@ -379,8 +379,6 @@ MmIsDirtyPageRmap(PFN_TYPE Page)
return(FALSE); return(FALSE);
} }
extern BOOLEAN RmapReady, PageOpReady, SectionsReady, PagingReady;
VOID VOID
NTAPI NTAPI
MmInsertRmap(PFN_TYPE Page, PEPROCESS Process, MmInsertRmap(PFN_TYPE Page, PEPROCESS Process,
@ -390,12 +388,6 @@ MmInsertRmap(PFN_TYPE Page, PEPROCESS Process,
PMM_RMAP_ENTRY new_entry; PMM_RMAP_ENTRY new_entry;
ULONG PrevSize; ULONG PrevSize;
if (!RmapReady)
{
DPRINT1("RMAPS USED TOO SOON!!!\n");
while (TRUE);
}
Address = (PVOID)PAGE_ROUND_DOWN(Address); Address = (PVOID)PAGE_ROUND_DOWN(Address);
new_entry = ExAllocateFromNPagedLookasideList(&RmapLookasideList); new_entry = ExAllocateFromNPagedLookasideList(&RmapLookasideList);
@ -467,12 +459,6 @@ MmDeleteAllRmaps(PFN_TYPE Page, PVOID Context,
PMM_RMAP_ENTRY previous_entry; PMM_RMAP_ENTRY previous_entry;
PEPROCESS Process; PEPROCESS Process;
if (!RmapReady)
{
DPRINT1("RMAPS USED TOO SOON!!!\n");
while (TRUE);
}
ExAcquireFastMutex(&RmapListLock); ExAcquireFastMutex(&RmapListLock);
current_entry = MmGetRmapListHeadPage(Page); current_entry = MmGetRmapListHeadPage(Page);
if (current_entry == NULL) if (current_entry == NULL)
@ -511,12 +497,6 @@ MmDeleteRmap(PFN_TYPE Page, PEPROCESS Process,
{ {
PMM_RMAP_ENTRY current_entry, previous_entry; PMM_RMAP_ENTRY current_entry, previous_entry;
if (!RmapReady)
{
DPRINT1("RMAPS USED TOO SOON!!!\n");
while (TRUE);
}
ExAcquireFastMutex(&RmapListLock); ExAcquireFastMutex(&RmapListLock);
previous_entry = NULL; previous_entry = NULL;
current_entry = MmGetRmapListHeadPage(Page); current_entry = MmGetRmapListHeadPage(Page);