]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/PlatformBootManagerLib: call ProcessCapsules() only once
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Wed, 6 Jun 2018 14:52:59 +0000 (16:52 +0200)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Fri, 15 Jun 2018 16:18:35 +0000 (18:18 +0200)
ARM platforms have no restriction on when a system firmware update
capsule can be applied, and so it is not necessary to call
ProcessCapsules() twice. So let's drop the first invocation that
occurs before EndOfDxe, and rewrite the second call so that all
capsule updates will be applied when the console is up and able to
provide progress feedback.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c
ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf

index 3456a71fbb9cd12912a443abc1907d2015cb0944..079f1552d5eac7d077f0bbd14b22a8e01c5acadd 100644 (file)
@@ -24,6 +24,7 @@
 #include <Library/PcdLib.h>\r
 #include <Library/UefiBootManagerLib.h>\r
 #include <Library/UefiLib.h>\r
+#include <Library/UefiRuntimeServicesTableLib.h>\r
 #include <Protocol/DevicePath.h>\r
 #include <Protocol/EsrtManagement.h>\r
 #include <Protocol/GraphicsOutput.h>\r
@@ -553,21 +554,6 @@ 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
@@ -618,6 +604,56 @@ PlatformBootManagerBeforeConsole (
   PlatformRegisterOptionsAndKeys ();\r
 }\r
 \r
+STATIC\r
+VOID\r
+HandleCapsules (\r
+  VOID\r
+  )\r
+{\r
+  ESRT_MANAGEMENT_PROTOCOL    *EsrtManagement;\r
+  EFI_PEI_HOB_POINTERS        HobPointer;\r
+  EFI_CAPSULE_HEADER          *CapsuleHeader;\r
+  BOOLEAN                     NeedReset;\r
+  EFI_STATUS                  Status;\r
+\r
+  DEBUG ((DEBUG_INFO, "%a: processing capsules ...\n", __FUNCTION__));\r
+\r
+  Status = gBS->LocateProtocol (&gEsrtManagementProtocolGuid, NULL,\r
+                  (VOID **)&EsrtManagement);\r
+  if (!EFI_ERROR (Status)) {\r
+    EsrtManagement->SyncEsrtFmp ();\r
+  }\r
+\r
+  //\r
+  // Find all capsule images from hob\r
+  //\r
+  HobPointer.Raw = GetHobList ();\r
+  NeedReset = FALSE;\r
+  while ((HobPointer.Raw = GetNextHob (EFI_HOB_TYPE_UEFI_CAPSULE,\r
+                             HobPointer.Raw)) != NULL) {\r
+    CapsuleHeader = (VOID *)(UINTN)HobPointer.Capsule->BaseAddress;\r
+\r
+    Status = ProcessCapsuleImage (CapsuleHeader);\r
+    if (EFI_ERROR (Status)) {\r
+      DEBUG ((DEBUG_ERROR, "%a: failed to process capsule %p - %r\n",\r
+        __FUNCTION__, CapsuleHeader, Status));\r
+      return;\r
+    }\r
+\r
+    NeedReset = TRUE;\r
+    HobPointer.Raw = GET_NEXT_HOB (HobPointer);\r
+  }\r
+\r
+  if (NeedReset) {\r
+      DEBUG ((DEBUG_WARN, "%a: capsule update successful, resetting ...\n",\r
+        __FUNCTION__));\r
+\r
+      gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);\r
+      CpuDeadLoop();\r
+  }\r
+}\r
+\r
+\r
 #define VERSION_STRING_PREFIX    L"Tianocore/EDK2 firmware version "\r
 \r
 /**\r
@@ -637,7 +673,6 @@ PlatformBootManagerAfterConsole (
   VOID\r
   )\r
 {\r
-  ESRT_MANAGEMENT_PROTOCOL      *EsrtManagement;\r
   EFI_STATUS                    Status;\r
   EFI_GRAPHICS_OUTPUT_PROTOCOL  *GraphicsOutput;\r
   UINTN                         FirmwareVerLength;\r
@@ -675,17 +710,14 @@ PlatformBootManagerAfterConsole (
   //\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
+  // On ARM, there is currently no reason to use the phased capsule\r
+  // update approach where some capsules are dispatched before EndOfDxe\r
+  // and some are dispatched after. So just handle all capsules here,\r
+  // when the console is up and we can actually give the user some\r
+  // feedback about what is going on.\r
+  //\r
+  HandleCapsules ();\r
 \r
   //\r
   // Enumerate all possible boot options.\r
index e8cbb10dabdd257605e84e8e926416b557517c92..28d606d5c32943fbbb4dfc889f5eba488026cb4a 100644 (file)
@@ -55,6 +55,7 @@
   UefiBootManagerLib\r
   UefiBootServicesTableLib\r
   UefiLib\r
+  UefiRuntimeServicesTableLib\r
 \r
 [FeaturePcd]\r
   gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport\r