ProcessCapsules(), ProcessTheseCapsules() will receive untrusted\r
input and do basic validation.\r
\r
- Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
\r
#include <PiDxe.h>\r
#include <Protocol/EsrtManagement.h>\r
+#include <Protocol/FirmwareManagementProgress.h>\r
\r
#include <Library/BaseLib.h>\r
#include <Library/DebugLib.h>\r
#include <Library/HobLib.h>\r
#include <Library/ReportStatusCodeLib.h>\r
#include <Library/CapsuleLib.h>\r
+#include <Library/DisplayUpdateProgressLib.h>\r
\r
#include <IndustryStandard/WindowsUxCapsule.h>\r
\r
+extern EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL *mFmpProgress;\r
+\r
/**\r
Return if this FMP is a system FMP or a device FMP, based upon CapsuleHeader.\r
\r
EFI_STATUS *mCapsuleStatusArray;\r
UINT32 mCapsuleTotalNumber;\r
\r
+/**\r
+ Function indicate the current completion progress of the firmware\r
+ update. Platform may override with own specific progress function.\r
+\r
+ @param[in] Completion A value between 1 and 100 indicating the current\r
+ completion progress of the firmware update\r
+\r
+ @retval EFI_SUCESS The capsule update progress was updated.\r
+ @retval EFI_INVALID_PARAMETER Completion is greater than 100%.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UpdateImageProgress (\r
+ IN UINTN Completion\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN Seconds;\r
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *Color;\r
+\r
+ DEBUG((DEBUG_INFO, "Update Progress - %d%%\n", Completion));\r
+\r
+ if (Completion > 100) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ //\r
+ // Use a default timeout of 5 minutes if there is not FMP Progress Protocol.\r
+ //\r
+ Seconds = 5 * 60;\r
+ Color = NULL;\r
+ if (mFmpProgress != NULL) {\r
+ Seconds = mFmpProgress->WatchdogSeconds;\r
+ Color = &mFmpProgress->ProgressBarForegroundColor;\r
+ }\r
+\r
+ //\r
+ // Cancel the watchdog timer\r
+ //\r
+ gBS->SetWatchdogTimer (0, 0x0000, 0, NULL);\r
+\r
+ if (Completion != 100) {\r
+ //\r
+ // Arm the watchdog timer from PCD setting\r
+ //\r
+ if (Seconds != 0) {\r
+ DEBUG ((DEBUG_VERBOSE, "Arm watchdog timer %d seconds\n", Seconds));\r
+ gBS->SetWatchdogTimer (Seconds, 0x0000, 0, NULL);\r
+ }\r
+ }\r
+\r
+ Status = DisplayUpdateProgress (Completion, Color);\r
+\r
+ return Status;\r
+}\r
+\r
/**\r
This function initializes the mCapsulePtr, mCapsuleStatusArray and mCapsuleTotalNumber.\r
**/\r
EFI_STATUS Status;\r
EFI_CAPSULE_HEADER *CapsuleHeader;\r
UINT32 Index;\r
- BOOLEAN DisplayCapsuleExist;\r
ESRT_MANAGEMENT_PROTOCOL *EsrtManagement;\r
UINT16 EmbeddedDriverCount;\r
\r
//\r
// If Windows UX capsule exist, process it first\r
//\r
- DisplayCapsuleExist = FALSE;\r
for (Index = 0; Index < mCapsuleTotalNumber; Index++) {\r
CapsuleHeader = (EFI_CAPSULE_HEADER*) mCapsulePtr [Index];\r
if (CompareGuid (&CapsuleHeader->CapsuleGuid, &gWindowsUxCapsuleGuid)) {\r
DEBUG ((DEBUG_INFO, "ProcessCapsuleImage (Ux) - 0x%x\n", CapsuleHeader));\r
- DisplayCapsuleExist = TRUE;\r
DEBUG ((DEBUG_INFO, "Display logo capsule is found.\n"));\r
Status = ProcessCapsuleImage (CapsuleHeader);\r
mCapsuleStatusArray [Index] = EFI_SUCCESS;\r
}\r
}\r
\r
- if (!DisplayCapsuleExist) {\r
- //\r
- // Display Capsule not found. Display the default string.\r
- //\r
- Print (L"Updating the firmware ......\r\n");\r
- }\r
+ DEBUG ((DEBUG_INFO, "Updating the firmware ......\n"));\r
\r
//\r
// All capsules left are recognized by platform.\r
if (EFI_ERROR(Status)) {\r
REPORT_STATUS_CODE(EFI_ERROR_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeUpdateFirmwareFailed)));\r
DEBUG ((DEBUG_ERROR, "Capsule process failed!\n"));\r
- Print (L"Firmware update failed...\r\n");\r
} else {\r
REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeUpdateFirmwareSuccess)));\r
}\r
VOID\r
)\r
{\r
- UINTN Index;\r
-\r
- REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeResettingSystem)));\r
-\r
- Print(L"Capsule Request Cold Reboot.\n");\r
DEBUG((DEBUG_INFO, "Capsule Request Cold Reboot."));\r
\r
- for (Index = 5; Index > 0; Index--) {\r
- Print(L"\rResetting system in %d seconds ...", Index);\r
- DEBUG((DEBUG_INFO, "\rResetting system in %d seconds ...", Index));\r
- gBS->Stall(1000000);\r
- }\r
+ REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeResettingSystem)));\r
\r
gRT->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL);\r
\r