#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
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
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
VOID\r
)\r
{\r
- ESRT_MANAGEMENT_PROTOCOL *EsrtManagement;\r
EFI_STATUS Status;\r
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
UINTN FirmwareVerLength;\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
+ // 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