On Tue, 2 May 2023 at 07:59, Gerd Hoffmann <kra...@redhat.com> wrote:
>
> Check whenever flash is actually writable.
>

This is a bit too terse. Could you explain why this is needed, and why
this approach is suitable?

> Signed-off-by: Gerd Hoffmann <kra...@redhat.com>
> ---
>  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c 
> b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c
> index 54f859de9ff9..a577aea55614 100644
> --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c
> +++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c
> @@ -114,9 +114,17 @@ QemuFlashDetected (
>        DEBUG ((DEBUG_INFO, "QemuFlashDetected => FD behaves as RAM\n"));
>        *Ptr = OriginalUint8;
>      } else if (ProbeUint8 == CLEARED_ARRAY_STATUS) {
> -      DEBUG ((DEBUG_INFO, "QemuFlashDetected => FD behaves as FLASH\n"));
> -      FlashDetected = TRUE;
> -      *Ptr          = READ_ARRAY_CMD;
> +      *Ptr       = WRITE_BYTE_CMD;
> +      *Ptr       = OriginalUint8;
> +      *Ptr       = READ_STATUS_CMD;
> +      ProbeUint8 = *Ptr;
> +      *Ptr       = READ_ARRAY_CMD;
> +      if (ProbeUint8 & 0x10 /* programming error */) {
> +        DEBUG ((DEBUG_INFO, "QemuFlashDetected => FD behaves as FLASH, 
> write-protected\n"));
> +      } else {
> +        DEBUG ((DEBUG_INFO, "QemuFlashDetected => FD behaves as FLASH, 
> writable\n"));
> +        FlashDetected = TRUE;
> +      }
>      }
>    }
>
> --
> 2.40.0
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#105315): https://edk2.groups.io/g/devel/message/105315
Mute This Topic: https://groups.io/mt/98633328/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to