Re: [edk2] [Patch 9/9] SignedCapsulePkg/SystemFirmwareUpdateDxe: Use progress API

2018-04-06 Thread Kinney, Michael D
Ard,

Yes.  I need to do an edk2-platforms patch to
go with this one.

The current API can be implemented on top of
the new API with no use of progress. That is the
simple patch.  Each platform can choose to use
progress for portions of flash update if needed.

Mike

> -Original Message-
> From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org]
> Sent: Friday, April 6, 2018 6:55 AM
> To: Kinney, Michael D 
> Cc: edk2-devel@lists.01.org; Yao, Jiewen
> 
> Subject: Re: [edk2] [Patch 9/9]
> SignedCapsulePkg/SystemFirmwareUpdateDxe: Use progress
> API
> 
> On 4 April 2018 at 22:25, Michael D Kinney
>  wrote:
> > From: "Kinney, Michael D"
> 
> >
> > https://bugzilla.tianocore.org/show_bug.cgi?id=801
> >
> > Use PlatformFlashWriteWithProgress() instead of
> PlatformFLashWrite()
> > so the user can be informed of the progress as a
> capsule is used
> > to update a firmware image in a firmware device.
> >
> > Cc: Jiewen Yao 
> > Signed-off-by: Michael D Kinney
> 
> > Contributed-under: TianoCore Contribution Agreement
> 1.1
> 
> Doesn't this break existing platforms that do not
> implement this in
> their PlatformFlashAccessLib?
> 
> > ---
> >  .../SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c |
> 92 --
> >  1 file changed, 68 insertions(+), 24 deletions(-)
> >
> > diff --git
> a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/Syste
> mFirmwareUpdateDxe.c
> b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/Syste
> mFirmwareUpdateDxe.c
> > index fd6641eb3e..8d2e0df81c 100644
> > ---
> a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/Syste
> mFirmwareUpdateDxe.c
> > +++
> b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/Syste
> mFirmwareUpdateDxe.c
> > @@ -8,7 +8,7 @@
> >
> >FmpSetImage() will receive untrusted input and do
> basic validation.
> >
> > -  Copyright (c) 2016, 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 BSD License
> >which accompanies this distribution.  The full
> text of the license may be found at
> > @@ -65,11 +65,14 @@ ParseUpdateDataFile (
> >  **/
> >  EFI_STATUS
> >  PerformUpdate (
> > -  IN VOID
> *SystemFirmwareImage,
> > -  IN UINTN
> SystemFirmwareImageSize,
> > -  IN UPDATE_CONFIG_DATA   *ConfigData,
> > -  OUT UINT32
> *LastAttemptVersion,
> > -  OUT UINT32  *LastAttemptStatus
> > +  IN VOID
> *SystemFirmwareImage,
> > +  IN UINTN
> SystemFirmwareImageSize,
> > +  IN UPDATE_CONFIG_DATA
> *ConfigData,
> > +  OUT UINT32
> *LastAttemptVersion,
> > +  OUT UINT32
> *LastAttemptStatus,
> > +  IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS
> Progress,
> > +  IN UINTN
> StartPercentage,
> > +  IN UINTN
> EndPercentage
> >)
> >  {
> >EFI_STATUS   Status;
> > @@ -78,12 +81,15 @@ PerformUpdate (
> >DEBUG((DEBUG_INFO, "  BaseAddress - 0x%lx,",
> ConfigData->BaseAddress));
> >DEBUG((DEBUG_INFO, "  ImageOffset - 0x%x,",
> ConfigData->ImageOffset));
> >DEBUG((DEBUG_INFO, "  Legnth - 0x%x\n",
> ConfigData->Length));
> > -  Status = PerformFlashWrite (
> > +  Status = PerformFlashWriteWithProgress (
> >   ConfigData->FirmwareType,
> >   ConfigData->BaseAddress,
> >   ConfigData->AddressType,
> >   (VOID *)((UINTN)SystemFirmwareImage +
> (UINTN)ConfigData->ImageOffset),
> > - ConfigData->Length
> > + ConfigData->Length,
> > + Progress,
> > + StartPercentage,
> > + EndPercentage
> >   );
> >if (!EFI_ERROR(Status)) {
> >  *LastAttemptStatus =
> LAST_ATTEMPT_STATUS_SUCCESS;
> > @@ -111,12 +117,13 @@ PerformUpdate (
> >  **/
> >  EFI_STATUS
> >  UpdateImage (
> > -  IN VOID
> *SystemFirmwareImage,
> > -  IN UINTN
> SystemFirmwareImageSize,
> > -  IN VOID *ConfigImage,
> > -  IN UINTNConfigImageSize,
> > -  OUT UINT32
> *LastAttemptVersion,
> > -  OUT UINT32  *LastAttemptStatus
> > +  IN VOID
> *SystemFirmwareImage,
> > +  IN UINTN
> SystemFirmwareImageSize,
> > +  IN VOID
> *ConfigImage,
> >

Re: [edk2] [Patch 9/9] SignedCapsulePkg/SystemFirmwareUpdateDxe: Use progress API

2018-04-06 Thread Ard Biesheuvel
On 4 April 2018 at 22:25, Michael D Kinney  wrote:
> From: "Kinney, Michael D" 
>
> https://bugzilla.tianocore.org/show_bug.cgi?id=801
>
> Use PlatformFlashWriteWithProgress() instead of PlatformFLashWrite()
> so the user can be informed of the progress as a capsule is used
> to update a firmware image in a firmware device.
>
> Cc: Jiewen Yao 
> Signed-off-by: Michael D Kinney 
> Contributed-under: TianoCore Contribution Agreement 1.1

Doesn't this break existing platforms that do not implement this in
their PlatformFlashAccessLib?

> ---
>  .../SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c | 92 
> --
>  1 file changed, 68 insertions(+), 24 deletions(-)
>
> diff --git 
> a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c 
> b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c
> index fd6641eb3e..8d2e0df81c 100644
> --- 
> a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c
> +++ 
> b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c
> @@ -8,7 +8,7 @@
>
>FmpSetImage() will receive untrusted input and do basic validation.
>
> -  Copyright (c) 2016, 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 BSD 
> License
>which accompanies this distribution.  The full text of the license may be 
> found at
> @@ -65,11 +65,14 @@ ParseUpdateDataFile (
>  **/
>  EFI_STATUS
>  PerformUpdate (
> -  IN VOID *SystemFirmwareImage,
> -  IN UINTNSystemFirmwareImageSize,
> -  IN UPDATE_CONFIG_DATA   *ConfigData,
> -  OUT UINT32  *LastAttemptVersion,
> -  OUT UINT32  *LastAttemptStatus
> +  IN VOID   *SystemFirmwareImage,
> +  IN UINTN  SystemFirmwareImageSize,
> +  IN UPDATE_CONFIG_DATA *ConfigData,
> +  OUT UINT32*LastAttemptVersion,
> +  OUT UINT32*LastAttemptStatus,
> +  IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS  Progress,
> +  IN UINTN  StartPercentage,
> +  IN UINTN  EndPercentage
>)
>  {
>EFI_STATUS   Status;
> @@ -78,12 +81,15 @@ PerformUpdate (
>DEBUG((DEBUG_INFO, "  BaseAddress - 0x%lx,", ConfigData->BaseAddress));
>DEBUG((DEBUG_INFO, "  ImageOffset - 0x%x,", ConfigData->ImageOffset));
>DEBUG((DEBUG_INFO, "  Legnth - 0x%x\n", ConfigData->Length));
> -  Status = PerformFlashWrite (
> +  Status = PerformFlashWriteWithProgress (
>   ConfigData->FirmwareType,
>   ConfigData->BaseAddress,
>   ConfigData->AddressType,
>   (VOID *)((UINTN)SystemFirmwareImage + 
> (UINTN)ConfigData->ImageOffset),
> - ConfigData->Length
> + ConfigData->Length,
> + Progress,
> + StartPercentage,
> + EndPercentage
>   );
>if (!EFI_ERROR(Status)) {
>  *LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
> @@ -111,12 +117,13 @@ PerformUpdate (
>  **/
>  EFI_STATUS
>  UpdateImage (
> -  IN VOID *SystemFirmwareImage,
> -  IN UINTNSystemFirmwareImageSize,
> -  IN VOID *ConfigImage,
> -  IN UINTNConfigImageSize,
> -  OUT UINT32  *LastAttemptVersion,
> -  OUT UINT32  *LastAttemptStatus
> +  IN VOID   *SystemFirmwareImage,
> +  IN UINTN  SystemFirmwareImageSize,
> +  IN VOID   *ConfigImage,
> +  IN UINTN  ConfigImageSize,
> +  OUT UINT32*LastAttemptVersion,
> +  OUT UINT32*LastAttemptStatus,
> +  IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS  Progress
>)
>  {
>EFI_STATUSStatus;
> @@ -124,19 +131,34 @@ UpdateImage (
>UPDATE_CONFIG_DATA*UpdateConfigData;
>CONFIG_HEADER ConfigHeader;
>UINTN Index;
> +  UINTN TotalSize;
> +  UINTN BytesWritten;
> +  UINTN StartPercentage;
> +  UINTN EndPercentage;
>
>if (ConfigImage == NULL) {
>  DEBUG((DEBUG_INFO, "PlatformUpdate (NoConfig):"));
>  DEBUG((DEBUG_INFO, "  BaseAddress - 0x%x,", 0));
>  DEBUG((DEBUG_INFO, "  Length - 0x%x\n", SystemFirmwareImageSize)

[edk2] [Patch 9/9] SignedCapsulePkg/SystemFirmwareUpdateDxe: Use progress API

2018-04-04 Thread Michael D Kinney
From: "Kinney, Michael D" 

https://bugzilla.tianocore.org/show_bug.cgi?id=801

Use PlatformFlashWriteWithProgress() instead of PlatformFLashWrite()
so the user can be informed of the progress as a capsule is used
to update a firmware image in a firmware device.

Cc: Jiewen Yao 
Signed-off-by: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
---
 .../SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c | 92 --
 1 file changed, 68 insertions(+), 24 deletions(-)

diff --git 
a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c 
b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c
index fd6641eb3e..8d2e0df81c 100644
--- a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c
+++ b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c
@@ -8,7 +8,7 @@
 
   FmpSetImage() will receive untrusted input and do basic validation.
 
-  Copyright (c) 2016, 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 BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -65,11 +65,14 @@ ParseUpdateDataFile (
 **/
 EFI_STATUS
 PerformUpdate (
-  IN VOID *SystemFirmwareImage,
-  IN UINTNSystemFirmwareImageSize,
-  IN UPDATE_CONFIG_DATA   *ConfigData,
-  OUT UINT32  *LastAttemptVersion,
-  OUT UINT32  *LastAttemptStatus
+  IN VOID   *SystemFirmwareImage,
+  IN UINTN  SystemFirmwareImageSize,
+  IN UPDATE_CONFIG_DATA *ConfigData,
+  OUT UINT32*LastAttemptVersion,
+  OUT UINT32*LastAttemptStatus,
+  IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS  Progress,
+  IN UINTN  StartPercentage,
+  IN UINTN  EndPercentage
   )
 {
   EFI_STATUS   Status;
@@ -78,12 +81,15 @@ PerformUpdate (
   DEBUG((DEBUG_INFO, "  BaseAddress - 0x%lx,", ConfigData->BaseAddress));
   DEBUG((DEBUG_INFO, "  ImageOffset - 0x%x,", ConfigData->ImageOffset));
   DEBUG((DEBUG_INFO, "  Legnth - 0x%x\n", ConfigData->Length));
-  Status = PerformFlashWrite (
+  Status = PerformFlashWriteWithProgress (
  ConfigData->FirmwareType,
  ConfigData->BaseAddress,
  ConfigData->AddressType,
  (VOID *)((UINTN)SystemFirmwareImage + 
(UINTN)ConfigData->ImageOffset),
- ConfigData->Length
+ ConfigData->Length,
+ Progress,
+ StartPercentage,
+ EndPercentage
  );
   if (!EFI_ERROR(Status)) {
 *LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
@@ -111,12 +117,13 @@ PerformUpdate (
 **/
 EFI_STATUS
 UpdateImage (
-  IN VOID *SystemFirmwareImage,
-  IN UINTNSystemFirmwareImageSize,
-  IN VOID *ConfigImage,
-  IN UINTNConfigImageSize,
-  OUT UINT32  *LastAttemptVersion,
-  OUT UINT32  *LastAttemptStatus
+  IN VOID   *SystemFirmwareImage,
+  IN UINTN  SystemFirmwareImageSize,
+  IN VOID   *ConfigImage,
+  IN UINTN  ConfigImageSize,
+  OUT UINT32*LastAttemptVersion,
+  OUT UINT32*LastAttemptStatus,
+  IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS  Progress
   )
 {
   EFI_STATUSStatus;
@@ -124,19 +131,34 @@ UpdateImage (
   UPDATE_CONFIG_DATA*UpdateConfigData;
   CONFIG_HEADER ConfigHeader;
   UINTN Index;
+  UINTN TotalSize;
+  UINTN BytesWritten;
+  UINTN StartPercentage;
+  UINTN EndPercentage;
 
   if (ConfigImage == NULL) {
 DEBUG((DEBUG_INFO, "PlatformUpdate (NoConfig):"));
 DEBUG((DEBUG_INFO, "  BaseAddress - 0x%x,", 0));
 DEBUG((DEBUG_INFO, "  Length - 0x%x\n", SystemFirmwareImageSize));
 // ASSUME the whole System Firmware include NVRAM region.
-Status = PerformFlashWrite (
+StartPercentage = 0;
+EndPercentage = 100;
+if (Progress != NULL) {
+  Progress (StartPercentage);
+}
+Status = PerformFlashWriteWithProgress (
PlatformFirmwareTypeNvRam,
0,
FlashAddres