Implement initial memory manager infrastructure #24

Open
harraiken wants to merge 169 commits from memmgr into master
Showing only changes of commit e66baa0da0 - Show all commits

View File

@@ -165,21 +165,24 @@ MM::KernelPool::FreeKernelStack(IN PVOID Stack,
/* Convert the stack size into a page count */ /* Convert the stack size into a page count */
StackPages = SIZE_TO_PAGES(StackSize); StackPages = SIZE_TO_PAGES(StackSize);
/* Acquire the PFN database lock */ /* Start guarded code block */
KE::QueuedSpinLockGuard SpinLock(SystemSpaceLock);
/* Loop through each page of the stack that needs to be freed */
for(Index = 0; Index < StackPages; Index++)
{ {
/* Ensure the PTE is valid */ /* Acquire the PFN database lock */
if(MM::Paging::PteValid(PointerPte)) KE::QueuedSpinLockGuard SpinLock(SystemSpaceLock);
{
/* Free the physical page */
MM::Pfn::FreePhysicalPage(PointerPte);
}
/* Advance to the next PTE */ /* Loop through each page of the stack that needs to be freed */
PointerPte = MM::Paging::AdvancePte(PointerPte, -1); for(Index = 0; Index < StackPages; Index++)
{
/* Ensure the PTE is valid */
if(MM::Paging::PteValid(PointerPte))
{
/* Free the physical page */
MM::Pfn::FreePhysicalPage(PointerPte);
}
/* Advance to the next PTE */
PointerPte = MM::Paging::AdvancePte(PointerPte, -1);
}
} }
/* Release all system PTEs used by the stack, including the guard page */ /* Release all system PTEs used by the stack, including the guard page */