]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/CpuDxe/CpuDxe.c
Original MTRR lib hardcode VARIABLE_MTRR as 8. But it is 7 in Core2 if SMRR enabled...
[mirror_edk2.git] / UefiCpuPkg / CpuDxe / CpuDxe.c
index 25131febf20a0fc098ffdb98eca905e562bfa7ca..68579a7da0ebaad88967b2164de0cf2a5b3c3943 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   CPU DXE Module.\r
 \r
-  Copyright (c) 2008 - 2009, Intel Corporation\r
+  Copyright (c) 2008 - 2010, Intel Corporation\r
   All rights reserved. This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -852,8 +852,12 @@ RefreshGcdMemoryAttributes (
   UINTN                               NumberOfDescriptors;\r
   EFI_GCD_MEMORY_SPACE_DESCRIPTOR     *MemorySpaceMap;\r
   UINT64                              DefaultAttributes;\r
-  VARIABLE_MTRR                       VariableMtrr[MTRR_NUMBER_OF_VARIABLE_MTRR];\r
+  VARIABLE_MTRR                       VariableMtrr[MAX_MTRR_NUMBER_OF_VARIABLE_MTRR];\r
   MTRR_FIXED_SETTINGS                 MtrrFixedSettings;\r
+  UINT32                              FirmwareVariableMtrrCount;\r
+  UINT32                              UsedMtrr;\r
+\r
+  FirmwareVariableMtrrCount = GetFirmwareVariableMtrrCount ();\r
 \r
 //  mIsFlushingGCD = TRUE;\r
   mIsFlushingGCD = FALSE;\r
@@ -867,9 +871,11 @@ RefreshGcdMemoryAttributes (
   //\r
   // Get the memory attribute of variable MTRRs\r
   //\r
+  UsedMtrr = MAX_MTRR_NUMBER_OF_VARIABLE_MTRR;\r
   MtrrGetMemoryAttributeInVariableMtrr (\r
     mValidMtrrBitsMask,\r
     mValidMtrrAddressMask,\r
+    &UsedMtrr,\r
     VariableMtrr\r
     );\r
 \r
@@ -902,7 +908,7 @@ RefreshGcdMemoryAttributes (
   //\r
   // Go for variable MTRRs with WB attribute\r
   //\r
-  for (Index = 0; Index < FIRMWARE_VARIABLE_MTRR_NUMBER; Index++) {\r
+  for (Index = 0; Index < FirmwareVariableMtrrCount; Index++) {\r
     if (VariableMtrr[Index].Valid &&\r
         VariableMtrr[Index].Type == MTRR_CACHE_WRITE_BACK) {\r
       SetGcdMemorySpaceAttributes (\r
@@ -917,7 +923,7 @@ RefreshGcdMemoryAttributes (
   //\r
   // Go for variable MTRRs with Non-WB attribute\r
   //\r
-  for (Index = 0; Index < FIRMWARE_VARIABLE_MTRR_NUMBER; Index++) {\r
+  for (Index = 0; Index < FirmwareVariableMtrrCount; Index++) {\r
     if (VariableMtrr[Index].Valid &&\r
         VariableMtrr[Index].Type != MTRR_CACHE_WRITE_BACK) {\r
       Attributes = GetMemorySpaceAttributeFromMtrrType ((UINT8) VariableMtrr[Index].Type);\r