@@ -30,12 +30,11 @@ do { \
30
30
#define ASSERT_LIST_INVARIANT (x )
31
31
#endif
32
32
33
- #define ARM3_COLORS 1
34
-
35
33
/* GLOBALS ********************************************************************/
36
34
37
35
BOOLEAN MmDynamicPfn ;
38
36
BOOLEAN MmMirroring ;
37
+ ULONG MmSystemPageColor ;
39
38
40
39
MMPFNLIST MmZeroedPageListHead = {0 , ZeroedPageList , LIST_HEAD , LIST_HEAD };
41
40
MMPFNLIST MmFreePageListHead = {0 , FreePageList , LIST_HEAD , LIST_HEAD };
@@ -80,11 +79,9 @@ MiUnlinkFreeOrZeroedPage(IN PMMPFN Entry)
80
79
PFN_NUMBER OldFlink , OldBlink ;
81
80
PMMPFNLIST ListHead ;
82
81
MMLISTS ListName ;
83
- #ifdef ARM3_COLORS
84
82
ULONG Color ;
85
83
PMMCOLOR_TABLES ColorTable ;
86
84
PMMPFN Pfn1 ;
87
- #endif
88
85
89
86
/* Make sure the PFN lock is held */
90
87
ASSERT (KeGetCurrentIrql () == DISPATCH_LEVEL );
@@ -131,7 +128,7 @@ MiUnlinkFreeOrZeroedPage(IN PMMPFN Entry)
131
128
/* Set the list head's backlink instead */
132
129
ListHead -> Flink = OldFlink ;
133
130
}
134
- #ifdef ARM3_COLORS
131
+
135
132
/* Get the page color */
136
133
OldBlink = MiGetPfnEntryIndex (Entry );
137
134
Color = OldBlink & MmSecondaryColorMask ;
@@ -185,7 +182,7 @@ MiUnlinkFreeOrZeroedPage(IN PMMPFN Entry)
185
182
186
183
/* ReactOS Hack */
187
184
Entry -> OriginalPte .u .Long = 0 ;
188
- #endif
185
+
189
186
/* We are not on a list anymore */
190
187
Entry -> u1 .Flink = Entry -> u2 .Blink = 0 ;
191
188
ASSERT_LIST_INVARIANT (ListHead );
@@ -219,9 +216,8 @@ MiRemovePageByColor(IN PFN_NUMBER PageIndex,
219
216
MMLISTS ListName ;
220
217
PFN_NUMBER OldFlink , OldBlink ;
221
218
ULONG OldColor , OldCache ;
222
- #ifdef ARM3_COLORS
223
219
PMMCOLOR_TABLES ColorTable ;
224
- #endif
220
+
225
221
/* Make sure PFN lock is held */
226
222
ASSERT (KeGetCurrentIrql () == DISPATCH_LEVEL );
227
223
ASSERT (Color < MmSecondaryColors );
@@ -280,7 +276,7 @@ MiRemovePageByColor(IN PFN_NUMBER PageIndex,
280
276
Pfn1 -> u3 .e2 .ShortFlags = 0 ;
281
277
Pfn1 -> u3 .e1 .PageColor = OldColor ;
282
278
Pfn1 -> u3 .e1 .CacheAttribute = OldCache ;
283
- #ifdef ARM3_COLORS
279
+
284
280
/* Get the first page on the color list */
285
281
ASSERT (Color < MmSecondaryColors );
286
282
ColorTable = & MmFreePagesByColor [ListName ][Color ];
@@ -306,7 +302,7 @@ MiRemovePageByColor(IN PFN_NUMBER PageIndex,
306
302
307
303
/* ReactOS Hack */
308
304
Pfn1 -> OriginalPte .u .Long = 0 ;
309
- #endif
305
+
310
306
/* See if we hit any thresholds */
311
307
if (MmAvailablePages == MmHighMemoryThreshold )
312
308
{
@@ -340,9 +336,8 @@ MiRemoveAnyPage(IN ULONG Color)
340
336
ASSERT (KeGetCurrentIrql () == DISPATCH_LEVEL );
341
337
ASSERT (MmAvailablePages != 0 );
342
338
ASSERT (Color < MmSecondaryColors );
343
-
339
+ #if 0
344
340
/* Check the colored free list */
345
- #if 0 // Enable when using ARM3 database */
346
341
PageIndex = MmFreePagesByColor [FreePageList ][Color ].Flink ;
347
342
if (PageIndex == LIST_HEAD )
348
343
{
@@ -368,11 +363,10 @@ MiRemoveAnyPage(IN ULONG Color)
368
363
ASSERT (MmZeroedPageListHead .Total == 0 );
369
364
}
370
365
}
371
- #if 0 // Enable when using ARM3 database */
366
+ #if 0
372
367
}
373
368
}
374
369
#endif
375
-
376
370
/* Remove the page from its list */
377
371
PageIndex = MiRemovePageByColor (PageIndex , Color );
378
372
@@ -403,7 +397,7 @@ MiRemoveZeroPage(IN ULONG Color)
403
397
ASSERT (Color < MmSecondaryColors );
404
398
405
399
/* Check the colored zero list */
406
- #if 0 // Enable when using ARM3 database */
400
+ #if 0
407
401
PageIndex = MmFreePagesByColor [ZeroedPageList ][Color ].Flink ;
408
402
if (PageIndex == LIST_HEAD )
409
403
{
@@ -414,9 +408,10 @@ MiRemoveZeroPage(IN ULONG Color)
414
408
Color = PageIndex & MmSecondaryColorMask ;
415
409
if (PageIndex == LIST_HEAD )
416
410
{
411
+ /* This means there's no zero pages, we have to look for free ones */
417
412
ASSERT (MmZeroedPageListHead .Total == 0 );
418
413
Zero = TRUE;
419
- #if 0 // Enable when using ARM3 database */
414
+ #if 0
420
415
/* Check the colored free list */
421
416
PageIndex = MmFreePagesByColor [ZeroedPageList ][Color ].Flink ;
422
417
if (PageIndex == LIST_HEAD )
@@ -432,13 +427,14 @@ MiRemoveZeroPage(IN ULONG Color)
432
427
/* FIXME: Should check the standby list */
433
428
ASSERT (MmZeroedPageListHead .Total == 0 );
434
429
}
435
- #if 0 // Enable when using ARM3 database */
430
+ #if 0
436
431
}
437
432
#endif
438
433
}
439
- #if 0 // Enable when using ARM3 database */
434
+ #if 0
440
435
}
441
436
#endif
437
+
442
438
/* Sanity checks */
443
439
Pfn1 = MiGetPfnEntry (PageIndex );
444
440
ASSERT ((Pfn1 -> u3 .e1 .PageLocation == FreePageList ) ||
@@ -468,11 +464,10 @@ MiInsertPageInFreeList(IN PFN_NUMBER PageFrameIndex)
468
464
PMMPFNLIST ListHead ;
469
465
PFN_NUMBER LastPage ;
470
466
PMMPFN Pfn1 ;
471
- #ifdef ARM3_COLORS
472
467
ULONG Color ;
473
468
PMMPFN Blink ;
474
469
PMMCOLOR_TABLES ColorTable ;
475
- #endif
470
+
476
471
/* Make sure the page index is valid */
477
472
ASSERT (KeGetCurrentIrql () >= DISPATCH_LEVEL );
478
473
ASSERT ((PageFrameIndex != 0 ) &&
@@ -537,7 +532,7 @@ MiInsertPageInFreeList(IN PFN_NUMBER PageFrameIndex)
537
532
/* Otherwise check if we reached the high threshold and signal the event */
538
533
KeSetEvent (MiHighMemoryEvent , 0 , FALSE);
539
534
}
540
- #ifdef ARM3_COLORS
535
+
541
536
/* Get the page color */
542
537
Color = PageFrameIndex & MmSecondaryColorMask ;
543
538
@@ -571,7 +566,7 @@ MiInsertPageInFreeList(IN PFN_NUMBER PageFrameIndex)
571
566
572
567
/* And increase the count in the colored list */
573
568
ColorTable -> Count ++ ;
574
- #endif
569
+
575
570
/* Notify zero page thread if enough pages are on the free list now */
576
571
if ((ListHead -> Total >= 8 ) && !(MmZeroingPageThreadActive ))
577
572
{
@@ -590,10 +585,9 @@ MiInsertPageInList(IN PMMPFNLIST ListHead,
590
585
PFN_NUMBER Flink ;
591
586
PMMPFN Pfn1 , Pfn2 ;
592
587
MMLISTS ListName ;
593
- #ifdef ARM3_COLORS
594
588
PMMCOLOR_TABLES ColorHead ;
595
589
ULONG Color ;
596
- #endif
590
+
597
591
/* For free pages, use MiInsertPageInFreeList */
598
592
ASSERT (ListHead != & MmFreePageListHead );
599
593
@@ -657,7 +651,7 @@ MiInsertPageInList(IN PMMPFNLIST ListHead,
657
651
KeSetEvent (MiHighMemoryEvent , 0 , FALSE);
658
652
}
659
653
660
- #ifdef ARM3_COLORS
654
+ /* Sanity checks */
661
655
ASSERT (ListName == ZeroedPageList );
662
656
ASSERT (Pfn1 -> u4 .InPageError == 0 );
663
657
@@ -695,7 +689,6 @@ MiInsertPageInList(IN PMMPFNLIST ListHead,
695
689
696
690
/* One more paged on the colored list */
697
691
ColorHead -> Count ++ ;
698
- #endif
699
692
}
700
693
701
694
VOID
@@ -783,7 +776,7 @@ MiAllocatePfn(IN PMMPTE PointerPte,
783
776
/* Grab a page */
784
777
ASSERT_LIST_INVARIANT (& MmFreePageListHead );
785
778
ASSERT_LIST_INVARIANT (& MmZeroedPageListHead );
786
- PageFrameIndex = MiRemoveAnyPage (0 );
779
+ PageFrameIndex = MiRemoveAnyPage (MI_GET_NEXT_COLOR () );
787
780
788
781
/* Write the software PTE */
789
782
MI_WRITE_INVALID_PTE (PointerPte , TempPte );
0 commit comments