From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.136; helo=mga12.intel.com; envelope-from=david.wei@intel.com; receiver=edk2-devel@lists.01.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (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 01C0D226516B3 for ; Sat, 7 Apr 2018 23:11:31 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Apr 2018 23:11:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,422,1517904000"; d="scan'208";a="31614724" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga007.jf.intel.com with ESMTP; 07 Apr 2018 23:11:30 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sat, 7 Apr 2018 23:11:29 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.115]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.197]) with mapi id 14.03.0319.002; Sun, 8 Apr 2018 14:11:28 +0800 From: "Wei, David" To: "Kinney, Michael D" , "edk2-devel@lists.01.org" Thread-Topic: [Patch 7/9] Vlv2TbltDevicePkg/PlatformFlashAccessLib: Add progress API Thread-Index: AQHTzFMwf+9GIy526kuZRAIVTTzfH6P2aB5g Date: Sun, 8 Apr 2018 06:11:27 +0000 Message-ID: <89954A0B46707A448411A627AD4EEE346903F5F1@SHSMSX101.ccr.corp.intel.com> References: <20180404202554.9568-1-michael.d.kinney@intel.com> <20180404202554.9568-8-michael.d.kinney@intel.com> In-Reply-To: <20180404202554.9568-8-michael.d.kinney@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZWFhM2M0M2QtN2E0ZS00YzJlLTgzYjUtZTk1N2ZiZjFhOWI4IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiIzSm1KQkRMOGdsTmljYXRpOUtRaEdsbmFKYzNvZ2Jqc2NENTlGa1hBTEtnVHF5SVJxTmIwZjZEdlVydTREU0pvIn0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch 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: , X-List-Received-Date: Sun, 08 Apr 2018 06:11:32 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: zwei4 Thanks, David Wei Intel SSG/STO/UEFI BIOS =20 -----Original Message----- From: Kinney, Michael D=20 Sent: Thursday, April 5, 2018 4:26 AM To: edk2-devel@lists.01.org Cc: Wei, David ; Guo, Mang Subject: [Patch 7/9] Vlv2TbltDevicePkg/PlatformFlashAccessLib: Add 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 | 84 +++++++++++++++---= ---- .../PlatformFlashAccessLib.inf | 3 +- 2 files changed, 58 insertions(+), 29 deletions(-) diff --git a/Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessL= ib/PlatformFlashAccessLib.c b/Vlv2TbltDevicePkg/Feature/Capsule/Library/Pla= tformFlashAccessLib/PlatformFlashAccessLib.c index 9162e025ed..868e4049bb 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,7 +381,7 @@ InternalWriteBlock ( } =20 /** - Perform flash write opreation. + Perform flash write operation with progress indicator. =20 @param[in] FirmwareType The type of firmware. @param[in] FlashAddress The address of flash device to be accessed. @@ -396,12 +396,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, + IN UINTN StartPercentage, + IN UINTN EndPercentage ) { EFI_STATUS Status =3D EFI_SUCCESS; @@ -456,42 +459,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 +507,55 @@ 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); - } - - // - // Print flash update failure message if error detected. - // - if (FlashError) { - Print (L"No %r\n", Status); } =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