From 9dc0c0d12abb59edefbcc19414e7ed70512596ec Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Mon, 4 Oct 2010 18:36:37 +0000 Subject: [PATCH] [NTOS]: Initialize system views by calling MiInitializeSystemSpaceMap. This sets up the lock, bitmap, and hash table. svn path=/trunk/; revision=48978 --- reactos/ntoskrnl/mm/ARM3/mminit.c | 3 ++ reactos/ntoskrnl/mm/ARM3/section.c | 54 ++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/reactos/ntoskrnl/mm/ARM3/mminit.c b/reactos/ntoskrnl/mm/ARM3/mminit.c index 0aad514ae7e..76df1586996 100644 --- a/reactos/ntoskrnl/mm/ARM3/mminit.c +++ b/reactos/ntoskrnl/mm/ARM3/mminit.c @@ -1674,6 +1674,9 @@ MiBuildPagedPool(VOID) MiHighPagedPoolThreshold = (60 * _1MB) >> PAGE_SHIFT; MiHighPagedPoolThreshold = min(MiHighPagedPoolThreshold, (Size * 2) / 5); ASSERT(MiLowPagedPoolThreshold < MiHighPagedPoolThreshold); + + /* Setup the global session space */ + MiInitializeSystemSpaceMap(NULL); } NTSTATUS diff --git a/reactos/ntoskrnl/mm/ARM3/section.c b/reactos/ntoskrnl/mm/ARM3/section.c index 9a544c6d59b..3529d631a97 100644 --- a/reactos/ntoskrnl/mm/ARM3/section.c +++ b/reactos/ntoskrnl/mm/ARM3/section.c @@ -70,6 +70,8 @@ CHAR MmUserProtectionToMask2[16] = (CHAR)MM_INVALID_PROTECTION }; +MMSESSION MmSession; + /* PRIVATE FUNCTIONS **********************************************************/ ULONG @@ -153,6 +155,58 @@ MiMakeProtectionMask(IN ULONG Protect) /* Return the final MM PTE protection mask */ return ProtectMask; } + +BOOLEAN +NTAPI +MiInitializeSystemSpaceMap(IN PVOID InputSession OPTIONAL) +{ + SIZE_T AllocSize, BitmapSize; + PMMSESSION Session; + + /* For now, always use the global session */ + ASSERT(InputSession == NULL); + Session = &MmSession; + + /* Initialize the system space lock */ + Session->SystemSpaceViewLockPointer = &Session->SystemSpaceViewLock; + KeInitializeGuardedMutex(Session->SystemSpaceViewLockPointer); + + /* Set the start address */ + Session->SystemSpaceViewStart = MiSystemViewStart; + + /* Create a bitmap to describe system space */ + BitmapSize = sizeof(RTL_BITMAP) + ((((MmSystemViewSize / 65536) + 31) / 32) * sizeof(ULONG)); + Session->SystemSpaceBitMap = ExAllocatePoolWithTag(NonPagedPool, + BitmapSize, + ' mM'); + ASSERT(Session->SystemSpaceBitMap); + RtlInitializeBitMap(Session->SystemSpaceBitMap, + (PULONG)(Session->SystemSpaceBitMap + 1), + MmSystemViewSize / 65536); + + /* Set system space fully empty to begin with */ + RtlClearAllBits(Session->SystemSpaceBitMap); + + /* Set default hash flags */ + Session->SystemSpaceHashSize = 31; + Session->SystemSpaceHashKey = Session->SystemSpaceHashSize - 1; + Session->SystemSpaceHashEntries = 0; + + /* Calculate how much space for the hash views we'll need */ + AllocSize = sizeof(MMVIEW) * Session->SystemSpaceHashSize; + ASSERT(AllocSize < PAGE_SIZE); + + /* Allocate and zero the view table */ + Session->SystemSpaceViewTable = ExAllocatePoolWithTag(NonPagedPool, + AllocSize, + ' mM'); + ASSERT(Session->SystemSpaceViewTable != NULL); + RtlZeroMemory(Session->SystemSpaceViewTable, AllocSize); + + /* Success */ + return TRUE; +} + /* SYSTEM CALLS ***************************************************************/ NTSTATUS