From nobody Fri May 3 22:58:25 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 1523494122491635.5227824192335; Wed, 11 Apr 2018 17:48:42 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 45FE7226CD797; Wed, 11 Apr 2018 17:48:39 -0700 (PDT) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 8DBC1226CD786 for ; Wed, 11 Apr 2018 17:48:37 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Apr 2018 17:48:37 -0700 Received: from mdkinney-mobl2.amr.corp.intel.com ([10.252.128.14]) by fmsmga006.fm.intel.com with ESMTP; 11 Apr 2018 17:48:36 -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=134.134.136.65; helo=mga03.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,438,1517904000"; d="scan'208";a="219727884" From: "Kinney, Michael D" To: edk2-devel@lists.01.org Date: Wed, 11 Apr 2018 17:48:22 -0700 Message-Id: <20180412004830.9904-2-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.14.2.windows.3 In-Reply-To: <20180412004830.9904-1-michael.d.kinney@intel.com> References: <20180412004830.9904-1-michael.d.kinney@intel.com> Subject: [edk2] [Patch V2 1/9] MdeModulePkg: Add DisplayUpdateProgressLib class 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: Michael D Kinney , 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: Michael D Kinney 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 Add the DisplayUpdateProgressLib class that is used to inform the user of progress during updates of firmware images in firmware devices. A platform specific instance of this library can be used to customize how the user is informed of progress. Add the EDK II Firmware Management Progress Protocol. This is an optional protocol that must be installed onto the same handle as a Firmware Management Protocol. This new protocol provides the color of a progress bar that allows different firmware devices to use different colors during a firmware update. It also provides a watchdog timer value in seconds that is armed each time the Progress() service passed into Firmware Management Protocol SetImage() is called. Cc: Sean Brogan Cc: Star Zeng Cc: Eric Dong Signed-off-by: Michael D Kinney Contributed-under: TianoCore Contribution Agreement 1.1 Reviewed-by: Star Zeng --- .../Include/Library/DisplayUpdateProgressLib.h | 65 ++++++++++++++++++= ++++ .../Include/Protocol/FirmwareManagementProgress.h | 51 +++++++++++++++++ MdeModulePkg/MdeModulePkg.dec | 11 ++++ 3 files changed, 127 insertions(+) create mode 100644 MdeModulePkg/Include/Library/DisplayUpdateProgressLib.h create mode 100644 MdeModulePkg/Include/Protocol/FirmwareManagementProgres= s.h diff --git a/MdeModulePkg/Include/Library/DisplayUpdateProgressLib.h b/MdeM= odulePkg/Include/Library/DisplayUpdateProgressLib.h new file mode 100644 index 0000000000..ad1f2cae38 --- /dev/null +++ b/MdeModulePkg/Include/Library/DisplayUpdateProgressLib.h @@ -0,0 +1,65 @@ +/** @file + Provides services to display completion progress when processing a + firmware update that updates the firmware image in a firmware device. + A platform may provide its own instance of this library class to custoim= ize + how a user is informed of completion progress. + + Copyright (c) 2016, Microsoft Corporation + Copyright (c) 2018, Intel Corporation. All rights reserved.
+ + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are m= et: + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright not= ice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS = IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IM= PLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE D= ISCLAIMED. + IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY= DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCL= UDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF= USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY TH= EORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEG= LIGENCE + OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +**/ + +#ifndef __DISPLAY_PROGRESS_LIB__ +#define __DISPLAY_PROGRESS_LIB__ + +#include + +/** + Indicates the current completion progress of a firmware update. + + @param[in] Completion A value between 0 and 100 indicating the current + completion progress of a firmware update. This + value must the the same or higher than previous + calls to this service. The first call of 0 or a + value of 0 after reaching a value of 100 resets + the progress indicator to 0. + @param[in] Color Color of the progress indicator. Only used when + Completion is 0 to set the color of the progress + indicator. If Color is NULL, then the default co= lor + is used. + + @retval EFI_SUCCESS Progress displayed successfully. + @retval EFI_INVALID_PARAMETER Completion is not in range 0..100. + @retval EFI_INVALID_PARAMETER Completion is less than Completion value = from + a previous call to this service. + @retval EFI_NOT_READY The device used to indicate progress is n= ot + available. +**/ +EFI_STATUS +EFIAPI +DisplayUpdateProgress ( + IN UINTN Completion, + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *Color OPTIONAL + ); + +#endif diff --git a/MdeModulePkg/Include/Protocol/FirmwareManagementProgress.h b/M= deModulePkg/Include/Protocol/FirmwareManagementProgress.h new file mode 100644 index 0000000000..1d7dd19254 --- /dev/null +++ b/MdeModulePkg/Include/Protocol/FirmwareManagementProgress.h @@ -0,0 +1,51 @@ +/** @file + EDK II Firmware Management Progress Protocol. + + Copyright (c) 2018, Intel Corporation. All rights reserved.
+ This program and the accompanying materials are licensed and made availa= ble under + the terms and conditions of the BSD License that accompanies this distri= bution. + The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ + +#ifndef __EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL_H__ +#define __EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL_H__ + +#include + +/// +/// EDK II Firmware Management Progress Protocol GUID value +/// +#define EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL_GUID \ + { \ + 0x1849bda2, 0x6952, 0x4e86, { 0xa1, 0xdb, 0x55, 0x9a, 0x3c, 0x47, 0x9d= , 0xf1 } \ + } + +/// +/// EDK II Firmware Management Progress Protocol structure +/// +typedef struct { + /// + /// The foreground color of a progress bar that is used by the Progress() + /// function that is passed into the Firmware Management Protocol SetIma= ge() + /// service is called. + /// + EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION ProgressBarForegroundColor; + /// + /// The time in seconds to arm the watchdog timer each time the Progress= () + /// function passed into the Firmware Management Protocol SetImage() se= rvice + /// is called. + /// + UINTN WatchdogSeconds; +} EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL; + +/// +/// EDK II Firmware Management Progress Protocol GUID variable. +/// +extern EFI_GUID gEdkiiFirmwareManagementProgressProtocolGuid; + +#endif diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index cc397185f7..d4833ea178 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -175,6 +175,13 @@ [LibraryClasses] # BmpSupportLib|Include/Library/BmpSupportLib.h =20 + ## @libraryclass Provides services to display completion progress when + # processing a firmware update that updates the firmware image in a fir= mware + # device. A platform may provide its own instance of this library clas= s to + # custoimize how a user is informed of completion progress. + # + DisplayUpdateProgressLib|Include/Library/DisplayUpdateProgressLib.h + [Guids] ## MdeModule package token space guid # Include/Guid/MdeModulePkgTokenSpace.h @@ -595,6 +602,10 @@ [Protocols] gEdkiiPlatformSpecificResetFilterProtocolGuid =3D { 0x695d7835, 0x8d47,= 0x4c11, { 0xab, 0x22, 0xfa, 0x8a, 0xcc, 0xe7, 0xae, 0x7a } } ## Include/Protocol/PlatformSpecificResetHandler.h gEdkiiPlatformSpecificResetHandlerProtocolGuid =3D { 0x2df6ba0b, 0x7092,= 0x440d, { 0xbd, 0x4, 0xfb, 0x9, 0x1e, 0xc3, 0xf3, 0xc1 } } + + ## Include/Protocol/FirmwareManagementProgress.h + gEdkiiFirmwareManagementProgressProtocolGuid =3D { 0x1849bda2, 0x6952, 0= x4e86, { 0xa1, 0xdb, 0x55, 0x9a, 0x3c, 0x47, 0x9d, 0xf1 } } + # # [Error.gEfiMdeModulePkgTokenSpaceGuid] # 0x80000001 | Invalid value provided. --=20 2.14.2.windows.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Fri May 3 22:58:25 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 1523494124116188.3143361686598; Wed, 11 Apr 2018 17:48:44 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 6F613226CD79D; Wed, 11 Apr 2018 17:48:40 -0700 (PDT) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 A76E8226CD790 for ; Wed, 11 Apr 2018 17:48:38 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Apr 2018 17:48:38 -0700 Received: from mdkinney-mobl2.amr.corp.intel.com ([10.252.128.14]) by fmsmga006.fm.intel.com with ESMTP; 11 Apr 2018 17:48:37 -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=134.134.136.65; helo=mga03.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,438,1517904000"; d="scan'208";a="219727887" From: "Kinney, Michael D" To: edk2-devel@lists.01.org Date: Wed, 11 Apr 2018 17:48:23 -0700 Message-Id: <20180412004830.9904-3-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.14.2.windows.3 In-Reply-To: <20180412004830.9904-1-michael.d.kinney@intel.com> References: <20180412004830.9904-1-michael.d.kinney@intel.com> Subject: [edk2] [Patch V2 2/9] MdeModulePkg: Add DisplayUpdateProgressLib instances 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: Michael D Kinney , 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: Michael D Kinney 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 Add DisplayUpdateProgressLib instances for text consoles and graphical consoles. Cc: Sean Brogan Cc: Star Zeng Cc: Eric Dong Signed-off-by: Michael D Kinney Contributed-under: TianoCore Contribution Agreement 1.1 Reviewed-by: Star Zeng --- .../DisplayUpdateProgressLibGraphics.c | 475 +++++++++++++++++= ++++ .../DisplayUpdateProgressLibGraphics.inf | 60 +++ .../DisplayUpdateProgressLibGraphics.uni | 18 + .../DisplayUpdateProgressLibText.c | 174 ++++++++ .../DisplayUpdateProgressLibText.inf | 53 +++ .../DisplayUpdateProgressLibText.uni | 18 + MdeModulePkg/MdeModulePkg.dsc | 3 + 7 files changed, 801 insertions(+) create mode 100644 MdeModulePkg/Library/DisplayUpdateProgressLibGraphics/D= isplayUpdateProgressLibGraphics.c create mode 100644 MdeModulePkg/Library/DisplayUpdateProgressLibGraphics/D= isplayUpdateProgressLibGraphics.inf create mode 100644 MdeModulePkg/Library/DisplayUpdateProgressLibGraphics/D= isplayUpdateProgressLibGraphics.uni create mode 100644 MdeModulePkg/Library/DisplayUpdateProgressLibText/Displ= ayUpdateProgressLibText.c create mode 100644 MdeModulePkg/Library/DisplayUpdateProgressLibText/Displ= ayUpdateProgressLibText.inf create mode 100644 MdeModulePkg/Library/DisplayUpdateProgressLibText/Displ= ayUpdateProgressLibText.uni diff --git a/MdeModulePkg/Library/DisplayUpdateProgressLibGraphics/DisplayU= pdateProgressLibGraphics.c b/MdeModulePkg/Library/DisplayUpdateProgressLibG= raphics/DisplayUpdateProgressLibGraphics.c new file mode 100644 index 0000000000..007522cea0 --- /dev/null +++ b/MdeModulePkg/Library/DisplayUpdateProgressLibGraphics/DisplayUpdatePr= ogressLibGraphics.c @@ -0,0 +1,475 @@ +/** @file + Provides services to display completion progress of a firmware update on= a + graphical console that supports the Graphics Output Protocol. + + Copyright (c) 2016, Microsoft Corporation. All rights reserved.
+ Copyright (c) 2018, Intel Corporation. All rights reserved.
+ + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are m= et: + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright not= ice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS = IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IM= PLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE D= ISCLAIMED. + IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY= DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCL= UDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF= USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY TH= EORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEG= LIGENCE + OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +**/ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +// +// Values in percent of of logo height. +// +#define LOGO_BOTTOM_PADDING 20 +#define PROGRESS_BLOCK_HEIGHT 10 + +// +// Graphics Output Protocol instance to display progress bar +// +EFI_GRAPHICS_OUTPUT_PROTOCOL *mGop =3D NULL; + +// +// Set to 100 percent so it is reset on first call. +// +UINTN mPreviousProgress =3D 100; + +// +// Display coordinates for the progress bar. +// +UINTN mStartX =3D 0; +UINTN mStartY =3D 0; + +// +// Width and height of the progress bar. +// +UINTN mBlockWidth =3D 0; +UINTN mBlockHeight =3D 0; + +// +// GOP bitmap of the progress bar. Initialized on every new progress of 10= 0% +// +EFI_GRAPHICS_OUTPUT_BLT_PIXEL *mBlockBitmap; + +// +// GOP bitmap of the progress bar backround. Initialized once. +// +EFI_GRAPHICS_OUTPUT_BLT_PIXEL *mProgressBarBackground; + +// +// Default mask used to detect the left, right , top, and bottom of logo. = Only +// green and blue pixels are used for logo detection. +// +const EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION mLogoDetectionColorMask =3D { + { + 0xFF, // Blue + 0xFF, // Green + 0x00, // Red + 0x00 // Reserved + } +}; + +// +// Background color of progress bar. Grey. +// +const EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION mProgressBarBackgroundColor =3D= { + { + 0x80, // Blue + 0x80, // Green + 0x80, // Red + 0x00 // Reserved + } +}; + +// +// Default color of progress completion. White. +// +const EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION mProgressBarDefaultColor =3D { + { + 0xFF, // Blue + 0xFF, // Green + 0xFF, // Red + 0x00 // Reserved + } +}; + +// +// Set to TRUE if a valid Graphics Output Protocol is found and the progre= ss +// bar fits under the boot logo using the current graphics mode. +// +BOOLEAN mGraphicsGood =3D FALSE; + +/* + Internal function used to find the bounds of the white logo (on black or + red background). + + These bounds are then computed to find the block size, 0%, 100%, etc. + +*/ +VOID +FindDim ( + VOID + ) +{ + EFI_STATUS Status; + INTN LogoX; + INTN LogoStartX; + INTN LogoEndX; + INTN LogoY; + INTN LogoStartY; + INTN LogoEndY; + UINTN OffsetX; // Logo screen coordin= ate + UINTN OffsetY; // Logo screen coordin= ate + UINTN Width; // Width of logo in pi= xels + UINTN Height; // Height of logo in p= ixels + EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Logo; + EDKII_BOOT_LOGO2_PROTOCOL *BootLogo; + EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *Pixel; + + Logo =3D NULL; + BootLogo =3D NULL; + + // + // Return if a Graphics Output Protocol ha snot been found. + // + if (mGop =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "No GOP found. No progress bar support. \n")); + return; + } + + // + // Get boot logo protocol so we know where on the screen to grab + // + Status =3D gBS->LocateProtocol ( + &gEdkiiBootLogo2ProtocolGuid, + NULL, + (VOID **)&BootLogo + ); + if ((BootLogo =3D=3D NULL) || (EFI_ERROR (Status))) { + DEBUG ((DEBUG_ERROR, "Failed to locate gEdkiiBootLogo2ProtocolGuid. N= o Progress bar support. \n", Status)); + return; + } + + // + // Get logo location and size + // + Status =3D BootLogo->GetBootLogo ( + BootLogo, + &Logo, + &OffsetX, + &OffsetY, + &Width, + &Height + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to Get Boot Logo Status =3D %r. No Progr= ess bar support. \n", Status)); + return; + } + + // + // Within logo buffer find where the actual logo starts/ends + // + LogoEndX =3D 0; + LogoEndY =3D 0; + + // + // Find left side of logo in logo coordinates + // + for (LogoX =3D 0, LogoStartX =3D Width; LogoX < LogoStartX; LogoX++) { + Pixel =3D (EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *)(Logo + LogoX); + for (LogoY =3D 0; LogoY < (INTN)Height; LogoY++) { + if ((Pixel->Raw & mLogoDetectionColorMask.Raw) !=3D 0x0) { + LogoStartX =3D LogoX; + // + // For loop searches from right side back to this column. + // + LogoEndX =3D LogoX; + DEBUG ((DEBUG_INFO, "StartX found at (%d, %d) Color is: 0x%X \n", = LogoX, LogoY, Pixel->Raw)); + break; + } + Pixel =3D Pixel + Width; + } + } + + // + // Find right side of logo + // + for (LogoX =3D Width - 1; LogoX >=3D LogoEndX; LogoX--) { + Pixel =3D (EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *)(Logo + LogoX); + for (LogoY =3D 0; LogoY < (INTN)Height; LogoY++) { + if ((Pixel->Raw & mLogoDetectionColorMask.Raw) !=3D 0x0) { + LogoEndX =3D LogoX; + DEBUG ((DEBUG_INFO, "EndX found at (%d, %d) Color is: 0x%X \n", Lo= goX, LogoY, Pixel->Raw)); + break; + } + Pixel =3D Pixel + Width; + } + } + + // + // Compute mBlockWidth + // + mBlockWidth =3D ((LogoEndX - LogoStartX) + 99) / 100; + + // + // Adjust mStartX based on block width so it is centered under logo + // + mStartX =3D LogoStartX + OffsetX - (((mBlockWidth * 100) - (LogoEndX - L= ogoStartX)) / 2); + DEBUG ((DEBUG_INFO, "mBlockWidth set to 0x%X\n", mBlockWidth)); + DEBUG ((DEBUG_INFO, "mStartX set to 0x%X\n", mStartX)); + + // + // Find the top of the logo + // + for (LogoY =3D 0, LogoStartY =3D Height; LogoY < LogoStartY; LogoY++) { + Pixel =3D (EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *)(Logo + (Width * Logo= Y)); + for (LogoX =3D 0; LogoX < (INTN)Width; LogoX++) { + //not black or red + if ((Pixel->Raw & mLogoDetectionColorMask.Raw) !=3D 0x0) { + LogoStartY =3D LogoY; + LogoEndY =3D LogoY; //for next loop will search from bottom side b= ack to this row. + DEBUG ((DEBUG_INFO, "StartY found at (%d, %d) Color is: 0x%X \n", = LogoX, LogoY, Pixel->Raw)); + break; + } + Pixel++; + } + } + + // + // Find the bottom of the logo + // + for (LogoY =3D Height - 1; LogoY >=3D LogoEndY; LogoY--) { + Pixel =3D (EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *)(Logo + (Width * Logo= Y)); + for (LogoX =3D 0; LogoX < (INTN)Width; LogoX++) { + if ((Pixel->Raw & mLogoDetectionColorMask.Raw) !=3D 0x0) { + LogoEndY =3D LogoY; + DEBUG ((DEBUG_INFO, "EndY found at (%d, %d) Color is: 0x%X \n", Lo= goX, LogoY, Pixel->Raw)); + break; + } + Pixel++; + } + } + + // + // Compute bottom padding (distance between logo bottom and progress bar) + // + mStartY =3D (((LogoEndY - LogoStartY) * LOGO_BOTTOM_PADDING) / 100) + Lo= goEndY + OffsetY; + + // + // Compute progress bar height + // + mBlockHeight =3D (((LogoEndY - LogoStartY) * PROGRESS_BLOCK_HEIGHT) / 10= 0); + + DEBUG ((DEBUG_INFO, "mBlockHeight set to 0x%X\n", mBlockHeight)); + + // + // Create progress bar background (one time init). + // + mProgressBarBackground =3D AllocatePool (mBlockWidth * 100 * mBlockHeigh= t * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)); + if (mProgressBarBackground =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "Failed to allocate progress bar background\n")); + return; + } + + // + // Fill the progress bar with the background color + // + SetMem32 ( + mProgressBarBackground, + (mBlockWidth * 100 * mBlockHeight * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PI= XEL)), + mProgressBarBackgroundColor.Raw + ); + + // + // Allocate mBlockBitmap + // + mBlockBitmap =3D AllocatePool (mBlockWidth * mBlockHeight * sizeof (EFI_= GRAPHICS_OUTPUT_BLT_PIXEL)); + if (mBlockBitmap =3D=3D NULL) { + FreePool (mProgressBarBackground); + DEBUG ((DEBUG_ERROR, "Failed to allocate block\n")); + return; + } + + // + // Check screen width and height and make sure it fits. + // + if ((mBlockHeight > Height) || (mBlockWidth > Width) || (mBlockHeight < = 1) || (mBlockWidth < 1)) { + DEBUG ((DEBUG_ERROR, "DisplayUpdateProgressLib - Progress - Failed to = get valid width and height.\n")); + DEBUG ((DEBUG_ERROR, "DisplayUpdateProgressLib - Progress - mBlockHeig= ht: 0x%X mBlockWidth: 0x%X.\n", mBlockHeight, mBlockWidth)); + FreePool (mProgressBarBackground); + FreePool (mBlockBitmap); + return; + } + + mGraphicsGood =3D TRUE; +} + +/** + Function indicates the current completion progress of a firmware update. + Platform may override with its own specific function. + + @param[in] Completion A value between 0 and 100 indicating the current + completion progress of a firmware update. This + value must the the same or higher than previous + calls to this service. The first call of 0 or a + value of 0 after reaching a value of 100 resets + the progress indicator to 0. + @param[in] Color Color of the progress indicator. Only used when + Completion is 0 to set the color of the progress + indicator. If Color is NULL, then the default co= lor + is used. + + @retval EFI_SUCCESS Progress displayed successfully. + @retval EFI_INVALID_PARAMETER Completion is not in range 0..100. + @retval EFI_INVALID_PARAMETER Completion is less than Completion value = from + a previous call to this service. + @retval EFI_NOT_READY The device used to indicate progress is n= ot + available. +**/ +EFI_STATUS +EFIAPI +DisplayUpdateProgress ( + IN UINTN Completion, + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *Color OPTIONAL + ) +{ + EFI_STATUS Status; + UINTN PreX; + UINTN Index; + + // + // Check range + // + if (Completion > 100) { + return EFI_INVALID_PARAMETER; + } + + // + // Check to see if this Completion percentage has already been displayed + // + if (Completion =3D=3D mPreviousProgress) { + return EFI_SUCCESS; + } + + // + // Find Graphics Output Protocol if not already set. 1 time. + // + if (mGop =3D=3D NULL) { + Status =3D gBS->HandleProtocol ( + gST->ConsoleOutHandle, + &gEfiGraphicsOutputProtocolGuid, + (VOID**)&mGop + ); + if (EFI_ERROR (Status)) { + Status =3D gBS->LocateProtocol (&gEfiGraphicsOutputProtocolGuid, NUL= L, (VOID **)&mGop); + if (EFI_ERROR (Status)) { + mGop =3D NULL; + DEBUG ((DEBUG_ERROR, "Show Progress Function could not locate GOP.= Status =3D %r\n", Status)); + return EFI_NOT_READY; + } + } + + // + // Run once + // + FindDim (); + } + + // + // Make sure a valid start, end, and size info are available (find the L= ogo) + // + if (!mGraphicsGood) { + DEBUG ((DEBUG_INFO, "Graphics Not Good. Not doing any onscreen visual= display\n")); + return EFI_NOT_READY; + } + + // + // Do special init on first call of each progress session + // + if (mPreviousProgress =3D=3D 100) { + // + // Draw progress bar background + // + mGop->Blt ( + mGop, + mProgressBarBackground, + EfiBltBufferToVideo, + 0, + 0, + mStartX, + mStartY, + (mBlockWidth * 100), + mBlockHeight, + 0 + ); + + DEBUG ((DEBUG_VERBOSE, "Color is 0x%X\n", + (Color =3D=3D NULL) ? mProgressBarDefaultColor.Raw : Color->Raw + )); + + // + // Update block bitmap with correct color + // + SetMem32 ( + mBlockBitmap, + (mBlockWidth * mBlockHeight * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)= ), + (Color =3D=3D NULL) ? mProgressBarDefaultColor.Raw : Color->Raw + ); + + // + // Clear previous + // + mPreviousProgress =3D 0; + } + + // + // Can not update progress bar if Completion is less than previous + // + if (Completion < mPreviousProgress) { + DEBUG ((DEBUG_WARN, "WARNING: Completion (%d) should not be lesss than= Previous (%d)!!!\n", Completion, mPreviousProgress)); + return EFI_INVALID_PARAMETER; + } + + PreX =3D ((mPreviousProgress * mBlockWidth) + mStartX); + for (Index =3D 0; Index < (Completion - mPreviousProgress); Index++) { + // + // Show progress by coloring new area + // + mGop->Blt ( + mGop, + mBlockBitmap, + EfiBltBufferToVideo, + 0, + 0, + PreX, + mStartY, + mBlockWidth, + mBlockHeight, + 0 + ); + PreX +=3D mBlockWidth; + } + + mPreviousProgress =3D Completion; + + return EFI_SUCCESS; +} diff --git a/MdeModulePkg/Library/DisplayUpdateProgressLibGraphics/DisplayU= pdateProgressLibGraphics.inf b/MdeModulePkg/Library/DisplayUpdateProgressLi= bGraphics/DisplayUpdateProgressLibGraphics.inf new file mode 100644 index 0000000000..ada6076770 --- /dev/null +++ b/MdeModulePkg/Library/DisplayUpdateProgressLibGraphics/DisplayUpdatePr= ogressLibGraphics.inf @@ -0,0 +1,60 @@ +## @file +# Provides services to display completion progress of a firmware update o= n a +# graphical console that supports the Graphics Output Protocol. +# +# Copyright (c) 2016, Microsoft Corporation, All rights reserved.
+# Copyright (c) 2018, Intel Corporation. All rights reserved.
+# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are = met: +# 1. Redistributions of source code must retain the above copyright notic= e, +# this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright no= tice, +# this list of conditions and the following disclaimer in the documentati= on +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS= IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE I= MPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE = DISCLAIMED. +# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR AN= Y DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INC= LUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS O= F USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY T= HEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NE= GLIGENCE +# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN = IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D DisplayUpdateProgressLibGraphics + MODULE_UNI_FILE =3D DisplayUpdateProgressLibGraphics.uni + FILE_GUID =3D 319E9E37-B2D6-4699-90F3-B8B72B6D4CBD + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D DisplayUpdateProgressLib|DXE_DRIVER UEFI_DRIVER UEFI= _APPLICATION + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 IPF EBC +# + +[Sources] + DisplayUpdateProgressLibGraphics.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + BaseMemoryLib + DebugLib + MemoryAllocationLib + UefiBootServicesTableLib + BaseLib + UefiLib + +[Protocols] + gEfiGraphicsOutputProtocolGuid # CONSUMES + gEdkiiBootLogo2ProtocolGuid # CONSUMES diff --git a/MdeModulePkg/Library/DisplayUpdateProgressLibGraphics/DisplayU= pdateProgressLibGraphics.uni b/MdeModulePkg/Library/DisplayUpdateProgressLi= bGraphics/DisplayUpdateProgressLibGraphics.uni new file mode 100644 index 0000000000..d7da641338 --- /dev/null +++ b/MdeModulePkg/Library/DisplayUpdateProgressLibGraphics/DisplayUpdatePr= ogressLibGraphics.uni @@ -0,0 +1,18 @@ +// /** @file +// Provides services to display completion progress of a firmware update = on a +// graphical console that supports the Graphics Output Protocol. +// +// Copyright (c) 2018, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the B= SD License +// which accompanies this distribution. The full text of the license may b= e found at +// http://opensource.org/licenses/bsd-license.php +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +// +// **/ + +#string STR_MODULE_ABSTRACT #language en-US "Provides services to dis= play completion progress of a firmware update on a graphical console that s= upports the Graphics Output Protocol." + +#string STR_MODULE_DESCRIPTION #language en-US "Provides services to dis= play completion progress of a firmware update on a graphical console that s= upports the Graphics Output Protocol." diff --git a/MdeModulePkg/Library/DisplayUpdateProgressLibText/DisplayUpdat= eProgressLibText.c b/MdeModulePkg/Library/DisplayUpdateProgressLibText/Disp= layUpdateProgressLibText.c new file mode 100644 index 0000000000..7aca8b89d0 --- /dev/null +++ b/MdeModulePkg/Library/DisplayUpdateProgressLibText/DisplayUpdateProgre= ssLibText.c @@ -0,0 +1,174 @@ +/** @file + Provides services to display completion progress of a firmware update on= a + text console. + + Copyright (c) 2016, Microsoft Corporation. All rights reserved.
+ Copyright (c) 2018, Intel Corporation. All rights reserved.
+ + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are m= et: + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright not= ice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS = IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IM= PLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE D= ISCLAIMED. + IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY= DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCL= UDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF= USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY TH= EORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEG= LIGENCE + OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +**/ + +#include +#include +#include +#include + +// +// Control Style. Set to 100 so it is reset on first call. +// +UINTN mPreviousProgress =3D 100; + +// +// Text foreground color of progress bar +// +UINTN mProgressBarForegroundColor; + +/** + Function indicates the current completion progress of a firmware update. + Platform may override with its own specific function. + + @param[in] Completion A value between 0 and 100 indicating the current + completion progress of a firmware update. This + value must the the same or higher than previous + calls to this service. The first call of 0 or a + value of 0 after reaching a value of 100 resets + the progress indicator to 0. + @param[in] Color Color of the progress indicator. Only used when + Completion is 0 to set the color of the progress + indicator. If Color is NULL, then the default co= lor + is used. + + @retval EFI_SUCCESS Progress displayed successfully. + @retval EFI_INVALID_PARAMETER Completion is not in range 0..100. + @retval EFI_INVALID_PARAMETER Completion is less than Completion value = from + a previous call to this service. + @retval EFI_NOT_READY The device used to indicate progress is n= ot + available. +**/ +EFI_STATUS +EFIAPI +DisplayUpdateProgress ( + IN UINTN Completion, + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *Color OPTIONAL + ) +{ + UINTN Index; + UINTN CurrentAttribute; + + // + // Check range + // + if (Completion > 100) { + return EFI_INVALID_PARAMETER; + } + + // + // Check to see if this Completion percentage has already been displayed + // + if (Completion =3D=3D mPreviousProgress) { + return EFI_SUCCESS; + } + + // + // Do special init on first call of each progress session + // + if (mPreviousProgress =3D=3D 100) { + Print (L"\n"); + + // + // Convert pixel color to text foreground color + // + if (Color =3D=3D NULL) { + mProgressBarForegroundColor =3D EFI_WHITE; + } else { + mProgressBarForegroundColor =3D EFI_BLACK; + if (Color->Pixel.Blue >=3D 0x40) { + mProgressBarForegroundColor |=3D EFI_BLUE; + } + if (Color->Pixel.Green >=3D 0x40) { + mProgressBarForegroundColor |=3D EFI_GREEN; + } + if (Color->Pixel.Red >=3D 0x40) { + mProgressBarForegroundColor |=3D EFI_RED; + } + if (Color->Pixel.Blue >=3D 0xC0 || Color->Pixel.Green >=3D 0xC0 || C= olor->Pixel.Red >=3D 0xC0) { + mProgressBarForegroundColor |=3D EFI_BRIGHT; + } + if (mProgressBarForegroundColor =3D=3D EFI_BLACK) { + mProgressBarForegroundColor =3D EFI_WHITE; + } + } + + // + // Clear previous + // + mPreviousProgress =3D 0; + } + + // + // Can not update progress bar if Completion is less than previous + // + if (Completion < mPreviousProgress) { + DEBUG ((DEBUG_WARN, "WARNING: Completion (%d) should not be lesss than= Previous (%d)!!!\n", Completion, mPreviousProgress)); + return EFI_INVALID_PARAMETER; + } + + // + // Save current text color + // + CurrentAttribute =3D (UINTN)gST->ConOut->Mode->Attribute; + + // + // Print progress percentage + // + Print (L"\rUpdate Progress - %3d%% ", Completion); + + // + // Set progress bar color + // + gST->ConOut->SetAttribute ( + gST->ConOut, + EFI_TEXT_ATTR (mProgressBarForegroundColor, EFI_BLACK) + ); + + // + // Print completed portion of progress bar + // + for (Index =3D 0; Index < Completion / 2; Index++) { + Print (L"%c", BLOCKELEMENT_FULL_BLOCK); + } + + // + // Restore text color + // + gST->ConOut->SetAttribute (gST->ConOut, CurrentAttribute); + + // + // Print remaining portion of progress bar + // + for (; Index < 50; Index++) { + Print (L"%c", BLOCKELEMENT_LIGHT_SHADE); + } + + mPreviousProgress =3D Completion; + + return EFI_SUCCESS; +} diff --git a/MdeModulePkg/Library/DisplayUpdateProgressLibText/DisplayUpdat= eProgressLibText.inf b/MdeModulePkg/Library/DisplayUpdateProgressLibText/Di= splayUpdateProgressLibText.inf new file mode 100644 index 0000000000..c3134439e4 --- /dev/null +++ b/MdeModulePkg/Library/DisplayUpdateProgressLibText/DisplayUpdateProgre= ssLibText.inf @@ -0,0 +1,53 @@ +## @file +# Provides services to display completion progress of a firmware update o= n a +# text console. +# +# Copyright (c) 2016, Microsoft Corporation, All rights reserved.
+# Copyright (c) 2018, Intel Corporation. All rights reserved.
+# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are = met: +# 1. Redistributions of source code must retain the above copyright notic= e, +# this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright no= tice, +# this list of conditions and the following disclaimer in the documentati= on +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS= IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE I= MPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE = DISCLAIMED. +# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR AN= Y DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INC= LUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS O= F USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY T= HEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NE= GLIGENCE +# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN = IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D DisplayUpdateProgressLibText + MODULE_UNI_FILE =3D DisplayUpdateProgressLibText.uni + FILE_GUID =3D CDEF83AE-1900-4B41-BF47-AAE9BD729CA5 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D DisplayUpdateProgressLib|DXE_DRIVER UEFI_DRIVER UEFI= _APPLICATION + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 IPF EBC +# + +[Sources] + DisplayUpdateProgressLibText.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + DebugLib + UefiBootServicesTableLib + UefiLib diff --git a/MdeModulePkg/Library/DisplayUpdateProgressLibText/DisplayUpdat= eProgressLibText.uni b/MdeModulePkg/Library/DisplayUpdateProgressLibText/Di= splayUpdateProgressLibText.uni new file mode 100644 index 0000000000..3c783722bc --- /dev/null +++ b/MdeModulePkg/Library/DisplayUpdateProgressLibText/DisplayUpdateProgre= ssLibText.uni @@ -0,0 +1,18 @@ +// /** @file +// Provides services to display completion progress of a firmware update = on a +// text console. +// +// Copyright (c) 2018, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the B= SD License +// which accompanies this distribution. The full text of the license may b= e found at +// http://opensource.org/licenses/bsd-license.php +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +// +// **/ + +#string STR_MODULE_ABSTRACT #language en-US "Provides services to dis= play completion progress of a firmware update on a text console." + +#string STR_MODULE_DESCRIPTION #language en-US "Provides services to dis= play completion progress of a firmware update on a text console." diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc index ec24a50c7d..b4e8a703af 100644 --- a/MdeModulePkg/MdeModulePkg.dsc +++ b/MdeModulePkg/MdeModulePkg.dsc @@ -108,6 +108,7 @@ [LibraryClasses] CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.i= nf SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf + DisplayUpdateProgressLib|MdeModulePkg/Library/DisplayUpdateProgressLibGr= aphics/DisplayUpdateProgressLibGraphics.inf =20 [LibraryClasses.EBC.PEIM] IoLib|MdePkg/Library/PeiIoLibCpuIo/PeiIoLibCpuIo.inf @@ -327,6 +328,8 @@ [Components] MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf MdeModulePkg/Library/NonDiscoverableDeviceRegistrationLib/NonDiscoverabl= eDeviceRegistrationLib.inf MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf + MdeModulePkg/Library/DisplayUpdateProgressLibGraphics/DisplayUpdateProgr= essLibGraphics.inf + MdeModulePkg/Library/DisplayUpdateProgressLibText/DisplayUpdateProgressL= ibText.inf =20 MdeModulePkg/Universal/BdsDxe/BdsDxe.inf MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf --=20 2.14.2.windows.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Fri May 3 22:58:25 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 1523494126713423.9982316789092; Wed, 11 Apr 2018 17:48:46 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9AD17226CD7A2; Wed, 11 Apr 2018 17:48:40 -0700 (PDT) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 64108226CD79A for ; Wed, 11 Apr 2018 17:48:39 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Apr 2018 17:48:39 -0700 Received: from mdkinney-mobl2.amr.corp.intel.com ([10.252.128.14]) by fmsmga006.fm.intel.com with ESMTP; 11 Apr 2018 17:48:38 -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=134.134.136.65; helo=mga03.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,438,1517904000"; d="scan'208";a="219727905" From: "Kinney, Michael D" To: edk2-devel@lists.01.org Date: Wed, 11 Apr 2018 17:48:24 -0700 Message-Id: <20180412004830.9904-4-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.14.2.windows.3 In-Reply-To: <20180412004830.9904-1-michael.d.kinney@intel.com> References: <20180412004830.9904-1-michael.d.kinney@intel.com> Subject: [edk2] [Patch V2 3/9] Vlv2Tbl2DevicePkg: Add DisplayUpdateProgressLib mapping 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: Michael D Kinney , David Wei 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: Michael D Kinney 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 Cc: Sean Brogan Cc: David Wei Cc: Mang Guo Signed-off-by: Michael D Kinney Contributed-under: TianoCore Contribution Agreement 1.1 Reviewed-by: David Wei Reviewed-by: Star Zeng --- Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc | 1 + Vlv2TbltDevicePkg/PlatformPkgIA32.dsc | 1 + Vlv2TbltDevicePkg/PlatformPkgX64.dsc | 1 + 3 files changed, 3 insertions(+) diff --git a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc b/Vlv2TbltDevicePkg/Pl= atformPkgGccX64.dsc index f918e44851..b6741257e7 100644 --- a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc +++ b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc @@ -195,6 +195,7 @@ [LibraryClasses.common] IniParsingLib|SignedCapsulePkg/Library/IniParsingLib/IniParsingLib.inf PlatformFlashAccessLib|Vlv2TbltDevicePkg/Feature/Capsule/Library/Platfor= mFlashAccessLib/PlatformFlashAccessLib.inf MicrocodeFlashAccessLib|Vlv2TbltDevicePkg/Feature/Capsule/Library/Platfo= rmFlashAccessLib/PlatformFlashAccessLib.inf + DisplayUpdateProgressLib|MdeModulePkg/Library/DisplayUpdateProgressLibGr= aphics/DisplayUpdateProgressLibGraphics.inf LanguageLib|EdkCompatibilityPkg/Compatibility/Library/UefiLanguageLib/Ue= fiLanguageLib.inf SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchroniza= tionLib.inf SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeS= ecurityManagementLib.inf diff --git a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc b/Vlv2TbltDevicePkg/Plat= formPkgIA32.dsc index 0a95d95557..bd276f0643 100644 --- a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc +++ b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc @@ -195,6 +195,7 @@ [LibraryClasses.common] IniParsingLib|SignedCapsulePkg/Library/IniParsingLib/IniParsingLib.inf PlatformFlashAccessLib|Vlv2TbltDevicePkg/Feature/Capsule/Library/Platfor= mFlashAccessLib/PlatformFlashAccessLib.inf MicrocodeFlashAccessLib|Vlv2TbltDevicePkg/Feature/Capsule/Library/Platfo= rmFlashAccessLib/PlatformFlashAccessLib.inf + DisplayUpdateProgressLib|MdeModulePkg/Library/DisplayUpdateProgressLibGr= aphics/DisplayUpdateProgressLibGraphics.inf LanguageLib|EdkCompatibilityPkg/Compatibility/Library/UefiLanguageLib/Ue= fiLanguageLib.inf SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchroniza= tionLib.inf SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeS= ecurityManagementLib.inf diff --git a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc b/Vlv2TbltDevicePkg/Platf= ormPkgX64.dsc index fb2743c727..042a35b2b7 100644 --- a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc +++ b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc @@ -195,6 +195,7 @@ [LibraryClasses.common] IniParsingLib|SignedCapsulePkg/Library/IniParsingLib/IniParsingLib.inf PlatformFlashAccessLib|Vlv2TbltDevicePkg/Feature/Capsule/Library/Platfor= mFlashAccessLib/PlatformFlashAccessLib.inf MicrocodeFlashAccessLib|Vlv2TbltDevicePkg/Feature/Capsule/Library/Platfo= rmFlashAccessLib/PlatformFlashAccessLib.inf + DisplayUpdateProgressLib|MdeModulePkg/Library/DisplayUpdateProgressLibGr= aphics/DisplayUpdateProgressLibGraphics.inf LanguageLib|EdkCompatibilityPkg/Compatibility/Library/UefiLanguageLib/Ue= fiLanguageLib.inf SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchroniza= tionLib.inf SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeS= ecurityManagementLib.inf --=20 2.14.2.windows.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Fri May 3 22:58:25 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 152349412889057.82732012043766; Wed, 11 Apr 2018 17:48:48 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id C3645226CD7A5; Wed, 11 Apr 2018 17:48:40 -0700 (PDT) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 1F3C9226CD79C for ; Wed, 11 Apr 2018 17:48:40 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Apr 2018 17:48:39 -0700 Received: from mdkinney-mobl2.amr.corp.intel.com ([10.252.128.14]) by fmsmga006.fm.intel.com with ESMTP; 11 Apr 2018 17:48:39 -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=134.134.136.65; helo=mga03.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,438,1517904000"; d="scan'208";a="219727908" From: "Kinney, Michael D" To: edk2-devel@lists.01.org Date: Wed, 11 Apr 2018 17:48:25 -0700 Message-Id: <20180412004830.9904-5-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.14.2.windows.3 In-Reply-To: <20180412004830.9904-1-michael.d.kinney@intel.com> References: <20180412004830.9904-1-michael.d.kinney@intel.com> Subject: [edk2] [Patch V2 4/9] QuarkPlatformPkg: Add DisplayUpdateProgressLib mapping 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: Michael D Kinney 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" 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 Cc: Sean Brogan Cc: Kelly Steele Signed-off-by: Michael D Kinney Contributed-under: TianoCore Contribution Agreement 1.1 Reviewed-by: Star Zeng --- QuarkPlatformPkg/Quark.dsc | 1 + 1 file changed, 1 insertion(+) diff --git a/QuarkPlatformPkg/Quark.dsc b/QuarkPlatformPkg/Quark.dsc index a43a5595d4..14142087bd 100644 --- a/QuarkPlatformPkg/Quark.dsc +++ b/QuarkPlatformPkg/Quark.dsc @@ -241,6 +241,7 @@ [LibraryClasses] FmpAuthenticationLib|MdeModulePkg/Library/FmpAuthenticationLibNull/FmpAu= thenticationLibNull.inf IniParsingLib|SignedCapsulePkg/Library/IniParsingLib/IniParsingLib.inf PlatformFlashAccessLib|QuarkPlatformPkg/Feature/Capsule/Library/Platform= FlashAccessLib/PlatformFlashAccessLibDxe.inf + DisplayUpdateProgressLib|MdeModulePkg/Library/DisplayUpdateProgressLibTe= xt/DisplayUpdateProgressLibText.inf =20 [LibraryClasses.common.SEC] # --=20 2.14.2.windows.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Fri May 3 22:58:25 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 1523494131614420.89941531417276; Wed, 11 Apr 2018 17:48:51 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E8877226CD7AB; Wed, 11 Apr 2018 17:48:41 -0700 (PDT) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 000B5226CD7A1 for ; Wed, 11 Apr 2018 17:48:40 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Apr 2018 17:48:40 -0700 Received: from mdkinney-mobl2.amr.corp.intel.com ([10.252.128.14]) by fmsmga006.fm.intel.com with ESMTP; 11 Apr 2018 17:48:40 -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=134.134.136.65; helo=mga03.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,438,1517904000"; d="scan'208";a="219727916" From: "Kinney, Michael D" To: edk2-devel@lists.01.org Date: Wed, 11 Apr 2018 17:48:26 -0700 Message-Id: <20180412004830.9904-6-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.14.2.windows.3 In-Reply-To: <20180412004830.9904-1-michael.d.kinney@intel.com> References: <20180412004830.9904-1-michael.d.kinney@intel.com> Subject: [edk2] [Patch V2 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: Michael D Kinney , 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" 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 Reviewed-by: Star Zeng --- .../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..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. =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->ProgressBarForegroundColor; + } + + // + // 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 From nobody Fri May 3 22:58:25 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 1523494134115521.9633393596034; Wed, 11 Apr 2018 17:48:54 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 22534226CD786; Wed, 11 Apr 2018 17:48:43 -0700 (PDT) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 8100D226CD7A9 for ; Wed, 11 Apr 2018 17:48:41 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Apr 2018 17:48:41 -0700 Received: from mdkinney-mobl2.amr.corp.intel.com ([10.252.128.14]) by fmsmga006.fm.intel.com with ESMTP; 11 Apr 2018 17:48:40 -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=134.134.136.65; helo=mga03.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,438,1517904000"; d="scan'208";a="219727921" From: "Kinney, Michael D" To: edk2-devel@lists.01.org Date: Wed, 11 Apr 2018 17:48:27 -0700 Message-Id: <20180412004830.9904-7-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.14.2.windows.3 In-Reply-To: <20180412004830.9904-1-michael.d.kinney@intel.com> References: <20180412004830.9904-1-michael.d.kinney@intel.com> Subject: [edk2] [Patch V2 6/9] SignedCapsulePkg/PlatformFlashAccessLib: Add progress API 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: Michael D Kinney , Jiewen Yao 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: Michael D Kinney https://bugzilla.tianocore.org/show_bug.cgi?id=3D801 Add a new API to the PlatformFlashAccessLib that passes in an optional Progress() function along with a start and end percentage to call the Progress() function with. If the Progress() function is not NULL, then it is the Progress() function that was passed into the Firmware Management Protocol SetImage() services and is used to update the user on the progress as a firmware device is updated with a firmware image. Implementations of the PlatformFlashAccessLib are recommended to call the Progress() function as work is performed to update to contents of a firmware storage device. Cc: Jiewen Yao Signed-off-by: Michael D Kinney Contributed-under: TianoCore Contribution Agreement 1.1 Reviewed-by: Star Zeng --- .../Include/Library/PlatformFlashAccessLib.h | 49 ++++++++++++++- .../PlatformFlashAccessLibNull.c | 70 ++++++++++++++++++= +--- 2 files changed, 110 insertions(+), 9 deletions(-) diff --git a/SignedCapsulePkg/Include/Library/PlatformFlashAccessLib.h b/Si= gnedCapsulePkg/Include/Library/PlatformFlashAccessLib.h index 0a8858e4c4..e3308251c2 100644 --- a/SignedCapsulePkg/Include/Library/PlatformFlashAccessLib.h +++ b/SignedCapsulePkg/Include/Library/PlatformFlashAccessLib.h @@ -1,7 +1,7 @@ /** @file Platform flash device access library. =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 @@ -16,6 +16,8 @@ #ifndef __PLATFORM_FLASH_ACCESS_LIB_H__ #define __PLATFORM_FLASH_ACCESS_LIB_H__ =20 +#include + typedef enum { FlashAddressTypeRelativeAddress, FlashAddressTypeAbsoluteAddress, @@ -31,7 +33,7 @@ typedef enum { } PLATFORM_FIRMWARE_TYPE; =20 /** - Perform flash write opreation. + Perform flash write operation. =20 @param[in] FirmwareType The type of firmware. @param[in] FlashAddress The address of flash device to be accessed. @@ -54,4 +56,47 @@ PerformFlashWrite ( IN UINTN Length ); =20 +/** + Perform flash write operation with progress indicator. The start and end + completion percentage values are passed into this function. If the requ= ested + flash write operation is broken up, then completion percentage between t= he + start and end values may be passed to the provided Progress function. T= he + caller of this function is required to call the Progress function for the + start and end completion percentage values. This allows the Progress, + StartPercentage, and EndPercentage parameters to be ignored if the reque= sted + flash write operation can not be broken up + + @param[in] FirmwareType The type of firmware. + @param[in] FlashAddress The address of flash device to be accessed. + @param[in] FlashAddressType The type of flash device address. + @param[in] Buffer The pointer to the data buffer. + @param[in] Length The length of data buffer in bytes. + @param[in] Progress A function used report the progress of the + firmware update. This is an optional param= eter + that may be NULL. + @param[in] StartPercentage The start completion percentage value that = may + be used to report progress during the flash + write operation. + @param[in] EndPercentage The end completion percentage value that may + be used to report progress during the flash + write operation. + + @retval EFI_SUCCESS The operation returns successfully. + @retval EFI_WRITE_PROTECTED The flash device is read only. + @retval EFI_UNSUPPORTED The flash device access is unsupported. + @retval EFI_INVALID_PARAMETER The input parameter is not valid. +**/ +EFI_STATUS +EFIAPI +PerformFlashWriteWithProgress ( + IN PLATFORM_FIRMWARE_TYPE FirmwareType, + IN EFI_PHYSICAL_ADDRESS FlashAddress, + IN FLASH_ADDRESS_TYPE FlashAddressType, + IN VOID *Buffer, + IN UINTN Length, + IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress, OPTIO= NAL + IN UINTN StartPercentage, + IN UINTN EndPercentage + ); + #endif diff --git a/SignedCapsulePkg/Library/PlatformFlashAccessLibNull/PlatformFl= ashAccessLibNull.c b/SignedCapsulePkg/Library/PlatformFlashAccessLibNull/Pl= atformFlashAccessLibNull.c index b34ebbba1e..854f108cf4 100644 --- a/SignedCapsulePkg/Library/PlatformFlashAccessLibNull/PlatformFlashAcce= ssLibNull.c +++ b/SignedCapsulePkg/Library/PlatformFlashAccessLibNull/PlatformFlashAcce= ssLibNull.c @@ -1,7 +1,7 @@ /** @file Platform flash device access library NULL instance. =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 @@ -20,7 +20,57 @@ UINT64 mInternalFdAddress; =20 /** - Perform flash write opreation. + Perform flash write operation with progress indicator. The start and end + completion percentage values are passed into this function. If the requ= ested + flash write operation is broken up, then completion percentage between t= he + start and end values may be passed to the provided Progress function. T= he + caller of this function is required to call the Progress function for the + start and end completion percentage values. This allows the Progress, + StartPercentage, and EndPercentage parameters to be ignored if the reque= sted + flash write operation can not be broken up + + @param[in] FirmwareType The type of firmware. + @param[in] FlashAddress The address of flash device to be accessed. + @param[in] FlashAddressType The type of flash device address. + @param[in] Buffer The pointer to the data buffer. + @param[in] Length The length of data buffer in bytes. + @param[in] Progress A function used report the progress of the + firmware update. This is an optional param= eter + that may be NULL. + @param[in] StartPercentage The start completion percentage value that = may + be used to report progress during the flash + write operation. + @param[in] EndPercentage The end completion percentage value that may + be used to report progress during the flash + write operation. + + @retval EFI_SUCCESS The operation returns successfully. + @retval EFI_WRITE_PROTECTED The flash device is read only. + @retval EFI_UNSUPPORTED The flash device access is unsupported. + @retval EFI_INVALID_PARAMETER The input parameter is not valid. +**/ +EFI_STATUS +EFIAPI +PerformFlashWriteWithProgress ( + IN PLATFORM_FIRMWARE_TYPE FirmwareType, + IN EFI_PHYSICAL_ADDRESS FlashAddress, + IN FLASH_ADDRESS_TYPE FlashAddressType, + IN VOID *Buffer, + IN UINTN Length, + IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress, OPTIO= NAL + IN UINTN StartPercentage, + IN UINTN EndPercentage + ) +{ + if (FlashAddressType =3D=3D FlashAddressTypeRelativeAddress) { + FlashAddress =3D FlashAddress + mInternalFdAddress; + } + CopyMem((VOID *)(UINTN)(FlashAddress), Buffer, Length); + return EFI_SUCCESS; +} + +/** + Perform flash write operation. =20 @param[in] FirmwareType The type of firmware. @param[in] FlashAddress The address of flash device to be accessed. @@ -43,9 +93,15 @@ PerformFlashWrite ( IN UINTN Length ) { - if (FlashAddressType =3D=3D FlashAddressTypeRelativeAddress) { - FlashAddress =3D FlashAddress + mInternalFdAddress; - } - CopyMem((VOID *)(UINTN)(FlashAddress), Buffer, Length); - return EFI_SUCCESS; + return PerformFlashWriteWithProgress ( + FirmwareType, + FlashAddress, + FlashAddressType, + Buffer, + Length, + NULL, + 0, + 0 + ); } + --=20 2.14.2.windows.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Fri May 3 22:58:25 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 1523494136829166.2534857670055; Wed, 11 Apr 2018 17:48:56 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 4F6E0226CD7B1; Wed, 11 Apr 2018 17:48:43 -0700 (PDT) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 328BC226CD7AA for ; Wed, 11 Apr 2018 17:48:42 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Apr 2018 17:48:42 -0700 Received: from mdkinney-mobl2.amr.corp.intel.com ([10.252.128.14]) by fmsmga006.fm.intel.com with ESMTP; 11 Apr 2018 17:48:41 -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=134.134.136.65; helo=mga03.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,438,1517904000"; d="scan'208";a="219727924" From: "Kinney, Michael D" To: edk2-devel@lists.01.org Date: Wed, 11 Apr 2018 17:48:28 -0700 Message-Id: <20180412004830.9904-8-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.14.2.windows.3 In-Reply-To: <20180412004830.9904-1-michael.d.kinney@intel.com> References: <20180412004830.9904-1-michael.d.kinney@intel.com> Subject: [edk2] [Patch V2 7/9] Vlv2TbltDevicePkg/PlatformFlashAccessLib: Add progress API 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: Michael D Kinney , David Wei 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: Michael D Kinney https://bugzilla.tianocore.org/show_bug.cgi?id=3D801 Add PerformFlashWriteWithProgress() to the PlatformFlashAccessLib. This allows the platform to inform the user of progress when a firmware storage device is being updated with a new firmware image. Cc: David Wei Cc: Mang Guo Signed-off-by: Michael D Kinney Contributed-under: TianoCore Contribution Agreement 1.1 Reviewed-by: David Wei Reviewed-by: Star Zeng --- .../PlatformFlashAccessLib.c | 102 +++++++++++++++--= ---- .../PlatformFlashAccessLib.inf | 3 +- 2 files changed, 77 insertions(+), 28 deletions(-) diff --git a/Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessL= ib/PlatformFlashAccessLib.c b/Vlv2TbltDevicePkg/Feature/Capsule/Library/Pla= tformFlashAccessLib/PlatformFlashAccessLib.c index 9162e025ed..06278d202a 100644 --- a/Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/Plat= formFlashAccessLib.c +++ b/Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/Plat= formFlashAccessLib.c @@ -1,7 +1,7 @@ /** @file Platform Flash Access library. =20 - Copyright (c) 2017, 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 @@ -381,13 +381,29 @@ InternalWriteBlock ( } =20 /** - Perform flash write opreation. + Perform flash write operation with progress indicator. The start and end + completion percentage values are passed into this function. If the requ= ested + flash write operation is broken up, then completion percentage between t= he + start and end values may be passed to the provided Progress function. T= he + caller of this function is required to call the Progress function for the + start and end completion percentage values. This allows the Progress, + StartPercentage, and EndPercentage parameters to be ignored if the reque= sted + flash write operation can not be broken up =20 @param[in] FirmwareType The type of firmware. @param[in] FlashAddress The address of flash device to be accessed. @param[in] FlashAddressType The type of flash device address. @param[in] Buffer The pointer to the data buffer. @param[in] Length The length of data buffer in bytes. + @param[in] Progress A function used report the progress of the + firmware update. This is an optional param= eter + that may be NULL. + @param[in] StartPercentage The start completion percentage value that = may + be used to report progress during the flash + write operation. + @param[in] EndPercentage The end completion percentage value that may + be used to report progress during the flash + write operation. =20 @retval EFI_SUCCESS The operation returns successfully. @retval EFI_WRITE_PROTECTED The flash device is read only. @@ -396,12 +412,15 @@ InternalWriteBlock ( **/ EFI_STATUS EFIAPI -PerformFlashWrite ( - IN PLATFORM_FIRMWARE_TYPE FirmwareType, - IN EFI_PHYSICAL_ADDRESS FlashAddress, - IN FLASH_ADDRESS_TYPE FlashAddressType, - IN VOID *Buffer, - IN UINTN Length +PerformFlashWriteWithProgress ( + IN PLATFORM_FIRMWARE_TYPE FirmwareType, + IN EFI_PHYSICAL_ADDRESS FlashAddress, + IN FLASH_ADDRESS_TYPE FlashAddressType, + IN VOID *Buffer, + IN UINTN Length, + IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress, OPTIO= NAL + IN UINTN StartPercentage, + IN UINTN EndPercentage ) { EFI_STATUS Status =3D EFI_SUCCESS; @@ -456,42 +475,40 @@ PerformFlashWrite ( // Raise TPL to TPL_NOTIFY to block any event handler, // while still allowing RaiseTPL(TPL_NOTIFY) within // output driver during Print() - // + // OldTpl =3D gBS->RaiseTPL (TPL_NOTIFY); for (Index =3D 0; Index < CountOfBlocks; Index++) { + if (Progress !=3D NULL) { + Progress (StartPercentage + ((Index * (EndPercentage - StartPercen= tage)) / CountOfBlocks)); + } // // Handle block based on address and contents. // if (!EFI_ERROR (InternalCompareBlock (Address, Buf))) { DEBUG((DEBUG_INFO, "Skipping block at 0x%lx (already programmed)\n= ", Address)); } else { - // - // Display a dot for each block being updated. - // - Print (L"."); - // // Make updating process uninterruptable, // so that the flash memory area is not accessed by other entities // which may interfere with the updating process // Status =3D InternalEraseBlock (Address); - if (EFI_ERROR(Status)) { + if (EFI_ERROR(Status)) { gBS->RestoreTPL (OldTpl); FlashError =3D TRUE; goto Done; - } + } Status =3D InternalWriteBlock ( Address, Buf, (UINT32)(Length > BLOCK_SIZE ? BLOCK_SIZE : Length) ); - if (EFI_ERROR(Status)) { + if (EFI_ERROR(Status)) { gBS->RestoreTPL (OldTpl); FlashError =3D TRUE; goto Done; } - } + } =20 // // Move to next block to update. @@ -506,26 +523,59 @@ PerformFlashWrite ( } gBS->RestoreTPL (OldTpl); =20 - Done: +Done: if ((BiosCntl & B_PCH_LPC_BIOS_CNTL_SMM_BWP) =3D=3D B_PCH_LPC_BIOS_CNTL_= SMM_BWP) { // // Restore original control setting // MmioWrite8 (LpcBaseAddress + R_PCH_LPC_BIOS_CNTL, BiosCntl); - } + } =20 - // - // Print flash update failure message if error detected. - // - if (FlashError) { - Print (L"No %r\n", Status); + if (Progress !=3D NULL) { + Progress (EndPercentage); } =20 return EFI_SUCCESS; } =20 /** - Perform microcode write opreation. + Perform flash write operation. + + @param[in] FirmwareType The type of firmware. + @param[in] FlashAddress The address of flash device to be accessed. + @param[in] FlashAddressType The type of flash device address. + @param[in] Buffer The pointer to the data buffer. + @param[in] Length The length of data buffer in bytes. + + @retval EFI_SUCCESS The operation returns successfully. + @retval EFI_WRITE_PROTECTED The flash device is read only. + @retval EFI_UNSUPPORTED The flash device access is unsupported. + @retval EFI_INVALID_PARAMETER The input parameter is not valid. +**/ +EFI_STATUS +EFIAPI +PerformFlashWrite ( + IN PLATFORM_FIRMWARE_TYPE FirmwareType, + IN EFI_PHYSICAL_ADDRESS FlashAddress, + IN FLASH_ADDRESS_TYPE FlashAddressType, + IN VOID *Buffer, + IN UINTN Length + ) +{ + return PerformFlashWriteWithProgress ( + FirmwareType, + FlashAddress, + FlashAddressType, + Buffer, + Length, + NULL, + 0, + 0 + ); +} + +/** + Perform microcode write operation. =20 @param[in] FlashAddress The address of flash device to be accessed. @param[in] Buffer The pointer to the data buffer. diff --git a/Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessL= ib/PlatformFlashAccessLib.inf b/Vlv2TbltDevicePkg/Feature/Capsule/Library/P= latformFlashAccessLib/PlatformFlashAccessLib.inf index fbbdb91b64..8ff0084dd4 100644 --- a/Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/Plat= formFlashAccessLib.inf +++ b/Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/Plat= formFlashAccessLib.inf @@ -1,7 +1,7 @@ ## @file # Platform Flash Access library. # -# Copyright (c) 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License # which accompanies this distribution. The full text of the license may = be found at @@ -43,7 +43,6 @@ [LibraryClasses] IoLib PcdLib DebugLib -# FlashDeviceLib MemoryAllocationLib CacheMaintenanceLib =20 --=20 2.14.2.windows.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Fri May 3 22:58:25 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 1523494139365985.691163250469; Wed, 11 Apr 2018 17:48:59 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 79B61226CD7B5; Wed, 11 Apr 2018 17:48:45 -0700 (PDT) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 D997D226CD782 for ; Wed, 11 Apr 2018 17:48:42 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Apr 2018 17:48:42 -0700 Received: from mdkinney-mobl2.amr.corp.intel.com ([10.252.128.14]) by fmsmga006.fm.intel.com with ESMTP; 11 Apr 2018 17:48:42 -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=134.134.136.65; helo=mga03.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,438,1517904000"; d="scan'208";a="219727929" From: "Kinney, Michael D" To: edk2-devel@lists.01.org Date: Wed, 11 Apr 2018 17:48:29 -0700 Message-Id: <20180412004830.9904-9-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.14.2.windows.3 In-Reply-To: <20180412004830.9904-1-michael.d.kinney@intel.com> References: <20180412004830.9904-1-michael.d.kinney@intel.com> Subject: [edk2] [Patch V2 8/9] QuarkPlatformPkg/PlatformFlashAccessLib: Add progress API 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: Michael D Kinney 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: Michael D Kinney https://bugzilla.tianocore.org/show_bug.cgi?id=3D801 Add PerformFlashWriteWithProgress() to the PlatformFlashAccessLib. This allows the platform to inform the user of progress when a firmware storage device is being updated with a new firmware image. Cc: Kelly Steele Signed-off-by: Michael D Kinney Contributed-under: TianoCore Contribution Agreement 1.1 Reviewed-by: Star Zeng --- .../PlatformFlashAccessLibDxe.c | 78 ++++++++++++++++++= +--- 1 file changed, 70 insertions(+), 8 deletions(-) diff --git a/QuarkPlatformPkg/Feature/Capsule/Library/PlatformFlashAccessLi= b/PlatformFlashAccessLibDxe.c b/QuarkPlatformPkg/Feature/Capsule/Library/Pl= atformFlashAccessLib/PlatformFlashAccessLibDxe.c index 839c3a726e..69d76df785 100644 --- a/QuarkPlatformPkg/Feature/Capsule/Library/PlatformFlashAccessLib/Platf= ormFlashAccessLibDxe.c +++ b/QuarkPlatformPkg/Feature/Capsule/Library/PlatformFlashAccessLib/Platf= ormFlashAccessLibDxe.c @@ -1,7 +1,7 @@ /** @file Platform Flash Access library. =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 @@ -112,13 +112,29 @@ FlashFdErase ( } =20 /** - Perform flash write opreation. + Perform flash write operation with progress indicator. The start and end + completion percentage values are passed into this function. If the requ= ested + flash write operation is broken up, then completion percentage between t= he + start and end values may be passed to the provided Progress function. T= he + caller of this function is required to call the Progress function for the + start and end completion percentage values. This allows the Progress, + StartPercentage, and EndPercentage parameters to be ignored if the reque= sted + flash write operation can not be broken up =20 @param[in] FirmwareType The type of firmware. @param[in] FlashAddress The address of flash device to be accessed. @param[in] FlashAddressType The type of flash device address. @param[in] Buffer The pointer to the data buffer. @param[in] Length The length of data buffer in bytes. + @param[in] Progress A function used report the progress of the + firmware update. This is an optional param= eter + that may be NULL. + @param[in] StartPercentage The start completion percentage value that = may + be used to report progress during the flash + write operation. + @param[in] EndPercentage The end completion percentage value that may + be used to report progress during the flash + write operation. =20 @retval EFI_SUCCESS The operation returns successfully. @retval EFI_WRITE_PROTECTED The flash device is read only. @@ -127,12 +143,15 @@ FlashFdErase ( **/ EFI_STATUS EFIAPI -PerformFlashWrite ( - IN PLATFORM_FIRMWARE_TYPE FirmwareType, - IN EFI_PHYSICAL_ADDRESS FlashAddress, - IN FLASH_ADDRESS_TYPE FlashAddressType, - IN VOID *Buffer, - IN UINTN Length +PerformFlashWriteWithProgress ( + IN PLATFORM_FIRMWARE_TYPE FirmwareType, + IN EFI_PHYSICAL_ADDRESS FlashAddress, + IN FLASH_ADDRESS_TYPE FlashAddressType, + IN VOID *Buffer, + IN UINTN Length, + IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress, OPTIO= NAL + IN UINTN StartPercentage, + IN UINTN EndPercentage ) { EFI_STATUS Status; @@ -150,6 +169,10 @@ PerformFlashWrite ( // SectorNum =3D Length / SPI_ERASE_SECTOR_SIZE; for (Index =3D 0; Index < SectorNum; Index++){ + if (Progress !=3D NULL) { + Progress (StartPercentage + ((Index * (EndPercentage - StartPercenta= ge)) / SectorNum)); + } + if (CompareMem( (UINT8 *)(UINTN)(FlashAddress + mInternalFdAddress) + Index * SP= I_ERASE_SECTOR_SIZE, (UINT8 *)Buffer + Index * SPI_ERASE_SECTOR_SIZE, @@ -175,10 +198,49 @@ PerformFlashWrite ( break; } } + if (Progress !=3D NULL) { + Progress (EndPercentage); + } =20 return EFI_SUCCESS; } =20 +/** + Perform flash write operation. + + @param[in] FirmwareType The type of firmware. + @param[in] FlashAddress The address of flash device to be accessed. + @param[in] FlashAddressType The type of flash device address. + @param[in] Buffer The pointer to the data buffer. + @param[in] Length The length of data buffer in bytes. + + @retval EFI_SUCCESS The operation returns successfully. + @retval EFI_WRITE_PROTECTED The flash device is read only. + @retval EFI_UNSUPPORTED The flash device access is unsupported. + @retval EFI_INVALID_PARAMETER The input parameter is not valid. +**/ +EFI_STATUS +EFIAPI +PerformFlashWrite ( + IN PLATFORM_FIRMWARE_TYPE FirmwareType, + IN EFI_PHYSICAL_ADDRESS FlashAddress, + IN FLASH_ADDRESS_TYPE FlashAddressType, + IN VOID *Buffer, + IN UINTN Length + ) +{ + return PerformFlashWriteWithProgress ( + FirmwareType, + FlashAddress, + FlashAddressType, + Buffer, + Length, + NULL, + 0, + 0 + ); +} + /** Platform Flash Access Lib Constructor. =20 --=20 2.14.2.windows.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Fri May 3 22:58:25 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 1523494141719572.230503582056; Wed, 11 Apr 2018 17:49:01 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A3892226CD7AE; Wed, 11 Apr 2018 17:48:45 -0700 (PDT) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 72593226CD79F for ; Wed, 11 Apr 2018 17:48:43 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Apr 2018 17:48:43 -0700 Received: from mdkinney-mobl2.amr.corp.intel.com ([10.252.128.14]) by fmsmga006.fm.intel.com with ESMTP; 11 Apr 2018 17:48:42 -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=134.134.136.65; helo=mga03.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,438,1517904000"; d="scan'208";a="219727933" From: "Kinney, Michael D" To: edk2-devel@lists.01.org Date: Wed, 11 Apr 2018 17:48:30 -0700 Message-Id: <20180412004830.9904-10-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.14.2.windows.3 In-Reply-To: <20180412004830.9904-1-michael.d.kinney@intel.com> References: <20180412004830.9904-1-michael.d.kinney@intel.com> Subject: [edk2] [Patch V2 9/9] SignedCapsulePkg/SystemFirmwareUpdateDxe: Use progress API 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: Michael D Kinney , Jiewen Yao 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" https://bugzilla.tianocore.org/show_bug.cgi?id=3D801 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 Signed-off-by: Michael D Kinney Contributed-under: TianoCore Contribution Agreement 1.1 Reviewed-by: Star Zeng --- .../SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c | 90 ++++++++++++++++--= ---- 1 file changed, 67 insertions(+), 23 deletions(-) diff --git a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmware= UpdateDxe.c b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwar= eUpdateDxe.c index d0b1c9913c..19b63695d2 100644 --- a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateD= xe.c +++ b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateD= xe.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 SystemFirmwareImageSiz= e, + 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 =3D PerformFlashWrite ( + if (Progress !=3D NULL) { + Progress (StartPercentage); + } + Status =3D PerformFlashWriteWithProgress ( ConfigData->FirmwareType, ConfigData->BaseAddress, ConfigData->AddressType, (VOID *)((UINTN)SystemFirmwareImage + (UINTN)ConfigData->Imag= eOffset), - ConfigData->Length + ConfigData->Length, + Progress, + StartPercentage, + EndPercentage ); + if (Progress !=3D NULL) { + Progress (EndPercentage); + } if (!EFI_ERROR(Status)) { *LastAttemptStatus =3D LAST_ATTEMPT_STATUS_SUCCESS; if (ConfigData->FirmwareType =3D=3D 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 SystemFirmwareImageSiz= e, + 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; =20 if (ConfigImage =3D=3D 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 =3D PerformFlashWrite ( + StartPercentage =3D 0; + EndPercentage =3D 100; + if (Progress !=3D NULL) { + Progress (StartPercentage); + } + Status =3D PerformFlashWriteWithProgress ( PlatformFirmwareTypeNvRam, 0, FlashAddressTypeRelativeAddress, SystemFirmwareImage, - SystemFirmwareImageSize + SystemFirmwareImageSize, + Progress, + StartPercentage, + EndPercentage ); + if (Progress !=3D NULL) { + Progress (EndPercentage); + } if (!EFI_ERROR(Status)) { *LastAttemptStatus =3D LAST_ATTEMPT_STATUS_SUCCESS; mNvRamUpdated =3D TRUE; @@ -163,17 +191,30 @@ UpdateImage ( DEBUG((DEBUG_INFO, "ConfigHeader.NumOfUpdates - 0x%x\n", ConfigHeader.Nu= mOfUpdates)); DEBUG((DEBUG_INFO, "PcdEdkiiSystemFirmwareFileGuid - %g\n", PcdGetPtr(Pc= dEdkiiSystemFirmwareFileGuid))); =20 + TotalSize =3D 0; + for (Index =3D 0; Index < ConfigHeader.NumOfUpdates; Index++) { + if (CompareGuid(&ConfigData[Index].FileGuid, PcdGetPtr(PcdEdkiiSystemF= irmwareFileGuid))) { + TotalSize =3D TotalSize + ConfigData[Index].Length; + } + } + + BytesWritten =3D 0; Index =3D 0; UpdateConfigData =3D ConfigData; while (Index < ConfigHeader.NumOfUpdates) { if (CompareGuid(&UpdateConfigData->FileGuid, PcdGetPtr(PcdEdkiiSystemF= irmwareFileGuid))) { DEBUG((DEBUG_INFO, "FileGuid - %g (processing)\n", &UpdateConfigData= ->FileGuid)); + StartPercentage =3D (BytesWritten * 100) / TotalSize; + EndPercentage =3D ((BytesWritten + UpdateConfigData->Length) * 100= ) / TotalSize; Status =3D PerformUpdate ( SystemFirmwareImage, SystemFirmwareImageSize, UpdateConfigData, LastAttemptVersion, - LastAttemptStatus + LastAttemptStatus, + Progress, + StartPercentage, + EndPercentage ); // // Shall updates be serialized so that if an update is not successfu= lly completed, @@ -186,6 +227,8 @@ UpdateImage ( DEBUG((DEBUG_INFO, "FileGuid - %g (ignored)\n", &UpdateConfigData->F= ileGuid)); } =20 + BytesWritten +=3D 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, &ConfigIm= age, &ConfigImageSize); =20 DEBUG((DEBUG_INFO, "UpdateImage ...\n")); - Status =3D UpdateImage(SystemFirmwareImage, SystemFirmwareImageSize, Con= figImage, ConfigImageSize, LastAttemptVersion, LastAttemptStatus); + Status =3D UpdateImage(SystemFirmwareImage, SystemFirmwareImageSize, Con= figImage, 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; } =20 - Status =3D SystemFirmwareAuthenticatedUpdate((VOID *)Image, ImageSize, &= SystemFmpPrivate->LastAttempt.LastAttemptVersion, &SystemFmpPrivate->LastAt= tempt.LastAttemptStatus); - DEBUG((DEBUG_INFO, "SetImage - LastAttemp Version - 0x%x, State - 0x%x\n= ", SystemFmpPrivate->LastAttempt.LastAttemptVersion, SystemFmpPrivate->Last= Attempt.LastAttemptStatus)); + Status =3D SystemFirmwareAuthenticatedUpdate((VOID *)Image, ImageSize, &= SystemFmpPrivate->LastAttempt.LastAttemptVersion, &SystemFmpPrivate->LastAt= tempt.LastAttemptStatus, Progress); + DEBUG((DEBUG_INFO, "SetImage - LastAttempt Version - 0x%x, State - 0x%x\= n", SystemFmpPrivate->LastAttempt.LastAttemptVersion, SystemFmpPrivate->Las= tAttempt.LastAttemptStatus)); =20 // // If NVRAM is updated, we should no longer touch variable services, bec= ause --=20 2.14.2.windows.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel