MdeModulePkg/DxeCapsuleLibFmp: Add progress bar support

https://bugzilla.tianocore.org/show_bug.cgi?id=801

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport

* Change Update_Image_Progress() to UpdateImageProcess()
* Call DisplayUpdateProgressLib from UpdateImageProgress().
* Split out a boot service and runtime version of
  UpdateImageProgress() so the DisplayUpdateProgressLib is
  not used at runtime.
* If gEdkiiFirmwareManagementProgressProtocolGuid is present,
  then use its progress bar color and watchdog timer value.
* If gEdkiiFirmwareManagementProgressProtocolGuid is not present,
  then use default progress bar color and 5 min watchdog timer.
* Remove Print() calls during capsule processing.  Instead,
  the DisplayUpdateProgressLib is used to inform the user
  of progress during a capsule update.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Star Zeng <star.zeng@intel.com>
This commit is contained in:
Kinney, Michael D
2018-02-15 14:02:06 -08:00
parent f3100a1a2f
commit 5747610657
5 changed files with 131 additions and 36 deletions

View File

@@ -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;
}