#define MODULE_INVOLVED_IN_ARM3
#include "../ARM3/miarm.h"
+#if DBG
#define ASSERT_LIST_INVARIANT(x) \
do { \
ASSERT(((x)->Total == 0 && \
(x)->Flink != LIST_HEAD && \
(x)->Blink != LIST_HEAD)); \
} while (0)
+#else
+#define ASSERT_LIST_INVARIANT(x)
+#endif
/* GLOBALS ********************************************************************/
IN PMMPFN Entry)
{
PFN_NUMBER OldBlink, EntryIndex = MiGetPfnEntryIndex(Entry);
-
ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL);
ASSERT_LIST_INVARIANT(ListHead);
/* And now the head points back to us, since we are last */
ListHead->Blink = EntryIndex;
+ ASSERT_LIST_INVARIANT(ListHead);
/* Update the page location */
Pfn1->u3.e1.PageLocation = ZeroedPageList;
KeSetEvent(MiHighMemoryEvent, 0, FALSE);
}
- ASSERT_LIST_INVARIANT(ListHead);
-
#if 0
/* Get the page color */
Color = EntryIndex & MmSecondaryColorMask;
}
/* We are not on a list anymore */
+ ASSERT_LIST_INVARIANT(ListHead);
Pfn1->u1.Flink = Pfn1->u2.Blink = 0;
/* Zero flags but restore color and cache */
Pfn1->u3.e1.PageColor = OldColor;
Pfn1->u3.e1.CacheAttribute = OldCache;
- ASSERT_LIST_INVARIANT(ListHead);
-
#if 0 // When switching to ARM3
/* Get the first page on the color list */
ColorTable = &MmFreePagesByColor[ListName][Color];
(Pfn1->u3.e1.PageLocation == ZeroedPageList));
ASSERT(Pfn1->u3.e2.ReferenceCount == 0);
ASSERT(Pfn1->u2.ShareCount == 0);
-
- /* Return the page */
ASSERT_LIST_INVARIANT(&MmFreePageListHead);
ASSERT_LIST_INVARIANT(&MmZeroedPageListHead);
-
+
+ /* Return the page */
return PageIndex;
}
{
PFN_NUMBER Entry, Flink;
PMMPFN Pfn1;
-
ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL);
ASSERT_LIST_INVARIANT(ListHead);
/* We are not on a list anymore */
Pfn1->u1.Flink = Pfn1->u2.Blink = 0;
ListHead->Total--;
-
ASSERT_LIST_INVARIANT(ListHead);
/* Return the head element */
/* Now make the list head point back to us (since we go at the end) */
ListHead->Blink = PageFrameIndex;
+ ASSERT_LIST_INVARIANT(ListHead);
/* And initialize our own list pointers */
Pfn1->u1.Flink = LIST_HEAD;
KeSetEvent(MiHighMemoryEvent, 0, FALSE);
}
- ASSERT_LIST_INVARIANT(ListHead);
-
#if 0 // When using ARM3 PFN
/* Get the page color */
Color = PageFrameIndex & MmSecondaryColorMask;
}
}
+VOID
+NTAPI
+MiInitializePfnForOtherProcess(IN PFN_NUMBER PageFrameIndex,
+ IN PMMPTE PointerPte,
+ IN PFN_NUMBER PteFrame)
+{
+ PMMPFN Pfn1;
+
+ /* Setup the PTE */
+ Pfn1 = MiGetPfnEntry(PageFrameIndex);
+ Pfn1->PteAddress = PointerPte;
+
+#if 0 // When using ARM3 PFN
+ /* Make this a software PTE */
+ MI_MAKE_SOFTWARE_PTE(&Pfn1->OriginalPte, MM_READWRITE);
+#endif
+
+ /* Setup the page */
+ ASSERT(Pfn1->u3.e2.ReferenceCount == 0);
+ Pfn1->u3.e2.ReferenceCount = 1;
+ Pfn1->u2.ShareCount = 1;
+ Pfn1->u3.e1.PageLocation = ActiveAndValid;
+ Pfn1->u3.e1.Modified = TRUE;
+ Pfn1->u4.InPageError = FALSE;
+
+ /* Did we get a PFN for the page table */
+ if (PteFrame)
+ {
+ /* Store it */
+ Pfn1->u4.PteFrame = PteFrame;
+
+ /* Increase its share count so we don't get rid of it */
+ Pfn1 = MiGetPfnEntry(PageFrameIndex);
+ Pfn1->u2.ShareCount++;
+ }
+}
+
/* EOF */
//
ASSERT(PointerPte->u.Hard.Valid == 0);
- //
- // Request a paged pool page and write the PFN for it
- //
- PageFrameNumber = MmAllocPage(MC_PPOOL);
+ /* Request a page */
+ PageFrameNumber = MiRemoveAnyPage(0);
TempPte.u.Hard.PageFrameNumber = PageFrameNumber;
//
// Save it into our double-buffered system page directory
//
/* This seems to be making the assumption that one PDE is one page long */
- ASSERT(PAGE_SIZE == (PD_COUNT * (sizeof(MMPTE) * PDE_COUNT)));
+ C_ASSERT(PAGE_SIZE == (PD_COUNT * (sizeof(MMPTE) * PDE_COUNT)));
MmSystemPagePtes[(ULONG_PTR)PointerPte & (PAGE_SIZE - 1) /
sizeof(MMPTE)] = TempPte;
+ /* Initialize the PFN */
+ MiInitializePfnForOtherProcess(PageFrameNumber,
+ PointerPte,
+ MmSystemPageDirectory[(PointerPte - (PMMPTE)PDE_BASE) / PDE_COUNT]);
+
/* Write the actual PTE now */
ASSERT(TempPte.u.Hard.Valid == 1);
*PointerPte++ = TempPte;