Reuse the BootLogoLib graphical progress bar to show the progress of a
capsule update, and in absence of a graphical console, write a period
to the text console for each block updated.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.c | 35 ++++++++++++++++++++
Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.inf | 3 ++
2 files changed, 38 insertions(+)
diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.c b/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.c
index 5a67f8c00995..fbb8f1f9e48c 100644
--- a/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.c
+++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.c
@@ -16,11 +16,13 @@
#include <PiDxe.h>
#include <Library/BaseMemoryLib.h>
+#include <Library/BootLogoLib.h>
#include <Library/DebugLib.h>
#include <Library/DxeServicesTableLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PlatformFlashAccessLib.h>
#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
#include <Protocol/FirmwareVolumeBlock.h>
@@ -145,6 +147,17 @@ PerformFlashWrite (
EFI_LBA Lba;
EFI_PHYSICAL_ADDRESS FvbBaseAddress;
UINTN NumBytes;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White;
+ UINTN Resolution;
+ UINTN Progress;
+ BOOLEAN HaveBootGraphics;
+
+ Black.Raw = 0x00000000;
+ White.Raw = 0x00FFFFFF;
+
+ Status = BootLogoEnableLogo ();
+ HaveBootGraphics = !EFI_ERROR (Status);
if (FlashAddressType != FlashAddressTypeAbsoluteAddress) {
DEBUG ((DEBUG_ERROR, "%a: only FlashAddressTypeAbsoluteAddress supported\n",
@@ -213,6 +226,16 @@ PerformFlashWrite (
return Status;
}
+ if (HaveBootGraphics) {
+ Resolution = (BlockSize * 100) / Length + 1;
+ Progress = 0;
+
+ Status = BootLogoUpdateProgress (White.Pixel, Black.Pixel,
+ L"Updating firmware - please wait", Black.Pixel, 100, 0);
+ } else {
+ Print (L"Updating firmware - please wait ");
+ }
+
//
// Erase the region
//
@@ -242,10 +265,22 @@ PerformFlashWrite (
__FUNCTION__, Lba, Status, NumBytes));
}
+ if (HaveBootGraphics) {
+ Status = BootLogoUpdateProgress (White.Pixel, Black.Pixel,
+ L"Updating firmware - please wait", White.Pixel,
+ Progress + Resolution, Progress);
+ Progress += Resolution;
+ } else {
+ Print (L".");
+ }
+
Buffer += BlockSize;
Length -= BlockSize;
Lba++;
}
+ if (!HaveBootGraphics) {
+ Print (L"\n");
+ }
return EFI_SUCCESS;
}
diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.inf b/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.inf
index 33f4795ddcf9..4dfa11372a38 100644
--- a/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.inf
+++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.inf
@@ -24,6 +24,7 @@ [Sources]
SynQuacerPlatformFlashAccessLib.c
[Packages]
+ MdeModulePkg/MdeModulePkg.dec
MdePkg/MdePkg.dec
SignedCapsulePkg/SignedCapsulePkg.dec
@@ -32,7 +33,9 @@ [Protocols]
[LibraryClasses]
BaseMemoryLib
+ BootLogoLib
DebugLib
DxeServicesTableLib
UefiBootServicesTableLib
+ UefiLib
--
2.11.0
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel