[REACTOS] Fix 64 bit build (#465)
[reactos.git] / ntoskrnl / mm / ARM3 / mminit.c
index 44f50b0..e8cf1dc 100644 (file)
@@ -240,8 +240,9 @@ PMMPTE MiHighestUserPxe;
 #endif
 
 /* These variables define the system cache address space */
-PVOID MmSystemCacheStart;
+PVOID MmSystemCacheStart = (PVOID)MI_SYSTEM_CACHE_START;
 PVOID MmSystemCacheEnd;
+ULONG MmSizeOfSystemCacheInPages;
 MMSUPPORT MmSystemCacheWs;
 
 //
@@ -386,6 +387,15 @@ PFN_NUMBER MiNumberOfFreePages = 0;
 ULONG MmCritsectTimeoutSeconds = 150; // NT value: 720 * 60 * 60; (30 days)
 LARGE_INTEGER MmCriticalSectionTimeout;
 
+//
+// Throttling limits for Cc (in pages)
+// Above top, we don't throttle
+// Above bottom, we throttle depending on the amount of modified pages
+// Otherwise, we throttle!
+//
+ULONG MmThrottleTop;
+ULONG MmThrottleBottom;
+
 /* PRIVATE FUNCTIONS **********************************************************/
 
 VOID
@@ -1779,6 +1789,8 @@ MiBuildPagedPool(VOID)
     TempPte.u.Hard.PageFrameNumber = MmSystemPageDirectory[0];
     MI_WRITE_VALID_PTE(PointerPte, TempPte);
 #endif
+
+#ifdef _M_IX86
     //
     // Let's get back to paged pool work: size it up.
     // By default, it should be twice as big as nonpaged pool.
@@ -1795,6 +1807,7 @@ MiBuildPagedPool(VOID)
         MmSizeOfPagedPoolInBytes = (ULONG_PTR)MmNonPagedSystemStart -
                                    (ULONG_PTR)MmPagedPoolStart;
     }
+#endif // _M_IX86
 
     //
     // Get the size in pages and make sure paged pool is at least 32MB.
@@ -1814,11 +1827,13 @@ MiBuildPagedPool(VOID)
     MmSizeOfPagedPoolInBytes = Size * PAGE_SIZE * 1024;
     MmSizeOfPagedPoolInPages = MmSizeOfPagedPoolInBytes >> PAGE_SHIFT;
 
+#ifdef _M_IX86
     //
     // Let's be really sure this doesn't overflow into nonpaged system VA
     //
     ASSERT((MmSizeOfPagedPoolInBytes + (ULONG_PTR)MmPagedPoolStart) <=
            (ULONG_PTR)MmNonPagedSystemStart);
+#endif // _M_IX86
 
     //
     // This is where paged pool ends
@@ -2068,6 +2083,13 @@ MmArmInitSystem(IN ULONG Phase,
         MiLowNonPagedPoolEvent = &MiTempEvent;
         MiHighNonPagedPoolEvent = &MiTempEvent;
 
+        //
+        // Default throttling limits for Cc
+        // May be ajusted later on depending on system type
+        //
+        MmThrottleTop = 450;
+        MmThrottleBottom = 127;
+
         //
         // Define the basic user vs. kernel address space separation
         //
@@ -2455,6 +2477,10 @@ MmArmInitSystem(IN ULONG Phase,
             /* Set Windows NT Workstation product type */
             SharedUserData->NtProductType = NtProductWinNt;
             MmProductType = 0;
+
+            /* For this product, we wait till the last moment to throttle */
+            MmThrottleTop = 250;
+            MmThrottleBottom = 30;
         }
         else
         {
@@ -2473,6 +2499,10 @@ MmArmInitSystem(IN ULONG Phase,
             /* Set the product type, and make the system more aggressive with low memory */
             MmProductType = 1;
             MmMinimumFreePages = 81;
+
+            /* We will throttle earlier to preserve memory */
+            MmThrottleTop = 450;
+            MmThrottleBottom = 80;
         }
 
         /* Update working set tuning parameters */
@@ -2489,6 +2519,14 @@ MmArmInitSystem(IN ULONG Phase,
             return FALSE;
         }
 
+        /* Define limits for system cache */
+#ifdef _M_AMD64
+        MmSizeOfSystemCacheInPages = (MI_SYSTEM_CACHE_END - MI_SYSTEM_CACHE_START) / PAGE_SIZE;
+#else
+        MmSizeOfSystemCacheInPages = ((ULONG_PTR)MI_PAGED_POOL_START - (ULONG_PTR)MI_SYSTEM_CACHE_START) / PAGE_SIZE;
+#endif
+        MmSystemCacheEnd = (PVOID)((ULONG_PTR)MmSystemCacheStart + (MmSizeOfSystemCacheInPages * PAGE_SIZE) - 1);
+
         /* Initialize the system cache */
         //MiInitializeSystemCache(MmSystemCacheWsMinimum, MmAvailablePages);