]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/PlatformPei/MemDetect.c
Set MTRR registers.
[mirror_edk2.git] / OvmfPkg / PlatformPei / MemDetect.c
index 78b43d22b75f5bb2c641f6ad86eaf2a4f25802b1..5070c79c0da9be00a1e6165b7721568db8e55271 100644 (file)
@@ -1,7 +1,7 @@
 /**@file\r
   Memory Detection for Virtual Machines.\r
 \r
-  Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2011, 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
@@ -30,6 +30,7 @@ Module Name:
 #include <Library/PcdLib.h>\r
 #include <Library/PeimEntryPoint.h>\r
 #include <Library/ResourcePublicationLib.h>\r
+#include <Library/MtrrLib.h>\r
 \r
 #include "Platform.h"\r
 #include "Cmos.h"\r
@@ -130,8 +131,17 @@ MemDetect (
   AddMemoryRangeHob (BASE_1MB, MemoryBase);\r
   AddMemoryRangeHob (0, BASE_512KB + BASE_128KB);\r
 \r
+  Status = MtrrSetMemoryAttribute (BASE_1MB, MemoryBase + MemorySize - BASE_1MB, CacheWriteBack);\r
+  ASSERT_EFI_ERROR(Status);\r
+\r
+  Status = MtrrSetMemoryAttribute (0, BASE_512KB + BASE_128KB, CacheWriteBack);\r
+  ASSERT_EFI_ERROR(Status);\r
+\r
   if (UpperMemorySize != 0) {\r
     AddUntestedMemoryBaseSizeHob (BASE_4GB, UpperMemorySize);\r
+\r
+    Status = MtrrSetMemoryAttribute (BASE_4GB, UpperMemorySize, CacheWriteBack);\r
+    ASSERT_EFI_ERROR(Status);\r
   }\r
 \r
   return MemoryBase + MemorySize;\r