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.65; helo=mga03.intel.com; envelope-from=david.wei@intel.com; receiver=edk2-devel@lists.01.org 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 8635C203B8CFF for ; Sat, 26 May 2018 06:45:54 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 May 2018 06:45:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,444,1520924400"; d="scan'208";a="44404760" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga008.jf.intel.com with ESMTP; 26 May 2018 06:45:54 -0700 Received: from fmsmsx112.amr.corp.intel.com (10.18.116.6) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sat, 26 May 2018 06:45:53 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX112.amr.corp.intel.com (10.18.116.6) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sat, 26 May 2018 06:45:53 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.47]) by shsmsx102.ccr.corp.intel.com ([169.254.2.134]) with mapi id 14.03.0319.002; Sat, 26 May 2018 21:45:51 +0800 From: "Wei, David" To: "Kinney, Michael D" , "edk2-devel@lists.01.org" Thread-Topic: [edk2] [Patch v3 2/4] Vlv2TbltDevicePkg/PlatformFlashAccessLib: Add progress API Thread-Index: AQHT8/DjXc1G7qRgu02JvvgqLvhWw6RCB9CA Date: Sat, 26 May 2018 13:45:51 +0000 Message-ID: <89954A0B46707A448411A627AD4EEE3469072633@SHSMSX101.ccr.corp.intel.com> References: <20180525062308.5436-1-michael.d.kinney@intel.com> <20180525062308.5436-3-michael.d.kinney@intel.com> In-Reply-To: <20180525062308.5436-3-michael.d.kinney@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMjNhN2UwMGEtYWFjNC00Njg4LWI3NGUtNzE3YjBmYzc4MzViIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiWW5KOThuMUd5SzRvV25NZG1GeWNGUkdSeWtWbnA0VzE2ZEd0dmQxV3lCbDBaZDI0NGVVaVM4bUdKSlUrNktOQyJ9 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 2/4] 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: , X-List-Received-Date: Sat, 26 May 2018 13:45:54 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed by: David Wei Thanks, David Wei Intel SSG/STO/UEFI BIOS =20 -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Mich= ael D Kinney Sent: Friday, May 25, 2018 2:23 PM To: edk2-devel@lists.01.org Cc: Wei, David Subject: [edk2] [Patch v3 2/4] Vlv2TbltDevicePkg/PlatformFlashAccessLib: Ad= d progress API 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 --- .../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 en= d + 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 th= e + 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 ma= y + 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