From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4001:c06::234; helo=mail-io0-x234.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-io0-x234.google.com (mail-io0-x234.google.com [IPv6:2607:f8b0:4001:c06::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 06B37210D4393 for ; Wed, 6 Jun 2018 10:34:28 -0700 (PDT) Received: by mail-io0-x234.google.com with SMTP id r24-v6so8544951ioh.9 for ; Wed, 06 Jun 2018 10:34:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=rSY1/cLXmyImsyFUV7iY+RrXH3ozAz5sDncKdtNRdyY=; b=Mfb6zrEV/BmDe14yrNHs61IJTAR4zl8OQqq7hRapRyrLrBML439u9Jh/CXreduIjFC QDxmGhyV4CJotC6DPiLeSavltsAo9SWDhcH8ky3JeI7wWSo4TfNaaqMh4EKm+j3w9U74 fHOC/mTIJYcIpohge3k5ex1A8F640eDdbBqnY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=rSY1/cLXmyImsyFUV7iY+RrXH3ozAz5sDncKdtNRdyY=; b=sLCcHvxjQbd7CV4NU3mUaOY3fkh6RPO6RIwyBak2+hhE1LCsUDNxU7yMXL9Ivdyo0p HKlts508imZfW3IKyBCZ4SB7F5G8Kl+5O5OWBzJQEZ3jf5lNfFFYMbM/XoENncsiEpjs Jl63wgqJ3BHsl7Docd15+zkxv0kaucEVQrvMO8gDYZEkj6SjlVLewJMGBjdiG6fqjowy kZ7G+fe3rSPFYDxiNY/1RI7SEUMKVjJuTY+v+qswWoKFBtJymcLe6Mq1N/YZy1rEoKFa WoRZlVwM77h+mzH+EKnvJZa4YS4dN0eAQqRmQoBduhH4Sw6kv3leK5ceQxpoLBzBVjxN qy7Q== X-Gm-Message-State: APt69E0IohSu/5mW+Dwa/8xUyzC6qNmjsW0Nn3WrXZYmk6Gex3UDVob3 JwHNGpXMGBrOUxGEQ/HDWzxaeLsXCX1NgOxIhyFj1Q== X-Google-Smtp-Source: ADUXVKKPCsSo43OIuLSwOp8cTG0aF0fUElwcpNtUhK2Alku4MkZe7UiYlOHpXnFrg2J5EuOJusGKGIU9CW6NNRhZtCU= X-Received: by 2002:a6b:4014:: with SMTP id k20-v6mr3580448ioa.277.1528306467861; Wed, 06 Jun 2018 10:34:27 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:bb86:0:0:0:0:0 with HTTP; Wed, 6 Jun 2018 10:34:27 -0700 (PDT) In-Reply-To: <20180529161755.9424-2-michael.d.kinney@intel.com> References: <20180529161755.9424-1-michael.d.kinney@intel.com> <20180529161755.9424-2-michael.d.kinney@intel.com> From: Ard Biesheuvel Date: Wed, 6 Jun 2018 19:34:27 +0200 Message-ID: To: Michael D Kinney Cc: "edk2-devel@lists.01.org" , Jiewen Yao , Eric Dong , Star Zeng Subject: Re: [Patch v3 1/2] 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: , X-List-Received-Date: Wed, 06 Jun 2018 17:34:29 -0000 Content-Type: text/plain; charset="UTF-8" On 29 May 2018 at 18:17, Michael D Kinney wrote: > From: "Kinney, Michael D" > > https://bugzilla.tianocore.org/show_bug.cgi?id=801 > > Based on content from the following branch/commits: > https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport > > * Change Update_Image_Progress() to UpdateImageProcess() > * Call DisplayUpdateProgressLib from UpdateImageProgress(). > * Split out a boot service and runtime version of > UpdateImageProgress() so the DisplayUpdateProgressLib is > not used at runtime. > * If gEdkiiFirmwareManagementProgressProtocolGuid is present, > then use its progress bar color and watchdog timer value. > * If gEdkiiFirmwareManagementProgressProtocolGuid is not present, > then use default progress bar color and 5 min watchdog timer. > * Remove Print() calls during capsule processing. Instead, > the DisplayUpdateProgressLib is used to inform the user > of progress during a capsule update. > > Cc: Star Zeng > Cc: Eric Dong > Cc: Jiewen Yao > Cc: Sean Brogan > Signed-off-by: Michael D Kinney > Contributed-under: TianoCore Contribution Agreement 1.1 Tested-by: Ard Biesheuvel Reviewed-by: Ard Biesheuvel Please don't push this before the edk2-platforms changes are in. > --- > .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.c | 47 +++++++++--- > .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf | 8 ++- > .../DxeCapsuleLibFmp/DxeCapsuleProcessLib.c | 84 ++++++++++++++++------ > .../DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c | 21 +++++- > .../DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf | 7 +- > 5 files changed, 131 insertions(+), 36 deletions(-) > > diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c > index 05fcd92deb..f0226eafa5 100644 > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c > +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c > @@ -45,6 +45,7 @@ > #include > #include > #include > +#include > #include > > EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable = NULL; > @@ -53,6 +54,8 @@ BOOLEAN mIsVirtualAddrConverted = FALSE; > BOOLEAN mDxeCapsuleLibEndOfDxe = FALSE; > EFI_EVENT mDxeCapsuleLibEndOfDxeEvent = NULL; > > +EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL *mFmpProgress = NULL; > + > /** > Initialize capsule related variables. > **/ > @@ -101,18 +104,17 @@ RecordFmpCapsuleStatusVariable ( > Function indicate the current completion progress of the firmware > update. Platform may override with own specific progress function. > > - @param[in] Completion A value between 1 and 100 indicating the current completion progress of the firmware update > + @param[in] Completion A value between 1 and 100 indicating the current > + completion progress of the firmware update > > - @retval EFI_SUCESS Input capsule is a correct FMP capsule. > + @retval EFI_SUCESS The capsule update progress was updated. > + @retval EFI_INVALID_PARAMETER Completion is greater than 100%. > **/ > EFI_STATUS > EFIAPI > -Update_Image_Progress ( > +UpdateImageProgress ( > IN UINTN Completion > - ) > -{ > - return EFI_SUCCESS; > -} > + ); > > /** > Return if this CapsuleGuid is a FMP capsule GUID or not. > @@ -849,6 +851,19 @@ SetFmpImageData ( > return Status; > } > > + // > + // Lookup Firmware Management Progress Protocol before SetImage() is called > + // This is an optional protocol that may not be present on Handle. > + // > + Status = gBS->HandleProtocol ( > + Handle, > + &gEdkiiFirmwareManagementProgressProtocolGuid, > + (VOID **)&mFmpProgress > + ); > + if (EFI_ERROR (Status)) { > + mFmpProgress = NULL; > + } > + > if (ImageHeader->Version >= EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER_INIT_VERSION) { > Image = (UINT8 *)(ImageHeader + 1); > } else { > @@ -873,21 +888,37 @@ SetFmpImageData ( > DEBUG((DEBUG_INFO, "(UpdateHardwareInstance - 0x%x)", ImageHeader->UpdateHardwareInstance)); > } > DEBUG((DEBUG_INFO, "\n")); > + > + // > + // Before calling SetImage(), reset the progress bar to 0% > + // > + UpdateImageProgress (0); > + > Status = Fmp->SetImage( > Fmp, > ImageHeader->UpdateImageIndex, // ImageIndex > Image, // Image > ImageHeader->UpdateImageSize, // ImageSize > VendorCode, // VendorCode > - Update_Image_Progress, // Progress > + UpdateImageProgress, // Progress > &AbortReason // AbortReason > ); > + // > + // Set the progress bar to 100% after returning from SetImage() > + // > + UpdateImageProgress (100); > + > DEBUG((DEBUG_INFO, "Fmp->SetImage - %r\n", Status)); > if (AbortReason != NULL) { > DEBUG ((DEBUG_ERROR, "%s\n", AbortReason)); > FreePool(AbortReason); > } > > + // > + // Clear mFmpProgress after SetImage() returns > + // > + mFmpProgress = NULL; > + > return Status; > } > > diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf > index 1d947101d3..8367264f76 100644 > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf > +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf > @@ -52,6 +52,7 @@ [LibraryClasses] > PrintLib > HobLib > BmpSupportLib > + DisplayUpdateProgressLib > > [Pcd] > gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleMax ## CONSUMES > @@ -66,9 +67,10 @@ [Pcd] > gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleStatusCodeResettingSystem ## CONSUMES > > [Protocols] > - gEsrtManagementProtocolGuid ## CONSUMES > - gEfiFirmwareManagementProtocolGuid ## CONSUMES > - gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES > + gEsrtManagementProtocolGuid ## CONSUMES > + gEfiFirmwareManagementProtocolGuid ## CONSUMES > + gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES > + gEdkiiFirmwareManagementProgressProtocolGuid ## SOMETIMES_CONSUMES > > [Guids] > gEfiFmpCapsuleGuid ## SOMETIMES_CONSUMES ## GUID > diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c > index ba3ff90b9f..26ca4e295f 100644 > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c > +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c > @@ -9,7 +9,7 @@ > ProcessCapsules(), ProcessTheseCapsules() will receive untrusted > input and do basic validation. > > - Copyright (c) 2016, Intel Corporation. All rights reserved.
> + 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 BSD License > which accompanies this distribution. The full text of the license may be found at > @@ -22,6 +22,7 @@ > > #include > #include > +#include > > #include > #include > @@ -34,9 +35,12 @@ > #include > #include > #include > +#include > > #include > > +extern EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL *mFmpProgress; > + > /** > Return if this FMP is a system FMP or a device FMP, based upon CapsuleHeader. > > @@ -101,6 +105,62 @@ VOID **mCapsulePtr; > EFI_STATUS *mCapsuleStatusArray; > UINT32 mCapsuleTotalNumber; > > +/** > + Function indicate the current completion progress of the firmware > + update. Platform may override with own specific progress function. > + > + @param[in] Completion A value between 1 and 100 indicating the current > + completion progress of the firmware update > + > + @retval EFI_SUCESS The capsule update progress was updated. > + @retval EFI_INVALID_PARAMETER Completion is greater than 100%. > +**/ > +EFI_STATUS > +EFIAPI > +UpdateImageProgress ( > + IN UINTN Completion > + ) > +{ > + EFI_STATUS Status; > + UINTN Seconds; > + EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *Color; > + > + DEBUG((DEBUG_INFO, "Update Progress - %d%%\n", Completion)); > + > + if (Completion > 100) { > + return EFI_INVALID_PARAMETER; > + } > + > + // > + // Use a default timeout of 5 minutes if there is not FMP Progress Protocol. > + // > + Seconds = 5 * 60; > + Color = NULL; > + if (mFmpProgress != NULL) { > + Seconds = mFmpProgress->WatchdogSeconds; > + Color = &mFmpProgress->ProgressBarForegroundColor; > + } > + > + // > + // Cancel the watchdog timer > + // > + gBS->SetWatchdogTimer (0, 0x0000, 0, NULL); > + > + if (Completion != 100) { > + // > + // Arm the watchdog timer from PCD setting > + // > + if (Seconds != 0) { > + DEBUG ((DEBUG_VERBOSE, "Arm watchdog timer %d seconds\n", Seconds)); > + gBS->SetWatchdogTimer (Seconds, 0x0000, 0, NULL); > + } > + } > + > + Status = DisplayUpdateProgress (Completion, Color); > + > + return Status; > +} > + > /** > This function initializes the mCapsulePtr, mCapsuleStatusArray and mCapsuleTotalNumber. > **/ > @@ -319,7 +379,6 @@ ProcessTheseCapsules ( > EFI_STATUS Status; > EFI_CAPSULE_HEADER *CapsuleHeader; > UINT32 Index; > - BOOLEAN DisplayCapsuleExist; > ESRT_MANAGEMENT_PROTOCOL *EsrtManagement; > UINT16 EmbeddedDriverCount; > > @@ -354,12 +413,10 @@ ProcessTheseCapsules ( > // > // If Windows UX capsule exist, process it first > // > - DisplayCapsuleExist = FALSE; > for (Index = 0; Index < mCapsuleTotalNumber; Index++) { > CapsuleHeader = (EFI_CAPSULE_HEADER*) mCapsulePtr [Index]; > if (CompareGuid (&CapsuleHeader->CapsuleGuid, &gWindowsUxCapsuleGuid)) { > DEBUG ((DEBUG_INFO, "ProcessCapsuleImage (Ux) - 0x%x\n", CapsuleHeader)); > - DisplayCapsuleExist = TRUE; > DEBUG ((DEBUG_INFO, "Display logo capsule is found.\n")); > Status = ProcessCapsuleImage (CapsuleHeader); > mCapsuleStatusArray [Index] = EFI_SUCCESS; > @@ -368,12 +425,7 @@ ProcessTheseCapsules ( > } > } > > - if (!DisplayCapsuleExist) { > - // > - // Display Capsule not found. Display the default string. > - // > - Print (L"Updating the firmware ......\r\n"); > - } > + DEBUG ((DEBUG_INFO, "Updating the firmware ......\n")); > > // > // All capsules left are recognized by platform. > @@ -411,7 +463,6 @@ ProcessTheseCapsules ( > if (EFI_ERROR(Status)) { > REPORT_STATUS_CODE(EFI_ERROR_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeUpdateFirmwareFailed))); > DEBUG ((DEBUG_ERROR, "Capsule process failed!\n")); > - Print (L"Firmware update failed...\r\n"); > } else { > REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeUpdateFirmwareSuccess))); > } > @@ -447,18 +498,9 @@ DoResetSystem ( > VOID > ) > { > - UINTN Index; > - > - REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeResettingSystem))); > - > - Print(L"Capsule Request Cold Reboot.\n"); > DEBUG((DEBUG_INFO, "Capsule Request Cold Reboot.")); > > - for (Index = 5; Index > 0; Index--) { > - Print(L"\rResetting system in %d seconds ...", Index); > - DEBUG((DEBUG_INFO, "\rResetting system in %d seconds ...", Index)); > - gBS->Stall(1000000); > - } > + REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeResettingSystem))); > > gRT->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL); > > diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c > index 07e9e46eae..274c1c4c1c 100644 > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c > +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c > @@ -3,7 +3,7 @@ > Dummy function for runtime module, because CapsuleDxeRuntime > does not need call ProcessCapsules(). > > - Copyright (c) 2016, Intel Corporation. All rights reserved.
> + 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 BSD License > which accompanies this distribution. The full text of the license may be found at > @@ -17,6 +17,25 @@ > #include > #include > > +/** > + Function indicate the current completion progress of the firmware > + update. Platform may override with own specific progress function. > + > + @param[in] Completion A value between 1 and 100 indicating the current > + completion progress of the firmware update > + > + @retval EFI_SUCESS The capsule update progress was updated. > + @retval EFI_INVALID_PARAMETER Completion is greater than 100%. > +**/ > +EFI_STATUS > +EFIAPI > +UpdateImageProgress ( > + IN UINTN Completion > + ) > +{ > + return EFI_SUCCESS; > +} > + > /** > > This routine is called to process capsules. > diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf > index 1659b13ef4..342df9e99c 100644 > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf > +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf > @@ -69,9 +69,10 @@ [Pcd] > gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleStatusCodeResettingSystem ## CONSUMES > > [Protocols] > - gEsrtManagementProtocolGuid ## CONSUMES > - gEfiFirmwareManagementProtocolGuid ## CONSUMES > - gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES > + gEsrtManagementProtocolGuid ## CONSUMES > + gEfiFirmwareManagementProtocolGuid ## CONSUMES > + gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES > + gEdkiiFirmwareManagementProgressProtocolGuid ## SOMETIMES_CONSUMES > > [Guids] > gEfiFmpCapsuleGuid ## SOMETIMES_CONSUMES ## GUID > -- > 2.14.2.windows.3 > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel