summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/PlatformPei/Xen.c
diff options
context:
space:
mode:
authorJordan Justen <jordan.l.justen@intel.com>2014-02-01 21:22:25 +0000
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>2014-02-01 21:22:25 +0000
commit18f31ada8d5f02a42408dfe4092a8bcc71fc4ed9 (patch)
tree6703b4e7a751ec6e7c4ef7d0fecbe8d8399e29f2 /OvmfPkg/PlatformPei/Xen.c
parentb98b4941e266526bf4c75f9004c869bfe9ef2f14 (diff)
downloadedk2-18f31ada8d5f02a42408dfe4092a8bcc71fc4ed9.tar.gz
edk2-18f31ada8d5f02a42408dfe4092a8bcc71fc4ed9.tar.bz2
edk2-18f31ada8d5f02a42408dfe4092a8bcc71fc4ed9.zip
OvmfPkg/PlatformPei: Add XenPublishRamRegions
This will be called from a unified MemDetect function. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Wei Liu <wei.liu2@citrix.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15203 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'OvmfPkg/PlatformPei/Xen.c')
-rw-r--r--OvmfPkg/PlatformPei/Xen.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/OvmfPkg/PlatformPei/Xen.c b/OvmfPkg/PlatformPei/Xen.c
index da3133bb9b..3a2e358661 100644
--- a/OvmfPkg/PlatformPei/Xen.c
+++ b/OvmfPkg/PlatformPei/Xen.c
@@ -27,6 +27,9 @@
#include <Library/MemoryAllocationLib.h>
#include <Library/PcdLib.h>
#include <Guid/XenInfo.h>
+#include <IndustryStandard/E820.h>
+#include <Library/ResourcePublicationLib.h>
+#include <Library/MtrrLib.h>
#include "Platform.h"
#include "Xen.h"
@@ -149,6 +152,55 @@ XenDetect (
return FALSE;
}
+
+VOID
+XenPublishRamRegions (
+ VOID
+ )
+{
+ EFI_E820_ENTRY64 *E820Map;
+ UINT32 E820EntriesCount;
+ EFI_STATUS Status;
+
+ if (!mXen) {
+ return;
+ }
+
+ DEBUG ((EFI_D_INFO, "Using memory map provided by Xen\n"));
+
+ //
+ // Parse RAM in E820 map
+ //
+ Status = XenGetE820Map (&E820Map, &E820EntriesCount);
+
+ ASSERT_EFI_ERROR (Status);
+
+ if (E820EntriesCount > 0) {
+ EFI_E820_ENTRY64 *Entry;
+ UINT32 Loop;
+
+ for (Loop = 0; Loop < E820EntriesCount; Loop++) {
+ Entry = E820Map + Loop;
+
+ //
+ // Only care about RAM
+ //
+ if (Entry->Type != EfiAcpiAddressRangeMemory) {
+ continue;
+ }
+
+ if (Entry->BaseAddr >= BASE_4GB) {
+ AddUntestedMemoryBaseSizeHob (Entry->BaseAddr, Entry->Length);
+ } else {
+ AddMemoryBaseSizeHob (Entry->BaseAddr, Entry->Length);
+ }
+
+ MtrrSetMemoryAttribute (Entry->BaseAddr, Entry->Length, CacheWriteBack);
+ }
+ }
+}
+
+
/**
Perform Xen PEI initialization.