X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FLibrary%2FDxeCapsuleLibFmp%2FDxeCapsuleLib.c;fp=MdeModulePkg%2FLibrary%2FDxeCapsuleLibFmp%2FDxeCapsuleLib.c;h=f0226eafa57691be76e07cc1db6da36a5b716791;hp=05fcd92deb00a9aaf1002653fed7d52439313564;hb=574761065744238440d2baf426d2ccc5912db13a;hpb=f3100a1a2f575e1a0ce4744cb2722e780135b1cf 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 #include #include +#include #include 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; }