[NTOS]: Implement MiAllocatePfn, it is a simpler wrapper that grabs a page, sets its protection, and initializes its PFN entry.

[NTOS]: Use MiAllocatePfn in MiLoadImageSection instead of MmAllocPage. Other than doing a better job at initializing the page, it creates our first caller of this function, great for testing, since this is a rather high-demand function, especially at boot.
Please test.

svn path=/trunk/; revision=47432
This commit is contained in:
Sir Richard 2010-05-30 03:02:39 +00:00
parent a77d6480a6
commit c816943def
2 changed files with 39 additions and 1 deletions

View file

@ -618,6 +618,44 @@ MiInitializePfn(IN PFN_NUMBER PageFrameIndex,
Pfn1->u2.ShareCount++;
}
PFN_NUMBER
NTAPI
MiAllocatePfn(IN PMMPTE PointerPte,
IN ULONG Protection)
{
KIRQL OldIrql;
PFN_NUMBER PageFrameIndex;
MMPTE TempPte;
/* Make an empty software PTE */
MI_MAKE_SOFTWARE_PTE(&TempPte, MM_READWRITE);
/* Lock the PFN database */
OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
/* Check if we're running low on pages */
if (MmAvailablePages < 128)
{
DPRINT1("Warning, running low on memory: %d pages left\n", MmAvailablePages);
//MiEnsureAvailablePageOrWait(NULL, OldIrql);
}
/* Grab a page */
PageFrameIndex = MiRemoveAnyPage(0);
/* Write the software PTE */
ASSERT(PointerPte->u.Hard.Valid == 0);
*PointerPte = TempPte;
PointerPte->u.Soft.Protection |= Protection;
/* Initialize its PFN entry */
MiInitializePfn(PageFrameIndex, PointerPte, TRUE);
/* Release the PFN lock and return the page */
KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql);
return PageFrameIndex;
}
VOID
NTAPI
MiDecrementShareCount(IN PMMPFN Pfn1,

View file

@ -172,7 +172,7 @@ MiLoadImageSection(IN OUT PVOID *SectionPtr,
while (PointerPte < LastPte)
{
/* Allocate a page */
TempPte.u.Hard.PageFrameNumber = MmAllocPage(MC_NPPOOL);
TempPte.u.Hard.PageFrameNumber = MiAllocatePfn(PointerPte, MM_EXECUTE);
/* Write it */
ASSERT(PointerPte->u.Hard.Valid == 0);