]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c
ArmVirtPkg/PlatformBootManagerLib: sync Timeout with PcdPlatformBootTimeOut
[mirror_edk2.git] / ArmVirtPkg / Library / PlatformBootManagerLib / PlatformBm.c
index 534357eff46bba9d5a04ab98d0c3b265c8c0ba89..69448ff65bde5bd98d970965d824c9f14a3c6161 100644 (file)
@@ -5,13 +5,7 @@
   Copyright (c) 2014, ARM Ltd. All rights reserved.<BR>\r
   Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
 \r
-  This program and the accompanying materials are licensed and made available\r
-  under the terms and conditions of the BSD License which accompanies this\r
-  distribution. The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
-  WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -20,6 +14,7 @@
 #include <Library/BootLogoLib.h>\r
 #include <Library/DevicePathLib.h>\r
 #include <Library/PcdLib.h>\r
+#include <Library/PlatformBmPrintScLib.h>\r
 #include <Library/QemuBootOrderLib.h>\r
 #include <Library/UefiBootManagerLib.h>\r
 #include <Protocol/DevicePath.h>\r
@@ -30,7 +25,9 @@
 #include <Protocol/PciRootBridgeIo.h>\r
 #include <Protocol/VirtioDevice.h>\r
 #include <Guid/EventGroup.h>\r
+#include <Guid/GlobalVariable.h>\r
 #include <Guid/RootBridgesConnectedEventGroup.h>\r
+#include <Guid/SerialPortLibVendor.h>\r
 \r
 #include "PlatformBm.h"\r
 \r
@@ -46,18 +43,13 @@ typedef struct {
 } PLATFORM_SERIAL_CONSOLE;\r
 #pragma pack ()\r
 \r
-#define SERIAL_DXE_FILE_GUID { \\r
-          0xD3987D4B, 0x971A, 0x435F, \\r
-          { 0x8C, 0xAF, 0x49, 0x67, 0xEB, 0x62, 0x72, 0x41 } \\r
-          }\r
-\r
 STATIC PLATFORM_SERIAL_CONSOLE mSerialConsole = {\r
   //\r
   // VENDOR_DEVICE_PATH SerialDxe\r
   //\r
   {\r
     { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DP_NODE_LEN (VENDOR_DEVICE_PATH) },\r
-    SERIAL_DXE_FILE_GUID\r
+    EDKII_SERIAL_PORT_LIB_VENDOR_GUID\r
   },\r
 \r
   //\r
@@ -695,7 +687,9 @@ PlatformBootManagerBeforeConsole (
   VOID\r
   )\r
 {\r
+  UINT16        FrontPageTimeout;\r
   RETURN_STATUS PcdStatus;\r
+  EFI_STATUS    Status;\r
 \r
   //\r
   // Signal EndOfDxe PI Event\r
@@ -753,9 +747,29 @@ PlatformBootManagerBeforeConsole (
   //\r
   // Set the front page timeout from the QEMU configuration.\r
   //\r
-  PcdStatus = PcdSet16S (PcdPlatformBootTimeOut,\r
-                GetFrontPageTimeoutFromQemu ());\r
+  FrontPageTimeout = GetFrontPageTimeoutFromQemu ();\r
+  PcdStatus = PcdSet16S (PcdPlatformBootTimeOut, FrontPageTimeout);\r
   ASSERT_RETURN_ERROR (PcdStatus);\r
+  //\r
+  // Reflect the PCD in the standard Timeout variable.\r
+  //\r
+  Status = gRT->SetVariable (\r
+                  EFI_TIME_OUT_VARIABLE_NAME,\r
+                  &gEfiGlobalVariableGuid,\r
+                  (EFI_VARIABLE_NON_VOLATILE |\r
+                   EFI_VARIABLE_BOOTSERVICE_ACCESS |\r
+                   EFI_VARIABLE_RUNTIME_ACCESS),\r
+                  sizeof FrontPageTimeout,\r
+                  &FrontPageTimeout\r
+                  );\r
+  DEBUG ((\r
+    EFI_ERROR (Status) ? DEBUG_ERROR : DEBUG_VERBOSE,\r
+    "%a: SetVariable(%s, %u): %r\n",\r
+    __FUNCTION__,\r
+    EFI_TIME_OUT_VARIABLE_NAME,\r
+    FrontPageTimeout,\r
+    Status\r
+    ));\r
 \r
   //\r
   // Register platform-specific boot options and keyboard shortcuts.\r
@@ -833,6 +847,8 @@ PlatformBootManagerAfterConsole (
 \r
   RemoveStaleFvFileOptions ();\r
   SetBootOrderFromQemu ();\r
+\r
+  PlatformBmPrintScRegisterHandler ();\r
 }\r
 \r
 /**\r
@@ -849,9 +865,17 @@ PlatformBootManagerWaitCallback (
 {\r
   EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black;\r
   EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White;\r
-  UINT16                              Timeout;\r
+  UINT16                              TimeoutInitial;\r
 \r
-  Timeout = PcdGet16 (PcdPlatformBootTimeOut);\r
+  TimeoutInitial = PcdGet16 (PcdPlatformBootTimeOut);\r
+\r
+  //\r
+  // If PcdPlatformBootTimeOut is set to zero, then we consider\r
+  // that no progress update should be enacted.\r
+  //\r
+  if (TimeoutInitial == 0) {\r
+    return;\r
+  }\r
 \r
   Black.Raw = 0x00000000;\r
   White.Raw = 0x00FFFFFF;\r
@@ -861,7 +885,7 @@ PlatformBootManagerWaitCallback (
     Black.Pixel,\r
     L"Start boot option",\r
     White.Pixel,\r
-    (Timeout - TimeoutRemain) * 100 / Timeout,\r
+    (TimeoutInitial - TimeoutRemain) * 100 / TimeoutInitial,\r
     0\r
     );\r
 }\r