]> xenbits.xensource.com Git - people/liuw/ovmf.git/commitdiff
OvmfPkg: extract OVMF info passed by Xen hvmloader
authorWei Liu <wei.liu2@citrix.com>
Fri, 15 Nov 2013 00:18:40 +0000 (00:18 +0000)
committerWei Liu <wei.liu2@citrix.com>
Tue, 26 Nov 2013 18:51:33 +0000 (18:51 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
OvmfPkg/PlatformPei/Xen.c

index a720b91b99bb1ad7ea26c0cf276eecd6ab5979de..737cb15547de27580f4c932fb253405026c385cc 100644 (file)
 #include <Library/HobLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/PcdLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <IndustryStandard/E820.h>\r
 #include <Guid/XenInfo.h>\r
 \r
 #include "Platform.h"\r
+#include "Xen.h"\r
 \r
 EFI_XEN_INFO mXenInfo;\r
 \r
-\r
 /**\r
   Connects to the Hypervisor.\r
  \r
@@ -50,6 +52,9 @@ XenConnect (
   UINT32 TransferReg;\r
   UINT32 TransferPages;\r
   UINT32 XenVersion;\r
+  EFI_XEN_OVMF_INFO *Info = (EFI_XEN_OVMF_INFO *) OVMF_INFO_PHYSICAL_ADDRESS;\r
+\r
+  ZeroMem (&mXenInfo, sizeof(mXenInfo));\r
 \r
   AsmCpuid (XenLeaf + 2, &TransferPages, &TransferReg, NULL, NULL);\r
   mXenInfo.HyperPages = AllocatePages (TransferPages);\r
@@ -72,6 +77,22 @@ XenConnect (
   /* TBD: Locate hvm_info and reserve it away. */\r
   mXenInfo.HvmInfo = NULL;\r
 \r
+  if (!AsciiStrCmp ((CHAR8 *) Info->Signature, "XenHVMOVMF")) {\r
+    EFI_E820_ENTRY64 *E820Map;\r
+\r
+    E820Map = AllocateCopyPool (sizeof(EFI_E820_ENTRY64) * Info->E820EntriesCount,\r
+                                (VOID *)Info->E820);\r
+    ASSERT (E820Map != NULL);\r
+\r
+    if (!E820Map) {\r
+      FreePages (mXenInfo.HyperPages, TransferPages);\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+\r
+    mXenInfo.E820 = (EFI_PHYSICAL_ADDRESS)E820Map;\r
+    mXenInfo.E820EntriesCount = Info->E820EntriesCount;\r
+  }\r
+\r
   BuildGuidDataHob (\r
     &gEfiXenInfoGuid,\r
     &mXenInfo,\r