/* Calculate the number of seconds we should be showing the FrontPage progress bar for. */
UINT16 EFIAPI GetFrontPageTimeoutFromQemu(VOID)
/* Calculate the number of seconds we should be showing the FrontPage progress bar for. */
UINT16 EFIAPI GetFrontPageTimeoutFromQemu(VOID)
{
  FIRMWARE_CONFIG_ITEM  BootMenuWaitItem;
  UINTN                 BootMenuWaitSize;
  UINT16                Timeout = PcdGet16 (PcdPlatformBootTimeOut);
  if (!QemuFwCfgIsAvailable ()) {
    return Timeout;
  }
  QemuFwCfgSelectItem (QemuFwCfgItemBootMenu);
  if (QemuFwCfgRead16 () == 0) {
    return PcdGet16 (PcdPlatformBootTimeOut);
  }
  if (RETURN_ERROR (
        QemuFwCfgFindFile (
          "etc/boot-menu-wait",
          &BootMenuWaitItem,
          &BootMenuWaitSize
          )
        ) ||
      (BootMenuWaitSize != sizeof (UINT16)))
  {
    if (Timeout == 0) {
      Timeout = 3;
    }
    return Timeout;
  }
  QemuFwCfgSelectItem (BootMenuWaitItem);
  return (UINT16)((QemuFwCfgRead16 () + 999) / 1000);
}