Author: sir_richard Date: Wed Sep 29 00:13:09 2010 New Revision: 48926
URL: http://svn.reactos.org/svn/reactos?rev=48926&view=rev Log: [NTOS]: Fix straggling bugs in color table algorithms. [NTOS]: Enable color tables! Right now pages are merely entering and exiting the tables, the tables themselves are never used for allocations. This will change with further commits.
Modified: trunk/reactos/ntoskrnl/mm/ARM3/miarm.h trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c
Modified: trunk/reactos/ntoskrnl/mm/ARM3/miarm.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/miarm.h?re... ============================================================================== --- trunk/reactos/ntoskrnl/mm/ARM3/miarm.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/ARM3/miarm.h [iso-8859-1] Wed Sep 29 00:13:09 2010 @@ -194,10 +194,24 @@ #define MM_SYSLDR_BOOT_LOADED (PVOID)0xFFFFFFFF #define MM_SYSLDR_SINGLE_ENTRY 0x1
+#if defined(_M_IX86) || defined(_M_ARM) // // PFN List Sentinel // #define LIST_HEAD 0xFFFFFFFF + +// +// Because GCC cannot automatically downcast 0xFFFFFFFF to lesser-width bits, +// we need a manual definition suited to the number of bits in the PteFrame. +// This is used as a LIST_HEAD for the colored list +// +#define COLORED_LIST_HEAD ((1 << 25) - 1) // 0x1FFFFFF +#elif defined(_M_AMD64) +#define LIST_HEAD 0xFFFFFFFFFFFFFFFFLL +#define COLORED_LIST_HEAD ((1 << 57) - 1) // 0x1FFFFFFFFFFFFFFLL +#else +#error Define these please! +#endif
// // Special IRQL value (found in assertions)
Modified: trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c?... ============================================================================== --- trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c [iso-8859-1] Wed Sep 29 00:13:09 2010 @@ -30,6 +30,8 @@ #define ASSERT_LIST_INVARIANT(x) #endif
+#define ARM3_COLORS 1 + /* GLOBALS ********************************************************************/
BOOLEAN MmDynamicPfn; @@ -133,11 +135,9 @@ /* Get the page color */ OldBlink = MiGetPfnEntryIndex(Entry); Color = OldBlink & MmSecondaryColorMask; - DPRINT1("Color: %lx\n", Color);
/* Get the first page on the color list */ ColorTable = &MmFreePagesByColor[ListName][Color]; - DPRINT1("Color table: %p %lx\n", ColorTable, ColorTable->Flink);
/* Check if this was was actually the head */ OldFlink = ColorTable->Flink; @@ -148,7 +148,7 @@ if (ColorTable->Flink != LIST_HEAD) { /* And make the previous link point to the head now */ - MiGetPfnEntry(ColorTable->Flink)->u4.PteFrame = -1; + MiGetPfnEntry(ColorTable->Flink)->u4.PteFrame = COLORED_LIST_HEAD; } else { @@ -159,7 +159,7 @@ else { /* This page shouldn't be pointing back to the head */ - ASSERT(Entry->u4.PteFrame != -1); + ASSERT(Entry->u4.PteFrame != COLORED_LIST_HEAD);
/* Make the back link point to whoever the next page is */ Pfn1 = MiGetPfnEntry(Entry->u4.PteFrame); @@ -170,7 +170,7 @@ { /* Make the back link point to the head */ Pfn1 = MiGetPfnEntry(Entry->OriginalPte.u.Long); - Pfn1->u4.PteFrame = -1; + Pfn1->u4.PteFrame = Entry->u4.PteFrame; } else { @@ -182,6 +182,9 @@ /* One less colored page */ ASSERT(ColorTable->Count >= 1); ColorTable->Count--; + + /* ReactOS Hack */ + Entry->OriginalPte.u.Long = 0; #endif /* We are not on a list anymore */ Entry->u1.Flink = Entry->u2.Blink = 0; @@ -284,8 +287,6 @@ ASSERT(ColorTable->Count >= 1);
/* Set the forward link to whoever we were pointing to */ - DPRINT1("Has RMAP: %lx (link: %lx)\n", Pfn1->u3.e1.ParityError, Pfn1->OriginalPte.u.Long); - DPRINT1("Color table: %p %lx\n", ColorTable, ColorTable->Flink); ColorTable->Flink = Pfn1->OriginalPte.u.Long;
/* Get the first page on the color list */ @@ -297,11 +298,14 @@ else { /* The list is empty, so we are the first page */ - MiGetPfnEntry(ColorTable->Flink)->u4.PteFrame = -1; + MiGetPfnEntry(ColorTable->Flink)->u4.PteFrame = COLORED_LIST_HEAD; }
/* One less page */ ColorTable->Count--; + + /* ReactOS Hack */ + Pfn1->OriginalPte.u.Long = 0; #endif /* See if we hit any thresholds */ if (MmAvailablePages == MmHighMemoryThreshold) @@ -536,16 +540,13 @@ #ifdef ARM3_COLORS /* Get the page color */ Color = PageFrameIndex & MmSecondaryColorMask; - DPRINT1("Color: %lx\n", Color);
/* Get the first page on the color list */ ColorTable = &MmFreePagesByColor[FreePageList][Color]; - DPRINT1("Color table: %p %lx\n", ColorTable, ColorTable->Flink); - DPRINT1("Has RMAP: %lx (link: %lx)\n", Pfn1->u3.e1.ParityError, Pfn1->OriginalPte.u.Long); if (ColorTable->Flink == LIST_HEAD) { /* The list is empty, so we are the first page */ - Pfn1->u4.PteFrame = -1; + Pfn1->u4.PteFrame = COLORED_LIST_HEAD; ColorTable->Flink = PageFrameIndex; } else @@ -557,7 +558,6 @@ Pfn1->u4.PteFrame = MiGetPfnEntryIndex(Blink);
/* If there is an original pte, it should be an old link, NOT a ReactOS RMAP */ - DPRINT1("Has RMAP: %lx (link: %lx)\n", Blink->u3.e1.ParityError, Blink->OriginalPte.u.Long); ASSERT(Blink->u3.e1.ParityError == FALSE); Blink->OriginalPte.u.Long = PageFrameIndex; } @@ -663,7 +663,6 @@
/* Get the page color */ Color = PageFrameIndex & MmSecondaryColorMask; - DPRINT1("Color: %lx\n", Color);
/* Get the list for this color */ ColorHead = &MmFreePagesByColor[ZeroedPageList][Color]; @@ -676,7 +675,7 @@
/* Make this page point back to the list, and point forwards to the old head */ Pfn1->OriginalPte.u.Long = Flink; - Pfn1->u4.PteFrame = -1; + Pfn1->u4.PteFrame = COLORED_LIST_HEAD;
/* Set the new head */ ColorHead->Flink = PageFrameIndex; @@ -849,7 +848,7 @@ * ways we shouldn't be seeing RMAP entries at this point */ ASSERT(Pfn1->OriginalPte.u.Soft.Prototype == 0); - ASSERT(Pfn1->OriginalPte.u.Long == 0); + ASSERT(Pfn1->u3.e1.ParityError == FALSE);
/* Mark the page temporarily as valid, we're going to make it free soon */ Pfn1->u3.e1.PageLocation = ActiveAndValid;