summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c')
-rw-r--r--MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c47
1 files changed, 39 insertions, 8 deletions
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
index 05fcd92deb..f0226eafa5 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
@@ -45,6 +45,7 @@
#include <Protocol/GraphicsOutput.h>
#include <Protocol/EsrtManagement.h>
#include <Protocol/FirmwareManagement.h>
+#include <Protocol/FirmwareManagementProgress.h>
#include <Protocol/DevicePath.h>
EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable = NULL;
@@ -53,6 +54,8 @@ BOOLEAN mIsVirtualAddrConverted = FALSE;
BOOLEAN mDxeCapsuleLibEndOfDxe = FALSE;
EFI_EVENT mDxeCapsuleLibEndOfDxeEvent = NULL;
+EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL *mFmpProgress = NULL;
+
/**
Initialize capsule related variables.
**/
@@ -101,18 +104,17 @@ RecordFmpCapsuleStatusVariable (
Function indicate the current completion progress of the firmware
update. Platform may override with own specific progress function.
- @param[in] Completion A value between 1 and 100 indicating the current completion progress of the firmware update
+ @param[in] Completion A value between 1 and 100 indicating the current
+ completion progress of the firmware update
- @retval EFI_SUCESS Input capsule is a correct FMP capsule.
+ @retval EFI_SUCESS The capsule update progress was updated.
+ @retval EFI_INVALID_PARAMETER Completion is greater than 100%.
**/
EFI_STATUS
EFIAPI
-Update_Image_Progress (
+UpdateImageProgress (
IN UINTN Completion
- )
-{
- return EFI_SUCCESS;
-}
+ );
/**
Return if this CapsuleGuid is a FMP capsule GUID or not.
@@ -849,6 +851,19 @@ SetFmpImageData (
return Status;
}
+ //
+ // Lookup Firmware Management Progress Protocol before SetImage() is called
+ // This is an optional protocol that may not be present on Handle.
+ //
+ Status = gBS->HandleProtocol (
+ Handle,
+ &gEdkiiFirmwareManagementProgressProtocolGuid,
+ (VOID **)&mFmpProgress
+ );
+ if (EFI_ERROR (Status)) {
+ mFmpProgress = NULL;
+ }
+
if (ImageHeader->Version >= EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER_INIT_VERSION) {
Image = (UINT8 *)(ImageHeader + 1);
} else {
@@ -873,21 +888,37 @@ SetFmpImageData (
DEBUG((DEBUG_INFO, "(UpdateHardwareInstance - 0x%x)", ImageHeader->UpdateHardwareInstance));
}
DEBUG((DEBUG_INFO, "\n"));
+
+ //
+ // Before calling SetImage(), reset the progress bar to 0%
+ //
+ UpdateImageProgress (0);
+
Status = Fmp->SetImage(
Fmp,
ImageHeader->UpdateImageIndex, // ImageIndex
Image, // Image
ImageHeader->UpdateImageSize, // ImageSize
VendorCode, // VendorCode
- Update_Image_Progress, // Progress
+ UpdateImageProgress, // Progress
&AbortReason // AbortReason
);
+ //
+ // Set the progress bar to 100% after returning from SetImage()
+ //
+ UpdateImageProgress (100);
+
DEBUG((DEBUG_INFO, "Fmp->SetImage - %r\n", Status));
if (AbortReason != NULL) {
DEBUG ((DEBUG_ERROR, "%s\n", AbortReason));
FreePool(AbortReason);
}
+ //
+ // Clear mFmpProgress after SetImage() returns
+ //
+ mFmpProgress = NULL;
+
return Status;
}