From nobody Fri Nov 1 04:29:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1522873578146550.5519875694432; Wed, 4 Apr 2018 13:26:18 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7C2B72264A214; Wed, 4 Apr 2018 13:26:05 -0700 (PDT) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 1279F21E08164 for ; Wed, 4 Apr 2018 13:26:04 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Apr 2018 13:26:03 -0700 Received: from mdkinney-mobl2.amr.corp.intel.com ([10.241.98.47]) by fmsmga006.fm.intel.com with ESMTP; 04 Apr 2018 13:26:02 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=michael.d.kinney@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,408,1517904000"; d="scan'208";a="217591873" From: Michael D Kinney To: edk2-devel@lists.01.org Date: Wed, 4 Apr 2018 13:25:50 -0700 Message-Id: <20180404202554.9568-6-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.14.2.windows.3 In-Reply-To: <20180404202554.9568-1-michael.d.kinney@intel.com> References: <20180404202554.9568-1-michael.d.kinney@intel.com> Subject: [edk2] [Patch 5/9] MdeModulePkg/DxeCapsuleLibFmp: Add progress bar support X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Kinney, Michael D" , Jiewen Yao , Eric Dong , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: "Kinney, Michael D" https://bugzilla.tianocore.org/show_bug.cgi?id=3D801 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 Cc: Eric Dong Cc: Jiewen Yao Cc: Sean Brogan Signed-off-by: Michael D Kinney 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/MdeMod= ulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c index 555c5971d0..5be6bf386e 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c @@ -45,6 +45,7 @@ #include #include #include +#include #include =20 EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable =3D NULL; @@ -53,6 +54,8 @@ BOOLEAN mIsVirtualAddrConverted = =3D FALSE; BOOLEAN mDxeCapsuleLibEndOfDxe =3D FALSE; EFI_EVENT mDxeCapsuleLibEndOfDxeEvent =3D NULL; =20 +EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL *mFmpProgress =3D 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. =20 - @param[in] Completion A value between 1 and 100 indicating the curre= nt completion progress of the firmware update + @param[in] Completion A value between 1 and 100 indicating the current + completion progress of the firmware update =20 - @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; -} + ); =20 /** Return if this CapsuleGuid is a FMP capsule GUID or not. @@ -849,6 +851,19 @@ SetFmpImageData ( return Status; } =20 + // + // Lookup Firmware Management Progress Protocol before SetImage() is cal= led + // This is an optional protocol that may not be present on Handle. + // + Status =3D gBS->HandleProtocol ( + Handle, + &gEdkiiFirmwareManagementProgressProtocolGuid, + (VOID **)&mFmpProgress + ); + if (EFI_ERROR (Status)) { + mFmpProgress =3D NULL; + } + if (ImageHeader->Version >=3D EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEAD= ER_INIT_VERSION) { Image =3D (UINT8 *)(ImageHeader + 1); } else { @@ -873,21 +888,37 @@ SetFmpImageData ( DEBUG((DEBUG_INFO, "(UpdateHardwareInstance - 0x%x)", ImageHeader->Upd= ateHardwareInstance)); } DEBUG((DEBUG_INFO, "\n")); + + // + // Before calling SetImage(), reset the progress bar to 0% + // + UpdateImageProgress (0); + Status =3D 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 !=3D NULL) { DEBUG ((DEBUG_ERROR, "%s\n", AbortReason)); FreePool(AbortReason); } =20 + // + // Clear mFmpProgress after SetImage() returns + // + mFmpProgress =3D NULL; + return Status; } =20 diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf b/MdeM= odulePkg/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 =20 [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleMax = ## CONSUMES @@ -66,9 +67,10 @@ [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleStatusCodeResettingSystem = ## CONSUMES =20 [Protocols] - gEsrtManagementProtocolGuid ## CONSUMES - gEfiFirmwareManagementProtocolGuid ## CONSUMES - gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES + gEsrtManagementProtocolGuid ## CONSUMES + gEfiFirmwareManagementProtocolGuid ## CONSUMES + gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES + gEdkiiFirmwareManagementProgressProtocolGuid ## SOMETIMES_CONSUMES =20 [Guids] gEfiFmpCapsuleGuid ## SOMETIMES_CONSUMES ## GUID diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c b= /MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c index ba3ff90b9f..e8c506080e 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. =20 - Copyright (c) 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -22,6 +22,7 @@ =20 #include #include +#include =20 #include #include @@ -34,9 +35,12 @@ #include #include #include +#include =20 #include =20 +extern EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL *mFmpProgress; + /** Return if this FMP is a system FMP or a device FMP, based upon CapsuleHe= ader. =20 @@ -101,6 +105,62 @@ VOID **mCapsulePtr; EFI_STATUS *mCapsuleStatusArray; UINT32 mCapsuleTotalNumber; =20 +/** + 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 Proto= col. + // + Seconds =3D 5 * 60; + Color =3D NULL; + if (mFmpProgress !=3D NULL) { + Seconds =3D mFmpProgress->WatchdogSeconds; + Color =3D &mFmpProgress->ProgressBarColor; + } + + // + // Cancel the watchdog timer + // + gBS->SetWatchdogTimer (0, 0x0000, 0, NULL); + + if (Completion !=3D 100) { + // + // Arm the watchdog timer from PCD setting + // + if (Seconds !=3D 0) { + DEBUG ((DEBUG_VERBOSE, "Arm watchdog timer %d seconds\n", Seconds)); + gBS->SetWatchdogTimer (Seconds, 0x0000, 0, NULL); + } + } + + Status =3D DisplayUpdateProgress (Completion, Color); + + return Status; +} + /** This function initializes the mCapsulePtr, mCapsuleStatusArray and mCaps= uleTotalNumber. **/ @@ -319,7 +379,6 @@ ProcessTheseCapsules ( EFI_STATUS Status; EFI_CAPSULE_HEADER *CapsuleHeader; UINT32 Index; - BOOLEAN DisplayCapsuleExist; ESRT_MANAGEMENT_PROTOCOL *EsrtManagement; UINT16 EmbeddedDriverCount; =20 @@ -354,12 +413,10 @@ ProcessTheseCapsules ( // // If Windows UX capsule exist, process it first // - DisplayCapsuleExist =3D FALSE; for (Index =3D 0; Index < mCapsuleTotalNumber; Index++) { CapsuleHeader =3D (EFI_CAPSULE_HEADER*) mCapsulePtr [Index]; if (CompareGuid (&CapsuleHeader->CapsuleGuid, &gWindowsUxCapsuleGuid))= { DEBUG ((DEBUG_INFO, "ProcessCapsuleImage (Ux) - 0x%x\n", CapsuleHead= er)); - DisplayCapsuleExist =3D TRUE; DEBUG ((DEBUG_INFO, "Display logo capsule is found.\n")); Status =3D ProcessCapsuleImage (CapsuleHeader); mCapsuleStatusArray [Index] =3D EFI_SUCCESS; @@ -368,12 +425,7 @@ ProcessTheseCapsules ( } } =20 - if (!DisplayCapsuleExist) { - // - // Display Capsule not found. Display the default string. - // - Print (L"Updating the firmware ......\r\n"); - } + DEBUG ((DEBUG_INFO, "Updating the firmware ......\n")); =20 // // 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(Pc= dStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeUpdateFirmwareFa= iled))); 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(PcdCapsuleStatusCodeUpdateFirmwar= eSuccess))); } @@ -447,18 +498,9 @@ DoResetSystem ( VOID ) { - UINTN Index; - - REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatus= CodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeResettingSystem))); - - Print(L"Capsule Request Cold Reboot.\n"); DEBUG((DEBUG_INFO, "Capsule Request Cold Reboot.")); =20 - for (Index =3D 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(PcdStatus= CodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeResettingSystem))); =20 gRT->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL); =20 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(). =20 - Copyright (c) 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -17,6 +17,25 @@ #include #include =20 +/** + 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; +} + /** =20 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 =20 [Protocols] - gEsrtManagementProtocolGuid ## CONSUMES - gEfiFirmwareManagementProtocolGuid ## CONSUMES - gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES + gEsrtManagementProtocolGuid ## CONSUMES + gEfiFirmwareManagementProtocolGuid ## CONSUMES + gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES + gEdkiiFirmwareManagementProgressProtocolGuid ## SOMETIMES_CONSUMES =20 [Guids] gEfiFmpCapsuleGuid ## SOMETIMES_CONSUMES ## GUID --=20 2.14.2.windows.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel