]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
OvmfPkg/PlatformBootManagerLib: Connect the Xen drivers before loading NvVars
[mirror_edk2.git] / OvmfPkg / Library / PlatformBootManagerLib / BdsPlatform.c
index cf774a16a78bde5e1a8e77f495d6bca13a9a18f1..912c5ed1ece40f39f27eec8a796d315e54fda540 100644 (file)
@@ -13,6 +13,7 @@
 **/\r
 \r
 #include "BdsPlatform.h"\r
+#include <Guid/XenInfo.h>\r
 #include <Guid/RootBridgesConnectedEventGroup.h>\r
 \r
 \r
@@ -184,12 +185,6 @@ PlatformRegisterOptionsAndKeys (
              NULL, (UINT16) BootOption.OptionNumber, 0, &Esc, NULL\r
              );\r
   ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);\r
-  //\r
-  // Register UEFI Shell\r
-  //\r
-  PlatformRegisterFvBootOption (\r
-    PcdGetPtr (PcdShellFile), L"EFI Internal Shell", LOAD_OPTION_ACTIVE\r
-    );\r
 }\r
 \r
 EFI_STATUS\r
@@ -1043,6 +1038,37 @@ PciAcpiInitialization (
   IoOr16 ((PciRead32 (Pmba) & ~BIT0) + 4, BIT0);\r
 }\r
 \r
+/**\r
+  This function detects if OVMF is running on Xen.\r
+\r
+**/\r
+STATIC\r
+BOOLEAN\r
+XenDetected (\r
+  VOID\r
+  )\r
+{\r
+  EFI_HOB_GUID_TYPE         *GuidHob;\r
+  STATIC INTN               FoundHob = -1;\r
+\r
+  if (FoundHob == 0) {\r
+    return FALSE;\r
+  } else if (FoundHob == 1) {\r
+    return TRUE;\r
+  }\r
+\r
+  //\r
+  // See if a XenInfo HOB is available\r
+  //\r
+  GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid);\r
+  if (GuidHob == NULL) {\r
+    FoundHob = 0;\r
+    return FALSE;\r
+  }\r
+\r
+  FoundHob = 1;\r
+  return TRUE;\r
+}\r
 \r
 EFI_STATUS\r
 EFIAPI\r
@@ -1056,7 +1082,11 @@ ConnectRecursivelyIfPciMassStorage (
   EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
   CHAR16                    *DevPathStr;\r
 \r
-  if (IS_CLASS1 (PciHeader, PCI_CLASS_MASS_STORAGE)) {\r
+  //\r
+  // Recognize PCI Mass Storage, and Xen PCI devices\r
+  //\r
+  if (IS_CLASS1 (PciHeader, PCI_CLASS_MASS_STORAGE) ||\r
+      (XenDetected() && IS_CLASS2 (PciHeader, 0xFF, 0x80))) {\r
     DevicePath = NULL;\r
     Status = gBS->HandleProtocol (\r
                     Handle,\r
@@ -1074,7 +1104,8 @@ ConnectRecursivelyIfPciMassStorage (
     if (DevPathStr != NULL) {\r
       DEBUG((\r
         EFI_D_INFO,\r
-        "Found Mass Storage device: %s\n",\r
+        "Found %s device: %s\n",\r
+        IS_CLASS1 (PciHeader, PCI_CLASS_MASS_STORAGE) ? L"Mass Storage" : L"Xen",\r
         DevPathStr\r
         ));\r
       FreePool(DevPathStr);\r
@@ -1206,11 +1237,6 @@ Returns:
   EfiBootManagerConnectAll ();\r
 \r
   PciAcpiInitialization ();\r
-\r
-  //\r
-  // Clear the logo after all devices are connected.\r
-  //\r
-  gST->ConOut->ClearScreen (gST->ConOut);\r
 }\r
 \r
 /**\r
@@ -1290,7 +1316,13 @@ Routine Description:
   //\r
   // Logo show\r
   //\r
-  EnableQuietBoot (PcdGetPtr (PcdLogoFile));\r
+  BootLogoEnableLogo (\r
+    ImageFormatBmp,                          // ImageFormat\r
+    PcdGetPtr (PcdLogoFile),                 // Logo\r
+    EdkiiPlatformLogoDisplayAttributeCenter, // Attribute\r
+    0,                                       // OffsetX\r
+    0                                        // OffsetY\r
+    );\r
 \r
   //\r
   // Perform some platform specific connect sequence\r
@@ -1304,7 +1336,14 @@ Routine Description:
 \r
   EfiBootManagerRefreshAllBootOption ();\r
 \r
-  SetBootOrderFromQemu (NULL);\r
+  //\r
+  // Register UEFI Shell\r
+  //\r
+  PlatformRegisterFvBootOption (\r
+    PcdGetPtr (PcdShellFile), L"EFI Internal Shell", LOAD_OPTION_ACTIVE\r
+    );\r
+\r
+  SetBootOrderFromQemu ();\r
 }\r
 \r
 /**\r
@@ -1418,5 +1457,22 @@ PlatformBootManagerWaitCallback (
   UINT16          TimeoutRemain\r
   )\r
 {\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White;\r
+  UINT16                              Timeout;\r
+\r
+  Timeout = PcdGet16 (PcdPlatformBootTimeOut);\r
+\r
+  Black.Raw = 0x00000000;\r
+  White.Raw = 0x00FFFFFF;\r
+\r
+  BootLogoUpdateProgress (\r
+    White.Pixel,\r
+    Black.Pixel,\r
+    L"Start boot option",\r
+    White.Pixel,\r
+    (Timeout - TimeoutRemain) * 100 / Timeout,\r
+    0\r
+    );\r
 }\r
 \r