]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Vlv2TbltDevicePkg/PlatformFlashAccessLib: Add progress API
authorMichael D Kinney <michael.d.kinney@intel.com>
Sat, 17 Mar 2018 02:17:26 +0000 (19:17 -0700)
committerMichael D Kinney <michael.d.kinney@intel.com>
Mon, 28 May 2018 19:23:13 +0000 (12:23 -0700)
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
Reviewed-by: David Wei <david.wei@intel.com>
Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.c
Vlv2TbltDevicePkg/Feature/Capsule/Library/PlatformFlashAccessLib/PlatformFlashAccessLib.inf

index 9162e025ede84faea31494f865ccb962f0bcd733..06278d202a443d506ef6904a807bbaf4e32755e0 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Platform Flash Access library.\r
 \r
 /** @file\r
   Platform Flash Access library.\r
 \r
-  Copyright (c) 2017, 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
@@ -381,13 +381,29 @@ InternalWriteBlock (
 }\r
 \r
 /**\r
 }\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
 \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
 \r
   @retval EFI_SUCCESS           The operation returns successfully.\r
   @retval EFI_WRITE_PROTECTED   The flash device is read only.\r
@@ -396,12 +412,15 @@ InternalWriteBlock (
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
-PerformFlashWrite (\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
+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
   EFI_STATUS            Status = EFI_SUCCESS;\r
   )\r
 {\r
   EFI_STATUS            Status = EFI_SUCCESS;\r
@@ -456,42 +475,40 @@ PerformFlashWrite (
     // Raise TPL to TPL_NOTIFY to block any event handler,\r
     // while still allowing RaiseTPL(TPL_NOTIFY) within\r
     // output driver during Print()\r
     // Raise TPL to TPL_NOTIFY to block any event handler,\r
     // while still allowing RaiseTPL(TPL_NOTIFY) within\r
     // output driver during Print()\r
-  //\r
+    //\r
     OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
     for (Index = 0; Index < CountOfBlocks; Index++) {\r
     OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
     for (Index = 0; Index < CountOfBlocks; Index++) {\r
+      if (Progress != NULL) {\r
+        Progress (StartPercentage + ((Index * (EndPercentage - StartPercentage)) / CountOfBlocks));\r
+      }\r
       //\r
       // Handle block based on address and contents.\r
       //\r
       if (!EFI_ERROR (InternalCompareBlock (Address, Buf))) {\r
         DEBUG((DEBUG_INFO, "Skipping block at 0x%lx (already programmed)\n", Address));\r
       } else {\r
       //\r
       // Handle block based on address and contents.\r
       //\r
       if (!EFI_ERROR (InternalCompareBlock (Address, Buf))) {\r
         DEBUG((DEBUG_INFO, "Skipping block at 0x%lx (already programmed)\n", Address));\r
       } else {\r
-        //\r
-        // Display a dot for each block being updated.\r
-        //\r
-        Print (L".");\r
-\r
         //\r
         // Make updating process uninterruptable,\r
         // so that the flash memory area is not accessed by other entities\r
         // which may interfere with the updating process\r
         //\r
         Status  = InternalEraseBlock (Address);\r
         //\r
         // Make updating process uninterruptable,\r
         // so that the flash memory area is not accessed by other entities\r
         // which may interfere with the updating process\r
         //\r
         Status  = InternalEraseBlock (Address);\r
-  if (EFI_ERROR(Status)) {\r
+        if (EFI_ERROR(Status)) {\r
           gBS->RestoreTPL (OldTpl);\r
           FlashError = TRUE;\r
           goto Done;\r
           gBS->RestoreTPL (OldTpl);\r
           FlashError = TRUE;\r
           goto Done;\r
-  }\r
+        }\r
         Status = InternalWriteBlock (\r
                   Address,\r
                   Buf,\r
                   (UINT32)(Length > BLOCK_SIZE ? BLOCK_SIZE : Length)\r
                   );\r
         Status = InternalWriteBlock (\r
                   Address,\r
                   Buf,\r
                   (UINT32)(Length > BLOCK_SIZE ? BLOCK_SIZE : Length)\r
                   );\r
-  if (EFI_ERROR(Status)) {\r
+        if (EFI_ERROR(Status)) {\r
           gBS->RestoreTPL (OldTpl);\r
           FlashError = TRUE;\r
           goto Done;\r
         }\r
           gBS->RestoreTPL (OldTpl);\r
           FlashError = TRUE;\r
           goto Done;\r
         }\r
-  }\r
+      }\r
 \r
       //\r
       // Move to next block to update.\r
 \r
       //\r
       // Move to next block to update.\r
@@ -506,26 +523,59 @@ PerformFlashWrite (
     }\r
     gBS->RestoreTPL (OldTpl);\r
 \r
     }\r
     gBS->RestoreTPL (OldTpl);\r
 \r
-  Done:\r
+Done:\r
   if ((BiosCntl & B_PCH_LPC_BIOS_CNTL_SMM_BWP) == B_PCH_LPC_BIOS_CNTL_SMM_BWP) {\r
     //\r
     // Restore original control setting\r
     //\r
     MmioWrite8 (LpcBaseAddress + R_PCH_LPC_BIOS_CNTL, BiosCntl);\r
   if ((BiosCntl & B_PCH_LPC_BIOS_CNTL_SMM_BWP) == B_PCH_LPC_BIOS_CNTL_SMM_BWP) {\r
     //\r
     // Restore original control setting\r
     //\r
     MmioWrite8 (LpcBaseAddress + R_PCH_LPC_BIOS_CNTL, BiosCntl);\r
-    }\r
+  }\r
 \r
 \r
-  //\r
-  // Print flash update failure message if error detected.\r
-  //\r
-  if (FlashError) {\r
-    Print (L"No %r\n", Status);\r
+  if (Progress != NULL) {\r
+    Progress (EndPercentage);\r
   }\r
 \r
   return EFI_SUCCESS;\r
 }\r
 \r
 /**\r
   }\r
 \r
   return EFI_SUCCESS;\r
 }\r
 \r
 /**\r
-  Perform microcode 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
+  @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
+\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
+PerformFlashWrite (\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
+  )\r
+{\r
+  return PerformFlashWriteWithProgress (\r
+           FirmwareType,\r
+           FlashAddress,\r
+           FlashAddressType,\r
+           Buffer,\r
+           Length,\r
+           NULL,\r
+           0,\r
+           0\r
+           );\r
+}\r
+\r
+/**\r
+  Perform microcode write operation.\r
 \r
   @param[in] FlashAddress      The address of flash device to be accessed.\r
   @param[in] Buffer            The pointer to the data buffer.\r
 \r
   @param[in] FlashAddress      The address of flash device to be accessed.\r
   @param[in] Buffer            The pointer to the data buffer.\r
index fbbdb91b64cd843658ae87eff078b41c154f0d2e..8ff0084dd4155375a630204759eeaf6c0f4309ad 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 #  Platform Flash Access library.\r
 #\r
 ## @file\r
 #  Platform Flash Access library.\r
 #\r
-#  Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2017 - 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
@@ -43,7 +43,6 @@
   IoLib\r
   PcdLib\r
   DebugLib\r
   IoLib\r
   PcdLib\r
   DebugLib\r
-#  FlashDeviceLib\r
   MemoryAllocationLib\r
   CacheMaintenanceLib\r
 \r
   MemoryAllocationLib\r
   CacheMaintenanceLib\r
 \r