Author: sir_richard
Date: Tue Nov 9 13:26:26 2010
New Revision: 49541
URL:
http://svn.reactos.org/svn/reactos?rev=49541&view=rev
Log:
[NTOS]: Fix bugs in MiAllocateContiguousPages. Fixes an ASSERT Caemyr was seeting a lot
(the cont-able ASSERT).
Modified:
trunk/reactos/ntoskrnl/mm/ARM3/contmem.c
trunk/reactos/ntoskrnl/mm/ARM3/miarm.h
Modified: trunk/reactos/ntoskrnl/mm/ARM3/contmem.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/contmem.c…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/contmem.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/contmem.c [iso-8859-1] Tue Nov 9 13:26:26 2010
@@ -30,13 +30,16 @@
ULONG i = 0;
PMMPFN Pfn1, EndPfn;
KIRQL OldIrql;
- PAGED_CODE ();
+ PAGED_CODE();
ASSERT(SizeInPages != 0);
//
// Convert the boundary PFN into an alignment mask
//
BoundaryMask = ~(BoundaryPfn - 1);
+
+ /* Disable APCs */
+ KeEnterGuardedRegion();
//
// Loop all the physical memory blocks
@@ -69,12 +72,17 @@
// Now scan all the relevant PFNs in this run
//
Length = 0;
- for (Pfn1 = MiGetPfnEntry(Page); Page < LastPage; Page++, Pfn1++)
+ for (Pfn1 = MI_PFN_ELEMENT(Page); Page < LastPage; Page++, Pfn1++)
{
//
// If this PFN is in use, ignore it
//
- if (MiIsPfnInUse(Pfn1)) continue;
+ if (MiIsPfnInUse(Pfn1))
+ {
+ //DPRINT1("In use: reset\n");
+ Length = 0;
+ continue;
+ }
//
// If we haven't chosen a start PFN yet and the caller specified an
@@ -86,6 +94,7 @@
//
// It does not, so bail out
//
+ //DPRINT1("Doesn't match restrictions: reset\n");
continue;
}
@@ -164,14 +173,17 @@
// Quick sanity check that the last PFN is consistent
//
EndPfn = Pfn1 + SizeInPages;
- ASSERT(EndPfn == MiGetPfnEntry(Page + 1));
+ ASSERT(EndPfn == MI_PFN_ELEMENT(Page + 1));
//
// Compute the first page, and make sure it's consistent
//
- Page -= SizeInPages - 1;
- ASSERT(Pfn1 == MiGetPfnEntry(Page));
+ Page = Page - SizeInPages + 1;
+ ASSERT(Pfn1 == MI_PFN_ELEMENT(Page));
ASSERT(Page != 0);
+
+ /* Enable APCs and return the page */
+ KeLeaveGuardedRegion();
return Page;
}
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] Tue Nov 9 13:26:26 2010
@@ -851,6 +851,18 @@
return ProtoPte;
}
+//
+// Returns the PFN Database entry for the given page number
+// Warning: This is not necessarily a valid PFN database entry!
+//
+FORCEINLINE
+PMMPFN
+MI_PFN_ELEMENT(IN PFN_NUMBER Pfn)
+{
+ /* Get the entry */
+ return &MmPfnDatabase[Pfn];
+};
+
BOOLEAN
NTAPI
MmArmInitSystem(