From nobody Fri Nov 1 04:39:08 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 1522873587412159.29039499190014; Wed, 4 Apr 2018 13:26:27 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 20AE322526487; Wed, 4 Apr 2018 13:26:07 -0700 (PDT) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 67F7621F85E75 for ; Wed, 4 Apr 2018 13:26:04 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Apr 2018 13:26:04 -0700 Received: from mdkinney-mobl2.amr.corp.intel.com ([10.241.98.47]) by fmsmga006.fm.intel.com with ESMTP; 04 Apr 2018 13:26:03 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=michael.d.kinney@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,408,1517904000"; d="scan'208";a="217591891" From: Michael D Kinney To: edk2-devel@lists.01.org Date: Wed, 4 Apr 2018 13:25:54 -0700 Message-Id: <20180404202554.9568-10-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.14.2.windows.3 In-Reply-To: <20180404202554.9568-1-michael.d.kinney@intel.com> References: <20180404202554.9568-1-michael.d.kinney@intel.com> Subject: [edk2] [Patch 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: "Kinney, Michael D" , 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: "Kinney, Michael D" 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 --- .../SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c | 92 ++++++++++++++++--= ---- 1 file changed, 68 insertions(+), 24 deletions(-) diff --git a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmware= UpdateDxe.c b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwar= eUpdateDxe.c index fd6641eb3e..8d2e0df81c 100644 --- a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateD= xe.c +++ b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateD= xe.c @@ -8,7 +8,7 @@ =20 FmpSetImage() 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 @@ -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,12 +81,15 @@ 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 ( + Status =3D PerformFlashWriteWithProgress ( ConfigData->FirmwareType, ConfigData->BaseAddress, ConfigData->AddressType, (VOID *)((UINTN)SystemFirmwareImage + (UINTN)ConfigData->Imag= eOffset), - ConfigData->Length + ConfigData->Length, + Progress, + StartPercentage, + EndPercentage ); if (!EFI_ERROR(Status)) { *LastAttemptStatus =3D LAST_ATTEMPT_STATUS_SUCCESS; @@ -111,12 +117,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 +131,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,18 +185,37 @@ 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; + if (Progress !=3D NULL) { + Progress (StartPercentage); + } Status =3D PerformUpdate ( SystemFirmwareImage, SystemFirmwareImageSize, UpdateConfigData, LastAttemptVersion, - LastAttemptStatus + LastAttemptStatus, + Progress, + StartPercentage, + EndPercentage ); + if (Progress !=3D NULL) { + Progress (EndPercentage); + } // // Shall updates be serialized so that if an update is not successfu= lly completed, // the remaining updates won't be performed. @@ -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