]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/Library/MtrrLib/MtrrLib.c
UefiCpuPkg MtrrLib: For MtrrSetAllMtrrs(), do not set FE/E bits in IA32_MTRR_DEF_TYPE...
[mirror_edk2.git] / UefiCpuPkg / Library / MtrrLib / MtrrLib.c
index 5f1a22c5fd1cf963caca42190ba323af4392a081..b598d51b4b86c4c62724c50027ab1dc24fa9af02 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   MTRR setting library\r
 \r
-  Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.<BR>\r
   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
@@ -203,26 +203,20 @@ PreMtrrChange (
   return Value;\r
 }\r
 \r
-\r
 /**\r
   Cleaning up after programming MTRRs.\r
 \r
   This function will do some clean up after programming MTRRs:\r
-  enable MTRR caching functionality, and enable cache\r
+  Flush all TLBs,  re-enable caching, restore CR4.\r
 \r
   @param  Cr4  CR4 value to restore\r
 \r
 **/\r
 VOID\r
-PostMtrrChange (\r
-  UINTN Cr4\r
+PostMtrrChangeEnableCache (\r
+  IN UINTN  Cr4\r
   )\r
 {\r
-  //\r
-  // Enable Cache MTRR\r
-  //\r
-  AsmMsrBitFieldWrite64 (MTRR_LIB_IA32_MTRR_DEF_TYPE, 10, 11, 3);\r
-\r
   //\r
   // Flush all TLBs \r
   //\r
@@ -239,6 +233,28 @@ PostMtrrChange (
   AsmWriteCr4 (Cr4);\r
 }\r
 \r
+/**\r
+  Cleaning up after programming MTRRs.\r
+\r
+  This function will do some clean up after programming MTRRs:\r
+  enable MTRR caching functionality, and enable cache\r
+\r
+  @param  Cr4  CR4 value to restore\r
+\r
+**/\r
+VOID\r
+PostMtrrChange (\r
+  IN UINTN  Cr4\r
+  )\r
+{\r
+  //\r
+  // Enable Cache MTRR\r
+  //\r
+  AsmMsrBitFieldWrite64 (MTRR_LIB_IA32_MTRR_DEF_TYPE, 10, 11, 3);\r
+\r
+  PostMtrrChangeEnableCache (Cr4);\r
+}\r
+\r
 \r
 /**\r
   Programs fixed MTRRs registers.\r
@@ -1026,16 +1042,6 @@ MtrrSetMemoryAttribute (
     }\r
   }\r
 \r
-  //\r
-  // Program Variable MTRRs\r
-  //\r
-  // Avoid hardcode here and read data dynamically\r
-  //\r
-  if (UsedMtrr >= FirmwareVariableMtrrCount) {\r
-    Status = RETURN_OUT_OF_RESOURCES;\r
-    goto Done;\r
-  }\r
-\r
   //\r
   // The memory type is the same with the type specified by\r
   // MTRR_LIB_IA32_MTRR_DEF_TYPE.\r
@@ -1512,7 +1518,7 @@ MtrrSetAllMtrrs (
   //\r
   AsmWriteMsr64 (MTRR_LIB_IA32_MTRR_DEF_TYPE, MtrrSetting->MtrrDefType);\r
 \r
-  PostMtrrChange (Cr4);\r
+  PostMtrrChangeEnableCache (Cr4);\r
 \r
   return MtrrSetting;\r
 }\r