Implement initial memory manager infrastructure #24

Open
harraiken wants to merge 198 commits from memmgr into master
Showing only changes of commit 5a78512561 - Show all commits

View File

@@ -27,8 +27,8 @@ XTSTATUS
MM::Allocator::AllocateNonPagedPoolPages(IN PFN_COUNT Pages, MM::Allocator::AllocateNonPagedPoolPages(IN PFN_COUNT Pages,
OUT PVOID *Memory) OUT PVOID *Memory)
{ {
PMMPTE CurrentPte, PointerPte, ValidPte;
PLIST_ENTRY Entry, LastHead, ListHead; PLIST_ENTRY Entry, LastHead, ListHead;
PMMPTE PointerPte, ValidPte;
PMMFREE_POOL_ENTRY FreePage; PMMFREE_POOL_ENTRY FreePage;
PFN_NUMBER PageFrameNumber; PFN_NUMBER PageFrameNumber;
PVOID BaseAddress; PVOID BaseAddress;
@@ -139,6 +139,9 @@ MM::Allocator::AllocateNonPagedPoolPages(IN PFN_COUNT Pages,
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
} }
/* Set the tracking pointer to iterate through the reserved PTE space */
CurrentPte = PointerPte;
/* Get a template valid PTE and loop through the allocation to map physical pages */ /* Get a template valid PTE and loop through the allocation to map physical pages */
ValidPte = MM::Pte::GetValidPte(); ValidPte = MM::Pte::GetValidPte();
do do
@@ -148,7 +151,7 @@ MM::Allocator::AllocateNonPagedPoolPages(IN PFN_COUNT Pages,
/* Initialize the PFN entry for the allocated physical page */ /* Initialize the PFN entry for the allocated physical page */
Pfn = MM::Pfn::GetPfnEntry(PageFrameNumber); Pfn = MM::Pfn::GetPfnEntry(PageFrameNumber);
Pfn->PteAddress = PointerPte; Pfn->PteAddress = CurrentPte;
Pfn->u2.ShareCount = 1; Pfn->u2.ShareCount = 1;
Pfn->u3.e1.PageLocation = ActiveAndValid; Pfn->u3.e1.PageLocation = ActiveAndValid;
Pfn->u3.e2.ReferenceCount = 1; Pfn->u3.e2.ReferenceCount = 1;
@@ -157,8 +160,9 @@ MM::Allocator::AllocateNonPagedPoolPages(IN PFN_COUNT Pages,
/* Build a valid PTE pointing to the allocated page frame */ /* Build a valid PTE pointing to the allocated page frame */
MM::Paging::SetPte(ValidPte, PageFrameNumber, 0); MM::Paging::SetPte(ValidPte, PageFrameNumber, 0);
/* Write the valid PTE into the system PTE range */ /* Write the valid PTE into the system PTE range and advance to the next PTE */
*(MM::Paging::GetNextPte(PointerPte)) = *ValidPte; *CurrentPte = *ValidPte;
CurrentPte = MM::Paging::GetNextPte(CurrentPte);
} }
while(--Pages > 0); while(--Pages > 0);