The command line option -boot menu=on,splash-time=N
of QEMU causes SeaBIOS to wait N milliseconds 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, SeaBIOS boots as it normally would. 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. RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1170507 Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <[email protected]> --- OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf | 3 +++ OvmfPkg/Include/Library/QemuBootOrderLib.h | 12 ++++++++++++ OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) diff --git a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf index 6289e6a..e7be0f3 100644 --- a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf +++ b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf @@ -57,3 +57,6 @@ [FeaturePcd] gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderMmioTranslation + +[Pcd] + gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdPlatformBootTimeOut diff --git a/OvmfPkg/Include/Library/QemuBootOrderLib.h b/OvmfPkg/Include/Library/QemuBootOrderLib.h index 12cda6a..80d02c8 100644 --- a/OvmfPkg/Include/Library/QemuBootOrderLib.h +++ b/OvmfPkg/Include/Library/QemuBootOrderLib.h @@ -54,4 +54,16 @@ SetBootOrderFromQemu ( IN CONST LIST_ENTRY *BootOptionList ); + +/** + Calculate the number of seconds we should be showing the FrontPage progress + bar for. + + @return The TimeoutDefault argument for PlatformBdsEnterFrontPage(). +**/ +UINT16 +GetFrontPageTimeoutFromQemu ( + VOID + ); + #endif diff --git a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c index bc2fb56..4155240 100644 --- a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c +++ b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c @@ -1571,3 +1571,56 @@ ErrorFreeFwCfg: return Status; } + + +/** + Calculate the number of seconds we should be showing the FrontPage progress + bar for. + + @return The TimeoutDefault argument for PlatformBdsEnterFrontPage(). +**/ +UINT16 +GetFrontPageTimeoutFromQemu ( + VOID + ) +{ + UINT16 Timeout; + + // + // Set default. + // + Timeout = PcdGet16 (PcdPlatformBootTimeOut); + + // + // See if the user requested a boot menu. + // + QemuFwCfgSelectItem (QemuFwCfgItemBootMenu); + if (QemuFwCfgRead16 () != 0) { + FIRMWARE_CONFIG_ITEM BootMenuWaitItem; + UINTN BootMenuWaitSize; + UINT16 TimeoutMs; + + if (!RETURN_ERROR (QemuFwCfgFindFile ("etc/boot-menu-wait", + &BootMenuWaitItem, &BootMenuWaitSize)) && + BootMenuWaitSize == sizeof TimeoutMs) { + // + // The user specified the timeout for entering the boot menu. + // + QemuFwCfgSelectItem (BootMenuWaitItem); + QemuFwCfgReadBytes (sizeof TimeoutMs, &TimeoutMs); + } else { + // + // SeaBIOS default if the user didn't state a timeout. + // + TimeoutMs = 2500; + } + + // + // The Intel BDS Front Page progress bar only supports whole seconds. Round + // up the timeout from milliseconds. + // + Timeout = (UINT16)((TimeoutMs + 999) / 1000); + } + + return Timeout; +} -- 1.8.3.1 ------------------------------------------------------------------------------ Dive into the World of Parallel Programming! The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net _______________________________________________ edk2-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/edk2-devel
