Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenzeropage.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactOS Kernel 00003 * LICENSE: BSD - See COPYING.ARM in the top level directory 00004 * FILE: ntoskrnl/mm/ARM3/zeropage.c 00005 * PURPOSE: ARM Memory Manager Zero Page Thread Support 00006 * PROGRAMMERS: ReactOS Portable Systems Group 00007 */ 00008 00009 /* INCLUDES *******************************************************************/ 00010 00011 #include <ntoskrnl.h> 00012 #define NDEBUG 00013 #include <debug.h> 00014 00015 #define MODULE_INVOLVED_IN_ARM3 00016 #include "../ARM3/miarm.h" 00017 00018 /* GLOBALS ********************************************************************/ 00019 00020 BOOLEAN MmZeroingPageThreadActive; 00021 KEVENT MmZeroingPageEvent; 00022 00023 /* PRIVATE FUNCTIONS **********************************************************/ 00024 00025 VOID 00026 NTAPI 00027 MiFindInitializationCode(OUT PVOID *StartVa, 00028 OUT PVOID *EndVa); 00029 00030 VOID 00031 NTAPI 00032 MiFreeInitializationCode(IN PVOID StartVa, 00033 IN PVOID EndVa); 00034 00035 VOID 00036 NTAPI 00037 MmZeroPageThread(VOID) 00038 { 00039 PKTHREAD Thread = KeGetCurrentThread(); 00040 PVOID StartAddress, EndAddress; 00041 PVOID WaitObjects[2]; 00042 KIRQL OldIrql; 00043 PVOID ZeroAddress; 00044 PFN_NUMBER PageIndex, FreePage; 00045 PMMPFN Pfn1; 00046 00047 /* Get the discardable sections to free them */ 00048 MiFindInitializationCode(&StartAddress, &EndAddress); 00049 if (StartAddress) MiFreeInitializationCode(StartAddress, EndAddress); 00050 DPRINT1("Free non-cache pages: %lx\n", MmAvailablePages + MiMemoryConsumers[MC_CACHE].PagesUsed); 00051 00052 /* Set our priority to 0 */ 00053 Thread->BasePriority = 0; 00054 KeSetPriorityThread(Thread, 0); 00055 00056 /* Setup the wait objects */ 00057 WaitObjects[0] = &MmZeroingPageEvent; 00058 // WaitObjects[1] = &PoSystemIdleTimer; FIXME: Implement idle timer 00059 00060 while (TRUE) 00061 { 00062 KeWaitForMultipleObjects(1, // 2 00063 WaitObjects, 00064 WaitAny, 00065 WrFreePage, 00066 KernelMode, 00067 FALSE, 00068 NULL, 00069 NULL); 00070 OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); 00071 while (TRUE) 00072 { 00073 if (!MmFreePageListHead.Total) 00074 { 00075 MmZeroingPageThreadActive = FALSE; 00076 KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql); 00077 break; 00078 } 00079 00080 PageIndex = MmFreePageListHead.Flink; 00081 ASSERT(PageIndex != LIST_HEAD); 00082 Pfn1 = MiGetPfnEntry(PageIndex); 00083 MI_SET_USAGE(MI_USAGE_ZERO_LOOP); 00084 MI_SET_PROCESS2("Kernel 0 Loop"); 00085 FreePage = MiRemoveAnyPage(MI_GET_PAGE_COLOR(PageIndex)); 00086 00087 /* The first global free page should also be the first on its own list */ 00088 if (FreePage != PageIndex) 00089 { 00090 KeBugCheckEx(PFN_LIST_CORRUPT, 00091 0x8F, 00092 FreePage, 00093 PageIndex, 00094 0); 00095 } 00096 00097 Pfn1->u1.Flink = LIST_HEAD; 00098 KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql); 00099 00100 ZeroAddress = MiMapPagesInZeroSpace(Pfn1, 1); 00101 ASSERT(ZeroAddress); 00102 RtlZeroMemory(ZeroAddress, PAGE_SIZE); 00103 MiUnmapPagesInZeroSpace(ZeroAddress, 1); 00104 00105 OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); 00106 00107 MiInsertPageInList(&MmZeroedPageListHead, PageIndex); 00108 } 00109 } 00110 } 00111 00112 /* EOF */ Generated on Fri May 25 2012 04:36:03 for ReactOS by
1.7.6.1
|