From nobody Mon Sep 16 20:06:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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 1528130543353499.99827890963456; Mon, 4 Jun 2018 09:42:23 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id EF00E20971733; Mon, 4 Jun 2018 09:42:18 -0700 (PDT) Received: from mail-lf0-x242.google.com (mail-lf0-x242.google.com [IPv6:2a00:1450:4010:c07::242]) (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 8004C20971733 for ; Mon, 4 Jun 2018 09:42:17 -0700 (PDT) Received: by mail-lf0-x242.google.com with SMTP id d24-v6so26290304lfa.8 for ; Mon, 04 Jun 2018 09:42:17 -0700 (PDT) Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id j11-v6sm2140955lja.42.2018.06.04.09.42.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Jun 2018 09:42:14 -0700 (PDT) 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: None (no SPF record) identity=mailfrom; client-ip=2a00:1450:4010:c07::242; helo=mail-lf0-x242.google.com; envelope-from=mw@semihalf.com; receiver=edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=C4FiCMcO+/htWI34yn5+KcG4Xs9+7gFBftN2VPLIrMY=; b=zF0rqhdCnKGNuDuzR1KYld1lq0wPe5niA+uBxoKGWRzAASufatELxuckEfXXtD0g+n sP5H5xmlHC3AWiwiXYPFOihRNrlmM6hJSRSGNkndFVmBBTIXL+gp4qzvaisB40o7ATPY m1vuR+zxa647k9BnWSiWIOa9VVW8I4qpF0GLPNfI4MUXD7WD1iV87ZaEdnuW+crJeKaD YXVhiLfdE6r2yqzhQsFbv4LaFhYsqlJd3xS1UYV+c0cAsMXTr8nxKFtbMDocujSk9WV7 qfZAr2IlSGHa3yIcRNkCYHEtvDguBVR7k9/eFkU1fvKNw+6CaTOoGndI8oLIj43x8rAP 5BeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=C4FiCMcO+/htWI34yn5+KcG4Xs9+7gFBftN2VPLIrMY=; b=nQFiq5ESeXC2zdz8/6XYemJVn8iTti2rI1Nctuv9z+3O95QwtNV1Z/tQ/XgzL0yX6I rZVpdVZMH0WZwjQbDLlcH+zRgXcjARNvStFzk3JNKCg6U92pF4t3KM0KxtcOXHyo9bZX bDdvuLFB4r3vz3yjzW/PVeL5ZaJG1argZhUkrwOub3C4kDL8bK35SyN9uSyM/enuXNiy tkR18hB9ak7UnXUKNDeSW5CjZbHcrwPXZ8KgmhkFSB3DzXpqXp5QChzkm5IZhOSDxdM4 gfmjjqeZ03T0RNuX4EbEykm+7CxImuOZD8xzd+Jo4czmMLCtY35HMIwHpHy/qtV3DdyY 1s5g== X-Gm-Message-State: ALKqPwebVQQIhGeisaAJNz/FUOG+seOQvVjk9E/MjUTkWRC1+wR0T62J LeOVRCxdQghoZZpU5AeXswtIfHULdSo= X-Google-Smtp-Source: ADUXVKIO7decOczRI4O6XJohdOxtUTUKYb72vo8dKe4WhVykPYKfDN1TicRe69epUGWxiWSqtU8aSQ== X-Received: by 2002:a2e:594d:: with SMTP id n74-v6mr16266662ljb.128.1528130535305; Mon, 04 Jun 2018 09:42:15 -0700 (PDT) From: Marcin Wojtas To: edk2-devel@lists.01.org Date: Mon, 4 Jun 2018 18:41:55 +0200 Message-Id: <1528130517-11387-4-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528130517-11387-1-git-send-email-mw@semihalf.com> References: <1528130517-11387-1-git-send-email-mw@semihalf.com> Subject: [edk2] [platforms PATCH v3 3/5] Marvell/Drivers: MvSpiFlashDxe: 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: , Cc: davidsn@marvell.com, jinghua@marvell.com, ard.biesheuvel@linaro.org, jaz@semihalf.com, leif.lindholm@linaro.org MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In order to support new API of the PlatformFlashAccessLib, which passes and optional Progress() function, introduce new callback for updating data in the SPI flash, that can utilize it. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marcin Wojtas Reviewed-by: Leif Lindholm --- Silicon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.c | 60 +++++++++++= +++++++++ Silicon/Marvell/Include/Protocol/SpiFlash.h | 14 +++++ 2 files changed, 74 insertions(+) diff --git a/Silicon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.c b/Si= licon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.c index a2ce975..d81f6e3 100755 --- a/Silicon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.c +++ b/Silicon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.c @@ -397,6 +397,65 @@ MvSpiFlashUpdate ( } =20 EFI_STATUS +MvSpiFlashUpdateWithProgress ( + IN SPI_DEVICE *Slave, + IN UINT32 Offset, + IN UINTN ByteCount, + IN UINT8 *Buffer, + IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress, OPTIO= NAL + IN UINTN StartPercentage, + IN UINTN EndPercentage + ) +{ + EFI_STATUS Status; + UINTN SectorSize; + UINTN SectorNum; + UINTN ToUpdate; + UINTN Index; + UINT8 *TmpBuf; + + SectorSize =3D Slave->Info->SectorSize; + SectorNum =3D ByteCount / SectorSize; + ToUpdate =3D SectorSize; + + TmpBuf =3D (UINT8 *)AllocateZeroPool (SectorSize); + if (TmpBuf =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: Cannot allocate memory\n", __FUNCTION__)); + return EFI_OUT_OF_RESOURCES; + } + + for (Index =3D 0; Index < SectorNum; Index++) { + if (Progress !=3D NULL) { + Progress (StartPercentage + + ((Index * (EndPercentage - StartPercentage)) / SectorNum)); + } + + // In the last chunk update only an actual number of remaining bytes. + if (Index + 1 =3D=3D SectorNum) { + ToUpdate =3D ByteCount % SectorSize; + } + + Status =3D MvSpiFlashUpdateBlock (Slave, + Offset + Index * SectorSize, + ToUpdate, + Buffer + Index * SectorSize, + TmpBuf, + SectorSize); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Error while updating\n", __FUNCTION__)); + return Status; + } + } + FreePool (TmpBuf); + + if (Progress !=3D NULL) { + Progress (EndPercentage); + } + + return EFI_SUCCESS; +} + +EFI_STATUS EFIAPI MvSpiFlashReadId ( IN SPI_DEVICE *SpiDev, @@ -500,6 +559,7 @@ MvSpiFlashInitProtocol ( SpiFlashProtocol->Write =3D MvSpiFlashWrite; SpiFlashProtocol->Erase =3D MvSpiFlashErase; SpiFlashProtocol->Update =3D MvSpiFlashUpdate; + SpiFlashProtocol->UpdateWithProgress =3D MvSpiFlashUpdateWithProgress; =20 return EFI_SUCCESS; } diff --git a/Silicon/Marvell/Include/Protocol/SpiFlash.h b/Silicon/Marvell/= Include/Protocol/SpiFlash.h index 4ba29ba..e703330 100644 --- a/Silicon/Marvell/Include/Protocol/SpiFlash.h +++ b/Silicon/Marvell/Include/Protocol/SpiFlash.h @@ -34,6 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMA= GE. #ifndef __MV_SPI_FLASH__ #define __MV_SPI_FLASH__ =20 +#include #include =20 extern EFI_GUID gMarvellSpiFlashProtocolGuid; @@ -89,6 +90,18 @@ EFI_STATUS IN UINT8 *Buffer ); =20 +typedef +EFI_STATUS +(EFIAPI *MV_SPI_FLASH_UPDATE_WITH_PROGRESS) ( + IN SPI_DEVICE *Slave, + IN UINT32 Offset, + IN UINTN ByteCount, + IN UINT8 *Buffer, + IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress, OPTIO= NAL + IN UINTN StartPercentage, + IN UINTN EndPercentage + ); + struct _MARVELL_SPI_FLASH_PROTOCOL { MV_SPI_FLASH_INIT Init; MV_SPI_FLASH_READ_ID ReadId; @@ -96,6 +109,7 @@ struct _MARVELL_SPI_FLASH_PROTOCOL { MV_SPI_FLASH_WRITE Write; MV_SPI_FLASH_ERASE Erase; MV_SPI_FLASH_UPDATE Update; + MV_SPI_FLASH_UPDATE_WITH_PROGRESS UpdateWithProgress; }; =20 #endif // __MV_SPI_FLASH__ --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel