From 44baeebd8aa6200553af6562518f219dbb48dd1a Mon Sep 17 00:00:00 2001 From: ReactOS Portable Systems Group Date: Thu, 14 Feb 2008 03:08:20 +0000 Subject: [PATCH] [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 --- reactos/ntoskrnl/mm/mminit.c | 185 +++++++++++---------------------- reactos/ntoskrnl/mm/pagefile.c | 27 ----- reactos/ntoskrnl/mm/pageop.c | 8 -- reactos/ntoskrnl/mm/rmap.c | 20 ---- 4 files changed, 59 insertions(+), 181 deletions(-) diff --git a/reactos/ntoskrnl/mm/mminit.c b/reactos/ntoskrnl/mm/mminit.c index 0797e37b35f..fbca3c2da6b 100644 --- a/reactos/ntoskrnl/mm/mminit.c +++ b/reactos/ntoskrnl/mm/mminit.c @@ -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 #define NDEBUG #include -/* 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 diff --git a/reactos/ntoskrnl/mm/pagefile.c b/reactos/ntoskrnl/mm/pagefile.c index 3947574418f..a0d3cf01a61 100644 --- a/reactos/ntoskrnl/mm/pagefile.c +++ b/reactos/ntoskrnl/mm/pagefile.c @@ -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) diff --git a/reactos/ntoskrnl/mm/pageop.c b/reactos/ntoskrnl/mm/pageop.c index d3a69058856..1c9b75e6b37 100644 --- a/reactos/ntoskrnl/mm/pageop.c +++ b/reactos/ntoskrnl/mm/pageop.c @@ -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 */ diff --git a/reactos/ntoskrnl/mm/rmap.c b/reactos/ntoskrnl/mm/rmap.c index 416e9117c2a..2b12552ef30 100644 --- a/reactos/ntoskrnl/mm/rmap.c +++ b/reactos/ntoskrnl/mm/rmap.c @@ -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);