mirror of https://github.com/acidanthera/audk.git
OvmfPkg/VirtNorFlashDxe: add a loop for NorFlashWriteBuffer calls.
Replace the two NorFlashWriteBuffer() calls with a loop containing a single NorFlashWriteBuffer() call. With the changes in place the code is able to handle updates larger than two P30_MAX_BUFFER_SIZE_IN_BYTES blocks, even though the patch does not actually change the size limit. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Message-Id: <20240116171105.37831-4-kraxel@redhat.com>
This commit is contained in:
parent
35d8ea8097
commit
28ffd72689
|
@ -521,6 +521,7 @@ NorFlashWriteSingleBlock (
|
||||||
UINTN BlockAddress;
|
UINTN BlockAddress;
|
||||||
UINT8 *OrigData;
|
UINT8 *OrigData;
|
||||||
UINTN Start, End;
|
UINTN Start, End;
|
||||||
|
UINT32 Index, Count;
|
||||||
|
|
||||||
DEBUG ((DEBUG_BLKIO, "NorFlashWriteSingleBlock(Parameters: Lba=%ld, Offset=0x%x, *NumBytes=0x%x, Buffer @ 0x%08x)\n", Lba, Offset, *NumBytes, Buffer));
|
DEBUG ((DEBUG_BLKIO, "NorFlashWriteSingleBlock(Parameters: Lba=%ld, Offset=0x%x, *NumBytes=0x%x, Buffer @ 0x%08x)\n", Lba, Offset, *NumBytes, Buffer));
|
||||||
|
|
||||||
|
@ -621,23 +622,17 @@ NorFlashWriteSingleBlock (
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Count = (End - Start) / P30_MAX_BUFFER_SIZE_IN_BYTES;
|
||||||
|
for (Index = 0; Index < Count; Index++) {
|
||||||
Status = NorFlashWriteBuffer (
|
Status = NorFlashWriteBuffer (
|
||||||
Instance,
|
Instance,
|
||||||
BlockAddress + Start,
|
BlockAddress + Start + Index * P30_MAX_BUFFER_SIZE_IN_BYTES,
|
||||||
P30_MAX_BUFFER_SIZE_IN_BYTES,
|
P30_MAX_BUFFER_SIZE_IN_BYTES,
|
||||||
Instance->ShadowBuffer
|
Instance->ShadowBuffer + Index * P30_MAX_BUFFER_SIZE_IN_BYTES
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((End - Start) > P30_MAX_BUFFER_SIZE_IN_BYTES) {
|
|
||||||
Status = NorFlashWriteBuffer (
|
|
||||||
Instance,
|
|
||||||
BlockAddress + Start + P30_MAX_BUFFER_SIZE_IN_BYTES,
|
|
||||||
P30_MAX_BUFFER_SIZE_IN_BYTES,
|
|
||||||
Instance->ShadowBuffer + P30_MAX_BUFFER_SIZE_IN_BYTES
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Exit:
|
Exit:
|
||||||
|
|
Loading…
Reference in New Issue