public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch 0/9] Add DisplayUpdateProgressLib for capsules
@ 2018-04-04 20:25 Michael D Kinney
  2018-04-04 20:25 ` [Patch 1/9] MdeModulePkg: Add DisplayUpdateProgressLib class Michael D Kinney
                   ` (10 more replies)
  0 siblings, 11 replies; 17+ messages in thread
From: Michael D Kinney @ 2018-04-04 20:25 UTC (permalink / raw)
  To: edk2-devel
  Cc: Sean Brogan, Star Zeng, Eric Dong, Jiewen Yao, David Wei,
	Mang Guo, Kelly Steele

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

Based on content from:

https://github.com/Microsoft/MS_UEFI/blob/share/MsCapsuleSupport/MsCapsuleUpdatePkg/Include/Library/DisplayUpdateProgressLib.h
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport/MsCapsuleUpdatePkg/Library/DisplayUpdateProgressGraphicsLib
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport/MsCapsuleUpdatePkg/Library/DisplayUpdateProgressTextLib

Add DisplayUpdateProgressLib class along implementations for both graphical
(Graphics Output Protocol based) and text (Simple Text Output Protocol based)
consoles.  Also add the EDK II Firmware Management Progress Protocol that is an
optional protocol that provides the progress bar color and a watchdog timeout
value thaty can be used when a firmware image is updated in a firmware device.

* Add progress support to DxeCapsuleLibFmp
* Add progress support to SystemFirmwareUpdateDxe
* Add progress support to PlatformFlashAccessLib class and instances.
* Reduce Print() calls during a firmware update.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: David Wei <david.wei@intel.com>
Cc: Mang Guo <mang.guo@intel.com>
Cc: Kelly Steele <kelly.steele@intel.com>

Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1

Kinney, Michael D (3):
  QuarkPlatformPkg: Add DisplayUpdateProgressLib mapping
  MdeModulePkg/DxeCapsuleLibFmp: Add progress bar support
  SignedCapsulePkg/SystemFirmwareUpdateDxe: Use progress API

Michael D Kinney (6):
  MdeModulePkg: Add DisplayUpdateProgressLib class
  MdeModulePkg: Add DisplayUpdateProgressLib instances
  Vlv2Tbl2DevicePkg: Add DisplayUpdateProgressLib mapping
  SignedCapsulePkg/PlatformFlashAccessLib: Add progress API
  Vlv2TbltDevicePkg/PlatformFlashAccessLib: Add progress API
  QuarkPlatformPkg/PlatformFlashAccessLib: Add progress API

 .../Include/Library/DisplayUpdateProgressLib.h     |  65 +++
 .../Include/Protocol/FirmwareManagementProgress.h  |  50 +++
 .../DisplayUpdateProgressGraphicsLib.c             | 475 +++++++++++++++++++++
 .../DisplayUpdateProgressGraphicsLib.inf           |  60 +++
 .../DisplayUpdateProgressGraphicsLib.uni           |  18 +
 .../DisplayUpdateProgressTextLib.c                 | 142 ++++++
 .../DisplayUpdateProgressTextLib.inf               |  53 +++
 .../DisplayUpdateProgressTextLib.uni               |  18 +
 .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.c       |  47 +-
 .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf     |   8 +-
 .../DxeCapsuleLibFmp/DxeCapsuleProcessLib.c        |  84 +++-
 .../DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c    |  21 +-
 .../DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf      |   7 +-
 MdeModulePkg/MdeModulePkg.dec                      |  11 +
 MdeModulePkg/MdeModulePkg.dsc                      |   3 +
 .../PlatformFlashAccessLibDxe.c                    |  59 ++-
 QuarkPlatformPkg/Quark.dsc                         |   1 +
 .../Include/Library/PlatformFlashAccessLib.h       |  33 +-
 .../PlatformFlashAccessLibNull.c                   |  54 ++-
 .../SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c |  92 ++--
 .../PlatformFlashAccessLib.c                       |  84 ++--
 .../PlatformFlashAccessLib.inf                     |   3 +-
 Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc            |   1 +
 Vlv2TbltDevicePkg/PlatformPkgIA32.dsc              |   1 +
 Vlv2TbltDevicePkg/PlatformPkgX64.dsc               |   1 +
 25 files changed, 1285 insertions(+), 106 deletions(-)
 create mode 100644 MdeModulePkg/Include/Library/DisplayUpdateProgressLib.h
 create mode 100644 MdeModulePkg/Include/Protocol/FirmwareManagementProgress.h
 create mode 100644 MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/DisplayUpdateProgressGraphicsLib.c
 create mode 100644 MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/DisplayUpdateProgressGraphicsLib.inf
 create mode 100644 MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/DisplayUpdateProgressGraphicsLib.uni
 create mode 100644 MdeModulePkg/Library/DisplayUpdateProgressTextLib/DisplayUpdateProgressTextLib.c
 create mode 100644 MdeModulePkg/Library/DisplayUpdateProgressTextLib/DisplayUpdateProgressTextLib.inf
 create mode 100644 MdeModulePkg/Library/DisplayUpdateProgressTextLib/DisplayUpdateProgressTextLib.uni

-- 
2.14.2.windows.3



^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Patch 1/9] MdeModulePkg: Add DisplayUpdateProgressLib class
  2018-04-04 20:25 [Patch 0/9] Add DisplayUpdateProgressLib for capsules Michael D Kinney
@ 2018-04-04 20:25 ` Michael D Kinney
  2018-04-04 20:25 ` [Patch 2/9] MdeModulePkg: Add DisplayUpdateProgressLib instances Michael D Kinney
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: Michael D Kinney @ 2018-04-04 20:25 UTC (permalink / raw)
  To: edk2-devel; +Cc: Sean Brogan, Star Zeng, Eric Dong

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

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport

Add the DisplayUpdateProgressLib class that is used
to inform the user of progress during updates of
firmware images in firmware devices.  A platform
specific instance of this library can be used to
customize how the user is informed of progress.

Add the EDK II Firmware Management Progress Protocol.
This is an optional protocol that must be installed
onto the same handle as a Firmware Management Protocol.
This new protocol provides the color of a progress
bar that allows different firmware devices to use
different colors during a firmware update.  It also
provides a watchdog timer value in seconds that is
armed each time the Progress() service passed
into Firmware Management Protocol SetImage()
is called.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
---
 .../Include/Library/DisplayUpdateProgressLib.h     | 65 ++++++++++++++++++++++
 .../Include/Protocol/FirmwareManagementProgress.h  | 50 +++++++++++++++++
 MdeModulePkg/MdeModulePkg.dec                      | 11 ++++
 3 files changed, 126 insertions(+)
 create mode 100644 MdeModulePkg/Include/Library/DisplayUpdateProgressLib.h
 create mode 100644 MdeModulePkg/Include/Protocol/FirmwareManagementProgress.h

diff --git a/MdeModulePkg/Include/Library/DisplayUpdateProgressLib.h b/MdeModulePkg/Include/Library/DisplayUpdateProgressLib.h
new file mode 100644
index 0000000000..ad1f2cae38
--- /dev/null
+++ b/MdeModulePkg/Include/Library/DisplayUpdateProgressLib.h
@@ -0,0 +1,65 @@
+/** @file
+  Provides services to display completion progress when processing a
+  firmware update that updates the firmware image in a firmware device.
+  A platform may provide its own instance of this library class to custoimize
+  how a user is informed of completion progress.
+
+  Copyright (c) 2016, Microsoft Corporation
+  Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+
+  All rights reserved.
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions are met:
+  1. Redistributions of source code must retain the above copyright notice,
+  this list of conditions and the following disclaimer.
+  2. Redistributions in binary form must reproduce the above copyright notice,
+  this list of conditions and the following disclaimer in the documentation
+   and/or other materials provided with the distribution.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+**/
+
+#ifndef __DISPLAY_PROGRESS_LIB__
+#define __DISPLAY_PROGRESS_LIB__
+
+#include <Protocol/GraphicsOutput.h>
+
+/**
+  Indicates the current completion progress of a firmware update.
+
+  @param[in] Completion  A value between 0 and 100 indicating the current
+                         completion progress of a firmware update.  This
+                         value must the the same or higher than previous
+                         calls to this service.  The first call of 0 or a
+                         value of 0 after reaching a value of 100 resets
+                         the progress indicator to 0.
+  @param[in] Color       Color of the progress indicator.  Only used when
+                         Completion is 0 to set the color of the progress
+                         indicator.  If Color is NULL, then the default color
+                         is used.
+
+  @retval EFI_SUCCESS            Progress displayed successfully.
+  @retval EFI_INVALID_PARAMETER  Completion is not in range 0..100.
+  @retval EFI_INVALID_PARAMETER  Completion is less than Completion value from
+                                 a previous call to this service.
+  @retval EFI_NOT_READY          The device used to indicate progress is not
+                                 available.
+**/
+EFI_STATUS
+EFIAPI
+DisplayUpdateProgress (
+  IN UINTN                                Completion,
+  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION  *Color       OPTIONAL
+  );
+
+#endif
diff --git a/MdeModulePkg/Include/Protocol/FirmwareManagementProgress.h b/MdeModulePkg/Include/Protocol/FirmwareManagementProgress.h
new file mode 100644
index 0000000000..1b17415e0a
--- /dev/null
+++ b/MdeModulePkg/Include/Protocol/FirmwareManagementProgress.h
@@ -0,0 +1,50 @@
+/** @file
+  EDK II Firmware Management Progress Protocol.
+
+  Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+  This program and the accompanying materials are licensed and made available under
+  the terms and conditions of the BSD License that accompanies this distribution.
+  The full text of the license may be found at
+  http://opensource.org/licenses/bsd-license.php.
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef __EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL_H__
+#define __EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL_H__
+
+#include <Protocol/GraphicsOutput.h>
+
+///
+/// EDK II Firmware Management Progress Protocol GUID value
+///
+#define EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL_GUID \
+  { \
+    0x1849bda2, 0x6952, 0x4e86, { 0xa1, 0xdb, 0x55, 0x9a, 0x3c, 0x47, 0x9d, 0xf1 } \
+  }
+
+///
+/// EDK II Firmware Management Progress Protocol structure
+///
+typedef struct {
+  ///
+  /// The progress bar color to use each time the Progress() function passed
+  /// into the  Firmware Management Protocol SetImage() service is called.
+  ///
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION  ProgressBarColor;
+  ///
+  /// The time in seconds to arm the watchdog timer each time the Progress()
+  /// function passed into the  Firmware Management Protocol SetImage() service
+  /// is called.
+  ///
+  UINTN                                WatchdogSeconds;
+} EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL;
+
+///
+/// EDK II Firmware Management Progress Protocol GUID variable.
+///
+extern EFI_GUID gEdkiiFirmwareManagementProgressProtocolGuid;
+
+#endif
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index cc397185f7..d4833ea178 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -175,6 +175,13 @@ [LibraryClasses]
   #
   BmpSupportLib|Include/Library/BmpSupportLib.h
 
+  ## @libraryclass  Provides services to display completion progress when
+  #  processing a firmware update that updates the firmware image in a firmware
+  #  device.  A platform may provide its own instance of this library class to
+  #  custoimize how a user is informed of completion progress.
+  #
+  DisplayUpdateProgressLib|Include/Library/DisplayUpdateProgressLib.h
+
 [Guids]
   ## MdeModule package token space guid
   # Include/Guid/MdeModulePkgTokenSpace.h
@@ -595,6 +602,10 @@ [Protocols]
   gEdkiiPlatformSpecificResetFilterProtocolGuid  = { 0x695d7835, 0x8d47, 0x4c11, { 0xab, 0x22, 0xfa, 0x8a, 0xcc, 0xe7, 0xae, 0x7a } }
   ## Include/Protocol/PlatformSpecificResetHandler.h
   gEdkiiPlatformSpecificResetHandlerProtocolGuid = { 0x2df6ba0b, 0x7092, 0x440d, { 0xbd, 0x4, 0xfb, 0x9, 0x1e, 0xc3, 0xf3, 0xc1 } }
+
+  ## Include/Protocol/FirmwareManagementProgress.h
+  gEdkiiFirmwareManagementProgressProtocolGuid = { 0x1849bda2, 0x6952, 0x4e86, { 0xa1, 0xdb, 0x55, 0x9a, 0x3c, 0x47, 0x9d, 0xf1 } }
+
 #
 # [Error.gEfiMdeModulePkgTokenSpaceGuid]
 #   0x80000001 | Invalid value provided.
-- 
2.14.2.windows.3



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [Patch 2/9] MdeModulePkg: Add DisplayUpdateProgressLib instances
  2018-04-04 20:25 [Patch 0/9] Add DisplayUpdateProgressLib for capsules Michael D Kinney
  2018-04-04 20:25 ` [Patch 1/9] MdeModulePkg: Add DisplayUpdateProgressLib class Michael D Kinney
@ 2018-04-04 20:25 ` Michael D Kinney
  2018-04-04 20:25 ` [Patch 3/9] Vlv2Tbl2DevicePkg: Add DisplayUpdateProgressLib mapping Michael D Kinney
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: Michael D Kinney @ 2018-04-04 20:25 UTC (permalink / raw)
  To: edk2-devel; +Cc: Sean Brogan, Star Zeng, Eric Dong

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

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport

Add DisplayUpdateProgressLib instances for text consoles
and graphical consoles.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
---
 .../DisplayUpdateProgressGraphicsLib.c             | 475 +++++++++++++++++++++
 .../DisplayUpdateProgressGraphicsLib.inf           |  60 +++
 .../DisplayUpdateProgressGraphicsLib.uni           |  18 +
 .../DisplayUpdateProgressTextLib.c                 | 142 ++++++
 .../DisplayUpdateProgressTextLib.inf               |  53 +++
 .../DisplayUpdateProgressTextLib.uni               |  18 +
 MdeModulePkg/MdeModulePkg.dsc                      |   3 +
 7 files changed, 769 insertions(+)
 create mode 100644 MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/DisplayUpdateProgressGraphicsLib.c
 create mode 100644 MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/DisplayUpdateProgressGraphicsLib.inf
 create mode 100644 MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/DisplayUpdateProgressGraphicsLib.uni
 create mode 100644 MdeModulePkg/Library/DisplayUpdateProgressTextLib/DisplayUpdateProgressTextLib.c
 create mode 100644 MdeModulePkg/Library/DisplayUpdateProgressTextLib/DisplayUpdateProgressTextLib.inf
 create mode 100644 MdeModulePkg/Library/DisplayUpdateProgressTextLib/DisplayUpdateProgressTextLib.uni

diff --git a/MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/DisplayUpdateProgressGraphicsLib.c b/MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/DisplayUpdateProgressGraphicsLib.c
new file mode 100644
index 0000000000..007522cea0
--- /dev/null
+++ b/MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/DisplayUpdateProgressGraphicsLib.c
@@ -0,0 +1,475 @@
+/**  @file
+  Provides services to display completion progress of a firmware update on a
+  graphical console that supports the Graphics Output Protocol.
+
+  Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
+  Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions are met:
+  1. Redistributions of source code must retain the above copyright notice,
+  this list of conditions and the following disclaimer.
+  2. Redistributions in binary form must reproduce the above copyright notice,
+  this list of conditions and the following disclaimer in the documentation
+  and/or other materials provided with the distribution.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+**/
+
+#include <PiDxe.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseLib.h>
+#include <Library/UefiLib.h>
+
+#include <Protocol/GraphicsOutput.h>
+#include <Protocol/BootLogo2.h>
+
+//
+// Values in percent of of logo height.
+//
+#define LOGO_BOTTOM_PADDING    20
+#define PROGRESS_BLOCK_HEIGHT  10
+
+//
+// Graphics Output Protocol instance to display progress bar
+//
+EFI_GRAPHICS_OUTPUT_PROTOCOL  *mGop = NULL;
+
+//
+// Set to 100 percent so it is reset on first call.
+//
+UINTN mPreviousProgress = 100;
+
+//
+// Display coordinates for the progress bar.
+//
+UINTN  mStartX = 0;
+UINTN  mStartY = 0;
+
+//
+// Width and height of the progress bar.
+//
+UINTN  mBlockWidth  = 0;
+UINTN  mBlockHeight = 0;
+
+//
+// GOP bitmap of the progress bar. Initialized on every new progress of 100%
+//
+EFI_GRAPHICS_OUTPUT_BLT_PIXEL  *mBlockBitmap;
+
+//
+// GOP bitmap of the progress bar backround.  Initialized once.
+//
+EFI_GRAPHICS_OUTPUT_BLT_PIXEL  *mProgressBarBackground;
+
+//
+// Default mask used to detect the left, right , top, and bottom of logo.  Only
+// green and blue pixels are used for logo detection.
+//
+const EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION  mLogoDetectionColorMask = {
+  {
+    0xFF,  // Blue
+    0xFF,  // Green
+    0x00,  // Red
+    0x00   // Reserved
+  }
+};
+
+//
+// Background color of progress bar.  Grey.
+//
+const EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION  mProgressBarBackgroundColor = {
+  {
+    0x80,  // Blue
+    0x80,  // Green
+    0x80,  // Red
+    0x00   // Reserved
+  }
+};
+
+//
+// Default color of progress completion.  White.
+//
+const EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION  mProgressBarDefaultColor = {
+  {
+    0xFF,  // Blue
+    0xFF,  // Green
+    0xFF,  // Red
+    0x00   // Reserved
+  }
+};
+
+//
+// Set to TRUE if a valid Graphics Output Protocol is found and the progress
+// bar fits under the boot logo using the current graphics mode.
+//
+BOOLEAN mGraphicsGood = FALSE;
+
+/*
+  Internal function used to find the bounds of the white logo (on black or
+  red background).
+
+  These bounds are then computed to find the block size, 0%, 100%, etc.
+
+*/
+VOID
+FindDim (
+   VOID
+  )
+{
+  EFI_STATUS                           Status;
+  INTN                                 LogoX;
+  INTN                                 LogoStartX;
+  INTN                                 LogoEndX;
+  INTN                                 LogoY;
+  INTN                                 LogoStartY;
+  INTN                                 LogoEndY;
+  UINTN                                OffsetX;     // Logo screen coordinate
+  UINTN                                OffsetY;     // Logo screen coordinate
+  UINTN                                Width;       // Width of logo in pixels
+  UINTN                                Height;      // Height of logo in pixels
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL        *Logo;
+  EDKII_BOOT_LOGO2_PROTOCOL            *BootLogo;
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION  *Pixel;
+
+  Logo     = NULL;
+  BootLogo = NULL;
+
+  //
+  // Return if a Graphics Output Protocol ha snot been found.
+  //
+  if (mGop == NULL) {
+    DEBUG ((DEBUG_ERROR, "No GOP found.  No progress bar support. \n"));
+    return;
+  }
+
+  //
+  // Get boot logo protocol so we know where on the screen to grab
+  //
+  Status = gBS->LocateProtocol (
+                  &gEdkiiBootLogo2ProtocolGuid,
+                  NULL,
+                  (VOID **)&BootLogo
+                  );
+  if ((BootLogo == NULL) || (EFI_ERROR (Status))) {
+    DEBUG ((DEBUG_ERROR, "Failed to locate gEdkiiBootLogo2ProtocolGuid.  No Progress bar support. \n", Status));
+    return;
+  }
+
+  //
+  // Get logo location and size
+  //
+  Status = BootLogo->GetBootLogo (
+                       BootLogo,
+                       &Logo,
+                       &OffsetX,
+                       &OffsetY,
+                       &Width,
+                       &Height
+                       );
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "Failed to Get Boot Logo Status = %r.  No Progress bar support. \n", Status));
+    return;
+  }
+
+  //
+  // Within logo buffer find where the actual logo starts/ends
+  //
+  LogoEndX = 0;
+  LogoEndY = 0;
+
+  //
+  // Find left side of logo in logo coordinates
+  //
+  for (LogoX = 0, LogoStartX = Width; LogoX < LogoStartX; LogoX++) {
+    Pixel = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *)(Logo + LogoX);
+    for (LogoY = 0; LogoY < (INTN)Height; LogoY++) {
+      if ((Pixel->Raw & mLogoDetectionColorMask.Raw) != 0x0) {
+        LogoStartX = LogoX;
+        //
+        // For loop searches from right side back to this column.
+        //
+        LogoEndX = LogoX;
+        DEBUG ((DEBUG_INFO, "StartX found at (%d, %d) Color is: 0x%X \n", LogoX, LogoY, Pixel->Raw));
+        break;
+      }
+      Pixel = Pixel + Width;
+    }
+  }
+
+  //
+  // Find right side of logo
+  //
+  for (LogoX = Width - 1; LogoX >= LogoEndX; LogoX--) {
+    Pixel = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *)(Logo + LogoX);
+    for (LogoY = 0; LogoY < (INTN)Height; LogoY++) {
+      if ((Pixel->Raw & mLogoDetectionColorMask.Raw) != 0x0) {
+        LogoEndX = LogoX;
+        DEBUG ((DEBUG_INFO, "EndX found at (%d, %d) Color is: 0x%X \n", LogoX, LogoY, Pixel->Raw));
+        break;
+      }
+      Pixel = Pixel + Width;
+    }
+  }
+
+  //
+  // Compute mBlockWidth
+  //
+  mBlockWidth = ((LogoEndX - LogoStartX) + 99) / 100;
+
+  //
+  // Adjust mStartX based on block width so it is centered under logo
+  //
+  mStartX = LogoStartX + OffsetX - (((mBlockWidth * 100) - (LogoEndX - LogoStartX)) / 2);
+  DEBUG ((DEBUG_INFO, "mBlockWidth set to 0x%X\n", mBlockWidth));
+  DEBUG ((DEBUG_INFO, "mStartX set to 0x%X\n", mStartX));
+
+  //
+  // Find the top of the logo
+  //
+  for (LogoY = 0, LogoStartY = Height; LogoY < LogoStartY; LogoY++) {
+    Pixel = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *)(Logo + (Width * LogoY));
+    for (LogoX = 0; LogoX < (INTN)Width; LogoX++) {
+      //not black or red
+      if ((Pixel->Raw & mLogoDetectionColorMask.Raw) != 0x0) {
+        LogoStartY = LogoY;
+        LogoEndY = LogoY; //for next loop will search from bottom side back to this row.
+        DEBUG ((DEBUG_INFO, "StartY found at (%d, %d) Color is: 0x%X \n", LogoX, LogoY, Pixel->Raw));
+        break;
+      }
+      Pixel++;
+    }
+  }
+
+  //
+  // Find the bottom of the logo
+  //
+  for (LogoY = Height - 1; LogoY >= LogoEndY; LogoY--) {
+    Pixel = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *)(Logo + (Width * LogoY));
+    for (LogoX = 0; LogoX < (INTN)Width; LogoX++) {
+      if ((Pixel->Raw & mLogoDetectionColorMask.Raw) != 0x0) {
+        LogoEndY = LogoY;
+        DEBUG ((DEBUG_INFO, "EndY found at (%d, %d) Color is: 0x%X \n", LogoX, LogoY, Pixel->Raw));
+        break;
+      }
+      Pixel++;
+    }
+  }
+
+  //
+  // Compute bottom padding (distance between logo bottom and progress bar)
+  //
+  mStartY = (((LogoEndY - LogoStartY) * LOGO_BOTTOM_PADDING) / 100) + LogoEndY + OffsetY;
+
+  //
+  // Compute progress bar height
+  //
+  mBlockHeight = (((LogoEndY - LogoStartY) * PROGRESS_BLOCK_HEIGHT) / 100);
+
+  DEBUG ((DEBUG_INFO, "mBlockHeight set to 0x%X\n", mBlockHeight));
+
+  //
+  // Create progress bar background (one time init).
+  //
+  mProgressBarBackground = AllocatePool (mBlockWidth * 100 * mBlockHeight * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
+  if (mProgressBarBackground == NULL) {
+    DEBUG ((DEBUG_ERROR, "Failed to allocate progress bar background\n"));
+    return;
+  }
+
+  //
+  // Fill the progress bar with the background color
+  //
+  SetMem32 (
+    mProgressBarBackground,
+    (mBlockWidth * 100 * mBlockHeight * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)),
+    mProgressBarBackgroundColor.Raw
+    );
+
+  //
+  // Allocate mBlockBitmap
+  //
+  mBlockBitmap = AllocatePool (mBlockWidth * mBlockHeight * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
+  if (mBlockBitmap == NULL) {
+    FreePool (mProgressBarBackground);
+    DEBUG ((DEBUG_ERROR, "Failed to allocate block\n"));
+    return;
+  }
+
+  //
+  // Check screen width and height and make sure it fits.
+  //
+  if ((mBlockHeight > Height) || (mBlockWidth > Width) || (mBlockHeight < 1) || (mBlockWidth < 1)) {
+    DEBUG ((DEBUG_ERROR, "DisplayUpdateProgressLib - Progress - Failed to get valid width and height.\n"));
+    DEBUG ((DEBUG_ERROR, "DisplayUpdateProgressLib - Progress - mBlockHeight: 0x%X  mBlockWidth: 0x%X.\n", mBlockHeight, mBlockWidth));
+    FreePool (mProgressBarBackground);
+    FreePool (mBlockBitmap);
+    return;
+  }
+
+  mGraphicsGood = TRUE;
+}
+
+/**
+  Function indicates the current completion progress of a firmware update.
+  Platform may override with its own specific function.
+
+  @param[in] Completion  A value between 0 and 100 indicating the current
+                         completion progress of a firmware update.  This
+                         value must the the same or higher than previous
+                         calls to this service.  The first call of 0 or a
+                         value of 0 after reaching a value of 100 resets
+                         the progress indicator to 0.
+  @param[in] Color       Color of the progress indicator.  Only used when
+                         Completion is 0 to set the color of the progress
+                         indicator.  If Color is NULL, then the default color
+                         is used.
+
+  @retval EFI_SUCCESS            Progress displayed successfully.
+  @retval EFI_INVALID_PARAMETER  Completion is not in range 0..100.
+  @retval EFI_INVALID_PARAMETER  Completion is less than Completion value from
+                                 a previous call to this service.
+  @retval EFI_NOT_READY          The device used to indicate progress is not
+                                 available.
+**/
+EFI_STATUS
+EFIAPI
+DisplayUpdateProgress (
+  IN UINTN                                Completion,
+  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION  *Color       OPTIONAL
+  )
+{
+  EFI_STATUS  Status;
+  UINTN       PreX;
+  UINTN       Index;
+
+  //
+  // Check range
+  //
+  if (Completion > 100) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  //
+  // Check to see if this Completion percentage has already been displayed
+  //
+  if (Completion == mPreviousProgress) {
+    return EFI_SUCCESS;
+  }
+
+  //
+  // Find Graphics Output Protocol if not already set.  1 time.
+  //
+  if (mGop == NULL) {
+    Status = gBS->HandleProtocol (
+                    gST->ConsoleOutHandle,
+                    &gEfiGraphicsOutputProtocolGuid,
+                    (VOID**)&mGop
+                    );
+    if (EFI_ERROR (Status)) {
+      Status = gBS->LocateProtocol (&gEfiGraphicsOutputProtocolGuid, NULL, (VOID **)&mGop);
+      if (EFI_ERROR (Status)) {
+        mGop = NULL;
+        DEBUG ((DEBUG_ERROR, "Show Progress Function could not locate GOP.  Status = %r\n", Status));
+        return EFI_NOT_READY;
+      }
+    }
+
+    //
+    // Run once
+    //
+    FindDim ();
+  }
+
+  //
+  // Make sure a valid start, end, and size info are available (find the Logo)
+  //
+  if (!mGraphicsGood) {
+    DEBUG ((DEBUG_INFO, "Graphics Not Good.  Not doing any onscreen visual display\n"));
+    return EFI_NOT_READY;
+  }
+
+  //
+  // Do special init on first call of each progress session
+  //
+  if (mPreviousProgress == 100) {
+    //
+    // Draw progress bar background
+    //
+    mGop->Blt (
+            mGop,
+            mProgressBarBackground,
+            EfiBltBufferToVideo,
+            0,
+            0,
+            mStartX,
+            mStartY,
+            (mBlockWidth * 100),
+            mBlockHeight,
+            0
+            );
+
+    DEBUG ((DEBUG_VERBOSE, "Color is 0x%X\n",
+      (Color == NULL) ? mProgressBarDefaultColor.Raw : Color->Raw
+      ));
+
+    //
+    // Update block bitmap with correct color
+    //
+    SetMem32 (
+      mBlockBitmap,
+      (mBlockWidth * mBlockHeight * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)),
+      (Color == NULL) ? mProgressBarDefaultColor.Raw : Color->Raw
+      );
+
+    //
+    // Clear previous
+    //
+    mPreviousProgress = 0;
+  }
+
+  //
+  // Can not update progress bar if Completion is less than previous
+  //
+  if (Completion < mPreviousProgress) {
+    DEBUG ((DEBUG_WARN, "WARNING: Completion (%d) should not be lesss than Previous (%d)!!!\n", Completion, mPreviousProgress));
+    return EFI_INVALID_PARAMETER;
+  }
+
+  PreX = ((mPreviousProgress * mBlockWidth) + mStartX);
+  for (Index = 0; Index < (Completion - mPreviousProgress); Index++) {
+    //
+    // Show progress by coloring new area
+    //
+    mGop->Blt (
+            mGop,
+            mBlockBitmap,
+            EfiBltBufferToVideo,
+            0,
+            0,
+            PreX,
+            mStartY,
+            mBlockWidth,
+            mBlockHeight,
+            0
+            );
+    PreX += mBlockWidth;
+  }
+
+  mPreviousProgress = Completion;
+
+  return EFI_SUCCESS;
+}
diff --git a/MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/DisplayUpdateProgressGraphicsLib.inf b/MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/DisplayUpdateProgressGraphicsLib.inf
new file mode 100644
index 0000000000..810f13acd9
--- /dev/null
+++ b/MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/DisplayUpdateProgressGraphicsLib.inf
@@ -0,0 +1,60 @@
+## @file
+#  Provides services to display completion progress of a firmware update on a
+#  graphical console that supports the Graphics Output Protocol.
+#
+#  Copyright (c) 2016, Microsoft Corporation, All rights reserved.<BR>
+#  Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+#
+#  Redistribution and use in source and binary forms, with or without
+#  modification, are permitted provided that the following conditions are met:
+#  1. Redistributions of source code must retain the above copyright notice,
+#  this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright notice,
+#  this list of conditions and the following disclaimer in the documentation
+#  and/or other materials provided with the distribution.
+#
+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+#  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+#  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+#  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+#  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+#  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+#  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+#  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+##
+
+[Defines]
+  INF_VERSION     = 0x00010005
+  BASE_NAME       = DisplayUpdateProgressGraphicsLib
+  MODULE_UNI_FILE = DisplayUpdateProgressGraphicsLib.uni
+  FILE_GUID       = 319E9E37-B2D6-4699-90F3-B8B72B6D4CBD
+  MODULE_TYPE     = DXE_DRIVER
+  VERSION_STRING  = 1.0
+  LIBRARY_CLASS   = DisplayUpdateProgressLib|DXE_DRIVER UEFI_DRIVER UEFI_APPLICATION
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC
+#
+
+[Sources]
+  DisplayUpdateProgressGraphicsLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+
+[LibraryClasses]
+  BaseMemoryLib
+  DebugLib
+  MemoryAllocationLib
+  UefiBootServicesTableLib
+  BaseLib
+  UefiLib
+
+[Protocols]
+  gEfiGraphicsOutputProtocolGuid  # CONSUMES
+  gEdkiiBootLogo2ProtocolGuid     # CONSUMES
diff --git a/MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/DisplayUpdateProgressGraphicsLib.uni b/MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/DisplayUpdateProgressGraphicsLib.uni
new file mode 100644
index 0000000000..d7da641338
--- /dev/null
+++ b/MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/DisplayUpdateProgressGraphicsLib.uni
@@ -0,0 +1,18 @@
+// /** @file
+//  Provides services to display completion progress of a firmware update on a
+//  graphical console that supports the Graphics Output Protocol.
+//
+// Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+//
+// 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
+// http://opensource.org/licenses/bsd-license.php
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+//
+// **/
+
+#string STR_MODULE_ABSTRACT     #language en-US  "Provides services to display completion progress of a firmware update on a graphical console that supports the Graphics Output Protocol."
+
+#string STR_MODULE_DESCRIPTION  #language en-US  "Provides services to display completion progress of a firmware update on a graphical console that supports the Graphics Output Protocol."
diff --git a/MdeModulePkg/Library/DisplayUpdateProgressTextLib/DisplayUpdateProgressTextLib.c b/MdeModulePkg/Library/DisplayUpdateProgressTextLib/DisplayUpdateProgressTextLib.c
new file mode 100644
index 0000000000..aa849aba2e
--- /dev/null
+++ b/MdeModulePkg/Library/DisplayUpdateProgressTextLib/DisplayUpdateProgressTextLib.c
@@ -0,0 +1,142 @@
+/**  @file
+  Provides services to display completion progress of a firmware update on a
+  text console.
+
+  Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
+  Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions are met:
+  1. Redistributions of source code must retain the above copyright notice,
+  this list of conditions and the following disclaimer.
+  2. Redistributions in binary form must reproduce the above copyright notice,
+  this list of conditions and the following disclaimer in the documentation
+  and/or other materials provided with the distribution.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+**/
+
+#include <PiDxe.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+
+//
+// Control Style.  Set to 100 so it is reset on first call.
+//
+UINTN  mPreviousProgress = 100;
+
+/**
+  Function indicates the current completion progress of a firmware update.
+  Platform may override with its own specific function.
+
+  @param[in] Completion  A value between 0 and 100 indicating the current
+                         completion progress of a firmware update.  This
+                         value must the the same or higher than previous
+                         calls to this service.  The first call of 0 or a
+                         value of 0 after reaching a value of 100 resets
+                         the progress indicator to 0.
+  @param[in] Color       Color of the progress indicator.  Only used when
+                         Completion is 0 to set the color of the progress
+                         indicator.  If Color is NULL, then the default color
+                         is used.
+
+  @retval EFI_SUCCESS            Progress displayed successfully.
+  @retval EFI_INVALID_PARAMETER  Completion is not in range 0..100.
+  @retval EFI_INVALID_PARAMETER  Completion is less than Completion value from
+                                 a previous call to this service.
+  @retval EFI_NOT_READY          The device used to indicate progress is not
+                                 available.
+**/
+EFI_STATUS
+EFIAPI
+DisplayUpdateProgress (
+  IN UINTN                                Completion,
+  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION  *Color       OPTIONAL
+  )
+{
+  UINTN  Foreground;
+  UINTN  Index;
+
+  //
+  // Check range
+  //
+  if (Completion > 100) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  //
+  // Check to see if this Completion percentage has already been displayed
+  //
+  if (Completion == mPreviousProgress) {
+    return EFI_SUCCESS;
+  }
+
+  //
+  // Do special init on first call of each progress session
+  //
+  if (mPreviousProgress == 100) {
+    Print (L"\n");
+
+    //
+    // Convert pixel color to text foreground color
+    //
+    if (Color == NULL) {
+      Foreground = EFI_WHITE;
+    } else {
+      Foreground = EFI_BLACK;
+      if (Color->Pixel.Blue >= 0x40) {
+        Foreground = Foreground | EFI_BLUE;
+      }
+      if (Color->Pixel.Green >= 0x40) {
+        Foreground = Foreground | EFI_GREEN;
+      }
+      if (Color->Pixel.Red >= 0x40) {
+        Foreground = Foreground | EFI_RED;
+      }
+      if (Color->Pixel.Blue >= 0xC0 || Color->Pixel.Green >= 0xC0 || Color->Pixel.Red >= 0xC0) {
+        Foreground = Foreground | EFI_BRIGHT;
+      }
+      if (Foreground == EFI_BLACK) {
+        Foreground = EFI_WHITE;
+      }
+    }
+    gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (Foreground, EFI_BLACK));
+
+    //
+    // Clear previous
+    //
+    mPreviousProgress = 0;
+  }
+
+  //
+  // Can not update progress bar if Completion is less than previous
+  //
+  if (Completion < mPreviousProgress) {
+    DEBUG ((DEBUG_WARN, "WARNING: Completion (%d) should not be lesss than Previous (%d)!!!\n", Completion, mPreviousProgress));
+    return EFI_INVALID_PARAMETER;
+  }
+
+  Print (L"\rUpdate Progress - %3d%% ", Completion);
+  for (Index = 0; Index < 50; Index++) {
+    if (Index <= Completion / 2) {
+      Print (L"%c", 0x2588);
+    } else {
+      Print (L"%c", 0x2591);
+    }
+  }
+
+  mPreviousProgress = Completion;
+
+  return EFI_SUCCESS;
+}
diff --git a/MdeModulePkg/Library/DisplayUpdateProgressTextLib/DisplayUpdateProgressTextLib.inf b/MdeModulePkg/Library/DisplayUpdateProgressTextLib/DisplayUpdateProgressTextLib.inf
new file mode 100644
index 0000000000..b5782dc44c
--- /dev/null
+++ b/MdeModulePkg/Library/DisplayUpdateProgressTextLib/DisplayUpdateProgressTextLib.inf
@@ -0,0 +1,53 @@
+## @file
+#  Provides services to display completion progress of a firmware update on a
+#  text console.
+#
+#  Copyright (c) 2016, Microsoft Corporation, All rights reserved.<BR>
+#  Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+#
+#  Redistribution and use in source and binary forms, with or without
+#  modification, are permitted provided that the following conditions are met:
+#  1. Redistributions of source code must retain the above copyright notice,
+#  this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright notice,
+#  this list of conditions and the following disclaimer in the documentation
+#  and/or other materials provided with the distribution.
+#
+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+#  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+#  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+#  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+#  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+#  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+#  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+#  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+##
+
+[Defines]
+  INF_VERSION     = 0x00010005
+  BASE_NAME       = DisplayUpdateProgressTextLib
+  MODULE_UNI_FILE = DisplayUpdateProgressTextLib.uni
+  FILE_GUID       = CDEF83AE-1900-4B41-BF47-AAE9BD729CA5
+  MODULE_TYPE     = DXE_DRIVER
+  VERSION_STRING  = 1.0
+  LIBRARY_CLASS   = DisplayUpdateProgressLib|DXE_DRIVER UEFI_DRIVER UEFI_APPLICATION
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC
+#
+
+[Sources]
+  DisplayUpdateProgressTextLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+
+[LibraryClasses]
+  DebugLib
+  UefiBootServicesTableLib
+  UefiLib
diff --git a/MdeModulePkg/Library/DisplayUpdateProgressTextLib/DisplayUpdateProgressTextLib.uni b/MdeModulePkg/Library/DisplayUpdateProgressTextLib/DisplayUpdateProgressTextLib.uni
new file mode 100644
index 0000000000..3c783722bc
--- /dev/null
+++ b/MdeModulePkg/Library/DisplayUpdateProgressTextLib/DisplayUpdateProgressTextLib.uni
@@ -0,0 +1,18 @@
+// /** @file
+//  Provides services to display completion progress of a firmware update on a
+//  text console.
+//
+// Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+//
+// 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
+// http://opensource.org/licenses/bsd-license.php
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+//
+// **/
+
+#string STR_MODULE_ABSTRACT     #language en-US  "Provides services to display completion progress of a firmware update on a text console."
+
+#string STR_MODULE_DESCRIPTION  #language en-US  "Provides services to display completion progress of a firmware update on a text console."
diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index ec24a50c7d..d122e78266 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -108,6 +108,7 @@ [LibraryClasses]
   CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
   BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf
   SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
+  DisplayUpdateProgressLib|MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/DisplayUpdateProgressGraphicsLib.inf
 
 [LibraryClasses.EBC.PEIM]
   IoLib|MdePkg/Library/PeiIoLibCpuIo/PeiIoLibCpuIo.inf
@@ -327,6 +328,8 @@ [Components]
   MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
   MdeModulePkg/Library/NonDiscoverableDeviceRegistrationLib/NonDiscoverableDeviceRegistrationLib.inf
   MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf
+  MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/DisplayUpdateProgressGraphicsLib.inf
+  MdeModulePkg/Library/DisplayUpdateProgressTextLib/DisplayUpdateProgressTextLib.inf
 
   MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
   MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf
-- 
2.14.2.windows.3



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [Patch 3/9] Vlv2Tbl2DevicePkg: Add DisplayUpdateProgressLib mapping
  2018-04-04 20:25 [Patch 0/9] Add DisplayUpdateProgressLib for capsules Michael D Kinney
  2018-04-04 20:25 ` [Patch 1/9] MdeModulePkg: Add DisplayUpdateProgressLib class Michael D Kinney
  2018-04-04 20:25 ` [Patch 2/9] MdeModulePkg: Add DisplayUpdateProgressLib instances Michael D Kinney
@ 2018-04-04 20:25 ` Michael D Kinney
  2018-04-08  6:12   ` Wei, David
  2018-04-04 20:25 ` [Patch 4/9] QuarkPlatformPkg: " Michael D Kinney
                   ` (7 subsequent siblings)
  10 siblings, 1 reply; 17+ messages in thread
From: Michael D Kinney @ 2018-04-04 20:25 UTC (permalink / raw)
  To: edk2-devel; +Cc: Sean Brogan, David Wei, Mang Guo

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

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: David Wei <david.wei@intel.com>
Cc: Mang Guo <mang.guo@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
---
 Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc | 1 +
 Vlv2TbltDevicePkg/PlatformPkgIA32.dsc   | 1 +
 Vlv2TbltDevicePkg/PlatformPkgX64.dsc    | 1 +
 3 files changed, 3 insertions(+)

diff --git a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
index f918e44851..f43449c588 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
@@ -195,6 +195,7 @@ [LibraryClasses.common]
   IniParsingLib|SignedCapsulePkg/Library/IniParsingLib/IniParsingLib.inf
   PlatformFlashAccessLib|Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.inf
   MicrocodeFlashAccessLib|Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.inf
+  DisplayUpdateProgressLib|MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/DisplayUpdateProgressGraphicsLib.inf
   LanguageLib|EdkCompatibilityPkg/Compatibility/Library/UefiLanguageLib/UefiLanguageLib.inf
   SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
   SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
diff --git a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
index 0a95d95557..f69f61ca71 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
@@ -195,6 +195,7 @@ [LibraryClasses.common]
   IniParsingLib|SignedCapsulePkg/Library/IniParsingLib/IniParsingLib.inf
   PlatformFlashAccessLib|Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.inf
   MicrocodeFlashAccessLib|Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.inf
+  DisplayUpdateProgressLib|MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/DisplayUpdateProgressGraphicsLib.inf
   LanguageLib|EdkCompatibilityPkg/Compatibility/Library/UefiLanguageLib/UefiLanguageLib.inf
   SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
   SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
diff --git a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
index fb2743c727..63c23a1689 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
@@ -195,6 +195,7 @@ [LibraryClasses.common]
   IniParsingLib|SignedCapsulePkg/Library/IniParsingLib/IniParsingLib.inf
   PlatformFlashAccessLib|Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.inf
   MicrocodeFlashAccessLib|Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.inf
+  DisplayUpdateProgressLib|MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/DisplayUpdateProgressGraphicsLib.inf
   LanguageLib|EdkCompatibilityPkg/Compatibility/Library/UefiLanguageLib/UefiLanguageLib.inf
   SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
   SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
-- 
2.14.2.windows.3



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [Patch 4/9] QuarkPlatformPkg: Add DisplayUpdateProgressLib mapping
  2018-04-04 20:25 [Patch 0/9] Add DisplayUpdateProgressLib for capsules Michael D Kinney
                   ` (2 preceding siblings ...)
  2018-04-04 20:25 ` [Patch 3/9] Vlv2Tbl2DevicePkg: Add DisplayUpdateProgressLib mapping Michael D Kinney
@ 2018-04-04 20:25 ` Michael D Kinney
  2018-04-04 20:25 ` [Patch 5/9] MdeModulePkg/DxeCapsuleLibFmp: Add progress bar support Michael D Kinney
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: Michael D Kinney @ 2018-04-04 20:25 UTC (permalink / raw)
  To: edk2-devel; +Cc: Kinney, Michael D, Sean Brogan, Kelly Steele

From: "Kinney, Michael D" <michael.d.kinney@intel.com>

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

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Kelly Steele <kelly.steele@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
---
 QuarkPlatformPkg/Quark.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/QuarkPlatformPkg/Quark.dsc b/QuarkPlatformPkg/Quark.dsc
index a43a5595d4..9926b26a27 100644
--- a/QuarkPlatformPkg/Quark.dsc
+++ b/QuarkPlatformPkg/Quark.dsc
@@ -241,6 +241,7 @@ [LibraryClasses]
   FmpAuthenticationLib|MdeModulePkg/Library/FmpAuthenticationLibNull/FmpAuthenticationLibNull.inf
   IniParsingLib|SignedCapsulePkg/Library/IniParsingLib/IniParsingLib.inf
   PlatformFlashAccessLib|QuarkPlatformPkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLibDxe.inf
+  DisplayUpdateProgressLib|MdeModulePkg/Library/DisplayUpdateProgressTextLib/DisplayUpdateProgressTextLib.inf
 
 [LibraryClasses.common.SEC]
   #
-- 
2.14.2.windows.3



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [Patch 5/9] MdeModulePkg/DxeCapsuleLibFmp: Add progress bar support
  2018-04-04 20:25 [Patch 0/9] Add DisplayUpdateProgressLib for capsules Michael D Kinney
                   ` (3 preceding siblings ...)
  2018-04-04 20:25 ` [Patch 4/9] QuarkPlatformPkg: " Michael D Kinney
@ 2018-04-04 20:25 ` Michael D Kinney
  2018-04-04 20:25 ` [Patch 6/9] SignedCapsulePkg/PlatformFlashAccessLib: Add progress API Michael D Kinney
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: Michael D Kinney @ 2018-04-04 20:25 UTC (permalink / raw)
  To: edk2-devel
  Cc: Kinney, Michael D, Star Zeng, Eric Dong, Jiewen Yao, Sean Brogan

From: "Kinney, Michael D" <michael.d.kinney@intel.com>

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

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport

* Change Update_Image_Progress() to UpdateImageProcess()
* Call DisplayUpdateProgressLib from UpdateImageProgress().
* Split out a boot service and runtime version of
  UpdateImageProgress() so the DisplayUpdateProgressLib is
  not used at runtime.
* If gEdkiiFirmwareManagementProgressProtocolGuid is present,
  then use its progress bar color and watchdog timer value.
* If gEdkiiFirmwareManagementProgressProtocolGuid is not present,
  then use default progress bar color and 5 min watchdog timer.
* Remove Print() calls during capsule processing.  Instead,
  the DisplayUpdateProgressLib is used to inform the user
  of progress during a capsule update.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
---
 .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.c       | 47 +++++++++---
 .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf     |  8 ++-
 .../DxeCapsuleLibFmp/DxeCapsuleProcessLib.c        | 84 ++++++++++++++++------
 .../DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c    | 21 +++++-
 .../DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf      |  7 +-
 5 files changed, 131 insertions(+), 36 deletions(-)

diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
index 555c5971d0..5be6bf386e 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
@@ -45,6 +45,7 @@
 #include <Protocol/GraphicsOutput.h>
 #include <Protocol/EsrtManagement.h>
 #include <Protocol/FirmwareManagement.h>
+#include <Protocol/FirmwareManagementProgress.h>
 #include <Protocol/DevicePath.h>
 
 EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable                  = NULL;
@@ -53,6 +54,8 @@ BOOLEAN                   mIsVirtualAddrConverted      = FALSE;
 BOOLEAN                   mDxeCapsuleLibEndOfDxe       = FALSE;
 EFI_EVENT                 mDxeCapsuleLibEndOfDxeEvent  = NULL;
 
+EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL  *mFmpProgress = NULL;
+
 /**
   Initialize capsule related variables.
 **/
@@ -101,18 +104,17 @@ RecordFmpCapsuleStatusVariable (
   Function indicate the current completion progress of the firmware
   update. Platform may override with own specific progress function.
 
-  @param[in]  Completion    A value between 1 and 100 indicating the current completion progress of the firmware update
+  @param[in]  Completion  A value between 1 and 100 indicating the current
+                          completion progress of the firmware update
 
-  @retval EFI_SUCESS    Input capsule is a correct FMP capsule.
+  @retval EFI_SUCESS             The capsule update progress was updated.
+  @retval EFI_INVALID_PARAMETER  Completion is greater than 100%.
 **/
 EFI_STATUS
 EFIAPI
-Update_Image_Progress (
+UpdateImageProgress (
   IN UINTN  Completion
-  )
-{
-  return EFI_SUCCESS;
-}
+  );
 
 /**
   Return if this CapsuleGuid is a FMP capsule GUID or not.
@@ -849,6 +851,19 @@ SetFmpImageData (
     return Status;
   }
 
+  //
+  // Lookup Firmware Management Progress Protocol before SetImage() is called
+  // This is an optional protocol that may not be present on Handle.
+  //
+  Status = gBS->HandleProtocol (
+                  Handle,
+                  &gEdkiiFirmwareManagementProgressProtocolGuid,
+                  (VOID **)&mFmpProgress
+                  );
+  if (EFI_ERROR (Status)) {
+    mFmpProgress = NULL;
+  }
+
   if (ImageHeader->Version >= EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER_INIT_VERSION) {
     Image = (UINT8 *)(ImageHeader + 1);
   } else {
@@ -873,21 +888,37 @@ SetFmpImageData (
     DEBUG((DEBUG_INFO, "(UpdateHardwareInstance - 0x%x)", ImageHeader->UpdateHardwareInstance));
   }
   DEBUG((DEBUG_INFO, "\n"));
+
+  //
+  // Before calling SetImage(), reset the progress bar to 0%
+  //
+  UpdateImageProgress (0);
+
   Status = Fmp->SetImage(
                   Fmp,
                   ImageHeader->UpdateImageIndex,          // ImageIndex
                   Image,                                  // Image
                   ImageHeader->UpdateImageSize,           // ImageSize
                   VendorCode,                             // VendorCode
-                  Update_Image_Progress,                  // Progress
+                  UpdateImageProgress,                    // Progress
                   &AbortReason                            // AbortReason
                   );
+  //
+  // Set the progress bar to 100% after returning from SetImage()
+  //
+  UpdateImageProgress (100);
+
   DEBUG((DEBUG_INFO, "Fmp->SetImage - %r\n", Status));
   if (AbortReason != NULL) {
     DEBUG ((DEBUG_ERROR, "%s\n", AbortReason));
     FreePool(AbortReason);
   }
 
+  //
+  // Clear mFmpProgress after SetImage() returns
+  //
+  mFmpProgress = NULL;
+
   return Status;
 }
 
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
index 1d947101d3..8367264f76 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
@@ -52,6 +52,7 @@ [LibraryClasses]
   PrintLib
   HobLib
   BmpSupportLib
+  DisplayUpdateProgressLib
 
 [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleMax                               ## CONSUMES
@@ -66,9 +67,10 @@ [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleStatusCodeResettingSystem         ## CONSUMES
 
 [Protocols]
-  gEsrtManagementProtocolGuid             ## CONSUMES
-  gEfiFirmwareManagementProtocolGuid      ## CONSUMES
-  gEdkiiVariableLockProtocolGuid          ## SOMETIMES_CONSUMES
+  gEsrtManagementProtocolGuid                   ## CONSUMES
+  gEfiFirmwareManagementProtocolGuid            ## CONSUMES
+  gEdkiiVariableLockProtocolGuid                ## SOMETIMES_CONSUMES
+  gEdkiiFirmwareManagementProgressProtocolGuid  ## SOMETIMES_CONSUMES
 
 [Guids]
   gEfiFmpCapsuleGuid                      ## SOMETIMES_CONSUMES ## GUID
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c
index ba3ff90b9f..e8c506080e 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c
@@ -9,7 +9,7 @@
   ProcessCapsules(), ProcessTheseCapsules() will receive untrusted
   input and do basic validation.
 
-  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
   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
@@ -22,6 +22,7 @@
 
 #include <PiDxe.h>
 #include <Protocol/EsrtManagement.h>
+#include <Protocol/FirmwareManagementProgress.h>
 
 #include <Library/BaseLib.h>
 #include <Library/DebugLib.h>
@@ -34,9 +35,12 @@
 #include <Library/HobLib.h>
 #include <Library/ReportStatusCodeLib.h>
 #include <Library/CapsuleLib.h>
+#include <Library/DisplayUpdateProgressLib.h>
 
 #include <IndustryStandard/WindowsUxCapsule.h>
 
+extern EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL  *mFmpProgress;
+
 /**
   Return if this FMP is a system FMP or a device FMP, based upon CapsuleHeader.
 
@@ -101,6 +105,62 @@ VOID                        **mCapsulePtr;
 EFI_STATUS                  *mCapsuleStatusArray;
 UINT32                      mCapsuleTotalNumber;
 
+/**
+  Function indicate the current completion progress of the firmware
+  update. Platform may override with own specific progress function.
+
+  @param[in]  Completion  A value between 1 and 100 indicating the current
+                          completion progress of the firmware update
+
+  @retval EFI_SUCESS             The capsule update progress was updated.
+  @retval EFI_INVALID_PARAMETER  Completion is greater than 100%.
+**/
+EFI_STATUS
+EFIAPI
+UpdateImageProgress (
+  IN UINTN  Completion
+  )
+{
+  EFI_STATUS                           Status;
+  UINTN                                Seconds;
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION  *Color;
+
+  DEBUG((DEBUG_INFO, "Update Progress - %d%%\n", Completion));
+
+  if (Completion > 100) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  //
+  // Use a default timeout of 5 minutes if there is not FMP Progress Protocol.
+  //
+  Seconds = 5 * 60;
+  Color   = NULL;
+  if (mFmpProgress != NULL) {
+    Seconds = mFmpProgress->WatchdogSeconds;
+    Color   = &mFmpProgress->ProgressBarColor;
+  }
+
+  //
+  // Cancel the watchdog timer
+  //
+  gBS->SetWatchdogTimer (0, 0x0000, 0, NULL);
+
+  if (Completion != 100) {
+    //
+    // Arm the watchdog timer from PCD setting
+    //
+    if (Seconds != 0) {
+      DEBUG ((DEBUG_VERBOSE, "Arm watchdog timer %d seconds\n", Seconds));
+      gBS->SetWatchdogTimer (Seconds, 0x0000, 0, NULL);
+    }
+  }
+
+  Status = DisplayUpdateProgress (Completion, Color);
+
+  return Status;
+}
+
 /**
   This function initializes the mCapsulePtr, mCapsuleStatusArray and mCapsuleTotalNumber.
 **/
@@ -319,7 +379,6 @@ ProcessTheseCapsules (
   EFI_STATUS                  Status;
   EFI_CAPSULE_HEADER          *CapsuleHeader;
   UINT32                      Index;
-  BOOLEAN                     DisplayCapsuleExist;
   ESRT_MANAGEMENT_PROTOCOL    *EsrtManagement;
   UINT16                      EmbeddedDriverCount;
 
@@ -354,12 +413,10 @@ ProcessTheseCapsules (
   //
   // If Windows UX capsule exist, process it first
   //
-  DisplayCapsuleExist = FALSE;
   for (Index = 0; Index < mCapsuleTotalNumber; Index++) {
     CapsuleHeader = (EFI_CAPSULE_HEADER*) mCapsulePtr [Index];
     if (CompareGuid (&CapsuleHeader->CapsuleGuid, &gWindowsUxCapsuleGuid)) {
       DEBUG ((DEBUG_INFO, "ProcessCapsuleImage (Ux) - 0x%x\n", CapsuleHeader));
-      DisplayCapsuleExist = TRUE;
       DEBUG ((DEBUG_INFO, "Display logo capsule is found.\n"));
       Status = ProcessCapsuleImage (CapsuleHeader);
       mCapsuleStatusArray [Index] = EFI_SUCCESS;
@@ -368,12 +425,7 @@ ProcessTheseCapsules (
     }
   }
 
-  if (!DisplayCapsuleExist) {
-    //
-    // Display Capsule not found. Display the default string.
-    //
-    Print (L"Updating the firmware ......\r\n");
-  }
+  DEBUG ((DEBUG_INFO, "Updating the firmware ......\n"));
 
   //
   // All capsules left are recognized by platform.
@@ -411,7 +463,6 @@ ProcessTheseCapsules (
           if (EFI_ERROR(Status)) {
             REPORT_STATUS_CODE(EFI_ERROR_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeUpdateFirmwareFailed)));
             DEBUG ((DEBUG_ERROR, "Capsule process failed!\n"));
-            Print (L"Firmware update failed...\r\n");
           } else {
             REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeUpdateFirmwareSuccess)));
           }
@@ -447,18 +498,9 @@ DoResetSystem (
   VOID
   )
 {
-  UINTN                         Index;
-
-  REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeResettingSystem)));
-
-  Print(L"Capsule Request Cold Reboot.\n");
   DEBUG((DEBUG_INFO, "Capsule Request Cold Reboot."));
 
-  for (Index = 5; Index > 0; Index--) {
-    Print(L"\rResetting system in %d seconds ...", Index);
-    DEBUG((DEBUG_INFO, "\rResetting system in %d seconds ...", Index));
-    gBS->Stall(1000000);
-  }
+  REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeResettingSystem)));
 
   gRT->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL);
 
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c
index 07e9e46eae..274c1c4c1c 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c
@@ -3,7 +3,7 @@
   Dummy function for runtime module, because CapsuleDxeRuntime
   does not need call ProcessCapsules().
 
-  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
   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
@@ -17,6 +17,25 @@
 #include <PiDxe.h>
 #include <Library/CapsuleLib.h>
 
+/**
+  Function indicate the current completion progress of the firmware
+  update. Platform may override with own specific progress function.
+
+  @param[in]  Completion  A value between 1 and 100 indicating the current
+                          completion progress of the firmware update
+
+  @retval EFI_SUCESS             The capsule update progress was updated.
+  @retval EFI_INVALID_PARAMETER  Completion is greater than 100%.
+**/
+EFI_STATUS
+EFIAPI
+UpdateImageProgress (
+  IN UINTN  Completion
+  )
+{
+  return EFI_SUCCESS;
+}
+
 /**
 
   This routine is called to process capsules.
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
index 1659b13ef4..342df9e99c 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
@@ -69,9 +69,10 @@ [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleStatusCodeResettingSystem         ## CONSUMES
 
 [Protocols]
-  gEsrtManagementProtocolGuid             ## CONSUMES
-  gEfiFirmwareManagementProtocolGuid      ## CONSUMES
-  gEdkiiVariableLockProtocolGuid          ## SOMETIMES_CONSUMES
+  gEsrtManagementProtocolGuid                   ## CONSUMES
+  gEfiFirmwareManagementProtocolGuid            ## CONSUMES
+  gEdkiiVariableLockProtocolGuid                ## SOMETIMES_CONSUMES
+  gEdkiiFirmwareManagementProgressProtocolGuid  ## SOMETIMES_CONSUMES
 
 [Guids]
   gEfiFmpCapsuleGuid                      ## SOMETIMES_CONSUMES ## GUID
-- 
2.14.2.windows.3



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [Patch 6/9] SignedCapsulePkg/PlatformFlashAccessLib: Add progress API
  2018-04-04 20:25 [Patch 0/9] Add DisplayUpdateProgressLib for capsules Michael D Kinney
                   ` (4 preceding siblings ...)
  2018-04-04 20:25 ` [Patch 5/9] MdeModulePkg/DxeCapsuleLibFmp: Add progress bar support Michael D Kinney
@ 2018-04-04 20:25 ` Michael D Kinney
  2018-04-04 20:25 ` [Patch 7/9] Vlv2TbltDevicePkg/PlatformFlashAccessLib: " Michael D Kinney
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: Michael D Kinney @ 2018-04-04 20:25 UTC (permalink / raw)
  To: edk2-devel; +Cc: Jiewen Yao

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

Add a new API to the PlatformFlashAccessLib that passes
in an optional Progress() function along with a start and
end percentage to call the Progress() function with.
If the Progress() function is not NULL, then it is the
Progress() function that was passed into the Firmware
Management Protocol SetImage() services and is used
to update the user on the progress as a firmware device
is updated with a firmware image.

Implementations of the PlatformFlashAccessLib are
recommended to call the Progress() function as work
is performed to update to contents of a firmware
storage device.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
---
 .../Include/Library/PlatformFlashAccessLib.h       | 33 ++++++++++++-
 .../PlatformFlashAccessLibNull.c                   | 54 +++++++++++++++++++---
 2 files changed, 78 insertions(+), 9 deletions(-)

diff --git a/SignedCapsulePkg/Include/Library/PlatformFlashAccessLib.h b/SignedCapsulePkg/Include/Library/PlatformFlashAccessLib.h
index 0a8858e4c4..a691baccc4 100644
--- a/SignedCapsulePkg/Include/Library/PlatformFlashAccessLib.h
+++ b/SignedCapsulePkg/Include/Library/PlatformFlashAccessLib.h
@@ -1,7 +1,7 @@
 /** @file
   Platform flash device access library.
 
-  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
   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
@@ -16,6 +16,8 @@
 #ifndef __PLATFORM_FLASH_ACCESS_LIB_H__
 #define __PLATFORM_FLASH_ACCESS_LIB_H__
 
+#include <Protocol/FirmwareManagement.h>
+
 typedef enum {
   FlashAddressTypeRelativeAddress,
   FlashAddressTypeAbsoluteAddress,
@@ -31,7 +33,7 @@ typedef enum {
 } PLATFORM_FIRMWARE_TYPE;
 
 /**
-  Perform flash write opreation.
+  Perform flash write operation.
 
   @param[in] FirmwareType      The type of firmware.
   @param[in] FlashAddress      The address of flash device to be accessed.
@@ -54,4 +56,31 @@ PerformFlashWrite (
   IN UINTN                        Length
   );
 
+/**
+  Perform flash write operation with progress indicator.
+
+  @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
+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
+  );
+
 #endif
diff --git a/SignedCapsulePkg/Library/PlatformFlashAccessLibNull/PlatformFlashAccessLibNull.c b/SignedCapsulePkg/Library/PlatformFlashAccessLibNull/PlatformFlashAccessLibNull.c
index b34ebbba1e..19c8f1acd9 100644
--- a/SignedCapsulePkg/Library/PlatformFlashAccessLibNull/PlatformFlashAccessLibNull.c
+++ b/SignedCapsulePkg/Library/PlatformFlashAccessLibNull/PlatformFlashAccessLibNull.c
@@ -1,7 +1,7 @@
 /** @file
   Platform flash device access library NULL instance.
 
-  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
   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
@@ -20,7 +20,41 @@
 UINT64 mInternalFdAddress;
 
 /**
-  Perform flash write opreation.
+  Perform flash write operation with progress indicator.
+
+  @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
+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
+  )
+{
+  if (FlashAddressType == FlashAddressTypeRelativeAddress) {
+    FlashAddress = FlashAddress + mInternalFdAddress;
+  }
+  CopyMem((VOID *)(UINTN)(FlashAddress), Buffer, Length);
+  return EFI_SUCCESS;
+}
+
+/**
+  Perform flash write operation.
 
   @param[in] FirmwareType      The type of firmware.
   @param[in] FlashAddress      The address of flash device to be accessed.
@@ -43,9 +77,15 @@ PerformFlashWrite (
   IN UINTN                        Length
   )
 {
-  if (FlashAddressType == FlashAddressTypeRelativeAddress) {
-    FlashAddress = FlashAddress + mInternalFdAddress;
-  }
-  CopyMem((VOID *)(UINTN)(FlashAddress), Buffer, Length);
-  return EFI_SUCCESS;
+  return PerformFlashWriteWithProgress (
+           FirmwareType,
+           FlashAddress,
+           FlashAddressType,
+           Buffer,
+           Length,
+           NULL,
+           0,
+           0
+           );
 }
+
-- 
2.14.2.windows.3



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [Patch 7/9] Vlv2TbltDevicePkg/PlatformFlashAccessLib: Add progress API
  2018-04-04 20:25 [Patch 0/9] Add DisplayUpdateProgressLib for capsules Michael D Kinney
                   ` (5 preceding siblings ...)
  2018-04-04 20:25 ` [Patch 6/9] SignedCapsulePkg/PlatformFlashAccessLib: Add progress API Michael D Kinney
@ 2018-04-04 20:25 ` Michael D Kinney
  2018-04-08  6:11   ` Wei, David
  2018-04-04 20:25 ` [Patch 8/9] QuarkPlatformPkg/PlatformFlashAccessLib: " Michael D Kinney
                   ` (3 subsequent siblings)
  10 siblings, 1 reply; 17+ messages in thread
From: Michael D Kinney @ 2018-04-04 20:25 UTC (permalink / raw)
  To: edk2-devel; +Cc: David Wei, Mang Guo

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

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 <david.wei@intel.com>
Cc: Mang Guo <mang.guo@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
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/PlatformFlashAccessLib/PlatformFlashAccessLib.c b/Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.c
index 9162e025ed..868e4049bb 100644
--- a/Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.c
+++ b/Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.c
@@ -1,7 +1,7 @@
 /** @file
   Platform Flash Access library.
 
-  Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
   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
@@ -381,7 +381,7 @@ InternalWriteBlock (
 }
 
 /**
-  Perform flash write opreation.
+  Perform flash write operation with progress indicator.
 
   @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 = 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 = gBS->RaiseTPL (TPL_NOTIFY);
     for (Index = 0; Index < CountOfBlocks; Index++) {
+      if (Progress != NULL) {
+        Progress (StartPercentage + ((Index * (EndPercentage - StartPercentage)) / 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  = InternalEraseBlock (Address);
-  if (EFI_ERROR(Status)) {
+        if (EFI_ERROR(Status)) {
           gBS->RestoreTPL (OldTpl);
           FlashError = TRUE;
           goto Done;
-  }
+        }
         Status = InternalWriteBlock (
                   Address,
                   Buf,
                   (UINT32)(Length > BLOCK_SIZE ? BLOCK_SIZE : Length)
                   );
-  if (EFI_ERROR(Status)) {
+        if (EFI_ERROR(Status)) {
           gBS->RestoreTPL (OldTpl);
           FlashError = TRUE;
           goto Done;
         }
-  }
+      }
 
       //
       // Move to next block to update.
@@ -506,26 +507,55 @@ PerformFlashWrite (
     }
     gBS->RestoreTPL (OldTpl);
 
-  Done:
+Done:
   if ((BiosCntl & B_PCH_LPC_BIOS_CNTL_SMM_BWP) == 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);
   }
 
   return EFI_SUCCESS;
 }
 
 /**
-  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.
 
   @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/PlatformFlashAccessLib/PlatformFlashAccessLib.inf b/Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.inf
index fbbdb91b64..8ff0084dd4 100644
--- a/Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.inf
+++ b/Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.inf
@@ -1,7 +1,7 @@
 ## @file
 #  Platform Flash Access library.
 #
-#  Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>
 #  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
@@ -43,7 +43,6 @@ [LibraryClasses]
   IoLib
   PcdLib
   DebugLib
-#  FlashDeviceLib
   MemoryAllocationLib
   CacheMaintenanceLib
 
-- 
2.14.2.windows.3



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [Patch 8/9] QuarkPlatformPkg/PlatformFlashAccessLib: Add progress API
  2018-04-04 20:25 [Patch 0/9] Add DisplayUpdateProgressLib for capsules Michael D Kinney
                   ` (6 preceding siblings ...)
  2018-04-04 20:25 ` [Patch 7/9] Vlv2TbltDevicePkg/PlatformFlashAccessLib: " Michael D Kinney
@ 2018-04-04 20:25 ` Michael D Kinney
  2018-04-04 20:25 ` [Patch 9/9] SignedCapsulePkg/SystemFirmwareUpdateDxe: Use " Michael D Kinney
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 17+ messages in thread
From: Michael D Kinney @ 2018-04-04 20:25 UTC (permalink / raw)
  To: edk2-devel

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

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: Kelly Steele <kelly.steele@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
---
 .../PlatformFlashAccessLibDxe.c                    | 59 +++++++++++++++++++---
 1 file changed, 51 insertions(+), 8 deletions(-)

diff --git a/QuarkPlatformPkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLibDxe.c b/QuarkPlatformPkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLibDxe.c
index 839c3a726e..7bc6d20d52 100644
--- a/QuarkPlatformPkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLibDxe.c
+++ b/QuarkPlatformPkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLibDxe.c
@@ -1,7 +1,7 @@
 /** @file
   Platform Flash Access library.
 
-  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
   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
@@ -112,7 +112,7 @@ FlashFdErase (
 }
 
 /**
-  Perform flash write opreation.
+  Perform flash write opreration with progress indicator.
 
   @param[in] FirmwareType      The type of firmware.
   @param[in] FlashAddress      The address of flash device to be accessed.
@@ -127,12 +127,15 @@ FlashFdErase (
 **/
 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;
@@ -150,6 +153,10 @@ PerformFlashWrite (
   //
   SectorNum = Length / SPI_ERASE_SECTOR_SIZE;
   for (Index = 0; Index < SectorNum; Index++){
+    if (Progress != NULL) {
+      Progress (StartPercentage + ((Index * (EndPercentage - StartPercentage)) / SectorNum));
+    }
+
     if (CompareMem(
           (UINT8 *)(UINTN)(FlashAddress + mInternalFdAddress) + Index * SPI_ERASE_SECTOR_SIZE,
           (UINT8 *)Buffer + Index * SPI_ERASE_SECTOR_SIZE,
@@ -179,6 +186,42 @@ PerformFlashWrite (
   return EFI_SUCCESS;
 }
 
+/**
+  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
+           );
+}
+
 /**
   Platform Flash Access Lib Constructor.
 
-- 
2.14.2.windows.3



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [Patch 9/9] SignedCapsulePkg/SystemFirmwareUpdateDxe: Use progress API
  2018-04-04 20:25 [Patch 0/9] Add DisplayUpdateProgressLib for capsules Michael D Kinney
                   ` (7 preceding siblings ...)
  2018-04-04 20:25 ` [Patch 8/9] QuarkPlatformPkg/PlatformFlashAccessLib: " Michael D Kinney
@ 2018-04-04 20:25 ` Michael D Kinney
  2018-04-06 13:55   ` Ard Biesheuvel
  2018-04-04 20:29 ` [Patch 0/9] Add DisplayUpdateProgressLib for capsules Kinney, Michael D
  2018-04-05  0:02 ` Yao, Jiewen
  10 siblings, 1 reply; 17+ messages in thread
From: Michael D Kinney @ 2018-04-04 20:25 UTC (permalink / raw)
  To: edk2-devel; +Cc: Kinney, Michael D, Jiewen Yao

From: "Kinney, Michael D" <michael.d.kinney@intel.com>

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 <jiewen.yao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
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.<BR>
+  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
   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 UINTN                        ConfigImageSize,
-  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_STATUS                            Status;
@@ -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,
                FlashAddressTypeRelativeAddress,
                SystemFirmwareImage,
-               SystemFirmwareImageSize
+               SystemFirmwareImageSize,
+               Progress,
+               StartPercentage,
+               EndPercentage
                );
+    if (Progress != NULL) {
+      Progress (EndPercentage);
+    }
     if (!EFI_ERROR(Status)) {
       *LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
       mNvRamUpdated = TRUE;
@@ -163,18 +185,37 @@ UpdateImage (
   DEBUG((DEBUG_INFO, "ConfigHeader.NumOfUpdates - 0x%x\n", ConfigHeader.NumOfUpdates));
   DEBUG((DEBUG_INFO, "PcdEdkiiSystemFirmwareFileGuid - %g\n", PcdGetPtr(PcdEdkiiSystemFirmwareFileGuid)));
 
+  TotalSize = 0;
+  for (Index = 0; Index < ConfigHeader.NumOfUpdates; Index++) {
+    if (CompareGuid(&ConfigData[Index].FileGuid, PcdGetPtr(PcdEdkiiSystemFirmwareFileGuid))) {
+      TotalSize = TotalSize + ConfigData[Index].Length;
+    }
+  }
+
+  BytesWritten = 0;
   Index = 0;
   UpdateConfigData = ConfigData;
   while (Index < ConfigHeader.NumOfUpdates) {
     if (CompareGuid(&UpdateConfigData->FileGuid, PcdGetPtr(PcdEdkiiSystemFirmwareFileGuid))) {
       DEBUG((DEBUG_INFO, "FileGuid - %g (processing)\n", &UpdateConfigData->FileGuid));
+      StartPercentage = (BytesWritten * 100) / TotalSize;
+      EndPercentage   = ((BytesWritten + UpdateConfigData->Length) * 100) / TotalSize;
+      if (Progress != NULL) {
+        Progress (StartPercentage);
+      }
       Status = PerformUpdate (
                  SystemFirmwareImage,
                  SystemFirmwareImageSize,
                  UpdateConfigData,
                  LastAttemptVersion,
-                 LastAttemptStatus
+                 LastAttemptStatus,
+                 Progress,
+                 StartPercentage,
+                 EndPercentage
                  );
+      if (Progress != NULL) {
+        Progress (EndPercentage);
+      }
       //
       // Shall updates be serialized so that if an update is not successfully completed,
       // the remaining updates won't be performed.
@@ -186,6 +227,8 @@ UpdateImage (
       DEBUG((DEBUG_INFO, "FileGuid - %g (ignored)\n", &UpdateConfigData->FileGuid));
     }
 
+    BytesWritten += UpdateConfigData->Length;
+
     Index++;
     UpdateConfigData++;
   }
@@ -209,10 +252,11 @@ UpdateImage (
 **/
 EFI_STATUS
 SystemFirmwareAuthenticatedUpdate (
-  IN VOID                         *Image,
-  IN UINTN                        ImageSize,
-  OUT UINT32                      *LastAttemptVersion,
-  OUT UINT32                      *LastAttemptStatus
+  IN VOID                                           *Image,
+  IN UINTN                                          ImageSize,
+  OUT UINT32                                        *LastAttemptVersion,
+  OUT UINT32                                        *LastAttemptStatus,
+  IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS  Progress
   )
 {
   EFI_STATUS                  Status;
@@ -240,7 +284,7 @@ SystemFirmwareAuthenticatedUpdate (
   ExtractConfigImage(AuthenticatedImage, AuthenticatedImageSize, &ConfigImage, &ConfigImageSize);
 
   DEBUG((DEBUG_INFO, "UpdateImage ...\n"));
-  Status = UpdateImage(SystemFirmwareImage, SystemFirmwareImageSize, ConfigImage, ConfigImageSize, LastAttemptVersion, LastAttemptStatus);
+  Status = UpdateImage(SystemFirmwareImage, SystemFirmwareImageSize, ConfigImage, ConfigImageSize, LastAttemptVersion, LastAttemptStatus, Progress);
   if (EFI_ERROR(Status)) {
     DEBUG((DEBUG_INFO, "UpdateImage - %r\n", Status));
     return Status;
@@ -442,8 +486,8 @@ FmpSetImage (
     return EFI_INVALID_PARAMETER;
   }
 
-  Status = SystemFirmwareAuthenticatedUpdate((VOID *)Image, ImageSize, &SystemFmpPrivate->LastAttempt.LastAttemptVersion, &SystemFmpPrivate->LastAttempt.LastAttemptStatus);
-  DEBUG((DEBUG_INFO, "SetImage - LastAttemp Version - 0x%x, State - 0x%x\n", SystemFmpPrivate->LastAttempt.LastAttemptVersion, SystemFmpPrivate->LastAttempt.LastAttemptStatus));
+  Status = SystemFirmwareAuthenticatedUpdate((VOID *)Image, ImageSize, &SystemFmpPrivate->LastAttempt.LastAttemptVersion, &SystemFmpPrivate->LastAttempt.LastAttemptStatus, Progress);
+  DEBUG((DEBUG_INFO, "SetImage - LastAttempt Version - 0x%x, State - 0x%x\n", SystemFmpPrivate->LastAttempt.LastAttemptVersion, SystemFmpPrivate->LastAttempt.LastAttemptStatus));
 
   //
   // If NVRAM is updated, we should no longer touch variable services, because
-- 
2.14.2.windows.3



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [Patch 0/9] Add DisplayUpdateProgressLib for capsules
  2018-04-04 20:25 [Patch 0/9] Add DisplayUpdateProgressLib for capsules Michael D Kinney
                   ` (8 preceding siblings ...)
  2018-04-04 20:25 ` [Patch 9/9] SignedCapsulePkg/SystemFirmwareUpdateDxe: Use " Michael D Kinney
@ 2018-04-04 20:29 ` Kinney, Michael D
  2018-04-05  0:02 ` Yao, Jiewen
  10 siblings, 0 replies; 17+ messages in thread
From: Kinney, Michael D @ 2018-04-04 20:29 UTC (permalink / raw)
  To: Kinney, Michael D, edk2-devel@lists.01.org
  Cc: Dong, Eric, Yao, Jiewen, Zeng, Star, Wei, David

This patch series is also available for review on the 
following branch:

https://github.com/mdkinney/edk2/tree/Bug_801_DisplayUpdateProgressLib

Mike

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-
> bounces@lists.01.org] On Behalf Of Michael D Kinney
> Sent: Wednesday, April 4, 2018 1:26 PM
> To: edk2-devel@lists.01.org
> Cc: Dong, Eric <eric.dong@intel.com>; Yao, Jiewen
> <jiewen.yao@intel.com>; Zeng, Star
> <star.zeng@intel.com>; Wei, David <david.wei@intel.com>
> Subject: [edk2] [Patch 0/9] Add
> DisplayUpdateProgressLib for capsules
> 
> https://bugzilla.tianocore.org/show_bug.cgi?id=801
> 
> Based on content from:
> 
> https://github.com/Microsoft/MS_UEFI/blob/share/MsCapsu
> leSupport/MsCapsuleUpdatePkg/Include/Library/DisplayUpd
> ateProgressLib.h
> https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsu
> leSupport/MsCapsuleUpdatePkg/Library/DisplayUpdateProgr
> essGraphicsLib
> https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsu
> leSupport/MsCapsuleUpdatePkg/Library/DisplayUpdateProgr
> essTextLib
> 
> Add DisplayUpdateProgressLib class along
> implementations for both graphical
> (Graphics Output Protocol based) and text (Simple Text
> Output Protocol based)
> consoles.  Also add the EDK II Firmware Management
> Progress Protocol that is an
> optional protocol that provides the progress bar color
> and a watchdog timeout
> value thaty can be used when a firmware image is
> updated in a firmware device.
> 
> * Add progress support to DxeCapsuleLibFmp
> * Add progress support to SystemFirmwareUpdateDxe
> * Add progress support to PlatformFlashAccessLib class
> and instances.
> * Reduce Print() calls during a firmware update.
> 
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: David Wei <david.wei@intel.com>
> Cc: Mang Guo <mang.guo@intel.com>
> Cc: Kelly Steele <kelly.steele@intel.com>
> 
> Signed-off-by: Michael D Kinney
> <michael.d.kinney@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> 
> Kinney, Michael D (3):
>   QuarkPlatformPkg: Add DisplayUpdateProgressLib
> mapping
>   MdeModulePkg/DxeCapsuleLibFmp: Add progress bar
> support
>   SignedCapsulePkg/SystemFirmwareUpdateDxe: Use
> progress API
> 
> Michael D Kinney (6):
>   MdeModulePkg: Add DisplayUpdateProgressLib class
>   MdeModulePkg: Add DisplayUpdateProgressLib instances
>   Vlv2Tbl2DevicePkg: Add DisplayUpdateProgressLib
> mapping
>   SignedCapsulePkg/PlatformFlashAccessLib: Add progress
> API
>   Vlv2TbltDevicePkg/PlatformFlashAccessLib: Add
> progress API
>   QuarkPlatformPkg/PlatformFlashAccessLib: Add progress
> API
> 
>  .../Include/Library/DisplayUpdateProgressLib.h     |
> 65 +++
>  .../Include/Protocol/FirmwareManagementProgress.h  |
> 50 +++
>  .../DisplayUpdateProgressGraphicsLib.c             |
> 475 +++++++++++++++++++++
>  .../DisplayUpdateProgressGraphicsLib.inf           |
> 60 +++
>  .../DisplayUpdateProgressGraphicsLib.uni           |
> 18 +
>  .../DisplayUpdateProgressTextLib.c                 |
> 142 ++++++
>  .../DisplayUpdateProgressTextLib.inf               |
> 53 +++
>  .../DisplayUpdateProgressTextLib.uni               |
> 18 +
>  .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.c       |
> 47 +-
>  .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf     |
> 8 +-
>  .../DxeCapsuleLibFmp/DxeCapsuleProcessLib.c        |
> 84 +++-
>  .../DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c    |
> 21 +-
>  .../DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf      |
> 7 +-
>  MdeModulePkg/MdeModulePkg.dec                      |
> 11 +
>  MdeModulePkg/MdeModulePkg.dsc                      |
> 3 +
>  .../PlatformFlashAccessLibDxe.c                    |
> 59 ++-
>  QuarkPlatformPkg/Quark.dsc                         |
> 1 +
>  .../Include/Library/PlatformFlashAccessLib.h       |
> 33 +-
>  .../PlatformFlashAccessLibNull.c                   |
> 54 ++-
>  .../SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c |
> 92 ++--
>  .../PlatformFlashAccessLib.c                       |
> 84 ++--
>  .../PlatformFlashAccessLib.inf                     |
> 3 +-
>  Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc            |
> 1 +
>  Vlv2TbltDevicePkg/PlatformPkgIA32.dsc              |
> 1 +
>  Vlv2TbltDevicePkg/PlatformPkgX64.dsc               |
> 1 +
>  25 files changed, 1285 insertions(+), 106 deletions(-)
>  create mode 100644
> MdeModulePkg/Include/Library/DisplayUpdateProgressLib.h
>  create mode 100644
> MdeModulePkg/Include/Protocol/FirmwareManagementProgres
> s.h
>  create mode 100644
> MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/D
> isplayUpdateProgressGraphicsLib.c
>  create mode 100644
> MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/D
> isplayUpdateProgressGraphicsLib.inf
>  create mode 100644
> MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/D
> isplayUpdateProgressGraphicsLib.uni
>  create mode 100644
> MdeModulePkg/Library/DisplayUpdateProgressTextLib/Displ
> ayUpdateProgressTextLib.c
>  create mode 100644
> MdeModulePkg/Library/DisplayUpdateProgressTextLib/Displ
> ayUpdateProgressTextLib.inf
>  create mode 100644
> MdeModulePkg/Library/DisplayUpdateProgressTextLib/Displ
> ayUpdateProgressTextLib.uni
> 
> --
> 2.14.2.windows.3
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [Patch 0/9] Add DisplayUpdateProgressLib for capsules
  2018-04-04 20:25 [Patch 0/9] Add DisplayUpdateProgressLib for capsules Michael D Kinney
                   ` (9 preceding siblings ...)
  2018-04-04 20:29 ` [Patch 0/9] Add DisplayUpdateProgressLib for capsules Kinney, Michael D
@ 2018-04-05  0:02 ` Yao, Jiewen
  2018-04-05  0:37   ` Kinney, Michael D
  10 siblings, 1 reply; 17+ messages in thread
From: Yao, Jiewen @ 2018-04-05  0:02 UTC (permalink / raw)
  To: Kinney, Michael D, edk2-devel@lists.01.org
  Cc: Sean Brogan, Zeng, Star, Dong, Eric, Wei, David, Guo, Mang,
	Steele, Kelly

Thanks Mike.
It is a good feature to add progress support.

Some thought below:
1) for EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL
Do you think if we need add full support for WatchdogTimer services?
Such as WatchdogCode, WatchdogData?

Or should we add a version field for the protocol for future extension?

2) For EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL and DisplayUpdateProgress(), we only add EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION  *Color.

Do the color means the foreground color or background color?
I found you treat as background in TextLib. But it seems complicated.
Can we add both to avoid calculation?

That might be another reason to add version field for EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL.

3) According to lib naming conversion, we should use DisplayUpdateProgressLibGraphic, and DisplayUpdateProgressLibText. :-)

4) For PerformFlashWriteWithProgress(), I found the caller (system firmware update) handles Progress (StartPercentage) and Progress (EndPercentage).

And the callee (Quark flash access lib) handles Progress (StartPercentage) but not Progress (EndPercentage).

That is a little weird to me. Can we add more detail description in the PerformFlashWriteWithProgress() function header to clarify who should handle StartPercentage and EndPercentage ?


Thank you
Yao Jiewen

> -----Original Message-----
> From: Kinney, Michael D
> Sent: Thursday, April 5, 2018 4:26 AM
> To: edk2-devel@lists.01.org
> Cc: Sean Brogan <sean.brogan@microsoft.com>; Zeng, Star
> <star.zeng@intel.com>; Dong, Eric <eric.dong@intel.com>; Yao, Jiewen
> <jiewen.yao@intel.com>; Wei, David <david.wei@intel.com>; Guo, Mang
> <mang.guo@intel.com>; Steele, Kelly <kelly.steele@intel.com>
> Subject: [Patch 0/9] Add DisplayUpdateProgressLib for capsules
> 
> https://bugzilla.tianocore.org/show_bug.cgi?id=801
> 
> Based on content from:
> 
> https://github.com/Microsoft/MS_UEFI/blob/share/MsCapsuleSupport/MsCaps
> uleUpdatePkg/Include/Library/DisplayUpdateProgressLib.h
> https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport/MsCapsu
> leUpdatePkg/Library/DisplayUpdateProgressGraphicsLib
> https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport/MsCapsu
> leUpdatePkg/Library/DisplayUpdateProgressTextLib
> 
> Add DisplayUpdateProgressLib class along implementations for both graphical
> (Graphics Output Protocol based) and text (Simple Text Output Protocol based)
> consoles.  Also add the EDK II Firmware Management Progress Protocol that is
> an
> optional protocol that provides the progress bar color and a watchdog timeout
> value thaty can be used when a firmware image is updated in a firmware device.
> 
> * Add progress support to DxeCapsuleLibFmp
> * Add progress support to SystemFirmwareUpdateDxe
> * Add progress support to PlatformFlashAccessLib class and instances.
> * Reduce Print() calls during a firmware update.
> 
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: David Wei <david.wei@intel.com>
> Cc: Mang Guo <mang.guo@intel.com>
> Cc: Kelly Steele <kelly.steele@intel.com>
> 
> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> 
> Kinney, Michael D (3):
>   QuarkPlatformPkg: Add DisplayUpdateProgressLib mapping
>   MdeModulePkg/DxeCapsuleLibFmp: Add progress bar support
>   SignedCapsulePkg/SystemFirmwareUpdateDxe: Use progress API
> 
> Michael D Kinney (6):
>   MdeModulePkg: Add DisplayUpdateProgressLib class
>   MdeModulePkg: Add DisplayUpdateProgressLib instances
>   Vlv2Tbl2DevicePkg: Add DisplayUpdateProgressLib mapping
>   SignedCapsulePkg/PlatformFlashAccessLib: Add progress API
>   Vlv2TbltDevicePkg/PlatformFlashAccessLib: Add progress API
>   QuarkPlatformPkg/PlatformFlashAccessLib: Add progress API
> 
>  .../Include/Library/DisplayUpdateProgressLib.h     |  65 +++
>  .../Include/Protocol/FirmwareManagementProgress.h  |  50 +++
>  .../DisplayUpdateProgressGraphicsLib.c             | 475
> +++++++++++++++++++++
>  .../DisplayUpdateProgressGraphicsLib.inf           |  60 +++
>  .../DisplayUpdateProgressGraphicsLib.uni           |  18 +
>  .../DisplayUpdateProgressTextLib.c                 | 142 ++++++
>  .../DisplayUpdateProgressTextLib.inf               |  53 +++
>  .../DisplayUpdateProgressTextLib.uni               |  18 +
>  .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.c       |  47 +-
>  .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf     |   8 +-
>  .../DxeCapsuleLibFmp/DxeCapsuleProcessLib.c        |  84 +++-
>  .../DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c    |  21 +-
>  .../DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf      |   7 +-
>  MdeModulePkg/MdeModulePkg.dec                      |  11 +
>  MdeModulePkg/MdeModulePkg.dsc                      |   3 +
>  .../PlatformFlashAccessLibDxe.c                    |  59 ++-
>  QuarkPlatformPkg/Quark.dsc                         |   1 +
>  .../Include/Library/PlatformFlashAccessLib.h       |  33 +-
>  .../PlatformFlashAccessLibNull.c                   |  54 ++-
>  .../SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c |  92 ++--
>  .../PlatformFlashAccessLib.c                       |  84 ++--
>  .../PlatformFlashAccessLib.inf                     |   3 +-
>  Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc            |   1 +
>  Vlv2TbltDevicePkg/PlatformPkgIA32.dsc              |   1 +
>  Vlv2TbltDevicePkg/PlatformPkgX64.dsc               |   1 +
>  25 files changed, 1285 insertions(+), 106 deletions(-)
>  create mode 100644
> MdeModulePkg/Include/Library/DisplayUpdateProgressLib.h
>  create mode 100644
> MdeModulePkg/Include/Protocol/FirmwareManagementProgress.h
>  create mode 100644
> MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/DisplayUpdateProg
> ressGraphicsLib.c
>  create mode 100644
> MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/DisplayUpdateProg
> ressGraphicsLib.inf
>  create mode 100644
> MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/DisplayUpdateProg
> ressGraphicsLib.uni
>  create mode 100644
> MdeModulePkg/Library/DisplayUpdateProgressTextLib/DisplayUpdateProgressT
> extLib.c
>  create mode 100644
> MdeModulePkg/Library/DisplayUpdateProgressTextLib/DisplayUpdateProgressT
> extLib.inf
>  create mode 100644
> MdeModulePkg/Library/DisplayUpdateProgressTextLib/DisplayUpdateProgressT
> extLib.uni
> 
> --
> 2.14.2.windows.3



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [Patch 0/9] Add DisplayUpdateProgressLib for capsules
  2018-04-05  0:02 ` Yao, Jiewen
@ 2018-04-05  0:37   ` Kinney, Michael D
  0 siblings, 0 replies; 17+ messages in thread
From: Kinney, Michael D @ 2018-04-05  0:37 UTC (permalink / raw)
  To: Yao, Jiewen, edk2-devel@lists.01.org, Kinney, Michael D
  Cc: Sean Brogan, Zeng, Star, Dong, Eric, Wei, David, Guo, Mang,
	Steele, Kelly, Bret Barkelew

Jiewen,

Responses below.

Mike

> -----Original Message-----
> From: Yao, Jiewen
> Sent: Wednesday, April 4, 2018 5:03 PM
> To: Kinney, Michael D <michael.d.kinney@intel.com>;
> edk2-devel@lists.01.org
> Cc: Sean Brogan <sean.brogan@microsoft.com>; Zeng, Star
> <star.zeng@intel.com>; Dong, Eric
> <eric.dong@intel.com>; Wei, David
> <david.wei@intel.com>; Guo, Mang <mang.guo@intel.com>;
> Steele, Kelly <kelly.steele@intel.com>
> Subject: RE: [Patch 0/9] Add DisplayUpdateProgressLib
> for capsules
> 
> Thanks Mike.
> It is a good feature to add progress support.
> 
> Some thought below:
> 1) for EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL
> Do you think if we need add full support for
> WatchdogTimer services?
> Such as WatchdogCode, WatchdogData?
> 
> Or should we add a version field for the protocol for
> future extension?
> 

A version field is a good idea.  Let's keep it as simple
as possible right now and only add new features based on
real use cases.

> 2) For EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL and
> DisplayUpdateProgress(), we only add
> EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION  *Color.
> 
> Do the color means the foreground color or background
> color?
> I found you treat as background in TextLib. But it
> seems complicated.
> Can we add both to avoid calculation?
> 

It is foreground color.  The text lib should use grey
as background like the graphics lib.

> That might be another reason to add version field for
> EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL.
> 
> 3) According to lib naming conversion, we should use
> DisplayUpdateProgressLibGraphic, and
> DisplayUpdateProgressLibText. :-)
> 

Yes.  We should make that change.

> 4) For PerformFlashWriteWithProgress(), I found the
> caller (system firmware update) handles Progress
> (StartPercentage) and Progress (EndPercentage).
> 
> And the callee (Quark flash access lib) handles
> Progress (StartPercentage) but not Progress
> (EndPercentage).
> 
> That is a little weird to me. Can we add more detail
> description in the PerformFlashWriteWithProgress()
> function header to clarify who should handle
> StartPercentage and EndPercentage ?

The Progress() API passed into functions is OPTIONAL.
Which means it may never get called by the next layer
down.  As a result, if the top level always wants the
progress bar to be displayed correctly, it must always
call for start before and end after.

The Quark and Vlv2 versions of the lib should do the
start and the end.  That is a bug that I can fix.

> 
> 
> Thank you
> Yao Jiewen
> 
> > -----Original Message-----
> > From: Kinney, Michael D
> > Sent: Thursday, April 5, 2018 4:26 AM
> > To: edk2-devel@lists.01.org
> > Cc: Sean Brogan <sean.brogan@microsoft.com>; Zeng,
> Star
> > <star.zeng@intel.com>; Dong, Eric
> <eric.dong@intel.com>; Yao, Jiewen
> > <jiewen.yao@intel.com>; Wei, David
> <david.wei@intel.com>; Guo, Mang
> > <mang.guo@intel.com>; Steele, Kelly
> <kelly.steele@intel.com>
> > Subject: [Patch 0/9] Add DisplayUpdateProgressLib for
> capsules
> >
> > https://bugzilla.tianocore.org/show_bug.cgi?id=801
> >
> > Based on content from:
> >
> >
> https://github.com/Microsoft/MS_UEFI/blob/share/MsCapsu
> leSupport/MsCaps
> >
> uleUpdatePkg/Include/Library/DisplayUpdateProgressLib.h
> >
> https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsu
> leSupport/MsCapsu
> > leUpdatePkg/Library/DisplayUpdateProgressGraphicsLib
> >
> https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsu
> leSupport/MsCapsu
> > leUpdatePkg/Library/DisplayUpdateProgressTextLib
> >
> > Add DisplayUpdateProgressLib class along
> implementations for both graphical
> > (Graphics Output Protocol based) and text (Simple
> Text Output Protocol based)
> > consoles.  Also add the EDK II Firmware Management
> Progress Protocol that is
> > an
> > optional protocol that provides the progress bar
> color and a watchdog timeout
> > value thaty can be used when a firmware image is
> updated in a firmware device.
> >
> > * Add progress support to DxeCapsuleLibFmp
> > * Add progress support to SystemFirmwareUpdateDxe
> > * Add progress support to PlatformFlashAccessLib
> class and instances.
> > * Reduce Print() calls during a firmware update.
> >
> > Cc: Sean Brogan <sean.brogan@microsoft.com>
> > Cc: Star Zeng <star.zeng@intel.com>
> > Cc: Eric Dong <eric.dong@intel.com>
> > Cc: Jiewen Yao <jiewen.yao@intel.com>
> > Cc: David Wei <david.wei@intel.com>
> > Cc: Mang Guo <mang.guo@intel.com>
> > Cc: Kelly Steele <kelly.steele@intel.com>
> >
> > Signed-off-by: Michael D Kinney
> <michael.d.kinney@intel.com>
> > Contributed-under: TianoCore Contribution Agreement
> 1.1
> >
> > Kinney, Michael D (3):
> >   QuarkPlatformPkg: Add DisplayUpdateProgressLib
> mapping
> >   MdeModulePkg/DxeCapsuleLibFmp: Add progress bar
> support
> >   SignedCapsulePkg/SystemFirmwareUpdateDxe: Use
> progress API
> >
> > Michael D Kinney (6):
> >   MdeModulePkg: Add DisplayUpdateProgressLib class
> >   MdeModulePkg: Add DisplayUpdateProgressLib
> instances
> >   Vlv2Tbl2DevicePkg: Add DisplayUpdateProgressLib
> mapping
> >   SignedCapsulePkg/PlatformFlashAccessLib: Add
> progress API
> >   Vlv2TbltDevicePkg/PlatformFlashAccessLib: Add
> progress API
> >   QuarkPlatformPkg/PlatformFlashAccessLib: Add
> progress API
> >
> >  .../Include/Library/DisplayUpdateProgressLib.h     |
> 65 +++
> >  .../Include/Protocol/FirmwareManagementProgress.h  |
> 50 +++
> >  .../DisplayUpdateProgressGraphicsLib.c             |
> 475
> > +++++++++++++++++++++
> >  .../DisplayUpdateProgressGraphicsLib.inf           |
> 60 +++
> >  .../DisplayUpdateProgressGraphicsLib.uni           |
> 18 +
> >  .../DisplayUpdateProgressTextLib.c                 |
> 142 ++++++
> >  .../DisplayUpdateProgressTextLib.inf               |
> 53 +++
> >  .../DisplayUpdateProgressTextLib.uni               |
> 18 +
> >  .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.c       |
> 47 +-
> >  .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf     |
> 8 +-
> >  .../DxeCapsuleLibFmp/DxeCapsuleProcessLib.c        |
> 84 +++-
> >  .../DxeCapsuleLibFmp/DxeCapsuleProcessLibNull.c    |
> 21 +-
> >  .../DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf      |
> 7 +-
> >  MdeModulePkg/MdeModulePkg.dec                      |
> 11 +
> >  MdeModulePkg/MdeModulePkg.dsc                      |
> 3 +
> >  .../PlatformFlashAccessLibDxe.c                    |
> 59 ++-
> >  QuarkPlatformPkg/Quark.dsc                         |
> 1 +
> >  .../Include/Library/PlatformFlashAccessLib.h       |
> 33 +-
> >  .../PlatformFlashAccessLibNull.c                   |
> 54 ++-
> >  .../SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c |
> 92 ++--
> >  .../PlatformFlashAccessLib.c                       |
> 84 ++--
> >  .../PlatformFlashAccessLib.inf                     |
> 3 +-
> >  Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc            |
> 1 +
> >  Vlv2TbltDevicePkg/PlatformPkgIA32.dsc              |
> 1 +
> >  Vlv2TbltDevicePkg/PlatformPkgX64.dsc               |
> 1 +
> >  25 files changed, 1285 insertions(+), 106
> deletions(-)
> >  create mode 100644
> >
> MdeModulePkg/Include/Library/DisplayUpdateProgressLib.h
> >  create mode 100644
> >
> MdeModulePkg/Include/Protocol/FirmwareManagementProgres
> s.h
> >  create mode 100644
> >
> MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/D
> isplayUpdateProg
> > ressGraphicsLib.c
> >  create mode 100644
> >
> MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/D
> isplayUpdateProg
> > ressGraphicsLib.inf
> >  create mode 100644
> >
> MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/D
> isplayUpdateProg
> > ressGraphicsLib.uni
> >  create mode 100644
> >
> MdeModulePkg/Library/DisplayUpdateProgressTextLib/Displ
> ayUpdateProgressT
> > extLib.c
> >  create mode 100644
> >
> MdeModulePkg/Library/DisplayUpdateProgressTextLib/Displ
> ayUpdateProgressT
> > extLib.inf
> >  create mode 100644
> >
> MdeModulePkg/Library/DisplayUpdateProgressTextLib/Displ
> ayUpdateProgressT
> > extLib.uni
> >
> > --
> > 2.14.2.windows.3



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [Patch 9/9] SignedCapsulePkg/SystemFirmwareUpdateDxe: Use progress API
  2018-04-04 20:25 ` [Patch 9/9] SignedCapsulePkg/SystemFirmwareUpdateDxe: Use " Michael D Kinney
@ 2018-04-06 13:55   ` Ard Biesheuvel
  2018-04-06 15:29     ` Kinney, Michael D
  0 siblings, 1 reply; 17+ messages in thread
From: Ard Biesheuvel @ 2018-04-06 13:55 UTC (permalink / raw)
  To: Michael D Kinney; +Cc: edk2-devel@lists.01.org, Jiewen Yao

On 4 April 2018 at 22:25, Michael D Kinney <michael.d.kinney@intel.com> wrote:
> From: "Kinney, Michael D" <michael.d.kinney@intel.com>
>
> 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 <jiewen.yao@intel.com>
> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
> 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.<BR>
> +  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
>    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 UINTN                        ConfigImageSize,
> -  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_STATUS                            Status;
> @@ -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,
>                 FlashAddressTypeRelativeAddress,
>                 SystemFirmwareImage,
> -               SystemFirmwareImageSize
> +               SystemFirmwareImageSize,
> +               Progress,
> +               StartPercentage,
> +               EndPercentage
>                 );
> +    if (Progress != NULL) {
> +      Progress (EndPercentage);
> +    }
>      if (!EFI_ERROR(Status)) {
>        *LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
>        mNvRamUpdated = TRUE;
> @@ -163,18 +185,37 @@ UpdateImage (
>    DEBUG((DEBUG_INFO, "ConfigHeader.NumOfUpdates - 0x%x\n", ConfigHeader.NumOfUpdates));
>    DEBUG((DEBUG_INFO, "PcdEdkiiSystemFirmwareFileGuid - %g\n", PcdGetPtr(PcdEdkiiSystemFirmwareFileGuid)));
>
> +  TotalSize = 0;
> +  for (Index = 0; Index < ConfigHeader.NumOfUpdates; Index++) {
> +    if (CompareGuid(&ConfigData[Index].FileGuid, PcdGetPtr(PcdEdkiiSystemFirmwareFileGuid))) {
> +      TotalSize = TotalSize + ConfigData[Index].Length;
> +    }
> +  }
> +
> +  BytesWritten = 0;
>    Index = 0;
>    UpdateConfigData = ConfigData;
>    while (Index < ConfigHeader.NumOfUpdates) {
>      if (CompareGuid(&UpdateConfigData->FileGuid, PcdGetPtr(PcdEdkiiSystemFirmwareFileGuid))) {
>        DEBUG((DEBUG_INFO, "FileGuid - %g (processing)\n", &UpdateConfigData->FileGuid));
> +      StartPercentage = (BytesWritten * 100) / TotalSize;
> +      EndPercentage   = ((BytesWritten + UpdateConfigData->Length) * 100) / TotalSize;
> +      if (Progress != NULL) {
> +        Progress (StartPercentage);
> +      }
>        Status = PerformUpdate (
>                   SystemFirmwareImage,
>                   SystemFirmwareImageSize,
>                   UpdateConfigData,
>                   LastAttemptVersion,
> -                 LastAttemptStatus
> +                 LastAttemptStatus,
> +                 Progress,
> +                 StartPercentage,
> +                 EndPercentage
>                   );
> +      if (Progress != NULL) {
> +        Progress (EndPercentage);
> +      }
>        //
>        // Shall updates be serialized so that if an update is not successfully completed,
>        // the remaining updates won't be performed.
> @@ -186,6 +227,8 @@ UpdateImage (
>        DEBUG((DEBUG_INFO, "FileGuid - %g (ignored)\n", &UpdateConfigData->FileGuid));
>      }
>
> +    BytesWritten += UpdateConfigData->Length;
> +
>      Index++;
>      UpdateConfigData++;
>    }
> @@ -209,10 +252,11 @@ UpdateImage (
>  **/
>  EFI_STATUS
>  SystemFirmwareAuthenticatedUpdate (
> -  IN VOID                         *Image,
> -  IN UINTN                        ImageSize,
> -  OUT UINT32                      *LastAttemptVersion,
> -  OUT UINT32                      *LastAttemptStatus
> +  IN VOID                                           *Image,
> +  IN UINTN                                          ImageSize,
> +  OUT UINT32                                        *LastAttemptVersion,
> +  OUT UINT32                                        *LastAttemptStatus,
> +  IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS  Progress
>    )
>  {
>    EFI_STATUS                  Status;
> @@ -240,7 +284,7 @@ SystemFirmwareAuthenticatedUpdate (
>    ExtractConfigImage(AuthenticatedImage, AuthenticatedImageSize, &ConfigImage, &ConfigImageSize);
>
>    DEBUG((DEBUG_INFO, "UpdateImage ...\n"));
> -  Status = UpdateImage(SystemFirmwareImage, SystemFirmwareImageSize, ConfigImage, ConfigImageSize, LastAttemptVersion, LastAttemptStatus);
> +  Status = UpdateImage(SystemFirmwareImage, SystemFirmwareImageSize, ConfigImage, ConfigImageSize, LastAttemptVersion, LastAttemptStatus, Progress);
>    if (EFI_ERROR(Status)) {
>      DEBUG((DEBUG_INFO, "UpdateImage - %r\n", Status));
>      return Status;
> @@ -442,8 +486,8 @@ FmpSetImage (
>      return EFI_INVALID_PARAMETER;
>    }
>
> -  Status = SystemFirmwareAuthenticatedUpdate((VOID *)Image, ImageSize, &SystemFmpPrivate->LastAttempt.LastAttemptVersion, &SystemFmpPrivate->LastAttempt.LastAttemptStatus);
> -  DEBUG((DEBUG_INFO, "SetImage - LastAttemp Version - 0x%x, State - 0x%x\n", SystemFmpPrivate->LastAttempt.LastAttemptVersion, SystemFmpPrivate->LastAttempt.LastAttemptStatus));
> +  Status = SystemFirmwareAuthenticatedUpdate((VOID *)Image, ImageSize, &SystemFmpPrivate->LastAttempt.LastAttemptVersion, &SystemFmpPrivate->LastAttempt.LastAttemptStatus, Progress);
> +  DEBUG((DEBUG_INFO, "SetImage - LastAttempt Version - 0x%x, State - 0x%x\n", SystemFmpPrivate->LastAttempt.LastAttemptVersion, SystemFmpPrivate->LastAttempt.LastAttemptStatus));
>
>    //
>    // If NVRAM is updated, we should no longer touch variable services, because
> --
> 2.14.2.windows.3
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [Patch 9/9] SignedCapsulePkg/SystemFirmwareUpdateDxe: Use progress API
  2018-04-06 13:55   ` Ard Biesheuvel
@ 2018-04-06 15:29     ` Kinney, Michael D
  0 siblings, 0 replies; 17+ messages in thread
From: Kinney, Michael D @ 2018-04-06 15:29 UTC (permalink / raw)
  To: Ard Biesheuvel, Kinney, Michael D; +Cc: edk2-devel@lists.01.org, Yao, Jiewen

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.biesheuvel@linaro.org]
> Sent: Friday, April 6, 2018 6:55 AM
> To: Kinney, Michael D <michael.d.kinney@intel.com>
> Cc: edk2-devel@lists.01.org; Yao, Jiewen
> <jiewen.yao@intel.com>
> Subject: Re: [edk2] [Patch 9/9]
> SignedCapsulePkg/SystemFirmwareUpdateDxe: Use progress
> API
> 
> On 4 April 2018 at 22:25, Michael D Kinney
> <michael.d.kinney@intel.com> wrote:
> > From: "Kinney, Michael D"
> <michael.d.kinney@intel.com>
> >
> > 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 <jiewen.yao@intel.com>
> > Signed-off-by: Michael D Kinney
> <michael.d.kinney@intel.com>
> > 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.<BR>
> > +  Copyright (c) 2016 - 2018, Intel Corporation. All
> rights reserved.<BR>
> >    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 UINTN                        ConfigImageSize,
> > -  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_STATUS                            Status;
> > @@ -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,
> >                 FlashAddressTypeRelativeAddress,
> >                 SystemFirmwareImage,
> > -               SystemFirmwareImageSize
> > +               SystemFirmwareImageSize,
> > +               Progress,
> > +               StartPercentage,
> > +               EndPercentage
> >                 );
> > +    if (Progress != NULL) {
> > +      Progress (EndPercentage);
> > +    }
> >      if (!EFI_ERROR(Status)) {
> >        *LastAttemptStatus =
> LAST_ATTEMPT_STATUS_SUCCESS;
> >        mNvRamUpdated = TRUE;
> > @@ -163,18 +185,37 @@ UpdateImage (
> >    DEBUG((DEBUG_INFO, "ConfigHeader.NumOfUpdates -
> 0x%x\n", ConfigHeader.NumOfUpdates));
> >    DEBUG((DEBUG_INFO, "PcdEdkiiSystemFirmwareFileGuid
> - %g\n", PcdGetPtr(PcdEdkiiSystemFirmwareFileGuid)));
> >
> > +  TotalSize = 0;
> > +  for (Index = 0; Index < ConfigHeader.NumOfUpdates;
> Index++) {
> > +    if (CompareGuid(&ConfigData[Index].FileGuid,
> PcdGetPtr(PcdEdkiiSystemFirmwareFileGuid))) {
> > +      TotalSize = TotalSize +
> ConfigData[Index].Length;
> > +    }
> > +  }
> > +
> > +  BytesWritten = 0;
> >    Index = 0;
> >    UpdateConfigData = ConfigData;
> >    while (Index < ConfigHeader.NumOfUpdates) {
> >      if (CompareGuid(&UpdateConfigData->FileGuid,
> PcdGetPtr(PcdEdkiiSystemFirmwareFileGuid))) {
> >        DEBUG((DEBUG_INFO, "FileGuid - %g
> (processing)\n", &UpdateConfigData->FileGuid));
> > +      StartPercentage = (BytesWritten * 100) /
> TotalSize;
> > +      EndPercentage   = ((BytesWritten +
> UpdateConfigData->Length) * 100) / TotalSize;
> > +      if (Progress != NULL) {
> > +        Progress (StartPercentage);
> > +      }
> >        Status = PerformUpdate (
> >                   SystemFirmwareImage,
> >                   SystemFirmwareImageSize,
> >                   UpdateConfigData,
> >                   LastAttemptVersion,
> > -                 LastAttemptStatus
> > +                 LastAttemptStatus,
> > +                 Progress,
> > +                 StartPercentage,
> > +                 EndPercentage
> >                   );
> > +      if (Progress != NULL) {
> > +        Progress (EndPercentage);
> > +      }
> >        //
> >        // Shall updates be serialized so that if an
> update is not successfully completed,
> >        // the remaining updates won't be performed.
> > @@ -186,6 +227,8 @@ UpdateImage (
> >        DEBUG((DEBUG_INFO, "FileGuid - %g
> (ignored)\n", &UpdateConfigData->FileGuid));
> >      }
> >
> > +    BytesWritten += UpdateConfigData->Length;
> > +
> >      Index++;
> >      UpdateConfigData++;
> >    }
> > @@ -209,10 +252,11 @@ UpdateImage (
> >  **/
> >  EFI_STATUS
> >  SystemFirmwareAuthenticatedUpdate (
> > -  IN VOID                         *Image,
> > -  IN UINTN                        ImageSize,
> > -  OUT UINT32
> *LastAttemptVersion,
> > -  OUT UINT32                      *LastAttemptStatus
> > +  IN VOID
> *Image,
> > +  IN UINTN
> ImageSize,
> > +  OUT UINT32
> *LastAttemptVersion,
> > +  OUT UINT32
> *LastAttemptStatus,
> > +  IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS
> Progress
> >    )
> >  {
> >    EFI_STATUS                  Status;
> > @@ -240,7 +284,7 @@ SystemFirmwareAuthenticatedUpdate
> (
> >    ExtractConfigImage(AuthenticatedImage,
> AuthenticatedImageSize, &ConfigImage,
> &ConfigImageSize);
> >
> >    DEBUG((DEBUG_INFO, "UpdateImage ...\n"));
> > -  Status = UpdateImage(SystemFirmwareImage,
> SystemFirmwareImageSize, ConfigImage, ConfigImageSize,
> LastAttemptVersion, LastAttemptStatus);
> > +  Status = UpdateImage(SystemFirmwareImage,
> SystemFirmwareImageSize, ConfigImage, ConfigImageSize,
> LastAttemptVersion, LastAttemptStatus, Progress);
> >    if (EFI_ERROR(Status)) {
> >      DEBUG((DEBUG_INFO, "UpdateImage - %r\n",
> Status));
> >      return Status;
> > @@ -442,8 +486,8 @@ FmpSetImage (
> >      return EFI_INVALID_PARAMETER;
> >    }
> >
> > -  Status = SystemFirmwareAuthenticatedUpdate((VOID
> *)Image, ImageSize, &SystemFmpPrivate-
> >LastAttempt.LastAttemptVersion, &SystemFmpPrivate-
> >LastAttempt.LastAttemptStatus);
> > -  DEBUG((DEBUG_INFO, "SetImage - LastAttemp Version
> - 0x%x, State - 0x%x\n", SystemFmpPrivate-
> >LastAttempt.LastAttemptVersion, SystemFmpPrivate-
> >LastAttempt.LastAttemptStatus));
> > +  Status = SystemFirmwareAuthenticatedUpdate((VOID
> *)Image, ImageSize, &SystemFmpPrivate-
> >LastAttempt.LastAttemptVersion, &SystemFmpPrivate-
> >LastAttempt.LastAttemptStatus, Progress);
> > +  DEBUG((DEBUG_INFO, "SetImage - LastAttempt Version
> - 0x%x, State - 0x%x\n", SystemFmpPrivate-
> >LastAttempt.LastAttemptVersion, SystemFmpPrivate-
> >LastAttempt.LastAttemptStatus));
> >
> >    //
> >    // If NVRAM is updated, we should no longer touch
> variable services, because
> > --
> > 2.14.2.windows.3
> >
> > _______________________________________________
> > edk2-devel mailing list
> > edk2-devel@lists.01.org
> > https://lists.01.org/mailman/listinfo/edk2-devel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [Patch 7/9] Vlv2TbltDevicePkg/PlatformFlashAccessLib: Add progress API
  2018-04-04 20:25 ` [Patch 7/9] Vlv2TbltDevicePkg/PlatformFlashAccessLib: " Michael D Kinney
@ 2018-04-08  6:11   ` Wei, David
  0 siblings, 0 replies; 17+ messages in thread
From: Wei, David @ 2018-04-08  6:11 UTC (permalink / raw)
  To: Kinney, Michael D, edk2-devel@lists.01.org

Reviewed-by: zwei4 <david.wei@intel.com>

Thanks,
David  Wei

Intel SSG/STO/UEFI BIOS                                 

-----Original Message-----
From: Kinney, Michael D 
Sent: Thursday, April 5, 2018 4:26 AM
To: edk2-devel@lists.01.org
Cc: Wei, David <david.wei@intel.com>; Guo, Mang <mang.guo@intel.com>
Subject: [Patch 7/9] Vlv2TbltDevicePkg/PlatformFlashAccessLib: Add progress API

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

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 <david.wei@intel.com>
Cc: Mang Guo <mang.guo@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
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/PlatformFlashAccessLib/PlatformFlashAccessLib.c b/Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.c
index 9162e025ed..868e4049bb 100644
--- a/Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.c
+++ b/Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.c
@@ -1,7 +1,7 @@
 /** @file
   Platform Flash Access library.
 
-  Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
   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
@@ -381,7 +381,7 @@ InternalWriteBlock (
 }
 
 /**
-  Perform flash write opreation.
+  Perform flash write operation with progress indicator.
 
   @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 = 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 = gBS->RaiseTPL (TPL_NOTIFY);
     for (Index = 0; Index < CountOfBlocks; Index++) {
+      if (Progress != NULL) {
+        Progress (StartPercentage + ((Index * (EndPercentage - StartPercentage)) / 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  = InternalEraseBlock (Address);
-  if (EFI_ERROR(Status)) {
+        if (EFI_ERROR(Status)) {
           gBS->RestoreTPL (OldTpl);
           FlashError = TRUE;
           goto Done;
-  }
+        }
         Status = InternalWriteBlock (
                   Address,
                   Buf,
                   (UINT32)(Length > BLOCK_SIZE ? BLOCK_SIZE : Length)
                   );
-  if (EFI_ERROR(Status)) {
+        if (EFI_ERROR(Status)) {
           gBS->RestoreTPL (OldTpl);
           FlashError = TRUE;
           goto Done;
         }
-  }
+      }
 
       //
       // Move to next block to update.
@@ -506,26 +507,55 @@ PerformFlashWrite (
     }
     gBS->RestoreTPL (OldTpl);
 
-  Done:
+Done:
   if ((BiosCntl & B_PCH_LPC_BIOS_CNTL_SMM_BWP) == 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);
   }
 
   return EFI_SUCCESS;
 }
 
 /**
-  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.
 
   @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/PlatformFlashAccessLib/PlatformFlashAccessLib.inf b/Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.inf
index fbbdb91b64..8ff0084dd4 100644
--- a/Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.inf
+++ b/Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.inf
@@ -1,7 +1,7 @@
 ## @file
 #  Platform Flash Access library.
 #
-#  Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>
 #  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
@@ -43,7 +43,6 @@ [LibraryClasses]
   IoLib
   PcdLib
   DebugLib
-#  FlashDeviceLib
   MemoryAllocationLib
   CacheMaintenanceLib
 
-- 
2.14.2.windows.3



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [Patch 3/9] Vlv2Tbl2DevicePkg: Add DisplayUpdateProgressLib mapping
  2018-04-04 20:25 ` [Patch 3/9] Vlv2Tbl2DevicePkg: Add DisplayUpdateProgressLib mapping Michael D Kinney
@ 2018-04-08  6:12   ` Wei, David
  0 siblings, 0 replies; 17+ messages in thread
From: Wei, David @ 2018-04-08  6:12 UTC (permalink / raw)
  To: Kinney, Michael D, edk2-devel@lists.01.org

Reviewed-by: David Wei <david.wei@intel.com>

Thanks,
David  Wei

Intel SSG/STO/UEFI BIOS                                 


-----Original Message-----
From: Kinney, Michael D 
Sent: Thursday, April 5, 2018 4:26 AM
To: edk2-devel@lists.01.org
Cc: Sean Brogan <sean.brogan@microsoft.com>; Wei, David <david.wei@intel.com>; Guo, Mang <mang.guo@intel.com>
Subject: [Patch 3/9] Vlv2Tbl2DevicePkg: Add DisplayUpdateProgressLib mapping

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

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: David Wei <david.wei@intel.com>
Cc: Mang Guo <mang.guo@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
---
 Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc | 1 +
 Vlv2TbltDevicePkg/PlatformPkgIA32.dsc   | 1 +
 Vlv2TbltDevicePkg/PlatformPkgX64.dsc    | 1 +
 3 files changed, 3 insertions(+)

diff --git a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
index f918e44851..f43449c588 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
@@ -195,6 +195,7 @@ [LibraryClasses.common]
   IniParsingLib|SignedCapsulePkg/Library/IniParsingLib/IniParsingLib.inf
   PlatformFlashAccessLib|Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.inf
   MicrocodeFlashAccessLib|Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.inf
+  DisplayUpdateProgressLib|MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/DisplayUpdateProgressGraphicsLib.inf
   LanguageLib|EdkCompatibilityPkg/Compatibility/Library/UefiLanguageLib/UefiLanguageLib.inf
   SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
   SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
diff --git a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
index 0a95d95557..f69f61ca71 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
@@ -195,6 +195,7 @@ [LibraryClasses.common]
   IniParsingLib|SignedCapsulePkg/Library/IniParsingLib/IniParsingLib.inf
   PlatformFlashAccessLib|Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.inf
   MicrocodeFlashAccessLib|Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.inf
+  DisplayUpdateProgressLib|MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/DisplayUpdateProgressGraphicsLib.inf
   LanguageLib|EdkCompatibilityPkg/Compatibility/Library/UefiLanguageLib/UefiLanguageLib.inf
   SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
   SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
diff --git a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
index fb2743c727..63c23a1689 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
@@ -195,6 +195,7 @@ [LibraryClasses.common]
   IniParsingLib|SignedCapsulePkg/Library/IniParsingLib/IniParsingLib.inf
   PlatformFlashAccessLib|Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.inf
   MicrocodeFlashAccessLib|Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.inf
+  DisplayUpdateProgressLib|MdeModulePkg/Library/DisplayUpdateProgressGraphicsLib/DisplayUpdateProgressGraphicsLib.inf
   LanguageLib|EdkCompatibilityPkg/Compatibility/Library/UefiLanguageLib/UefiLanguageLib.inf
   SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
   SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
-- 
2.14.2.windows.3



^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2018-04-08  6:12 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-04 20:25 [Patch 0/9] Add DisplayUpdateProgressLib for capsules Michael D Kinney
2018-04-04 20:25 ` [Patch 1/9] MdeModulePkg: Add DisplayUpdateProgressLib class Michael D Kinney
2018-04-04 20:25 ` [Patch 2/9] MdeModulePkg: Add DisplayUpdateProgressLib instances Michael D Kinney
2018-04-04 20:25 ` [Patch 3/9] Vlv2Tbl2DevicePkg: Add DisplayUpdateProgressLib mapping Michael D Kinney
2018-04-08  6:12   ` Wei, David
2018-04-04 20:25 ` [Patch 4/9] QuarkPlatformPkg: " Michael D Kinney
2018-04-04 20:25 ` [Patch 5/9] MdeModulePkg/DxeCapsuleLibFmp: Add progress bar support Michael D Kinney
2018-04-04 20:25 ` [Patch 6/9] SignedCapsulePkg/PlatformFlashAccessLib: Add progress API Michael D Kinney
2018-04-04 20:25 ` [Patch 7/9] Vlv2TbltDevicePkg/PlatformFlashAccessLib: " Michael D Kinney
2018-04-08  6:11   ` Wei, David
2018-04-04 20:25 ` [Patch 8/9] QuarkPlatformPkg/PlatformFlashAccessLib: " Michael D Kinney
2018-04-04 20:25 ` [Patch 9/9] SignedCapsulePkg/SystemFirmwareUpdateDxe: Use " Michael D Kinney
2018-04-06 13:55   ` Ard Biesheuvel
2018-04-06 15:29     ` Kinney, Michael D
2018-04-04 20:29 ` [Patch 0/9] Add DisplayUpdateProgressLib for capsules Kinney, Michael D
2018-04-05  0:02 ` Yao, Jiewen
2018-04-05  0:37   ` Kinney, Michael D

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox