diff options
author | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2018-03-16 15:09:11 +0000 |
---|---|---|
committer | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2018-06-01 11:57:27 +0200 |
commit | e45ae44ec07ef68aa9ba0e36b15186c9a7879c7f (patch) | |
tree | 6019e1559675957fa477fa0544641cbd40415572 /Silicon/Socionext/SynQuacer/Library | |
parent | 913fdda9f4b941916d73700848aefa0f4c722a02 (diff) |
Silicon/SynQuacerPlatformFlashAccessLib: skip empty blocks
Before adding more payload to the capsule which may be only partially
occupied, add some logic to skip writing these blocks after erasing
them.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Diffstat (limited to 'Silicon/Socionext/SynQuacer/Library')
-rw-r--r-- | Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.c | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.c b/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.c index 82fe3f74..0131e33a 100644 --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.c +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.c @@ -116,6 +116,35 @@ GetFvbByAddress ( }
/**
+ Check whether a buffer has any data in it, i.e., bytes with value != 0xff
+
+ @param[in] Buffer Address of the buffer
+ @param[in] Length Size of the buffer
+
+ @retval TRUE A non-0xff byte was found
+ @retval FALSE Buffer has 0xff bytes only
+
+**/
+STATIC
+BOOLEAN
+BufferHasData (
+ IN VOID *Buffer,
+ IN UINTN Length
+ )
+{
+ UINT8 *Data;
+ UINTN Index;
+
+ Data = Buffer;
+ for (Index = 0; Index < Length; Index++) {
+ if (Data[Index] != 0xff) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+/**
Perform flash write operation.
@param[in] FirmwareType The type of firmware.
@@ -257,11 +286,13 @@ PerformFlashWrite ( __FUNCTION__, BlockSize, Lba));
NumBytes = BlockSize;
- Status = Fvb->Write (Fvb, Lba, 0, &NumBytes, Buffer);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR,
- "%a: write of LBA 0x%lx failed - %r (NumBytes == 0x%lx)\n",
- __FUNCTION__, Lba, Status, NumBytes));
+ if (BufferHasData (Buffer, NumBytes)) {
+ Status = Fvb->Write (Fvb, Lba, 0, &NumBytes, Buffer);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR,
+ "%a: write of LBA 0x%lx failed - %r (NumBytes == 0x%lx)\n",
+ __FUNCTION__, Lba, Status, NumBytes));
+ }
}
if (HaveBootGraphics) {
|