public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* Graphic Output on qemu
@ 2023-02-07 10:22 Alireza Banejad
  2023-02-07 19:55 ` [edk2-devel] " Paul, Bill
  0 siblings, 1 reply; 6+ messages in thread
From: Alireza Banejad @ 2023-02-07 10:22 UTC (permalink / raw)
  To: devel

[-- Attachment #1: Type: text/plain, Size: 545 bytes --]

Hello everyone,
I am trying to use the GOP library for my uefi development. But no matter
what code whenever i want to open the GOP handle RETURN_UNSUPPORTED is
returned. I think this may be a qemu problem as if it doesn't support the
GOP at all. This is how I run my qemu

qemu-system-x86_64 -bios $FIRMWARE -hda fat:rw:$DRIVE -global
isa-debugcon.iobase=0x402  -net none -debugcon file:debug2.log  -machine
pc-q35-6.2 -device virtio-gpu

Should I add any specific options for the qemu command or should I just use
another lib for GOP on qemu?

[-- Attachment #2: Type: text/html, Size: 635 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [edk2-devel] Graphic Output on qemu
  2023-02-07 10:22 Graphic Output on qemu Alireza Banejad
@ 2023-02-07 19:55 ` Paul, Bill
  2023-02-08  8:03   ` Alireza Banejad
  0 siblings, 1 reply; 6+ messages in thread
From: Paul, Bill @ 2023-02-07 19:55 UTC (permalink / raw)
  To: devel@edk2.groups.io, devel@edk2.groups.io,
	alibanejad1376@gmail.com

Of all the gin joints in all the towns in all the world, Alireza Banejad had 
to walk into mine at 02:22:32 on Tuesday, 7 February 2023 and say:

> Do not click links or open attachments unless you recognize the sender and
> know the content is safe. Hello everyone,
> I am trying to use the GOP library for my uefi development. But no matter
> what code whenever i want to open the GOP handle RETURN_UNSUPPORTED is
> returned. I think this may be a qemu problem as if it doesn't support the
> GOP at all. This is how I run my qemu
> 
> qemu-system-x86_64 -bios $FIRMWARE -hda fat:rw:$DRIVE -global
> isa-debugcon.iobase=0x402  -net none -debugcon file:debug2.log  -machine
> pc-q35-6.2 -device virtio-gpu
> 
> Should I add any specific options for the qemu command or should I just use
> another lib for GOP on qemu?

One question: when you launch QEMU, do you actually see a graphics window pop 
up with the Tianocore logo? If you press F2 as it launches, are you able to 
enter the setup menu?

I'm trying to understand if QEMU/OVMF's graphics display is working all all. 
If it is, then in theory the GOP support should work.

If I may suggest, omit the -device virtio-gpu option. In my experience, the 
OVMF firmware for Intel works with the QEMU built-in emulated VGA display 
device. With the code I've written in the past, calling BS->LocateProtocol() 
with the GOP GUID returns a valid handle. Once you have that, you should be 
able to use the GOP methods, e.g. GOP->Blt().

-Bill

-- 
=============================================================================
-Bill Paul            (510) 749-2329 | VxWorks Software Architect,
                 wpaul@windriver.com | Master of Unix-Fu - Wind River Systems
=============================================================================
   "I put a dollar in a change machine. Nothing changed." - George Carlin
=============================================================================



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [edk2-devel] Graphic Output on qemu
  2023-02-07 19:55 ` [edk2-devel] " Paul, Bill
@ 2023-02-08  8:03   ` Alireza Banejad
  2023-02-08  9:06     ` Michael Brown
  0 siblings, 1 reply; 6+ messages in thread
From: Alireza Banejad @ 2023-02-08  8:03 UTC (permalink / raw)
  To: Paul, Bill; +Cc: devel@edk2.groups.io

[-- Attachment #1: Type: text/plain, Size: 3206 bytes --]

Hi Bill,

Yes, I have the graphics window with the logo showing and I see the setup
menu.
In fact, I have designed a HII form with my specific applications. The
problem is that it just uses the SimpleTextOutput. It doesn't use the GOP
or UgaDraw libraries.
Plus, I am able to locate the protocol and it returns the status code of 0.
the actual issue happens with the HandleProtocol Function.
After I compile my code with the debug macros enabled, the status code for
HandleProtocol() function is RETURN_UNSUPPORTED (Both for UgaDraw and GOP)
and if I were to use the GOP or UgaDraw methods, my application would
simply crash.
Below is how I use the HandleProtocol function:

  Status = gBS->HandleProtocol (
                  gST->ConsoleOutHandle,
                  &gEfiGraphicsOutputProtocolGuid,
                  (VOID **)&GraphicsOutput
                  );

Last but not least, whether using the virtio-gpu I get the same result.
Based on what I mentioned above, since I find the protocol but I'm not able
to open it, I concluded there might be something wrong with my qemu
settings.

On Tue, Feb 7, 2023, 23:25 Paul, Bill <Bill.Paul@windriver.com> wrote:

> Of all the gin joints in all the towns in all the world, Alireza Banejad
> had
> to walk into mine at 02:22:32 on Tuesday, 7 February 2023 and say:
>
> > Do not click links or open attachments unless you recognize the sender
> and
> > know the content is safe. Hello everyone,
> > I am trying to use the GOP library for my uefi development. But no matter
> > what code whenever i want to open the GOP handle RETURN_UNSUPPORTED is
> > returned. I think this may be a qemu problem as if it doesn't support the
> > GOP at all. This is how I run my qemu
> >
> > qemu-system-x86_64 -bios $FIRMWARE -hda fat:rw:$DRIVE -global
> > isa-debugcon.iobase=0x402  -net none -debugcon file:debug2.log  -machine
> > pc-q35-6.2 -device virtio-gpu
> >
> > Should I add any specific options for the qemu command or should I just
> use
> > another lib for GOP on qemu?
>
> One question: when you launch QEMU, do you actually see a graphics window
> pop
> up with the Tianocore logo? If you press F2 as it launches, are you able
> to
> enter the setup menu?
>
> I'm trying to understand if QEMU/OVMF's graphics display is working all
> all.
> If it is, then in theory the GOP support should work.
>
> If I may suggest, omit the -device virtio-gpu option. In my experience,
> the
> OVMF firmware for Intel works with the QEMU built-in emulated VGA display
> device. With the code I've written in the past, calling
> BS->LocateProtocol()
> with the GOP GUID returns a valid handle. Once you have that, you should
> be
> able to use the GOP methods, e.g. GOP->Blt().
>
> -Bill
>
> --
>
> =============================================================================
> -Bill Paul            (510) 749-2329 | VxWorks Software Architect,
>                  wpaul@windriver.com | Master of Unix-Fu - Wind River
> Systems
>
> =============================================================================
>    "I put a dollar in a change machine. Nothing changed." - George Carlin
>
> =============================================================================
>
>
>

[-- Attachment #2: Type: text/html, Size: 4087 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [edk2-devel] Graphic Output on qemu
  2023-02-08  8:03   ` Alireza Banejad
@ 2023-02-08  9:06     ` Michael Brown
  2023-02-08  9:55       ` Alireza Banejad
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Brown @ 2023-02-08  9:06 UTC (permalink / raw)
  To: devel, alibanejad1376, Paul, Bill

On 08/02/2023 08:03, Alireza Banejad wrote:
> Below is how I use the HandleProtocol function:
> 
>    Status = gBS->HandleProtocol (
>                    gST->ConsoleOutHandle,
>                    &gEfiGraphicsOutputProtocolGuid,
>                    (VOID **)&GraphicsOutput
>                    );

You are querying only the ConsoleOutHandle, which is not necessarily 
where the GOP will be installed.

Use LocateProtocol() to find the protocol instance instead:


   Status = gBS->LocateProtocol(&gEfiGraphicsOutputProtocolGuid, NULL,
                                (VOID **)&GraphicsOutput);

HTH,

Michael


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [edk2-devel] Graphic Output on qemu
  2023-02-08  9:06     ` Michael Brown
@ 2023-02-08  9:55       ` Alireza Banejad
  2023-02-08 10:00         ` Michael Brown
  0 siblings, 1 reply; 6+ messages in thread
From: Alireza Banejad @ 2023-02-08  9:55 UTC (permalink / raw)
  To: Michael Brown; +Cc: devel, Paul, Bill

[-- Attachment #1: Type: text/plain, Size: 2255 bytes --]

As my previous email, I mentioned that I am able to find the protocol since
the LocateProtocol returns 0 (EFI_SUCCESS) (using the exact code you wrote)
. But when I want to open it either with OpenProtocol or HandleProtocol I
get a RETURN_UNSUPPORTED. Are you implying that by calling LocateProtocol()
the protocol would also be opened? or do I still need to open it? if I
still need to open then I am still getting the UNSUPPORTED Status.
But if I don't need to open it I still don't know why I am not able to use
the GOP methods.
one example of the many examples which I get this error is as below:


Status = gBS->HandleProtocol (SystemTable->ConsoleOutHandle,
&gEfiGraphicsOutputProtocolGuid, (VOID **)&GraphicsOutput);
  if (EFI_ERROR (Status)) {
    Status = gBS->LocateProtocol (&gEfiGraphicsOutputProtocolGuid, NULL,
(VOID **)&GraphicsOutput);
    if (EFI_ERROR (Status)) {
      Print (L"Error: Could not find a GOP instance!\n");
      Status = EFI_NOT_FOUND;
      goto Done;
    }
  }
Blt         = NULL;
  ImageWidth  = 0;
  ImageHeight = 0;
  Status      =  TranslateBmpToGopBlt (
                   BmpFileData,
                   BmpFileSize,
                   &Blt,
                   &BltSize,
                   &ImageHeight,
                   &ImageWidth
                   );
It is worth mentioning that the BmpFIleData and BmpFileSize are valid
variables with the proper data stored. Anyways, the status code for the
TranslateBmpToGopBlt returns a RETURN_UNSUPPORTED. This is the same with
other GOP methods

On Wed, Feb 8, 2023 at 12:36 PM Michael Brown <mcb30@ipxe.org> wrote:

> On 08/02/2023 08:03, Alireza Banejad wrote:
> > Below is how I use the HandleProtocol function:
> >
> >    Status = gBS->HandleProtocol (
> >                    gST->ConsoleOutHandle,
> >                    &gEfiGraphicsOutputProtocolGuid,
> >                    (VOID **)&GraphicsOutput
> >                    );
>
> You are querying only the ConsoleOutHandle, which is not necessarily
> where the GOP will be installed.
>
> Use LocateProtocol() to find the protocol instance instead:
>
>
>    Status = gBS->LocateProtocol(&gEfiGraphicsOutputProtocolGuid, NULL,
>                                 (VOID **)&GraphicsOutput);
>
> HTH,
>
> Michael
>
>

[-- Attachment #2: Type: text/html, Size: 3009 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [edk2-devel] Graphic Output on qemu
  2023-02-08  9:55       ` Alireza Banejad
@ 2023-02-08 10:00         ` Michael Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Brown @ 2023-02-08 10:00 UTC (permalink / raw)
  To: Alireza Banejad; +Cc: devel, Paul, Bill

On 08/02/2023 09:55, Alireza Banejad wrote:
> As my previous email, I mentioned that I am able to find the protocol 
> since the LocateProtocol returns 0 (EFI_SUCCESS) (using the exact code 
> you wrote) . But when I want to open it either with OpenProtocol or 
> HandleProtocol I get a RETURN_UNSUPPORTED. Are you implying that by 
> calling LocateProtocol() the protocol would also be opened?

LocateProtocol() gives you back a pointer to the protocol instance. 
There is no need for a separate "open" action: you can just immediately 
use the protocol instance that LocateProtocol() returns to you.

Michael


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-02-08 10:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-07 10:22 Graphic Output on qemu Alireza Banejad
2023-02-07 19:55 ` [edk2-devel] " Paul, Bill
2023-02-08  8:03   ` Alireza Banejad
2023-02-08  9:06     ` Michael Brown
2023-02-08  9:55       ` Alireza Banejad
2023-02-08 10:00         ` Michael Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox