]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: QemuBootOrderLib: expose QEMU's "-boot menu=on[,splash-time=N]"
authorLaszlo Ersek <lersek@redhat.com>
Wed, 14 Jan 2015 16:25:54 +0000 (16:25 +0000)
committerlersek <lersek@Edk2>
Wed, 14 Jan 2015 16:25:54 +0000 (16:25 +0000)
The QEMU command line option

  -boot menu=on

is meant to have the guest firmware wait for a firmware-specific interval
for the user to enter the boot menu. During the wait, the user can opt to
enter the boot menu, or interrupt the wait and proceed to booting at once.
If the wait interval elapses, the firmware should boot as it normally
would.

The QEMU command line option

  -boot menu=on,splash-time=N

means the same, except the firmware should wait for cca. N milliseconds
instead of a firmware-specific interval.

We can approximate this behavior quite well for edk2's virtual platforms
because the Intel BDS front page already supports a progress bar, with
semantics similar to the above. Let's distill the fw_cfg bits underlying
"-boot menu=on,splash-time=N" for the BDS policies, in the form of a
timeout value they can pass to Intel's PlatformBdsEnterFrontPage().

If the boot menu is not requested, we return
"gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdPlatformBootTimeOut", which
is what the virtual platforms use right now.

If the boot menu is requested without specifying the timeout, we return
the same PCD, unless it would cause us to skip the boot menu at once. In
the latter case, we return 3 seconds (as an approximation of the 2500 ms
SeaBIOS default.)

RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1170507

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Olivier Martin <Olivier.martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16610 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/Include/Library/QemuBootOrderLib.h
OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf

index 12cda6aa91e0ac1190e3a53fc629e23a0ad0c6e0..80d02c80c260dedf683fbb68972eb36af0fe1c5a 100644 (file)
@@ -54,4 +54,16 @@ SetBootOrderFromQemu (
   IN  CONST LIST_ENTRY *BootOptionList\r
   );\r
 \r
+\r
+/**\r
+  Calculate the number of seconds we should be showing the FrontPage progress\r
+  bar for.\r
+\r
+  @return  The TimeoutDefault argument for PlatformBdsEnterFrontPage().\r
+**/\r
+UINT16\r
+GetFrontPageTimeoutFromQemu (\r
+  VOID\r
+  );\r
+\r
 #endif\r
index bc2fb56954259926033db5206e5756a4d8598f21..e63ad262247bbc4abd452d3e86d8d2ea9ebba20b 100644 (file)
@@ -1571,3 +1571,53 @@ ErrorFreeFwCfg:
 \r
   return Status;\r
 }\r
+\r
+\r
+/**\r
+  Calculate the number of seconds we should be showing the FrontPage progress\r
+  bar for.\r
+\r
+  @return  The TimeoutDefault argument for PlatformBdsEnterFrontPage().\r
+**/\r
+UINT16\r
+GetFrontPageTimeoutFromQemu (\r
+  VOID\r
+  )\r
+{\r
+  FIRMWARE_CONFIG_ITEM BootMenuWaitItem;\r
+  UINTN                BootMenuWaitSize;\r
+\r
+  QemuFwCfgSelectItem (QemuFwCfgItemBootMenu);\r
+  if (QemuFwCfgRead16 () == 0) {\r
+    //\r
+    // The user specified "-boot menu=off", or didn't specify "-boot\r
+    // menu=(on|off)" at all. Return the platform default.\r
+    //\r
+    return PcdGet16 (PcdPlatformBootTimeOut);\r
+  }\r
+\r
+  if (RETURN_ERROR (QemuFwCfgFindFile ("etc/boot-menu-wait", &BootMenuWaitItem,\r
+                      &BootMenuWaitSize)) ||\r
+      BootMenuWaitSize != sizeof (UINT16)) {\r
+    //\r
+    // "-boot menu=on" was specified without "splash-time=N". In this case,\r
+    // return three seconds if the platform default would cause us to skip the\r
+    // front page, and return the platform default otherwise.\r
+    //\r
+    UINT16 Timeout;\r
+\r
+    Timeout = PcdGet16 (PcdPlatformBootTimeOut);\r
+    if (Timeout == 0) {\r
+      Timeout = 3;\r
+    }\r
+    return Timeout;\r
+  }\r
+\r
+  //\r
+  // "-boot menu=on,splash-time=N" was specified, where N is in units of\r
+  // milliseconds. The Intel BDS Front Page progress bar only supports whole\r
+  // seconds, round N up.\r
+  //\r
+  QemuFwCfgSelectItem (BootMenuWaitItem);\r
+  return (UINT16)((QemuFwCfgRead16 () + 999) / 1000);\r
+}\r
index 6289e6abe6d296cc53f48d286f9fdea9cfe4d8f3..e7be0f3cd7f6931dd1c582c93fd8bdc1f13ed2c7 100644 (file)
@@ -57,3 +57,6 @@
 [FeaturePcd]\r
   gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation\r
   gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderMmioTranslation\r
+\r
+[Pcd]\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdPlatformBootTimeOut\r