-VOID
-NTAPI
-MiInsertInListTail(IN PMMPFNLIST ListHead,
- IN PMMPFN Entry)
-{
- PFN_NUMBER OldBlink, EntryIndex = MiGetPfnEntryIndex(Entry);
- ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL);
- ASSERT_LIST_INVARIANT(ListHead);
-
- /* Get the back link */
- OldBlink = ListHead->Blink;
- if (OldBlink != LIST_HEAD)
- {
- /* Set the back pointer to point to us now */
- MiGetPfnEntry(OldBlink)->u1.Flink = EntryIndex;
- }
- else
- {
- /* Set the list to point to us */
- ListHead->Flink = EntryIndex;
- }
-
- /* Set the entry to point to the list head forwards, and the old page backwards */
- Entry->u1.Flink = LIST_HEAD;
- Entry->u2.Blink = OldBlink;
-
- /* And now the head points back to us, since we are last */
- ListHead->Blink = EntryIndex;
- ListHead->Total++;
- ASSERT_LIST_INVARIANT(ListHead);
-}
-
-VOID
-NTAPI
-MiInsertZeroListAtBack(IN PFN_NUMBER EntryIndex)
-{
- PFN_NUMBER OldBlink;
- PMMPFNLIST ListHead;
- PMMPFN Pfn1;
-#if 0
- PMMPFN Blink;
- ULONG Color;
- PMMCOLOR_TABLES ColorHead;
-#endif
-
- /* Make sure the PFN lock is held */
- ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL);
-
- /* Get the descriptor */
- Pfn1 = MiGetPfnEntry(EntryIndex);
- ASSERT(Pfn1->u3.e2.ReferenceCount == 0);
- ASSERT(Pfn1->u4.MustBeCached == 0);
- ASSERT(Pfn1->u3.e1.Rom == 0);
- ASSERT(Pfn1->u3.e1.RemovalRequested == 0);
- ASSERT(Pfn1->u4.InPageError == 0);
-
- /* Use the zero list */
- ListHead = &MmZeroedPageListHead;
- ASSERT_LIST_INVARIANT(ListHead);
- ListHead->Total++;
-
- /* Get the back link */
- OldBlink = ListHead->Blink;
- if (OldBlink != LIST_HEAD)
- {
- /* Set the back pointer to point to us now */
- MiGetPfnEntry(OldBlink)->u1.Flink = EntryIndex;
- }
- else
- {
- /* Set the list to point to us */
- ListHead->Flink = EntryIndex;
- }
-
- /* Set the entry to point to the list head forwards, and the old page backwards */
- Pfn1->u1.Flink = LIST_HEAD;
- Pfn1->u2.Blink = OldBlink;
-
- /* 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;
-
- /* FIXME: NOT YET Due to caller semantics: Update the available page count */
- //MmAvailablePages++;
-
- /* Check if we've reached the configured low memory threshold */
- if (MmAvailablePages == MmLowMemoryThreshold)
- {
- /* Clear the event, because now we're ABOVE the threshold */
- KeClearEvent(MiLowMemoryEvent);
- }
- else if (MmAvailablePages == MmHighMemoryThreshold)
- {
- /* Otherwise check if we reached the high threshold and signal the event */
- KeSetEvent(MiHighMemoryEvent, 0, FALSE);
- }
-
-#if 0
- /* Get the page color */
- Color = EntryIndex & MmSecondaryColorMask;
-
- /* Get the first page on the color list */
- ColorHead = &MmFreePagesByColor[ZeroedPageList][Color];
- if (ColorHead->Flink == LIST_HEAD)
- {
- /* The list is empty, so we are the first page */
- Pfn1->u4.PteFrame = -1;
- ColorHead->Flink = EntryIndex;
- }
- else
- {
- /* Get the previous page */
- Blink = (PMMPFN)ColorHead->Blink;
-
- /* Make it link to us */
- Pfn1->u4.PteFrame = MiGetPfnEntryIndex(Blink);
- Blink->OriginalPte.u.Long = EntryIndex;
- }
-
- /* Now initialize our own list pointers */
- ColorHead->Blink = Pfn1;
- Pfn1->OriginalPte.u.Long = LIST_HEAD;
-
- /* And increase the count in the colored list */
- ColorHead->Count++;
-#endif
-}
-