From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=dGSbFoAg; spf=pass (domain: linaro.org, ip: 209.85.128.67, mailfrom: leif.lindholm@linaro.org) Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by groups.io with SMTP; Sat, 28 Sep 2019 15:47:52 -0700 Received: by mail-wm1-f67.google.com with SMTP id a6so9442116wma.5 for ; Sat, 28 Sep 2019 15:47:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=vLHwXwImXOLuPa7hGhgy+tuMOVmg6TnRJ5/U6OX90qI=; b=dGSbFoAg8Yt3O+evWfK4a7WMjKy0Ouj+EDywEwGXe5ehlFVQ3WJbUhk0AyztTEarGt WcPfmRfWtQV3bJx2CsE3sD6mGVqTvnKFDEbDRAslz4+vPB7KnSg63NYagjaP9hlm6MJp Iy0uYCAHBmo5ptn889WD+oq+BhOYj2jvnhncZQEwi+7pBqAaH8Vn3bW7YjwvXO/r3Ge/ csUNPOskCnlztsgWMyNG0xrsJmxfG5dVbxYo/uFATZrOpZPyyiQ7CN0vncZ4bnRizmpp mpUcx+SviC8h/XvmYmr+OqO+lBSauS3dw1rJqDjh8MtqTbn9w+YxFLO2NXuDoL7yhnMW D8Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=vLHwXwImXOLuPa7hGhgy+tuMOVmg6TnRJ5/U6OX90qI=; b=Z672Tqj9yxSrFUlSs0bLHr0kHWuUVZ3AZ8Mnht9U7bPeDGFvlawMO2VSRGh8zVSedq Ei7NTRv05G52G7gSh641YDrUF2PJvIinNW5Ws6MzzlAfYOXVIvlSqpeHEJ9T2BXsjQTh Z41OyiXgeuxfz+glaLY80yDps3M9xyWWW+c0Kd7Px1i/hj6RM52CDId9FS/Pi6xrcuys HKDXWf3Ogmk47xpqi3CreUG4aGqjLukH7MiYlZGqYCyWCqif6t3HdOXHvioFeRI6r/mz i1lSjIIvvMOFHZFc1Qmo9KPeFDwEqrqJ5ziQKh6L/s8wUeVjXIrGnt1Q8FUQNHC9NCpZ lKNA== X-Gm-Message-State: APjAAAXlv85gKpq5nC+BjiaajqSAJrDTRhGEudQdDl+ghvVwBqlmaiIU +nhgm19BApOK629+H6WJhlJYRA== X-Google-Smtp-Source: APXvYqweYMzCcPXIxmnZZlVIjDcVU5Ps3USpZSYDSwqCg/yP0cxtRhvHW+qG5rkmnqbNvIcWgj/BjA== X-Received: by 2002:a05:600c:c2:: with SMTP id u2mr11186500wmm.37.1569710871151; Sat, 28 Sep 2019 15:47:51 -0700 (PDT) Return-Path: Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id y186sm27985754wmb.41.2019.09.28.15.47.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2019 15:47:50 -0700 (PDT) Date: Sat, 28 Sep 2019 23:47:48 +0100 From: "Leif Lindholm" To: Patryk Duda Cc: devel@edk2.groups.io, ard.biesheuvel@linaro.org, mw@semihalf.com, jsd@semihalf.com Subject: Re: [edk2-platforms: PATCH 2/2] Marvell/Drivers: MvSpiFlashDxe: Implement progress bar Message-ID: <20190928224748.GU25504@bivouac.eciton.net> References: <20190909155212.30338-1-pdk@semihalf.com> <20190909155212.30338-3-pdk@semihalf.com> MIME-Version: 1.0 In-Reply-To: <20190909155212.30338-3-pdk@semihalf.com> User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Sep 09, 2019 at 05:52:12PM +0200, Patryk Duda wrote: > This patch implements TFTP-like progress bar in > MvSpiFlashUpdateWithProgress. This is necessary because > CapsuleRuntimeDxe uses DxeRuntimeCapsuleLib which uses > CapsuleProcessLibNull implementation of capsule process. I would prefer not adding more progress output code into individual drivers. Could this driver reuse MdeModulePkg/Library/DisplayUpdateProgressLibText/ instead? / Leif > Signed-off-by: Patryk Duda > --- > 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/Silicon/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 > > #include > #include > +#include > #include > #include > #include > diff --git a/Silicon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.c b/Silicon/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" > > +// Frame for the progression slider > +STATIC CONST CHAR16 mProgressFrame[] = 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[] = 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; > > SectorSize = Slave->Info->SectorSize; > SectorNum = (ByteCount / SectorSize) + 1; > @@ -397,12 +419,9 @@ MvSpiFlashUpdateWithProgress ( > return EFI_OUT_OF_RESOURCES; > } > > - for (Index = 0; Index < SectorNum; Index++) { > - if (Progress != NULL) { > - Progress (StartPercentage + > - ((Index * (EndPercentage - StartPercentage)) / SectorNum)); > - } > + Print(L"%s 0 Kb", mProgressFrame); > > + for (Index = 0; Index < SectorNum; Index++) { > // In the last chunk update only an actual number of remaining bytes. > if (Index + 1 == SectorNum) { > ToUpdate = ByteCount % SectorSize; > @@ -418,12 +437,32 @@ MvSpiFlashUpdateWithProgress ( > DEBUG ((DEBUG_ERROR, "%a: Error while updating\n", __FUNCTION__)); > return Status; > } > + > + ProgressBar[0] = L'\0'; > + Step = ((Index * SectorSize + ToUpdate) * PROGRESS_SLIDER_STEPS) / ByteCount; > + > + Print (L"%s", mProgressDelete); > + > + Status = StrCpyS (ProgressBar, PROGRESS_MESSAGE_SIZE, mProgressFrame); > + if (EFI_ERROR(Status)) { > + return Status; > + } > + for (ProgressIndex = 1; ProgressIndex < Step; ProgressIndex++) { > + ProgressBar[ProgressIndex] = L'='; > + } > + ProgressBar[Step] = 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); > > - if (Progress != NULL) { > - Progress (EndPercentage); > - } > + Print (L"\n"); > > return EFI_SUCCESS; > } > -- > 2.21.0 >