From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=jiewen.yao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 AF76C20977867 for ; Mon, 28 May 2018 12:18:15 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 May 2018 12:18:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,453,1520924400"; d="scan'208";a="54630409" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga003.jf.intel.com with ESMTP; 28 May 2018 12:18:15 -0700 Received: from fmsmsx157.amr.corp.intel.com (10.18.116.73) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 28 May 2018 12:18:14 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX157.amr.corp.intel.com (10.18.116.73) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 28 May 2018 12:18:06 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.223]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.70]) with mapi id 14.03.0319.002; Tue, 29 May 2018 03:18:04 +0800 From: "Yao, Jiewen" To: "Kinney, Michael D" , "edk2-devel@lists.01.org" Thread-Topic: [Patch v3 3/3] SignedCapsulePkg/PlatformFlashAccessLib: Add progress API Thread-Index: AQHT8+/gHr56+HvPREKtyDBmYgi2baRFiUNw Date: Mon, 28 May 2018 19:18:04 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503AC127D3@shsmsx102.ccr.corp.intel.com> References: <20180525061552.19840-1-michael.d.kinney@intel.com> <20180525061552.19840-4-michael.d.kinney@intel.com> In-Reply-To: <20180525061552.19840-4-michael.d.kinney@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYjkzMGVlYmItNjVhMC00OWFkLWE0N2QtZjAwYzUxNjIxMjJlIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiM2tGTEFsYlM3WVkrOGV5ZU1IMEpHWW1iNDg0bm4yMjZBNmxZYnAxZElUQ0JOMWZzMnFBeks2UmlybjRDeFB6eiJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch v3 3/3] 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: , X-List-Received-Date: Mon, 28 May 2018 19:18:15 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jiewen.yao@intel.com > -----Original Message----- > From: Kinney, Michael D > Sent: Thursday, May 24, 2018 11:16 PM > To: edk2-devel@lists.01.org > Cc: Yao, Jiewen > Subject: [Patch v3 3/3] SignedCapsulePkg/PlatformFlashAccessLib: Add prog= ress > API >=20 > https://bugzilla.tianocore.org/show_bug.cgi?id=3D801 >=20 > 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. >=20 > Implementations of the PlatformFlashAccessLib are > recommended to call the Progress() function as work > is performed to update to contents of a firmware > storage device. >=20 > Cc: Jiewen Yao > Signed-off-by: Michael D Kinney > Contributed-under: TianoCore Contribution Agreement 1.1 > --- > .../Include/Library/PlatformFlashAccessLib.h | 49 ++++++++++++++- > .../PlatformFlashAccessLibNull.c | 70 > +++++++++++++++++++--- > 2 files changed, 110 insertions(+), 9 deletions(-) >=20 > diff --git a/SignedCapsulePkg/Include/Library/PlatformFlashAccessLib.h > b/SignedCapsulePkg/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 = BSD > License > which accompanies this distribution. The full text of the license may= be > 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 accesse= d. > @@ -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 > requested > + flash write operation is broken up, then completion percentage between= the > + start and end values may be passed to the provided Progress function. = The > + 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 > requested > + 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 accesse= d. > + @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 th= e > + firmware update. This is an optional > parameter > + that may be NULL. > + @param[in] StartPercentage The start completion percentage value tha= t > may > + be used to report progress during the fla= sh > + write operation. > + @param[in] EndPercentage The end completion percentage value that > may > + be used to report progress during the fla= sh > + 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, > OPTIONAL > + IN UINTN StartPercentage, > + IN UINTN EndPercentage > + ); > + > #endif > diff --git > a/SignedCapsulePkg/Library/PlatformFlashAccessLibNull/PlatformFlashAccess= Lib > Null.c > b/SignedCapsulePkg/Library/PlatformFlashAccessLibNull/PlatformFlashAccess= Lib > Null.c > index b34ebbba1e..854f108cf4 100644 > --- > a/SignedCapsulePkg/Library/PlatformFlashAccessLibNull/PlatformFlashAccess= Lib > Null.c > +++ > b/SignedCapsulePkg/Library/PlatformFlashAccessLibNull/PlatformFlashAccess= Lib > Null.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 = BSD > License > which accompanies this distribution. The full text of the license may= be > 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 > requested > + flash write operation is broken up, then completion percentage between= the > + start and end values may be passed to the provided Progress function. = The > + 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 > requested > + 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 accesse= d. > + @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 th= e > + firmware update. This is an optional > parameter > + that may be NULL. > + @param[in] StartPercentage The start completion percentage value tha= t > may > + be used to report progress during the fla= sh > + write operation. > + @param[in] EndPercentage The end completion percentage value that > may > + be used to report progress during the fla= sh > + 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, > OPTIONAL > + 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 accesse= d. > @@ -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 > + ); > } > + > -- > 2.14.2.windows.3