* [Patch v3 0/2] Use DisplayUpdateProgressLib and PerformFlashWriteWithProgress()
@ 2018-05-29 16:17 Michael D Kinney
2018-05-29 16:17 ` [Patch v3 1/2] MdeModulePkg/DxeCapsuleLibFmp: Add progress bar support Michael D Kinney
2018-05-29 16:17 ` [Patch v3 2/2] SignedCapsulePkg/SystemFirmwareUpdateDxe: Use progress API Michael D Kinney
0 siblings, 2 replies; 7+ messages in thread
From: Michael D Kinney @ 2018-05-29 16:17 UTC (permalink / raw)
To: edk2-devel; +Cc: Star Zeng, Eric Dong, Jiewen Yao, Sean Brogan
https://bugzilla.tianocore.org/show_bug.cgi?id=801
Based on content from:
https://github.com/Microsoft/MS_UEFI/blob/share/MsCapsuleSupport/MsCapsuleUpdatePkg/Include/Library/DisplayUpdateProgressLib.h
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport/MsCapsuleUpdatePkg/Library/DisplayUpdateProgressGraphicsLib
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport/MsCapsuleUpdatePkg/Library/DisplayUpdateProgressTextLib
Updates for V3
==============
* Add Version field to EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL
* Break up patch series into 4 smaller patch series to handle dependencies
between the edk2 repository and the edk2-platforms repository.
+ Patch series for edk2 repo that adds DisplayUpdateProgressLib class and
instances. Defines the EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL.
Adds PerformFlashWriteWithProgress() API to the PlatformFlashAccessLib.
+ Patch series for platforms in edk2-platforms that use capsules to add the
DisplayUpdateProgressLib mapping to the DSC files and add the
PerformFlashWriteWithProgress() API implementation to the
PlatformFlashAccessLib implementations.
+ Patch series for platforms in edk2 that use capsules to add the
DisplayUpdateProgressLib mapping to the DSC files and add the
PerformFlashWriteWithProgress() API implementation to the
PlatformFlashAccessLib implementations.
+ Patch for edk2 that adds the use of the DisplayUpateProgressLib and the
PerformFlashWriteWithProgress() API .
Updates for V2
==============
* Change DisplayUpdateProgressGraphicsLib to DisplayUpdateProgressLibGraphics
* Change DisplayUpdateProgressTextLib to DisplayUpdateProgressLibText
* Clarify that color in Firmware Management Progress Protocol is the foreground color
* Add missing parameters to PerformFlashWriteWithProgress() function header.
* Update PerformFlashWriteWithProgress() function header describing the use of
the start and end percentage values.
* Update QuarkPlatformPkg PerformFlashWriteWithProgress() to call Progress() for
the end precentage.
* Update Vlv2Tbl2DevicePkg PerformFlashWriteWithProgress() to call Progress()
for the end precentage.
Add DisplayUpdateProgressLib class along implementations for both graphical
(Graphics Output Protocol based) and text (Simple Text Output Protocol based)
consoles. Also add the EDK II Firmware Management Progress Protocol that is an
optional protocol that provides the progress bar color and a watchdog timeout
value thaty can be used when a firmware image is updated in a firmware device.
* Add progress support to DxeCapsuleLibFmp
* Add progress support to SystemFirmwareUpdateDxe
* Add progress support to PlatformFlashAccessLib class and instances.
* Reduce Print() calls during a firmware 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
Kinney, Michael D (2):
MdeModulePkg/DxeCapsuleLibFmp: Add progress bar support
SignedCapsulePkg/SystemFirmwareUpdateDxe: Use progress API
.../Library/DxeCapsuleLibFmp/DxeCapsuleLib.c | 47 +++++++++--
.../Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf | 8 +-
.../DxeCapsuleLibFmp/DxeCapsuleProcessLib.c | 84 +++++++++++++++-----
.../DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c | 21 ++++-
.../DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf | 7 +-
.../SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c | 90 ++++++++++++++++------
6 files changed, 198 insertions(+), 59 deletions(-)
--
2.14.2.windows.3
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Patch v3 1/2] MdeModulePkg/DxeCapsuleLibFmp: Add progress bar support
2018-05-29 16:17 [Patch v3 0/2] Use DisplayUpdateProgressLib and PerformFlashWriteWithProgress() Michael D Kinney
@ 2018-05-29 16:17 ` Michael D Kinney
2018-05-31 9:43 ` Zeng, Star
` (2 more replies)
2018-05-29 16:17 ` [Patch v3 2/2] SignedCapsulePkg/SystemFirmwareUpdateDxe: Use progress API Michael D Kinney
1 sibling, 3 replies; 7+ messages in thread
From: Michael D Kinney @ 2018-05-29 16:17 UTC (permalink / raw)
To: edk2-devel
Cc: Kinney, Michael D, Star Zeng, Eric Dong, Jiewen Yao, Sean Brogan
From: "Kinney, Michael D" <michael.d.kinney@intel.com>
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
---
.../Library/DxeCapsuleLibFmp/DxeCapsuleLib.c | 47 +++++++++---
.../Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf | 8 ++-
.../DxeCapsuleLibFmp/DxeCapsuleProcessLib.c | 84 ++++++++++++++++------
.../DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c | 21 +++++-
.../DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf | 7 +-
5 files changed, 131 insertions(+), 36 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;
}
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
index 1d947101d3..8367264f76 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
@@ -52,6 +52,7 @@ [LibraryClasses]
PrintLib
HobLib
BmpSupportLib
+ DisplayUpdateProgressLib
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleMax ## CONSUMES
@@ -66,9 +67,10 @@ [Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleStatusCodeResettingSystem ## CONSUMES
[Protocols]
- gEsrtManagementProtocolGuid ## CONSUMES
- gEfiFirmwareManagementProtocolGuid ## CONSUMES
- gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES
+ gEsrtManagementProtocolGuid ## CONSUMES
+ gEfiFirmwareManagementProtocolGuid ## CONSUMES
+ gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES
+ gEdkiiFirmwareManagementProgressProtocolGuid ## SOMETIMES_CONSUMES
[Guids]
gEfiFmpCapsuleGuid ## SOMETIMES_CONSUMES ## GUID
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c
index ba3ff90b9f..26ca4e295f 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c
@@ -9,7 +9,7 @@
ProcessCapsules(), ProcessTheseCapsules() will receive untrusted
input and do basic validation.
- Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -22,6 +22,7 @@
#include <PiDxe.h>
#include <Protocol/EsrtManagement.h>
+#include <Protocol/FirmwareManagementProgress.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
@@ -34,9 +35,12 @@
#include <Library/HobLib.h>
#include <Library/ReportStatusCodeLib.h>
#include <Library/CapsuleLib.h>
+#include <Library/DisplayUpdateProgressLib.h>
#include <IndustryStandard/WindowsUxCapsule.h>
+extern EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL *mFmpProgress;
+
/**
Return if this FMP is a system FMP or a device FMP, based upon CapsuleHeader.
@@ -101,6 +105,62 @@ VOID **mCapsulePtr;
EFI_STATUS *mCapsuleStatusArray;
UINT32 mCapsuleTotalNumber;
+/**
+ 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
+
+ @retval EFI_SUCESS The capsule update progress was updated.
+ @retval EFI_INVALID_PARAMETER Completion is greater than 100%.
+**/
+EFI_STATUS
+EFIAPI
+UpdateImageProgress (
+ IN UINTN Completion
+ )
+{
+ EFI_STATUS Status;
+ UINTN Seconds;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *Color;
+
+ DEBUG((DEBUG_INFO, "Update Progress - %d%%\n", Completion));
+
+ if (Completion > 100) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Use a default timeout of 5 minutes if there is not FMP Progress Protocol.
+ //
+ Seconds = 5 * 60;
+ Color = NULL;
+ if (mFmpProgress != NULL) {
+ Seconds = mFmpProgress->WatchdogSeconds;
+ Color = &mFmpProgress->ProgressBarForegroundColor;
+ }
+
+ //
+ // Cancel the watchdog timer
+ //
+ gBS->SetWatchdogTimer (0, 0x0000, 0, NULL);
+
+ if (Completion != 100) {
+ //
+ // Arm the watchdog timer from PCD setting
+ //
+ if (Seconds != 0) {
+ DEBUG ((DEBUG_VERBOSE, "Arm watchdog timer %d seconds\n", Seconds));
+ gBS->SetWatchdogTimer (Seconds, 0x0000, 0, NULL);
+ }
+ }
+
+ Status = DisplayUpdateProgress (Completion, Color);
+
+ return Status;
+}
+
/**
This function initializes the mCapsulePtr, mCapsuleStatusArray and mCapsuleTotalNumber.
**/
@@ -319,7 +379,6 @@ ProcessTheseCapsules (
EFI_STATUS Status;
EFI_CAPSULE_HEADER *CapsuleHeader;
UINT32 Index;
- BOOLEAN DisplayCapsuleExist;
ESRT_MANAGEMENT_PROTOCOL *EsrtManagement;
UINT16 EmbeddedDriverCount;
@@ -354,12 +413,10 @@ ProcessTheseCapsules (
//
// If Windows UX capsule exist, process it first
//
- DisplayCapsuleExist = FALSE;
for (Index = 0; Index < mCapsuleTotalNumber; Index++) {
CapsuleHeader = (EFI_CAPSULE_HEADER*) mCapsulePtr [Index];
if (CompareGuid (&CapsuleHeader->CapsuleGuid, &gWindowsUxCapsuleGuid)) {
DEBUG ((DEBUG_INFO, "ProcessCapsuleImage (Ux) - 0x%x\n", CapsuleHeader));
- DisplayCapsuleExist = TRUE;
DEBUG ((DEBUG_INFO, "Display logo capsule is found.\n"));
Status = ProcessCapsuleImage (CapsuleHeader);
mCapsuleStatusArray [Index] = EFI_SUCCESS;
@@ -368,12 +425,7 @@ ProcessTheseCapsules (
}
}
- if (!DisplayCapsuleExist) {
- //
- // Display Capsule not found. Display the default string.
- //
- Print (L"Updating the firmware ......\r\n");
- }
+ DEBUG ((DEBUG_INFO, "Updating the firmware ......\n"));
//
// All capsules left are recognized by platform.
@@ -411,7 +463,6 @@ ProcessTheseCapsules (
if (EFI_ERROR(Status)) {
REPORT_STATUS_CODE(EFI_ERROR_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeUpdateFirmwareFailed)));
DEBUG ((DEBUG_ERROR, "Capsule process failed!\n"));
- Print (L"Firmware update failed...\r\n");
} else {
REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeUpdateFirmwareSuccess)));
}
@@ -447,18 +498,9 @@ DoResetSystem (
VOID
)
{
- UINTN Index;
-
- REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeResettingSystem)));
-
- Print(L"Capsule Request Cold Reboot.\n");
DEBUG((DEBUG_INFO, "Capsule Request Cold Reboot."));
- for (Index = 5; Index > 0; Index--) {
- Print(L"\rResetting system in %d seconds ...", Index);
- DEBUG((DEBUG_INFO, "\rResetting system in %d seconds ...", Index));
- gBS->Stall(1000000);
- }
+ REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeResettingSystem)));
gRT->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL);
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c
index 07e9e46eae..274c1c4c1c 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c
@@ -3,7 +3,7 @@
Dummy function for runtime module, because CapsuleDxeRuntime
does not need call ProcessCapsules().
- Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -17,6 +17,25 @@
#include <PiDxe.h>
#include <Library/CapsuleLib.h>
+/**
+ 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
+
+ @retval EFI_SUCESS The capsule update progress was updated.
+ @retval EFI_INVALID_PARAMETER Completion is greater than 100%.
+**/
+EFI_STATUS
+EFIAPI
+UpdateImageProgress (
+ IN UINTN Completion
+ )
+{
+ return EFI_SUCCESS;
+}
+
/**
This routine is called to process capsules.
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
index 1659b13ef4..342df9e99c 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
@@ -69,9 +69,10 @@ [Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleStatusCodeResettingSystem ## CONSUMES
[Protocols]
- gEsrtManagementProtocolGuid ## CONSUMES
- gEfiFirmwareManagementProtocolGuid ## CONSUMES
- gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES
+ gEsrtManagementProtocolGuid ## CONSUMES
+ gEfiFirmwareManagementProtocolGuid ## CONSUMES
+ gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES
+ gEdkiiFirmwareManagementProgressProtocolGuid ## SOMETIMES_CONSUMES
[Guids]
gEfiFmpCapsuleGuid ## SOMETIMES_CONSUMES ## GUID
--
2.14.2.windows.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Patch v3 2/2] SignedCapsulePkg/SystemFirmwareUpdateDxe: Use progress API
2018-05-29 16:17 [Patch v3 0/2] Use DisplayUpdateProgressLib and PerformFlashWriteWithProgress() Michael D Kinney
2018-05-29 16:17 ` [Patch v3 1/2] MdeModulePkg/DxeCapsuleLibFmp: Add progress bar support Michael D Kinney
@ 2018-05-29 16:17 ` Michael D Kinney
2018-06-06 17:35 ` Ard Biesheuvel
1 sibling, 1 reply; 7+ messages in thread
From: Michael D Kinney @ 2018-05-29 16:17 UTC (permalink / raw)
To: edk2-devel; +Cc: Kinney, Michael D, Jiewen Yao
From: "Kinney, Michael D" <michael.d.kinney@intel.com>
https://bugzilla.tianocore.org/show_bug.cgi?id=801
Use PlatformFlashWriteWithProgress() instead of PlatformFLashWrite()
so the user can be informed of the progress as a capsule is used
to update a firmware image in a firmware device.
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
---
.../SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c | 90 ++++++++++++++++------
1 file changed, 67 insertions(+), 23 deletions(-)
diff --git a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c
index ce6892d6a9..8e66aedf62 100644
--- a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c
+++ b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c
@@ -65,11 +65,14 @@ ParseUpdateDataFile (
**/
EFI_STATUS
PerformUpdate (
- IN VOID *SystemFirmwareImage,
- IN UINTN SystemFirmwareImageSize,
- IN UPDATE_CONFIG_DATA *ConfigData,
- OUT UINT32 *LastAttemptVersion,
- OUT UINT32 *LastAttemptStatus
+ IN VOID *SystemFirmwareImage,
+ IN UINTN SystemFirmwareImageSize,
+ IN UPDATE_CONFIG_DATA *ConfigData,
+ OUT UINT32 *LastAttemptVersion,
+ OUT UINT32 *LastAttemptStatus,
+ IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress,
+ IN UINTN StartPercentage,
+ IN UINTN EndPercentage
)
{
EFI_STATUS Status;
@@ -78,13 +81,22 @@ PerformUpdate (
DEBUG((DEBUG_INFO, " BaseAddress - 0x%lx,", ConfigData->BaseAddress));
DEBUG((DEBUG_INFO, " ImageOffset - 0x%x,", ConfigData->ImageOffset));
DEBUG((DEBUG_INFO, " Legnth - 0x%x\n", ConfigData->Length));
- Status = PerformFlashWrite (
+ if (Progress != NULL) {
+ Progress (StartPercentage);
+ }
+ Status = PerformFlashWriteWithProgress (
ConfigData->FirmwareType,
ConfigData->BaseAddress,
ConfigData->AddressType,
(VOID *)((UINTN)SystemFirmwareImage + (UINTN)ConfigData->ImageOffset),
- ConfigData->Length
+ ConfigData->Length,
+ Progress,
+ StartPercentage,
+ EndPercentage
);
+ if (Progress != NULL) {
+ Progress (EndPercentage);
+ }
if (!EFI_ERROR(Status)) {
*LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
if (ConfigData->FirmwareType == PlatformFirmwareTypeNvRam) {
@@ -111,12 +123,13 @@ PerformUpdate (
**/
EFI_STATUS
UpdateImage (
- IN VOID *SystemFirmwareImage,
- IN UINTN SystemFirmwareImageSize,
- IN VOID *ConfigImage,
- IN UINTN ConfigImageSize,
- OUT UINT32 *LastAttemptVersion,
- OUT UINT32 *LastAttemptStatus
+ IN VOID *SystemFirmwareImage,
+ IN UINTN SystemFirmwareImageSize,
+ IN VOID *ConfigImage,
+ IN UINTN ConfigImageSize,
+ OUT UINT32 *LastAttemptVersion,
+ OUT UINT32 *LastAttemptStatus,
+ IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress
)
{
EFI_STATUS Status;
@@ -124,19 +137,34 @@ UpdateImage (
UPDATE_CONFIG_DATA *UpdateConfigData;
CONFIG_HEADER ConfigHeader;
UINTN Index;
+ UINTN TotalSize;
+ UINTN BytesWritten;
+ UINTN StartPercentage;
+ UINTN EndPercentage;
if (ConfigImage == NULL) {
DEBUG((DEBUG_INFO, "PlatformUpdate (NoConfig):"));
DEBUG((DEBUG_INFO, " BaseAddress - 0x%x,", 0));
DEBUG((DEBUG_INFO, " Length - 0x%x\n", SystemFirmwareImageSize));
// ASSUME the whole System Firmware include NVRAM region.
- Status = PerformFlashWrite (
+ StartPercentage = 0;
+ EndPercentage = 100;
+ if (Progress != NULL) {
+ Progress (StartPercentage);
+ }
+ Status = PerformFlashWriteWithProgress (
PlatformFirmwareTypeNvRam,
0,
FlashAddressTypeRelativeAddress,
SystemFirmwareImage,
- SystemFirmwareImageSize
+ SystemFirmwareImageSize,
+ Progress,
+ StartPercentage,
+ EndPercentage
);
+ if (Progress != NULL) {
+ Progress (EndPercentage);
+ }
if (!EFI_ERROR(Status)) {
*LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
mNvRamUpdated = TRUE;
@@ -163,17 +191,30 @@ UpdateImage (
DEBUG((DEBUG_INFO, "ConfigHeader.NumOfUpdates - 0x%x\n", ConfigHeader.NumOfUpdates));
DEBUG((DEBUG_INFO, "PcdEdkiiSystemFirmwareFileGuid - %g\n", PcdGetPtr(PcdEdkiiSystemFirmwareFileGuid)));
+ TotalSize = 0;
+ for (Index = 0; Index < ConfigHeader.NumOfUpdates; Index++) {
+ if (CompareGuid(&ConfigData[Index].FileGuid, PcdGetPtr(PcdEdkiiSystemFirmwareFileGuid))) {
+ TotalSize = TotalSize + ConfigData[Index].Length;
+ }
+ }
+
+ BytesWritten = 0;
Index = 0;
UpdateConfigData = ConfigData;
while (Index < ConfigHeader.NumOfUpdates) {
if (CompareGuid(&UpdateConfigData->FileGuid, PcdGetPtr(PcdEdkiiSystemFirmwareFileGuid))) {
DEBUG((DEBUG_INFO, "FileGuid - %g (processing)\n", &UpdateConfigData->FileGuid));
+ StartPercentage = (BytesWritten * 100) / TotalSize;
+ EndPercentage = ((BytesWritten + UpdateConfigData->Length) * 100) / TotalSize;
Status = PerformUpdate (
SystemFirmwareImage,
SystemFirmwareImageSize,
UpdateConfigData,
LastAttemptVersion,
- LastAttemptStatus
+ LastAttemptStatus,
+ Progress,
+ StartPercentage,
+ EndPercentage
);
//
// Shall updates be serialized so that if an update is not successfully completed,
@@ -186,6 +227,8 @@ UpdateImage (
DEBUG((DEBUG_INFO, "FileGuid - %g (ignored)\n", &UpdateConfigData->FileGuid));
}
+ BytesWritten += UpdateConfigData->Length;
+
Index++;
UpdateConfigData++;
}
@@ -209,10 +252,11 @@ UpdateImage (
**/
EFI_STATUS
SystemFirmwareAuthenticatedUpdate (
- IN VOID *Image,
- IN UINTN ImageSize,
- OUT UINT32 *LastAttemptVersion,
- OUT UINT32 *LastAttemptStatus
+ IN VOID *Image,
+ IN UINTN ImageSize,
+ OUT UINT32 *LastAttemptVersion,
+ OUT UINT32 *LastAttemptStatus,
+ IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress
)
{
EFI_STATUS Status;
@@ -240,7 +284,7 @@ SystemFirmwareAuthenticatedUpdate (
ExtractConfigImage(AuthenticatedImage, AuthenticatedImageSize, &ConfigImage, &ConfigImageSize);
DEBUG((DEBUG_INFO, "UpdateImage ...\n"));
- Status = UpdateImage(SystemFirmwareImage, SystemFirmwareImageSize, ConfigImage, ConfigImageSize, LastAttemptVersion, LastAttemptStatus);
+ Status = UpdateImage(SystemFirmwareImage, SystemFirmwareImageSize, ConfigImage, ConfigImageSize, LastAttemptVersion, LastAttemptStatus, Progress);
if (EFI_ERROR(Status)) {
DEBUG((DEBUG_INFO, "UpdateImage - %r\n", Status));
return Status;
@@ -442,8 +486,8 @@ FmpSetImage (
return EFI_INVALID_PARAMETER;
}
- Status = SystemFirmwareAuthenticatedUpdate((VOID *)Image, ImageSize, &SystemFmpPrivate->LastAttempt.LastAttemptVersion, &SystemFmpPrivate->LastAttempt.LastAttemptStatus);
- DEBUG((DEBUG_INFO, "SetImage - LastAttemp Version - 0x%x, State - 0x%x\n", SystemFmpPrivate->LastAttempt.LastAttemptVersion, SystemFmpPrivate->LastAttempt.LastAttemptStatus));
+ Status = SystemFirmwareAuthenticatedUpdate((VOID *)Image, ImageSize, &SystemFmpPrivate->LastAttempt.LastAttemptVersion, &SystemFmpPrivate->LastAttempt.LastAttemptStatus, Progress);
+ DEBUG((DEBUG_INFO, "SetImage - LastAttempt Version - 0x%x, State - 0x%x\n", SystemFmpPrivate->LastAttempt.LastAttemptVersion, SystemFmpPrivate->LastAttempt.LastAttemptStatus));
//
// If NVRAM is updated, we should no longer touch variable services, because
--
2.14.2.windows.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Patch v3 1/2] MdeModulePkg/DxeCapsuleLibFmp: Add progress bar support
2018-05-29 16:17 ` [Patch v3 1/2] MdeModulePkg/DxeCapsuleLibFmp: Add progress bar support Michael D Kinney
@ 2018-05-31 9:43 ` Zeng, Star
2018-05-31 13:03 ` Ard Biesheuvel
2018-06-06 17:34 ` Ard Biesheuvel
2 siblings, 0 replies; 7+ messages in thread
From: Zeng, Star @ 2018-05-31 9:43 UTC (permalink / raw)
To: Kinney, Michael D, edk2-devel@lists.01.org
Cc: Kinney, Michael D, Yao, Jiewen, Dong, Eric, Zeng, Star
Reviewed-by: Star Zeng <star.zeng@intel.com>
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Michael D Kinney
Sent: Wednesday, May 30, 2018 12:18 AM
To: edk2-devel@lists.01.org
Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>; Dong, Eric <eric.dong@intel.com>; Zeng, Star <star.zeng@intel.com>
Subject: [edk2] [Patch v3 1/2] MdeModulePkg/DxeCapsuleLibFmp: Add progress bar support
From: "Kinney, Michael D" <michael.d.kinney@intel.com>
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
---
.../Library/DxeCapsuleLibFmp/DxeCapsuleLib.c | 47 +++++++++---
.../Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf | 8 ++-
.../DxeCapsuleLibFmp/DxeCapsuleProcessLib.c | 84 ++++++++++++++++------
.../DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c | 21 +++++-
.../DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf | 7 +-
5 files changed, 131 insertions(+), 36 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;
}
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
index 1d947101d3..8367264f76 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
@@ -52,6 +52,7 @@ [LibraryClasses]
PrintLib
HobLib
BmpSupportLib
+ DisplayUpdateProgressLib
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleMax ## CONSUMES
@@ -66,9 +67,10 @@ [Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleStatusCodeResettingSystem ## CONSUMES
[Protocols]
- gEsrtManagementProtocolGuid ## CONSUMES
- gEfiFirmwareManagementProtocolGuid ## CONSUMES
- gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES
+ gEsrtManagementProtocolGuid ## CONSUMES
+ gEfiFirmwareManagementProtocolGuid ## CONSUMES
+ gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES
+ gEdkiiFirmwareManagementProgressProtocolGuid ## SOMETIMES_CONSUMES
[Guids]
gEfiFmpCapsuleGuid ## SOMETIMES_CONSUMES ## GUID
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c
index ba3ff90b9f..26ca4e295f 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c
@@ -9,7 +9,7 @@
ProcessCapsules(), ProcessTheseCapsules() will receive untrusted
input and do basic validation.
- Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2016 - 2018, Intel Corporation. All rights
+ reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at @@ -22,6 +22,7 @@
#include <PiDxe.h>
#include <Protocol/EsrtManagement.h>
+#include <Protocol/FirmwareManagementProgress.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
@@ -34,9 +35,12 @@
#include <Library/HobLib.h>
#include <Library/ReportStatusCodeLib.h> #include <Library/CapsuleLib.h>
+#include <Library/DisplayUpdateProgressLib.h>
#include <IndustryStandard/WindowsUxCapsule.h>
+extern EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL *mFmpProgress;
+
/**
Return if this FMP is a system FMP or a device FMP, based upon CapsuleHeader.
@@ -101,6 +105,62 @@ VOID **mCapsulePtr;
EFI_STATUS *mCapsuleStatusArray;
UINT32 mCapsuleTotalNumber;
+/**
+ 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
+
+ @retval EFI_SUCESS The capsule update progress was updated.
+ @retval EFI_INVALID_PARAMETER Completion is greater than 100%.
+**/
+EFI_STATUS
+EFIAPI
+UpdateImageProgress (
+ IN UINTN Completion
+ )
+{
+ EFI_STATUS Status;
+ UINTN Seconds;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *Color;
+
+ DEBUG((DEBUG_INFO, "Update Progress - %d%%\n", Completion));
+
+ if (Completion > 100) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Use a default timeout of 5 minutes if there is not FMP Progress Protocol.
+ //
+ Seconds = 5 * 60;
+ Color = NULL;
+ if (mFmpProgress != NULL) {
+ Seconds = mFmpProgress->WatchdogSeconds;
+ Color = &mFmpProgress->ProgressBarForegroundColor;
+ }
+
+ //
+ // Cancel the watchdog timer
+ //
+ gBS->SetWatchdogTimer (0, 0x0000, 0, NULL);
+
+ if (Completion != 100) {
+ //
+ // Arm the watchdog timer from PCD setting
+ //
+ if (Seconds != 0) {
+ DEBUG ((DEBUG_VERBOSE, "Arm watchdog timer %d seconds\n", Seconds));
+ gBS->SetWatchdogTimer (Seconds, 0x0000, 0, NULL);
+ }
+ }
+
+ Status = DisplayUpdateProgress (Completion, Color);
+
+ return Status;
+}
+
/**
This function initializes the mCapsulePtr, mCapsuleStatusArray and mCapsuleTotalNumber.
**/
@@ -319,7 +379,6 @@ ProcessTheseCapsules (
EFI_STATUS Status;
EFI_CAPSULE_HEADER *CapsuleHeader;
UINT32 Index;
- BOOLEAN DisplayCapsuleExist;
ESRT_MANAGEMENT_PROTOCOL *EsrtManagement;
UINT16 EmbeddedDriverCount;
@@ -354,12 +413,10 @@ ProcessTheseCapsules (
//
// If Windows UX capsule exist, process it first
//
- DisplayCapsuleExist = FALSE;
for (Index = 0; Index < mCapsuleTotalNumber; Index++) {
CapsuleHeader = (EFI_CAPSULE_HEADER*) mCapsulePtr [Index];
if (CompareGuid (&CapsuleHeader->CapsuleGuid, &gWindowsUxCapsuleGuid)) {
DEBUG ((DEBUG_INFO, "ProcessCapsuleImage (Ux) - 0x%x\n", CapsuleHeader));
- DisplayCapsuleExist = TRUE;
DEBUG ((DEBUG_INFO, "Display logo capsule is found.\n"));
Status = ProcessCapsuleImage (CapsuleHeader);
mCapsuleStatusArray [Index] = EFI_SUCCESS; @@ -368,12 +425,7 @@ ProcessTheseCapsules (
}
}
- if (!DisplayCapsuleExist) {
- //
- // Display Capsule not found. Display the default string.
- //
- Print (L"Updating the firmware ......\r\n");
- }
+ DEBUG ((DEBUG_INFO, "Updating the firmware ......\n"));
//
// All capsules left are recognized by platform.
@@ -411,7 +463,6 @@ ProcessTheseCapsules (
if (EFI_ERROR(Status)) {
REPORT_STATUS_CODE(EFI_ERROR_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeUpdateFirmwareFailed)));
DEBUG ((DEBUG_ERROR, "Capsule process failed!\n"));
- Print (L"Firmware update failed...\r\n");
} else {
REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeUpdateFirmwareSuccess)));
}
@@ -447,18 +498,9 @@ DoResetSystem (
VOID
)
{
- UINTN Index;
-
- REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeResettingSystem)));
-
- Print(L"Capsule Request Cold Reboot.\n");
DEBUG((DEBUG_INFO, "Capsule Request Cold Reboot."));
- for (Index = 5; Index > 0; Index--) {
- Print(L"\rResetting system in %d seconds ...", Index);
- DEBUG((DEBUG_INFO, "\rResetting system in %d seconds ...", Index));
- gBS->Stall(1000000);
- }
+ REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE |
+ PcdGet32(PcdStatusCodeSubClassCapsule) |
+ PcdGet32(PcdCapsuleStatusCodeResettingSystem)));
gRT->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL);
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c
index 07e9e46eae..274c1c4c1c 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c
@@ -3,7 +3,7 @@
Dummy function for runtime module, because CapsuleDxeRuntime
does not need call ProcessCapsules().
- Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2016 - 2018, Intel Corporation. All rights
+ reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at @@ -17,6 +17,25 @@ #include <PiDxe.h> #include <Library/CapsuleLib.h>
+/**
+ 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
+
+ @retval EFI_SUCESS The capsule update progress was updated.
+ @retval EFI_INVALID_PARAMETER Completion is greater than 100%.
+**/
+EFI_STATUS
+EFIAPI
+UpdateImageProgress (
+ IN UINTN Completion
+ )
+{
+ return EFI_SUCCESS;
+}
+
/**
This routine is called to process capsules.
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
index 1659b13ef4..342df9e99c 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
@@ -69,9 +69,10 @@ [Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleStatusCodeResettingSystem ## CONSUMES
[Protocols]
- gEsrtManagementProtocolGuid ## CONSUMES
- gEfiFirmwareManagementProtocolGuid ## CONSUMES
- gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES
+ gEsrtManagementProtocolGuid ## CONSUMES
+ gEfiFirmwareManagementProtocolGuid ## CONSUMES
+ gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES
+ gEdkiiFirmwareManagementProgressProtocolGuid ## SOMETIMES_CONSUMES
[Guids]
gEfiFmpCapsuleGuid ## SOMETIMES_CONSUMES ## GUID
--
2.14.2.windows.3
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Patch v3 1/2] MdeModulePkg/DxeCapsuleLibFmp: Add progress bar support
2018-05-29 16:17 ` [Patch v3 1/2] MdeModulePkg/DxeCapsuleLibFmp: Add progress bar support Michael D Kinney
2018-05-31 9:43 ` Zeng, Star
@ 2018-05-31 13:03 ` Ard Biesheuvel
2018-06-06 17:34 ` Ard Biesheuvel
2 siblings, 0 replies; 7+ messages in thread
From: Ard Biesheuvel @ 2018-05-31 13:03 UTC (permalink / raw)
To: Michael D Kinney, Leif Lindholm
Cc: edk2-devel@lists.01.org, Jiewen Yao, Eric Dong, Star Zeng
On 29 May 2018 at 18:17, Michael D Kinney <michael.d.kinney@intel.com> wrote:
> From: "Kinney, Michael D" <michael.d.kinney@intel.com>
>
> 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
Mike,
I am trying to wire up this code for my platform, and I am having
trouble understanding how the pieces fit together.
I have merged your edk2 and edk2-platforms changes, and I have updated
my PerformFlashWriteWithProgress() implementation to invoke the
Progress() callback. Unfortunately, nothing happens when I run it.
Looking into the code in more detail, I am having trouble
understanding how this is ever supposed to work, given that:
- UpdateCapsule() is implemented by CapsuleRuntimeDxe, which is a
DXE_RUNTIME_DRIVER module
- CapsuleRuntimeDxe incorporates DxeRuntimeCapsuleLib.inf
- DxeRuntimeCapsuleLib.inf includes DxeCapsuleReportLibNull.c, and so
its SetFmpImageData() routine passes an empty implementation of
UpdateImageProgress() into Fmp->SetImage()
It seems to me that some pieces are missing, but the code is a bit
scattered so maybe I failed to incorporate a piece.
Thanks,
Ard.
> ---
> .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.c | 47 +++++++++---
> .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf | 8 ++-
> .../DxeCapsuleLibFmp/DxeCapsuleProcessLib.c | 84 ++++++++++++++++------
> .../DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c | 21 +++++-
> .../DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf | 7 +-
> 5 files changed, 131 insertions(+), 36 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;
> }
>
> diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> index 1d947101d3..8367264f76 100644
> --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> @@ -52,6 +52,7 @@ [LibraryClasses]
> PrintLib
> HobLib
> BmpSupportLib
> + DisplayUpdateProgressLib
>
> [Pcd]
> gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleMax ## CONSUMES
> @@ -66,9 +67,10 @@ [Pcd]
> gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleStatusCodeResettingSystem ## CONSUMES
>
> [Protocols]
> - gEsrtManagementProtocolGuid ## CONSUMES
> - gEfiFirmwareManagementProtocolGuid ## CONSUMES
> - gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES
> + gEsrtManagementProtocolGuid ## CONSUMES
> + gEfiFirmwareManagementProtocolGuid ## CONSUMES
> + gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES
> + gEdkiiFirmwareManagementProgressProtocolGuid ## SOMETIMES_CONSUMES
>
> [Guids]
> gEfiFmpCapsuleGuid ## SOMETIMES_CONSUMES ## GUID
> diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c
> index ba3ff90b9f..26ca4e295f 100644
> --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c
> +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c
> @@ -9,7 +9,7 @@
> ProcessCapsules(), ProcessTheseCapsules() will receive untrusted
> input and do basic validation.
>
> - Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
> This program and the accompanying materials
> are licensed and made available under the terms and conditions of the BSD License
> which accompanies this distribution. The full text of the license may be found at
> @@ -22,6 +22,7 @@
>
> #include <PiDxe.h>
> #include <Protocol/EsrtManagement.h>
> +#include <Protocol/FirmwareManagementProgress.h>
>
> #include <Library/BaseLib.h>
> #include <Library/DebugLib.h>
> @@ -34,9 +35,12 @@
> #include <Library/HobLib.h>
> #include <Library/ReportStatusCodeLib.h>
> #include <Library/CapsuleLib.h>
> +#include <Library/DisplayUpdateProgressLib.h>
>
> #include <IndustryStandard/WindowsUxCapsule.h>
>
> +extern EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL *mFmpProgress;
> +
> /**
> Return if this FMP is a system FMP or a device FMP, based upon CapsuleHeader.
>
> @@ -101,6 +105,62 @@ VOID **mCapsulePtr;
> EFI_STATUS *mCapsuleStatusArray;
> UINT32 mCapsuleTotalNumber;
>
> +/**
> + 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
> +
> + @retval EFI_SUCESS The capsule update progress was updated.
> + @retval EFI_INVALID_PARAMETER Completion is greater than 100%.
> +**/
> +EFI_STATUS
> +EFIAPI
> +UpdateImageProgress (
> + IN UINTN Completion
> + )
> +{
> + EFI_STATUS Status;
> + UINTN Seconds;
> + EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *Color;
> +
> + DEBUG((DEBUG_INFO, "Update Progress - %d%%\n", Completion));
> +
> + if (Completion > 100) {
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + //
> + // Use a default timeout of 5 minutes if there is not FMP Progress Protocol.
> + //
> + Seconds = 5 * 60;
> + Color = NULL;
> + if (mFmpProgress != NULL) {
> + Seconds = mFmpProgress->WatchdogSeconds;
> + Color = &mFmpProgress->ProgressBarForegroundColor;
> + }
> +
> + //
> + // Cancel the watchdog timer
> + //
> + gBS->SetWatchdogTimer (0, 0x0000, 0, NULL);
> +
> + if (Completion != 100) {
> + //
> + // Arm the watchdog timer from PCD setting
> + //
> + if (Seconds != 0) {
> + DEBUG ((DEBUG_VERBOSE, "Arm watchdog timer %d seconds\n", Seconds));
> + gBS->SetWatchdogTimer (Seconds, 0x0000, 0, NULL);
> + }
> + }
> +
> + Status = DisplayUpdateProgress (Completion, Color);
> +
> + return Status;
> +}
> +
> /**
> This function initializes the mCapsulePtr, mCapsuleStatusArray and mCapsuleTotalNumber.
> **/
> @@ -319,7 +379,6 @@ ProcessTheseCapsules (
> EFI_STATUS Status;
> EFI_CAPSULE_HEADER *CapsuleHeader;
> UINT32 Index;
> - BOOLEAN DisplayCapsuleExist;
> ESRT_MANAGEMENT_PROTOCOL *EsrtManagement;
> UINT16 EmbeddedDriverCount;
>
> @@ -354,12 +413,10 @@ ProcessTheseCapsules (
> //
> // If Windows UX capsule exist, process it first
> //
> - DisplayCapsuleExist = FALSE;
> for (Index = 0; Index < mCapsuleTotalNumber; Index++) {
> CapsuleHeader = (EFI_CAPSULE_HEADER*) mCapsulePtr [Index];
> if (CompareGuid (&CapsuleHeader->CapsuleGuid, &gWindowsUxCapsuleGuid)) {
> DEBUG ((DEBUG_INFO, "ProcessCapsuleImage (Ux) - 0x%x\n", CapsuleHeader));
> - DisplayCapsuleExist = TRUE;
> DEBUG ((DEBUG_INFO, "Display logo capsule is found.\n"));
> Status = ProcessCapsuleImage (CapsuleHeader);
> mCapsuleStatusArray [Index] = EFI_SUCCESS;
> @@ -368,12 +425,7 @@ ProcessTheseCapsules (
> }
> }
>
> - if (!DisplayCapsuleExist) {
> - //
> - // Display Capsule not found. Display the default string.
> - //
> - Print (L"Updating the firmware ......\r\n");
> - }
> + DEBUG ((DEBUG_INFO, "Updating the firmware ......\n"));
>
> //
> // All capsules left are recognized by platform.
> @@ -411,7 +463,6 @@ ProcessTheseCapsules (
> if (EFI_ERROR(Status)) {
> REPORT_STATUS_CODE(EFI_ERROR_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeUpdateFirmwareFailed)));
> DEBUG ((DEBUG_ERROR, "Capsule process failed!\n"));
> - Print (L"Firmware update failed...\r\n");
> } else {
> REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeUpdateFirmwareSuccess)));
> }
> @@ -447,18 +498,9 @@ DoResetSystem (
> VOID
> )
> {
> - UINTN Index;
> -
> - REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeResettingSystem)));
> -
> - Print(L"Capsule Request Cold Reboot.\n");
> DEBUG((DEBUG_INFO, "Capsule Request Cold Reboot."));
>
> - for (Index = 5; Index > 0; Index--) {
> - Print(L"\rResetting system in %d seconds ...", Index);
> - DEBUG((DEBUG_INFO, "\rResetting system in %d seconds ...", Index));
> - gBS->Stall(1000000);
> - }
> + REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeResettingSystem)));
>
> gRT->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL);
>
> diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c
> index 07e9e46eae..274c1c4c1c 100644
> --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c
> +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c
> @@ -3,7 +3,7 @@
> Dummy function for runtime module, because CapsuleDxeRuntime
> does not need call ProcessCapsules().
>
> - Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
> This program and the accompanying materials
> are licensed and made available under the terms and conditions of the BSD License
> which accompanies this distribution. The full text of the license may be found at
> @@ -17,6 +17,25 @@
> #include <PiDxe.h>
> #include <Library/CapsuleLib.h>
>
> +/**
> + 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
> +
> + @retval EFI_SUCESS The capsule update progress was updated.
> + @retval EFI_INVALID_PARAMETER Completion is greater than 100%.
> +**/
> +EFI_STATUS
> +EFIAPI
> +UpdateImageProgress (
> + IN UINTN Completion
> + )
> +{
> + return EFI_SUCCESS;
> +}
> +
> /**
>
> This routine is called to process capsules.
> diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
> index 1659b13ef4..342df9e99c 100644
> --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
> +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
> @@ -69,9 +69,10 @@ [Pcd]
> gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleStatusCodeResettingSystem ## CONSUMES
>
> [Protocols]
> - gEsrtManagementProtocolGuid ## CONSUMES
> - gEfiFirmwareManagementProtocolGuid ## CONSUMES
> - gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES
> + gEsrtManagementProtocolGuid ## CONSUMES
> + gEfiFirmwareManagementProtocolGuid ## CONSUMES
> + gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES
> + gEdkiiFirmwareManagementProgressProtocolGuid ## SOMETIMES_CONSUMES
>
> [Guids]
> gEfiFmpCapsuleGuid ## SOMETIMES_CONSUMES ## GUID
> --
> 2.14.2.windows.3
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Patch v3 1/2] MdeModulePkg/DxeCapsuleLibFmp: Add progress bar support
2018-05-29 16:17 ` [Patch v3 1/2] MdeModulePkg/DxeCapsuleLibFmp: Add progress bar support Michael D Kinney
2018-05-31 9:43 ` Zeng, Star
2018-05-31 13:03 ` Ard Biesheuvel
@ 2018-06-06 17:34 ` Ard Biesheuvel
2 siblings, 0 replies; 7+ messages in thread
From: Ard Biesheuvel @ 2018-06-06 17:34 UTC (permalink / raw)
To: Michael D Kinney
Cc: edk2-devel@lists.01.org, Jiewen Yao, Eric Dong, Star Zeng
On 29 May 2018 at 18:17, Michael D Kinney <michael.d.kinney@intel.com> wrote:
> From: "Kinney, Michael D" <michael.d.kinney@intel.com>
>
> 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>
Please don't push this before the edk2-platforms changes are in.
> ---
> .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.c | 47 +++++++++---
> .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf | 8 ++-
> .../DxeCapsuleLibFmp/DxeCapsuleProcessLib.c | 84 ++++++++++++++++------
> .../DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c | 21 +++++-
> .../DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf | 7 +-
> 5 files changed, 131 insertions(+), 36 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;
> }
>
> diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> index 1d947101d3..8367264f76 100644
> --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> @@ -52,6 +52,7 @@ [LibraryClasses]
> PrintLib
> HobLib
> BmpSupportLib
> + DisplayUpdateProgressLib
>
> [Pcd]
> gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleMax ## CONSUMES
> @@ -66,9 +67,10 @@ [Pcd]
> gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleStatusCodeResettingSystem ## CONSUMES
>
> [Protocols]
> - gEsrtManagementProtocolGuid ## CONSUMES
> - gEfiFirmwareManagementProtocolGuid ## CONSUMES
> - gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES
> + gEsrtManagementProtocolGuid ## CONSUMES
> + gEfiFirmwareManagementProtocolGuid ## CONSUMES
> + gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES
> + gEdkiiFirmwareManagementProgressProtocolGuid ## SOMETIMES_CONSUMES
>
> [Guids]
> gEfiFmpCapsuleGuid ## SOMETIMES_CONSUMES ## GUID
> diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c
> index ba3ff90b9f..26ca4e295f 100644
> --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c
> +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c
> @@ -9,7 +9,7 @@
> ProcessCapsules(), ProcessTheseCapsules() will receive untrusted
> input and do basic validation.
>
> - Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
> This program and the accompanying materials
> are licensed and made available under the terms and conditions of the BSD License
> which accompanies this distribution. The full text of the license may be found at
> @@ -22,6 +22,7 @@
>
> #include <PiDxe.h>
> #include <Protocol/EsrtManagement.h>
> +#include <Protocol/FirmwareManagementProgress.h>
>
> #include <Library/BaseLib.h>
> #include <Library/DebugLib.h>
> @@ -34,9 +35,12 @@
> #include <Library/HobLib.h>
> #include <Library/ReportStatusCodeLib.h>
> #include <Library/CapsuleLib.h>
> +#include <Library/DisplayUpdateProgressLib.h>
>
> #include <IndustryStandard/WindowsUxCapsule.h>
>
> +extern EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL *mFmpProgress;
> +
> /**
> Return if this FMP is a system FMP or a device FMP, based upon CapsuleHeader.
>
> @@ -101,6 +105,62 @@ VOID **mCapsulePtr;
> EFI_STATUS *mCapsuleStatusArray;
> UINT32 mCapsuleTotalNumber;
>
> +/**
> + 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
> +
> + @retval EFI_SUCESS The capsule update progress was updated.
> + @retval EFI_INVALID_PARAMETER Completion is greater than 100%.
> +**/
> +EFI_STATUS
> +EFIAPI
> +UpdateImageProgress (
> + IN UINTN Completion
> + )
> +{
> + EFI_STATUS Status;
> + UINTN Seconds;
> + EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *Color;
> +
> + DEBUG((DEBUG_INFO, "Update Progress - %d%%\n", Completion));
> +
> + if (Completion > 100) {
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + //
> + // Use a default timeout of 5 minutes if there is not FMP Progress Protocol.
> + //
> + Seconds = 5 * 60;
> + Color = NULL;
> + if (mFmpProgress != NULL) {
> + Seconds = mFmpProgress->WatchdogSeconds;
> + Color = &mFmpProgress->ProgressBarForegroundColor;
> + }
> +
> + //
> + // Cancel the watchdog timer
> + //
> + gBS->SetWatchdogTimer (0, 0x0000, 0, NULL);
> +
> + if (Completion != 100) {
> + //
> + // Arm the watchdog timer from PCD setting
> + //
> + if (Seconds != 0) {
> + DEBUG ((DEBUG_VERBOSE, "Arm watchdog timer %d seconds\n", Seconds));
> + gBS->SetWatchdogTimer (Seconds, 0x0000, 0, NULL);
> + }
> + }
> +
> + Status = DisplayUpdateProgress (Completion, Color);
> +
> + return Status;
> +}
> +
> /**
> This function initializes the mCapsulePtr, mCapsuleStatusArray and mCapsuleTotalNumber.
> **/
> @@ -319,7 +379,6 @@ ProcessTheseCapsules (
> EFI_STATUS Status;
> EFI_CAPSULE_HEADER *CapsuleHeader;
> UINT32 Index;
> - BOOLEAN DisplayCapsuleExist;
> ESRT_MANAGEMENT_PROTOCOL *EsrtManagement;
> UINT16 EmbeddedDriverCount;
>
> @@ -354,12 +413,10 @@ ProcessTheseCapsules (
> //
> // If Windows UX capsule exist, process it first
> //
> - DisplayCapsuleExist = FALSE;
> for (Index = 0; Index < mCapsuleTotalNumber; Index++) {
> CapsuleHeader = (EFI_CAPSULE_HEADER*) mCapsulePtr [Index];
> if (CompareGuid (&CapsuleHeader->CapsuleGuid, &gWindowsUxCapsuleGuid)) {
> DEBUG ((DEBUG_INFO, "ProcessCapsuleImage (Ux) - 0x%x\n", CapsuleHeader));
> - DisplayCapsuleExist = TRUE;
> DEBUG ((DEBUG_INFO, "Display logo capsule is found.\n"));
> Status = ProcessCapsuleImage (CapsuleHeader);
> mCapsuleStatusArray [Index] = EFI_SUCCESS;
> @@ -368,12 +425,7 @@ ProcessTheseCapsules (
> }
> }
>
> - if (!DisplayCapsuleExist) {
> - //
> - // Display Capsule not found. Display the default string.
> - //
> - Print (L"Updating the firmware ......\r\n");
> - }
> + DEBUG ((DEBUG_INFO, "Updating the firmware ......\n"));
>
> //
> // All capsules left are recognized by platform.
> @@ -411,7 +463,6 @@ ProcessTheseCapsules (
> if (EFI_ERROR(Status)) {
> REPORT_STATUS_CODE(EFI_ERROR_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeUpdateFirmwareFailed)));
> DEBUG ((DEBUG_ERROR, "Capsule process failed!\n"));
> - Print (L"Firmware update failed...\r\n");
> } else {
> REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeUpdateFirmwareSuccess)));
> }
> @@ -447,18 +498,9 @@ DoResetSystem (
> VOID
> )
> {
> - UINTN Index;
> -
> - REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeResettingSystem)));
> -
> - Print(L"Capsule Request Cold Reboot.\n");
> DEBUG((DEBUG_INFO, "Capsule Request Cold Reboot."));
>
> - for (Index = 5; Index > 0; Index--) {
> - Print(L"\rResetting system in %d seconds ...", Index);
> - DEBUG((DEBUG_INFO, "\rResetting system in %d seconds ...", Index));
> - gBS->Stall(1000000);
> - }
> + REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeResettingSystem)));
>
> gRT->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL);
>
> diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c
> index 07e9e46eae..274c1c4c1c 100644
> --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c
> +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c
> @@ -3,7 +3,7 @@
> Dummy function for runtime module, because CapsuleDxeRuntime
> does not need call ProcessCapsules().
>
> - Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
> This program and the accompanying materials
> are licensed and made available under the terms and conditions of the BSD License
> which accompanies this distribution. The full text of the license may be found at
> @@ -17,6 +17,25 @@
> #include <PiDxe.h>
> #include <Library/CapsuleLib.h>
>
> +/**
> + 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
> +
> + @retval EFI_SUCESS The capsule update progress was updated.
> + @retval EFI_INVALID_PARAMETER Completion is greater than 100%.
> +**/
> +EFI_STATUS
> +EFIAPI
> +UpdateImageProgress (
> + IN UINTN Completion
> + )
> +{
> + return EFI_SUCCESS;
> +}
> +
> /**
>
> This routine is called to process capsules.
> diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
> index 1659b13ef4..342df9e99c 100644
> --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
> +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
> @@ -69,9 +69,10 @@ [Pcd]
> gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleStatusCodeResettingSystem ## CONSUMES
>
> [Protocols]
> - gEsrtManagementProtocolGuid ## CONSUMES
> - gEfiFirmwareManagementProtocolGuid ## CONSUMES
> - gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES
> + gEsrtManagementProtocolGuid ## CONSUMES
> + gEfiFirmwareManagementProtocolGuid ## CONSUMES
> + gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES
> + gEdkiiFirmwareManagementProgressProtocolGuid ## SOMETIMES_CONSUMES
>
> [Guids]
> gEfiFmpCapsuleGuid ## SOMETIMES_CONSUMES ## GUID
> --
> 2.14.2.windows.3
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Patch v3 2/2] SignedCapsulePkg/SystemFirmwareUpdateDxe: Use progress API
2018-05-29 16:17 ` [Patch v3 2/2] SignedCapsulePkg/SystemFirmwareUpdateDxe: Use progress API Michael D Kinney
@ 2018-06-06 17:35 ` Ard Biesheuvel
0 siblings, 0 replies; 7+ messages in thread
From: Ard Biesheuvel @ 2018-06-06 17:35 UTC (permalink / raw)
To: Michael D Kinney; +Cc: edk2-devel@lists.01.org, Jiewen Yao
On 29 May 2018 at 18:17, Michael D Kinney <michael.d.kinney@intel.com> wrote:
> From: "Kinney, Michael D" <michael.d.kinney@intel.com>
>
> https://bugzilla.tianocore.org/show_bug.cgi?id=801
>
> Use PlatformFlashWriteWithProgress() instead of PlatformFLashWrite()
> so the user can be informed of the progress as a capsule is used
> to update a firmware image in a firmware device.
>
> Cc: Jiewen Yao <jiewen.yao@intel.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>
> ---
> .../SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c | 90 ++++++++++++++++------
> 1 file changed, 67 insertions(+), 23 deletions(-)
>
> diff --git a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c
> index ce6892d6a9..8e66aedf62 100644
> --- a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c
> +++ b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c
> @@ -65,11 +65,14 @@ ParseUpdateDataFile (
> **/
> EFI_STATUS
> PerformUpdate (
> - IN VOID *SystemFirmwareImage,
> - IN UINTN SystemFirmwareImageSize,
> - IN UPDATE_CONFIG_DATA *ConfigData,
> - OUT UINT32 *LastAttemptVersion,
> - OUT UINT32 *LastAttemptStatus
> + IN VOID *SystemFirmwareImage,
> + IN UINTN SystemFirmwareImageSize,
> + IN UPDATE_CONFIG_DATA *ConfigData,
> + OUT UINT32 *LastAttemptVersion,
> + OUT UINT32 *LastAttemptStatus,
> + IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress,
> + IN UINTN StartPercentage,
> + IN UINTN EndPercentage
> )
> {
> EFI_STATUS Status;
> @@ -78,13 +81,22 @@ PerformUpdate (
> DEBUG((DEBUG_INFO, " BaseAddress - 0x%lx,", ConfigData->BaseAddress));
> DEBUG((DEBUG_INFO, " ImageOffset - 0x%x,", ConfigData->ImageOffset));
> DEBUG((DEBUG_INFO, " Legnth - 0x%x\n", ConfigData->Length));
> - Status = PerformFlashWrite (
> + if (Progress != NULL) {
> + Progress (StartPercentage);
> + }
> + Status = PerformFlashWriteWithProgress (
> ConfigData->FirmwareType,
> ConfigData->BaseAddress,
> ConfigData->AddressType,
> (VOID *)((UINTN)SystemFirmwareImage + (UINTN)ConfigData->ImageOffset),
> - ConfigData->Length
> + ConfigData->Length,
> + Progress,
> + StartPercentage,
> + EndPercentage
> );
> + if (Progress != NULL) {
> + Progress (EndPercentage);
> + }
> if (!EFI_ERROR(Status)) {
> *LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
> if (ConfigData->FirmwareType == PlatformFirmwareTypeNvRam) {
> @@ -111,12 +123,13 @@ PerformUpdate (
> **/
> EFI_STATUS
> UpdateImage (
> - IN VOID *SystemFirmwareImage,
> - IN UINTN SystemFirmwareImageSize,
> - IN VOID *ConfigImage,
> - IN UINTN ConfigImageSize,
> - OUT UINT32 *LastAttemptVersion,
> - OUT UINT32 *LastAttemptStatus
> + IN VOID *SystemFirmwareImage,
> + IN UINTN SystemFirmwareImageSize,
> + IN VOID *ConfigImage,
> + IN UINTN ConfigImageSize,
> + OUT UINT32 *LastAttemptVersion,
> + OUT UINT32 *LastAttemptStatus,
> + IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress
> )
> {
> EFI_STATUS Status;
> @@ -124,19 +137,34 @@ UpdateImage (
> UPDATE_CONFIG_DATA *UpdateConfigData;
> CONFIG_HEADER ConfigHeader;
> UINTN Index;
> + UINTN TotalSize;
> + UINTN BytesWritten;
> + UINTN StartPercentage;
> + UINTN EndPercentage;
>
> if (ConfigImage == NULL) {
> DEBUG((DEBUG_INFO, "PlatformUpdate (NoConfig):"));
> DEBUG((DEBUG_INFO, " BaseAddress - 0x%x,", 0));
> DEBUG((DEBUG_INFO, " Length - 0x%x\n", SystemFirmwareImageSize));
> // ASSUME the whole System Firmware include NVRAM region.
> - Status = PerformFlashWrite (
> + StartPercentage = 0;
> + EndPercentage = 100;
> + if (Progress != NULL) {
> + Progress (StartPercentage);
> + }
> + Status = PerformFlashWriteWithProgress (
> PlatformFirmwareTypeNvRam,
> 0,
> FlashAddressTypeRelativeAddress,
> SystemFirmwareImage,
> - SystemFirmwareImageSize
> + SystemFirmwareImageSize,
> + Progress,
> + StartPercentage,
> + EndPercentage
> );
> + if (Progress != NULL) {
> + Progress (EndPercentage);
> + }
> if (!EFI_ERROR(Status)) {
> *LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
> mNvRamUpdated = TRUE;
> @@ -163,17 +191,30 @@ UpdateImage (
> DEBUG((DEBUG_INFO, "ConfigHeader.NumOfUpdates - 0x%x\n", ConfigHeader.NumOfUpdates));
> DEBUG((DEBUG_INFO, "PcdEdkiiSystemFirmwareFileGuid - %g\n", PcdGetPtr(PcdEdkiiSystemFirmwareFileGuid)));
>
> + TotalSize = 0;
> + for (Index = 0; Index < ConfigHeader.NumOfUpdates; Index++) {
> + if (CompareGuid(&ConfigData[Index].FileGuid, PcdGetPtr(PcdEdkiiSystemFirmwareFileGuid))) {
> + TotalSize = TotalSize + ConfigData[Index].Length;
> + }
> + }
> +
> + BytesWritten = 0;
> Index = 0;
> UpdateConfigData = ConfigData;
> while (Index < ConfigHeader.NumOfUpdates) {
> if (CompareGuid(&UpdateConfigData->FileGuid, PcdGetPtr(PcdEdkiiSystemFirmwareFileGuid))) {
> DEBUG((DEBUG_INFO, "FileGuid - %g (processing)\n", &UpdateConfigData->FileGuid));
> + StartPercentage = (BytesWritten * 100) / TotalSize;
> + EndPercentage = ((BytesWritten + UpdateConfigData->Length) * 100) / TotalSize;
> Status = PerformUpdate (
> SystemFirmwareImage,
> SystemFirmwareImageSize,
> UpdateConfigData,
> LastAttemptVersion,
> - LastAttemptStatus
> + LastAttemptStatus,
> + Progress,
> + StartPercentage,
> + EndPercentage
> );
> //
> // Shall updates be serialized so that if an update is not successfully completed,
> @@ -186,6 +227,8 @@ UpdateImage (
> DEBUG((DEBUG_INFO, "FileGuid - %g (ignored)\n", &UpdateConfigData->FileGuid));
> }
>
> + BytesWritten += UpdateConfigData->Length;
> +
> Index++;
> UpdateConfigData++;
> }
> @@ -209,10 +252,11 @@ UpdateImage (
> **/
> EFI_STATUS
> SystemFirmwareAuthenticatedUpdate (
> - IN VOID *Image,
> - IN UINTN ImageSize,
> - OUT UINT32 *LastAttemptVersion,
> - OUT UINT32 *LastAttemptStatus
> + IN VOID *Image,
> + IN UINTN ImageSize,
> + OUT UINT32 *LastAttemptVersion,
> + OUT UINT32 *LastAttemptStatus,
> + IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress
> )
> {
> EFI_STATUS Status;
> @@ -240,7 +284,7 @@ SystemFirmwareAuthenticatedUpdate (
> ExtractConfigImage(AuthenticatedImage, AuthenticatedImageSize, &ConfigImage, &ConfigImageSize);
>
> DEBUG((DEBUG_INFO, "UpdateImage ...\n"));
> - Status = UpdateImage(SystemFirmwareImage, SystemFirmwareImageSize, ConfigImage, ConfigImageSize, LastAttemptVersion, LastAttemptStatus);
> + Status = UpdateImage(SystemFirmwareImage, SystemFirmwareImageSize, ConfigImage, ConfigImageSize, LastAttemptVersion, LastAttemptStatus, Progress);
> if (EFI_ERROR(Status)) {
> DEBUG((DEBUG_INFO, "UpdateImage - %r\n", Status));
> return Status;
> @@ -442,8 +486,8 @@ FmpSetImage (
> return EFI_INVALID_PARAMETER;
> }
>
> - Status = SystemFirmwareAuthenticatedUpdate((VOID *)Image, ImageSize, &SystemFmpPrivate->LastAttempt.LastAttemptVersion, &SystemFmpPrivate->LastAttempt.LastAttemptStatus);
> - DEBUG((DEBUG_INFO, "SetImage - LastAttemp Version - 0x%x, State - 0x%x\n", SystemFmpPrivate->LastAttempt.LastAttemptVersion, SystemFmpPrivate->LastAttempt.LastAttemptStatus));
> + Status = SystemFirmwareAuthenticatedUpdate((VOID *)Image, ImageSize, &SystemFmpPrivate->LastAttempt.LastAttemptVersion, &SystemFmpPrivate->LastAttempt.LastAttemptStatus, Progress);
> + DEBUG((DEBUG_INFO, "SetImage - LastAttempt Version - 0x%x, State - 0x%x\n", SystemFmpPrivate->LastAttempt.LastAttemptVersion, SystemFmpPrivate->LastAttempt.LastAttemptStatus));
>
> //
> // If NVRAM is updated, we should no longer touch variable services, because
> --
> 2.14.2.windows.3
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-06-06 17:35 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-29 16:17 [Patch v3 0/2] Use DisplayUpdateProgressLib and PerformFlashWriteWithProgress() Michael D Kinney
2018-05-29 16:17 ` [Patch v3 1/2] MdeModulePkg/DxeCapsuleLibFmp: Add progress bar support Michael D Kinney
2018-05-31 9:43 ` Zeng, Star
2018-05-31 13:03 ` Ard Biesheuvel
2018-06-06 17:34 ` Ard Biesheuvel
2018-05-29 16:17 ` [Patch v3 2/2] SignedCapsulePkg/SystemFirmwareUpdateDxe: Use progress API Michael D Kinney
2018-06-06 17:35 ` Ard Biesheuvel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox