On 1/15/24 16:59, Gerd Hoffmann wrote: > 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 <kra...@redhat.com> > --- > OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c | 21 ++++++++------------- > 1 file changed, 8 insertions(+), 13 deletions(-) > > diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c > b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c > index 54251633d0ee..67610d6920f7 100644 > --- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c > +++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c > @@ -521,6 +521,7 @@ NorFlashWriteSingleBlock ( > UINTN BlockAddress; > UINT8 *OrigData; > 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)); > > @@ -620,23 +621,17 @@ NorFlashWriteSingleBlock ( > goto Exit; > } > > - Status = NorFlashWriteBuffer ( > - Instance, > - BlockAddress + Start, > - P30_MAX_BUFFER_SIZE_IN_BYTES, > - Instance->ShadowBuffer > - ); > - if (EFI_ERROR (Status)) { > - goto Exit; > - } > - > - if ((End - Start) > P30_MAX_BUFFER_SIZE_IN_BYTES) { > + Count = (End - Start) / P30_MAX_BUFFER_SIZE_IN_BYTES; > + for (Index = 0; Index < Count; Index++) { > Status = NorFlashWriteBuffer ( > Instance, > - BlockAddress + Start + P30_MAX_BUFFER_SIZE_IN_BYTES, > + BlockAddress + Start + Index * P30_MAX_BUFFER_SIZE_IN_BYTES, > P30_MAX_BUFFER_SIZE_IN_BYTES, > - Instance->ShadowBuffer + P30_MAX_BUFFER_SIZE_IN_BYTES > + Instance->ShadowBuffer + Index * > P30_MAX_BUFFER_SIZE_IN_BYTES > ); > + if (EFI_ERROR (Status)) { > + goto Exit; > + } > } > > Exit:
Reviewed-by: Laszlo Ersek <ler...@redhat.com> -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#113894): https://edk2.groups.io/g/devel/message/113894 Mute This Topic: https://groups.io/mt/103741663/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/9847357/21656/1706620634/xyzzy [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-