Author: ros-arm-bringup
Date: Thu Oct 15 19:23:21 2009
New Revision: 43482
URL:
http://svn.reactos.org/svn/reactos?rev=43482&view=rev
Log:
- Fix calculations error in the setup of the paged pool bitmap.
- Initialize the paged pool guarded mutex.
- Add helper routines ExLock/UnlockPool to either acquire the NPP QSL or the PP GM
depending on the pool descriptor, instead of hardcoding the NPP QSL.
- Implement InitializePool for the PagedPool case.
- Now call InitializePool for PagedPool as well.
Modified:
trunk/reactos/ntoskrnl/mm/ARM3/expool.c
trunk/reactos/ntoskrnl/mm/ARM3/i386/init.c
trunk/reactos/ntoskrnl/mm/ARM3/miarm.h
trunk/reactos/ntoskrnl/mm/ARM3/pool.c
Modified: trunk/reactos/ntoskrnl/mm/ARM3/expool.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/expool.c?…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/expool.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/expool.c [iso-8859-1] Thu Oct 15 19:23:21 2009
@@ -20,6 +20,7 @@
POOL_DESCRIPTOR NonPagedPoolDescriptor;
PPOOL_DESCRIPTOR PoolVector[2];
+PKGUARDED_MUTEX ExpPagedPoolMutex;
/* PRIVATE FUNCTIONS **********************************************************/
@@ -69,18 +70,107 @@
InitializePool(IN POOL_TYPE PoolType,
IN ULONG Threshold)
{
- ASSERT(PoolType == NonPagedPool);
-
- //
- // Initialize the nonpaged pool descirptor
- //
- PoolVector[PoolType] = &NonPagedPoolDescriptor;
- ExInitializePoolDescriptor(PoolVector[PoolType],
- PoolType,
- 0,
- Threshold,
- NULL);
-}
+ PPOOL_DESCRIPTOR Descriptor;
+
+ //
+ // Check what kind of pool this is
+ //
+ if (PoolType == NonPagedPool)
+ {
+ //
+ // Initialize the nonpaged pool descriptor
+ //
+ PoolVector[NonPagedPool] = &NonPagedPoolDescriptor;
+ ExInitializePoolDescriptor(PoolVector[NonPagedPool],
+ NonPagedPool,
+ 0,
+ Threshold,
+ NULL);
+ }
+ else
+ {
+ //
+ // Allocate the pool descriptor
+ //
+ Descriptor = ExAllocatePoolWithTag(NonPagedPool,
+ sizeof(KGUARDED_MUTEX) +
+ sizeof(POOL_DESCRIPTOR),
+ 'looP');
+ if (!Descriptor)
+ {
+ //
+ // This is really bad...
+ //
+ KeBugCheckEx(MUST_SUCCEED_POOL_EMPTY,
+ 0,
+ -1,
+ -1,
+ -1);
+ }
+
+ //
+ // Setup the vector and guarded mutex for paged pool
+ //
+ PoolVector[PagedPool] = Descriptor;
+ ExpPagedPoolMutex = (PKGUARDED_MUTEX)(Descriptor + 1);
+ KeInitializeGuardedMutex(ExpPagedPoolMutex);
+ ExInitializePoolDescriptor(Descriptor,
+ PagedPool,
+ 0,
+ Threshold,
+ ExpPagedPoolMutex);
+ }
+}
+
+FORCEINLINE
+KIRQL
+ExLockPool(IN PPOOL_DESCRIPTOR Descriptor)
+{
+ //
+ // Check if this is nonpaged pool
+ //
+ if ((Descriptor->PoolType & BASE_POOL_TYPE_MASK) == NonPagedPool)
+ {
+ //
+ // Use the queued spin lock
+ //
+ return KeAcquireQueuedSpinLock(LockQueueNonPagedPoolLock);
+ }
+ else
+ {
+ //
+ // Use the guarded mutex
+ //
+ KeAcquireGuardedMutex(Descriptor->LockAddress);
+ return APC_LEVEL;
+ }
+}
+
+FORCEINLINE
+VOID
+ExUnlockPool(IN PPOOL_DESCRIPTOR Descriptor,
+ IN KIRQL OldIrql)
+{
+ //
+ // Check if this is nonpaged pool
+ //
+ if ((Descriptor->PoolType & BASE_POOL_TYPE_MASK) == NonPagedPool)
+ {
+ //
+ // Use the queued spin lock
+ //
+ KeReleaseQueuedSpinLock(LockQueueNonPagedPoolLock, OldIrql);
+ }
+ else
+ {
+ //
+ // Use the guarded mutex
+ //
+ KeReleaseGuardedMutex(Descriptor->LockAddress);
+ }
+}
+
+/* PUBLIC FUNCTIONS ***********************************************************/
PVOID
NTAPI
@@ -153,7 +243,7 @@
//
// Acquire the nonpaged pool lock now
//
- OldIrql = KeAcquireQueuedSpinLock(LockQueueNonPagedPoolLock);
+ OldIrql = ExLockPool(PoolDesc);
//
// And make sure the list still has entries
@@ -166,7 +256,7 @@
//
// Try again!
//
- KeReleaseQueuedSpinLock(LockQueueNonPagedPoolLock, OldIrql);
+ ExUnlockPool(PoolDesc, OldIrql);
ListHead++;
continue;
}
@@ -292,7 +382,7 @@
// and release the lock since we're done
//
Entry->PoolType = PoolType + 1;
- KeReleaseQueuedSpinLock(LockQueueNonPagedPoolLock, OldIrql);
+ ExUnlockPool(PoolDesc, OldIrql);
//
// Return the pool allocation
@@ -332,7 +422,7 @@
//
// Excellent -- acquire the nonpaged pool lock
//
- OldIrql = KeAcquireQueuedSpinLock(LockQueueNonPagedPoolLock);
+ OldIrql = ExLockPool(PoolDesc);
//
// And insert the free entry into the free list for this block size
@@ -343,7 +433,7 @@
//
// Release the nonpaged pool lock
//
- KeReleaseQueuedSpinLock(LockQueueNonPagedPoolLock, OldIrql);
+ ExUnlockPool(PoolDesc, OldIrql);
}
//
@@ -408,7 +498,7 @@
//
// Acquire the nonpaged pool lock
//
- OldIrql = KeAcquireQueuedSpinLock(LockQueueNonPagedPoolLock);
+ OldIrql = ExLockPool(PoolDesc);
//
// Check if the next allocation is at the end of the page
@@ -500,7 +590,7 @@
//
// In this case, release the nonpaged pool lock, and free the page
//
- KeReleaseQueuedSpinLock(LockQueueNonPagedPoolLock, OldIrql);
+ ExUnlockPool(PoolDesc, OldIrql);
MiFreePoolPages(Entry);
return;
}
@@ -534,7 +624,7 @@
// Insert this new free block, and release the nonpaged pool lock
//
InsertHeadList(&PoolDesc->ListHeads[BlockSize - 1], (PLIST_ENTRY)Entry + 1);
- KeReleaseQueuedSpinLock(LockQueueNonPagedPoolLock, OldIrql);
+ ExUnlockPool(PoolDesc, OldIrql);
}
VOID
Modified: trunk/reactos/ntoskrnl/mm/ARM3/i386/init.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/i386/init…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/i386/init.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/i386/init.c [iso-8859-1] Thu Oct 15 19:23:21 2009
@@ -540,14 +540,15 @@
//
Size = Size * 1024;
ASSERT(Size == MmSizeOfPagedPoolInPages);
- BitMapSize = sizeof(RTL_BITMAP) + (((Size + 31) / 32) * sizeof(ULONG));
+ BitMapSize = Size;
+ Size = sizeof(RTL_BITMAP) + (((Size + 31) / 32) * sizeof(ULONG));
//
// Allocate the allocation bitmap, which tells us which regions have not yet
// been mapped into memory
//
MmPagedPoolInfo.PagedPoolAllocationMap = ExAllocatePoolWithTag(NonPagedPool,
- BitMapSize,
+ Size,
' mM');
ASSERT(MmPagedPoolInfo.PagedPoolAllocationMap);
@@ -568,7 +569,7 @@
// entire allocation is.
//
MmPagedPoolInfo.EndOfPagedPoolBitmap = ExAllocatePoolWithTag(NonPagedPool,
- BitMapSize,
+ Size,
' mM');
ASSERT(MmPagedPoolInfo.EndOfPagedPoolBitmap);
RtlInitializeBitMap(MmPagedPoolInfo.EndOfPagedPoolBitmap,
@@ -583,7 +584,12 @@
//
// Initialize paged pool.
//
- //InitializePool(PagedPool, 0);
+ InitializePool(PagedPool, 0);
+
+ //
+ // Initialize the paged pool mutex
+ //
+ KeInitializeGuardedMutex(&MmPagedPoolMutex);
}
NTSTATUS
Modified: trunk/reactos/ntoskrnl/mm/ARM3/miarm.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/miarm.h?r…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/miarm.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/miarm.h [iso-8859-1] Thu Oct 15 19:23:21 2009
@@ -146,6 +146,7 @@
extern ULONG MxPfnAllocation;
extern MM_PAGED_POOL_INFO MmPagedPoolInfo;
extern RTL_BITMAP MiPfnBitMap;
+extern KGUARDED_MUTEX MmPagedPoolMutex;
VOID
NTAPI
Modified: trunk/reactos/ntoskrnl/mm/ARM3/pool.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/pool.c?re…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/pool.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/pool.c [iso-8859-1] Thu Oct 15 19:23:21 2009
@@ -22,7 +22,7 @@
PFN_NUMBER MmNumberOfFreeNonPagedPool, MiExpansionPoolPagesInitialCharge;
PVOID MmNonPagedPoolEnd0;
PFN_NUMBER MiStartOfInitialPoolFrame, MiEndOfInitialPoolFrame;
-
+KGUARDED_MUTEX MmPagedPoolMutex;
MM_PAGED_POOL_INFO MmPagedPoolInfo;
/* PRIVATE FUNCTIONS **********************************************************/