]> git.proxmox.com Git - mirror_edk2.git/commitdiff
SignedCapsulePkg/PlatformFlashAccessLib: Add progress API
authorMichael D Kinney <michael.d.kinney@intel.com>
Sat, 17 Mar 2018 02:16:59 +0000 (19:16 -0700)
committerMichael D Kinney <michael.d.kinney@intel.com>
Mon, 28 May 2018 16:30:10 +0000 (09:30 -0700)
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
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
SignedCapsulePkg/Include/Library/PlatformFlashAccessLib.h
SignedCapsulePkg/Library/PlatformFlashAccessLibNull/PlatformFlashAccessLibNull.c

index 0a8858e4c495e9c435ccc03466ae17aba86389a9..e3308251c2785e4b12d8c2b6b3c6747dd944b985 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Platform flash device access library.\r
 \r
 /** @file\r
   Platform flash device access library.\r
 \r
-  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -16,6 +16,8 @@
 #ifndef __PLATFORM_FLASH_ACCESS_LIB_H__\r
 #define __PLATFORM_FLASH_ACCESS_LIB_H__\r
 \r
 #ifndef __PLATFORM_FLASH_ACCESS_LIB_H__\r
 #define __PLATFORM_FLASH_ACCESS_LIB_H__\r
 \r
+#include <Protocol/FirmwareManagement.h>\r
+\r
 typedef enum {\r
   FlashAddressTypeRelativeAddress,\r
   FlashAddressTypeAbsoluteAddress,\r
 typedef enum {\r
   FlashAddressTypeRelativeAddress,\r
   FlashAddressTypeAbsoluteAddress,\r
@@ -31,7 +33,7 @@ typedef enum {
 } PLATFORM_FIRMWARE_TYPE;\r
 \r
 /**\r
 } PLATFORM_FIRMWARE_TYPE;\r
 \r
 /**\r
-  Perform flash write opreation.\r
+  Perform flash write operation.\r
 \r
   @param[in] FirmwareType      The type of firmware.\r
   @param[in] FlashAddress      The address of flash device to be accessed.\r
 \r
   @param[in] FirmwareType      The type of firmware.\r
   @param[in] FlashAddress      The address of flash device to be accessed.\r
@@ -54,4 +56,47 @@ PerformFlashWrite (
   IN UINTN                        Length\r
   );\r
 \r
   IN UINTN                        Length\r
   );\r
 \r
+/**\r
+  Perform flash write operation with progress indicator.  The start and end\r
+  completion percentage values are passed into this function.  If the requested\r
+  flash write operation is broken up, then completion percentage between the\r
+  start and end values may be passed to the provided Progress function.  The\r
+  caller of this function is required to call the Progress function for the\r
+  start and end completion percentage values.  This allows the Progress,\r
+  StartPercentage, and EndPercentage parameters to be ignored if the requested\r
+  flash write operation can not be broken up\r
+\r
+  @param[in] FirmwareType      The type of firmware.\r
+  @param[in] FlashAddress      The address of flash device to be accessed.\r
+  @param[in] FlashAddressType  The type of flash device address.\r
+  @param[in] Buffer            The pointer to the data buffer.\r
+  @param[in] Length            The length of data buffer in bytes.\r
+  @param[in] Progress          A function used report the progress of the\r
+                               firmware update.  This is an optional parameter\r
+                               that may be NULL.\r
+  @param[in] StartPercentage   The start completion percentage value that may\r
+                               be used to report progress during the flash\r
+                               write operation.\r
+  @param[in] EndPercentage     The end completion percentage value that may\r
+                               be used to report progress during the flash\r
+                               write operation.\r
+\r
+  @retval EFI_SUCCESS           The operation returns successfully.\r
+  @retval EFI_WRITE_PROTECTED   The flash device is read only.\r
+  @retval EFI_UNSUPPORTED       The flash device access is unsupported.\r
+  @retval EFI_INVALID_PARAMETER The input parameter is not valid.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PerformFlashWriteWithProgress (\r
+  IN PLATFORM_FIRMWARE_TYPE                         FirmwareType,\r
+  IN EFI_PHYSICAL_ADDRESS                           FlashAddress,\r
+  IN FLASH_ADDRESS_TYPE                             FlashAddressType,\r
+  IN VOID                                           *Buffer,\r
+  IN UINTN                                          Length,\r
+  IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS  Progress,        OPTIONAL\r
+  IN UINTN                                          StartPercentage,\r
+  IN UINTN                                          EndPercentage\r
+  );\r
+\r
 #endif\r
 #endif\r
index b34ebbba1ed6091cb5e43750e1b1336db333f86e..854f108cf40351aadee044f2158c9f07af4a711c 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Platform flash device access library NULL instance.\r
 \r
 /** @file\r
   Platform flash device access library NULL instance.\r
 \r
-  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
 UINT64 mInternalFdAddress;\r
 \r
 /**\r
 UINT64 mInternalFdAddress;\r
 \r
 /**\r
-  Perform flash write opreation.\r
+  Perform flash write operation with progress indicator.  The start and end\r
+  completion percentage values are passed into this function.  If the requested\r
+  flash write operation is broken up, then completion percentage between the\r
+  start and end values may be passed to the provided Progress function.  The\r
+  caller of this function is required to call the Progress function for the\r
+  start and end completion percentage values.  This allows the Progress,\r
+  StartPercentage, and EndPercentage parameters to be ignored if the requested\r
+  flash write operation can not be broken up\r
+\r
+  @param[in] FirmwareType      The type of firmware.\r
+  @param[in] FlashAddress      The address of flash device to be accessed.\r
+  @param[in] FlashAddressType  The type of flash device address.\r
+  @param[in] Buffer            The pointer to the data buffer.\r
+  @param[in] Length            The length of data buffer in bytes.\r
+  @param[in] Progress          A function used report the progress of the\r
+                               firmware update.  This is an optional parameter\r
+                               that may be NULL.\r
+  @param[in] StartPercentage   The start completion percentage value that may\r
+                               be used to report progress during the flash\r
+                               write operation.\r
+  @param[in] EndPercentage     The end completion percentage value that may\r
+                               be used to report progress during the flash\r
+                               write operation.\r
+\r
+  @retval EFI_SUCCESS           The operation returns successfully.\r
+  @retval EFI_WRITE_PROTECTED   The flash device is read only.\r
+  @retval EFI_UNSUPPORTED       The flash device access is unsupported.\r
+  @retval EFI_INVALID_PARAMETER The input parameter is not valid.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PerformFlashWriteWithProgress (\r
+  IN PLATFORM_FIRMWARE_TYPE                         FirmwareType,\r
+  IN EFI_PHYSICAL_ADDRESS                           FlashAddress,\r
+  IN FLASH_ADDRESS_TYPE                             FlashAddressType,\r
+  IN VOID                                           *Buffer,\r
+  IN UINTN                                          Length,\r
+  IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS  Progress,        OPTIONAL\r
+  IN UINTN                                          StartPercentage,\r
+  IN UINTN                                          EndPercentage\r
+  )\r
+{\r
+  if (FlashAddressType == FlashAddressTypeRelativeAddress) {\r
+    FlashAddress = FlashAddress + mInternalFdAddress;\r
+  }\r
+  CopyMem((VOID *)(UINTN)(FlashAddress), Buffer, Length);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Perform flash write operation.\r
 \r
   @param[in] FirmwareType      The type of firmware.\r
   @param[in] FlashAddress      The address of flash device to be accessed.\r
 \r
   @param[in] FirmwareType      The type of firmware.\r
   @param[in] FlashAddress      The address of flash device to be accessed.\r
@@ -43,9 +93,15 @@ PerformFlashWrite (
   IN UINTN                        Length\r
   )\r
 {\r
   IN UINTN                        Length\r
   )\r
 {\r
-  if (FlashAddressType == FlashAddressTypeRelativeAddress) {\r
-    FlashAddress = FlashAddress + mInternalFdAddress;\r
-  }\r
-  CopyMem((VOID *)(UINTN)(FlashAddress), Buffer, Length);\r
-  return EFI_SUCCESS;\r
+  return PerformFlashWriteWithProgress (\r
+           FirmwareType,\r
+           FlashAddress,\r
+           FlashAddressType,\r
+           Buffer,\r
+           Length,\r
+           NULL,\r
+           0,\r
+           0\r
+           );\r
 }\r
 }\r
+\r