]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c
ArmPkg/PlatformBootManagerLib: print firmware version to console
[mirror_edk2.git] / ArmPkg / Library / PlatformBootManagerLib / PlatformBm.c
index 67e87c1c26421ed3e8d9dc5f6d995dffca039337..ccdb3e0a5d78a51b3aef96d67fbf429e9e82b1bd 100644 (file)
 **/\r
 \r
 #include <IndustryStandard/Pci22.h>\r
+#include <Library/BootLogoLib.h>\r
+#include <Library/CapsuleLib.h>\r
 #include <Library/DevicePathLib.h>\r
+#include <Library/HobLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/UefiBootManagerLib.h>\r
 #include <Library/UefiLib.h>\r
 #include <Protocol/DevicePath.h>\r
+#include <Protocol/EsrtManagement.h>\r
 #include <Protocol/GraphicsOutput.h>\r
 #include <Protocol/LoadedImage.h>\r
 #include <Protocol/PciIo.h>\r
@@ -33,7 +37,6 @@
 \r
 #define DP_NODE_LEN(Type) { (UINT8)sizeof (Type), (UINT8)(sizeof (Type) >> 8) }\r
 \r
-\r
 #pragma pack (1)\r
 typedef struct {\r
   VENDOR_DEVICE_PATH         SerialDxe;\r
@@ -327,7 +330,7 @@ AddOutput (
 STATIC\r
 VOID\r
 PlatformRegisterFvBootOption (\r
-  EFI_GUID                         *FileGuid,\r
+  CONST EFI_GUID                   *FileGuid,\r
   CHAR16                           *Description,\r
   UINT32                           Attributes\r
   )\r
@@ -447,6 +450,21 @@ PlatformBootManagerBeforeConsole (
   VOID\r
   )\r
 {\r
+  EFI_STATUS                    Status;\r
+  ESRT_MANAGEMENT_PROTOCOL      *EsrtManagement;\r
+\r
+  if (GetBootModeHob() == BOOT_ON_FLASH_UPDATE) {\r
+    DEBUG ((DEBUG_INFO, "ProcessCapsules Before EndOfDxe ......\n"));\r
+    Status = ProcessCapsules ();\r
+    DEBUG ((DEBUG_INFO, "ProcessCapsules returned %r\n", Status));\r
+  } else {\r
+    Status = gBS->LocateProtocol (&gEsrtManagementProtocolGuid, NULL,\r
+                    (VOID **)&EsrtManagement);\r
+    if (!EFI_ERROR (Status)) {\r
+      EsrtManagement->SyncEsrtFmp ();\r
+    }\r
+  }\r
+\r
   //\r
   // Signal EndOfDxe PI Event\r
   //\r
@@ -497,6 +515,8 @@ PlatformBootManagerBeforeConsole (
   PlatformRegisterOptionsAndKeys ();\r
 }\r
 \r
+#define VERSION_STRING_PREFIX    L"Tianocore/EDK2 firmware version "\r
+\r
 /**\r
   Do the platform specific action after the console is ready\r
   Possible things that can be done in PlatformBootManagerAfterConsole:\r
@@ -514,18 +534,56 @@ PlatformBootManagerAfterConsole (
   VOID\r
   )\r
 {\r
-  Print (L"Press ESCAPE for boot options ");\r
+  ESRT_MANAGEMENT_PROTOCOL      *EsrtManagement;\r
+  EFI_STATUS                    Status;\r
+  EFI_GRAPHICS_OUTPUT_PROTOCOL  *GraphicsOutput;\r
+  UINTN                         FirmwareVerLength;\r
+  UINTN                         PosX;\r
+  UINTN                         PosY;\r
+\r
+  FirmwareVerLength = StrLen (PcdGetPtr (PcdFirmwareVersionString));\r
 \r
   //\r
   // Show the splash screen.\r
   //\r
-  EnableQuietBoot (PcdGetPtr (PcdLogoFile));\r
+  Status = BootLogoEnableLogo ();\r
+  if (EFI_ERROR (Status)) {\r
+    if (FirmwareVerLength > 0) {\r
+      Print (VERSION_STRING_PREFIX L"%s",\r
+        PcdGetPtr (PcdFirmwareVersionString));\r
+    }\r
+    Print (L"Press ESCAPE for boot options ");\r
+  } else if (FirmwareVerLength > 0) {\r
+    Status = gBS->HandleProtocol (gST->ConsoleOutHandle,\r
+                    &gEfiGraphicsOutputProtocolGuid, (VOID **)&GraphicsOutput);\r
+    if (!EFI_ERROR (Status)) {\r
+      PosX = (GraphicsOutput->Mode->Info->HorizontalResolution -\r
+              (StrLen (VERSION_STRING_PREFIX) + FirmwareVerLength) *\r
+              EFI_GLYPH_WIDTH) / 2;\r
+      PosY = 0;\r
+\r
+      PrintXY (PosX, PosY, NULL, NULL, VERSION_STRING_PREFIX L"%s",\r
+        PcdGetPtr (PcdFirmwareVersionString));\r
+    }\r
+  }\r
 \r
   //\r
   // Connect the rest of the devices.\r
   //\r
   EfiBootManagerConnectAll ();\r
 \r
+  Status = gBS->LocateProtocol (&gEsrtManagementProtocolGuid, NULL,\r
+                  (VOID **)&EsrtManagement);\r
+  if (!EFI_ERROR (Status)) {\r
+    EsrtManagement->SyncEsrtFmp ();\r
+  }\r
+\r
+  if (GetBootModeHob() == BOOT_ON_FLASH_UPDATE) {\r
+    DEBUG((DEBUG_INFO, "ProcessCapsules After EndOfDxe ......\n"));\r
+    Status = ProcessCapsules ();\r
+    DEBUG((DEBUG_INFO, "ProcessCapsules returned %r\n", Status));\r
+  }\r
+\r
   //\r
   // Enumerate all possible boot options.\r
   //\r
@@ -535,7 +593,7 @@ PlatformBootManagerAfterConsole (
   // Register UEFI Shell\r
   //\r
   PlatformRegisterFvBootOption (\r
-    PcdGetPtr (PcdShellFile), L"UEFI Shell", LOAD_OPTION_ACTIVE\r
+    &gUefiShellFileGuid, L"UEFI Shell", LOAD_OPTION_ACTIVE\r
     );\r
 }\r
 \r
@@ -551,5 +609,25 @@ PlatformBootManagerWaitCallback (
   UINT16          TimeoutRemain\r
   )\r
 {\r
-  Print (L".");\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White;\r
+  UINT16                              Timeout;\r
+  EFI_STATUS                          Status;\r
+\r
+  Timeout = PcdGet16 (PcdPlatformBootTimeOut);\r
+\r
+  Black.Raw = 0x00000000;\r
+  White.Raw = 0x00FFFFFF;\r
+\r
+  Status = BootLogoUpdateProgress (\r
+             White.Pixel,\r
+             Black.Pixel,\r
+             L"Press ESCAPE for boot options",\r
+             White.Pixel,\r
+             (Timeout - TimeoutRemain) * 100 / Timeout,\r
+             0\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+    Print (L".");\r
+  }\r
 }\r