From nobody Tue Nov 26 18:43:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+47049+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47049+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1568066826; cv=none; d=zoho.com; s=zohoarc; b=ZeH8WUhUyO/i+X1ZeL8Oi3G/p79s8qkjIrYq+HwLygL4pv5LKwrzZxyDEfLN8Eu3Nw7elMd0pQW0bOFAwi5dgVevn2iUwtv3nisAUi2h14YcdoAEawwDF0bwStNp33WxrJjsP9r8WbnlzBGEo6yf+LNLXltIQLebPPXuQrqChiE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568066826; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=0jOEkz51h/3KMmX+Vx4ZacSK5FQigglsukSZia+yX8E=; b=QWAArCY+ct0dgLtPBASiTaF/J86xC9DRoptgWngKbLys0b+uKlwpXbdPXFK1bF2Rj0//0e3vNScA9PNODAgnqaEoVBbkgsMjS74zuRL6/qLLwWpH0t5OQYqN6vh45zkTMGAVvshz/xusY/UVYkiIk6UakTAzWPb1WP5JVW0dsnQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47049+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1568066826173741.7266274272329; Mon, 9 Sep 2019 15:07:06 -0700 (PDT) Return-Path: X-Received: from mail-lf1-f65.google.com (mail-lf1-f65.google.com [209.85.167.65]) by groups.io with SMTP; Mon, 09 Sep 2019 08:53:02 -0700 X-Received: by mail-lf1-f65.google.com with SMTP id d10so10922292lfi.0 for ; Mon, 09 Sep 2019 08:53:01 -0700 (PDT) X-Gm-Message-State: APjAAAUU3m9NyAxTRtwcoQKSjXME5fqZowVM6g4/2CuIRqbwXgC7tzVb U1yMDFSc28hRMPx6DiMytPijv0B8J+YAKA== X-Google-Smtp-Source: APXvYqxWSW5zsrngGfU+Ny8SWHhumJ/u7HllkLpV/C7LNEWuq6SjNwEWk96pX/fPYS8X5dI4aHrd4A== X-Received: by 2002:ac2:4a70:: with SMTP id q16mr16914203lfp.4.1568044380350; Mon, 09 Sep 2019 08:53:00 -0700 (PDT) X-Received: from pdkmachine.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id d8sm3221238ljj.59.2019.09.09.08.52.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Sep 2019 08:52:59 -0700 (PDT) From: Patryk Duda To: devel@edk2.groups.io Cc: leif.lindholm@linaro.org, ard.biesheuvel@linaro.org, mw@semihalf.com, jsd@semihalf.com, Patryk Duda Subject: [edk2-devel] [edk2-platforms: PATCH 1/2] Marvell/Drivers: MvSpiFlashDxe: Fix sector number obtaining Date: Mon, 9 Sep 2019 17:52:11 +0200 Message-Id: <20190909155212.30338-2-pdk@semihalf.com> In-Reply-To: <20190909155212.30338-1-pdk@semihalf.com> References: <20190909155212.30338-1-pdk@semihalf.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pdk@semihalf.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1568066824; bh=Uwk0xQ5K6Txz2BtxouLjyPQ1STMPyEOGKEYBLFarDBw=; h=Cc:Date:From:Reply-To:Subject:To; b=l9NYZGQ0PxATmO3MjlT5WzgDQn7K1LTiiD0YWzMkMGUzdO1M2uoNvvpzkBnPbL72A9s 1QRLjHNlNHmlAkW+Pl8riwwEct4qJxj4xL9P7LkgRcrBrdtnjYk/F9FG8QzmIksIQHcba 1D/9F0Kz2kBuBsBNNc1W7IzkLisP7hg4LpQ= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" This commit fixes bug which was causing one sector of bytes to be ommited. It was discovered when bytes to be written was 0 in last block, but total count of bytes was multiplication of sector size. It turned out that in every case one sector of data was missing. This bug can be fixed in various ways, but this solution fixes hypotetical situation in which total bytes count is smaller than sector size. Signed-off-by: Patryk Duda Reviewed-by: Leif Lindholm Tested-by: Marcin Wojtas --- Silicon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Silicon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.c b/Si= licon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.c index 02bc281c8b..db12adb764 100755 --- a/Silicon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.c +++ b/Silicon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.c @@ -388,7 +388,7 @@ MvSpiFlashUpdateWithProgress ( UINT8 *TmpBuf; =20 SectorSize =3D Slave->Info->SectorSize; - SectorNum =3D ByteCount / SectorSize; + SectorNum =3D (ByteCount / SectorSize) + 1; ToUpdate =3D SectorSize; =20 TmpBuf =3D (UINT8 *)AllocateZeroPool (SectorSize); --=20 2.21.0 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#47049): https://edk2.groups.io/g/devel/message/47049 Mute This Topic: https://groups.io/mt/34085584/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue Nov 26 18:43:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+47050+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47050+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1568066826; cv=none; d=zoho.com; s=zohoarc; b=EdYsdQHUG9mNmrZli6KiDXSP18LFUtjReHM6SOsnSVLcN/5Ezq8dRsTbMos0S9sh3jITG9ZfIGOjRmjgFHJOcum5qMt6kjrQGJJGVJ3c4Mu0KDR309qCzN9XNqIs6eTc1/wppr0Cp1MFigyG/3fOocz96fma9rLVclOByImnOZA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568066826; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=kV7KgZuZu6Wj9OqQ733VAynp8gZd4GgOTqNbz7KXlcQ=; b=avd8SxIpEpuLotSL6bJyIl5egg7eECBIapTichbdA23nZtAvTq1eKzhwufaxuWz5CSZvKGLC21TO9P7UZOWBn9GJULmGtV+E306cz6Yl4IsZDezIGlZuPmr5R8DNrQi+ZTfXvUL18j7lwQAJmP7XPGYSd4julmrXSM6ZZevTNOg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47050+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1568066826711628.1037732059756; Mon, 9 Sep 2019 15:07:06 -0700 (PDT) Return-Path: X-Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) by groups.io with SMTP; Mon, 09 Sep 2019 08:53:03 -0700 X-Received: by mail-lf1-f67.google.com with SMTP id z21so10940005lfe.1 for ; Mon, 09 Sep 2019 08:53:02 -0700 (PDT) X-Gm-Message-State: APjAAAVZEBYTZpwSDLRD59evxFGAmjzL7kWDKxhTteSvuS2iD+e7CLLY HJ4NQ3R+E33m3PiiY1hbhZoTmPzPY0ikNQ== X-Google-Smtp-Source: APXvYqysINUjp9Uve/FHsNLFKr/e1kewOUziFf00v/a5h0hpHpgbsDvUpRrSbpbycewYQvkyH/5y6Q== X-Received: by 2002:ac2:4835:: with SMTP id 21mr16717795lft.121.1568044381273; Mon, 09 Sep 2019 08:53:01 -0700 (PDT) X-Received: from pdkmachine.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id d8sm3221238ljj.59.2019.09.09.08.53.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Sep 2019 08:53:00 -0700 (PDT) From: Patryk Duda To: devel@edk2.groups.io Cc: leif.lindholm@linaro.org, ard.biesheuvel@linaro.org, mw@semihalf.com, jsd@semihalf.com, Patryk Duda Subject: [edk2-devel] [edk2-platforms: PATCH 2/2] Marvell/Drivers: MvSpiFlashDxe: Implement progress bar Date: Mon, 9 Sep 2019 17:52:12 +0200 Message-Id: <20190909155212.30338-3-pdk@semihalf.com> In-Reply-To: <20190909155212.30338-1-pdk@semihalf.com> References: <20190909155212.30338-1-pdk@semihalf.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pdk@semihalf.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1568066825; bh=xB58h6KekRlJTfI6NDLN+EnVXiay8eApuvQ6vEk3Jfo=; h=Cc:Date:From:Reply-To:Subject:To; b=VR8VCVMyLdJvG+jwO9487fxIodTr4Qb2Vh/opCvLeC4EegATvP2rI6brHNira3UGRUX HclD/J5URhGKJ420RP6hy7HhejrvZtMHBbzJUeVPxtc8+3ct2lXsvViNCt5NhWkA6xXwq jWixIaqbjf69G+ygePjgll6L2/Rl3FxzLXM= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" This patch implements TFTP-like progress bar in MvSpiFlashUpdateWithProgress. This is necessary because CapsuleRuntimeDxe uses DxeRuntimeCapsuleLib which uses CapsuleProcessLibNull implementation of capsule process. Signed-off-by: Patryk Duda Tested-by: Marcin Wojtas --- Silicon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.inf | 1 + Silicon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.h | 1 + Silicon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.c | 57 +++++++++= +++++++---- 3 files changed, 50 insertions(+), 9 deletions(-) diff --git a/Silicon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.inf b/= Silicon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.inf index c6e93b82a1..088e9592e2 100644 --- a/Silicon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.inf +++ b/Silicon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.inf @@ -23,6 +23,7 @@ DebugLib MemoryAllocationLib NorFlashInfoLib + PrintLib TimerLib UefiBootServicesTableLib UefiDriverEntryPoint diff --git a/Silicon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.h b/Si= licon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.h index 21877ba2a6..d51892c439 100755 --- a/Silicon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.h +++ b/Silicon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.h @@ -9,6 +9,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 #include #include +#include #include #include #include diff --git a/Silicon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.c b/Si= licon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.c index db12adb764..91e195b97c 100755 --- a/Silicon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.c +++ b/Silicon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.c @@ -6,6 +6,25 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **************************************************************************= *****/ #include "MvSpiFlashDxe.h" =20 +// Frame for the progression slider +STATIC CONST CHAR16 mProgressFrame[] =3D L"[ = ]"; + +// Number of steps in the progression slider +#define PROGRESS_SLIDER_STEPS ((sizeof (mProgressFrame) / sizeof (CHAR16)= ) - 3) + +// Size in number of characters plus one (final zero) of the message to +// indicate the progress of update. The format is "[(progress slider: +// 40 characters)] (nb of KBytes written so far: 7 characters) Kb". There +// are thus the number of characters in mProgressFrame[] plus 11 characters +// (2 // spaces, "Kb" and seven characters for the number of KBytes). +#define PROGRESS_MESSAGE_SIZE ((sizeof (mProgressFrame) / sizeof (CHAR16)= ) + 12) + +// String to delete progress message to be able to update it : +// (PROGRESS_MESSAGE_SIZE-1) '\b' +STATIC CONST CHAR16 mProgressDelete[] =3D L"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b= \b\b\b" + "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b= \b\b" + "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b= \b"; + STATIC EFI_EVENT mMvSpiFlashVirtualAddrChangeEvent; MARVELL_SPI_MASTER_PROTOCOL *SpiMasterProtocol; SPI_FLASH_INSTANCE *mSpiFlashInstance; @@ -380,12 +399,15 @@ MvSpiFlashUpdateWithProgress ( IN UINTN EndPercentage ) { + CHAR16 ProgressBar[PROGRESS_MESSAGE_SIZE]; + UINTN ProgressIndex; EFI_STATUS Status; UINTN SectorSize; UINTN SectorNum; UINTN ToUpdate; - UINTN Index; UINT8 *TmpBuf; + UINTN Index; + UINTN Step; =20 SectorSize =3D Slave->Info->SectorSize; SectorNum =3D (ByteCount / SectorSize) + 1; @@ -397,12 +419,9 @@ MvSpiFlashUpdateWithProgress ( return EFI_OUT_OF_RESOURCES; } =20 - for (Index =3D 0; Index < SectorNum; Index++) { - if (Progress !=3D NULL) { - Progress (StartPercentage + - ((Index * (EndPercentage - StartPercentage)) / SectorNum)); - } + Print(L"%s 0 Kb", mProgressFrame); =20 + for (Index =3D 0; Index < SectorNum; Index++) { // In the last chunk update only an actual number of remaining bytes. if (Index + 1 =3D=3D SectorNum) { ToUpdate =3D ByteCount % SectorSize; @@ -418,12 +437,32 @@ MvSpiFlashUpdateWithProgress ( DEBUG ((DEBUG_ERROR, "%a: Error while updating\n", __FUNCTION__)); return Status; } + + ProgressBar[0] =3D L'\0'; + Step =3D ((Index * SectorSize + ToUpdate) * PROGRESS_SLIDER_STEPS) / B= yteCount; + + Print (L"%s", mProgressDelete); + + Status =3D StrCpyS (ProgressBar, PROGRESS_MESSAGE_SIZE, mProgressFrame= ); + if (EFI_ERROR(Status)) { + return Status; + } + for (ProgressIndex =3D 1; ProgressIndex < Step; ProgressIndex++) { + ProgressBar[ProgressIndex] =3D L'=3D'; + } + ProgressBar[Step] =3D L'>'; + UnicodeSPrint ( + ProgressBar + (sizeof (mProgressFrame) / sizeof (CHAR16)) - 1, + sizeof (ProgressBar) - sizeof (mProgressFrame), + L" %7d Kb", + (Index * SectorSize + ToUpdate) / 1024 + ); + + Print(L"%s", ProgressBar); } FreePool (TmpBuf); =20 - if (Progress !=3D NULL) { - Progress (EndPercentage); - } + Print (L"\n"); =20 return EFI_SUCCESS; } --=20 2.21.0 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#47050): https://edk2.groups.io/g/devel/message/47050 Mute This Topic: https://groups.io/mt/34085585/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-