Strange GOP handle

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Strange GOP handle

Post by nexos »

Hello,
I have recently made my bootloader work on EFI based systems. However, when I call locate LocateHandle for the GOP, two handles are returned, even though I only have one display. This is true on OVMF and most hardware I've tested (an HP Pavillion and a MacBook Pro), but was not true on a Dell OptiPlex. Even stranger is that the only supported mode is 1x120, which doesn't even seem valid to me. My only guess is that this is GOP representation of ConOut, but I'm not sure. Does anyone know what this mysterious handle is?

Thanks,
nexos
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
kzinti
Member
Member
Posts: 898
Joined: Mon Feb 02, 2015 7:11 pm

Re: Strange GOP handle

Post by kzinti »

One of the GOP entry is the "Console Splitter". It is basically a virtual device used to draw on all screens at the same time. It doesn't represent a real hardware device. You can identify this entry by checking if it has a device path. Here is how I handle it:

Code: Select all

for (auto handle : handles)
    {
        efi::DevicePathProtocol* dpp = nullptr;
        if (efi::Error(bootServices->HandleProtocol(handle, &efi::kDevicePathProtocolGuid, (void**)&dpp)))
            continue;

        // If dpp is null, this is the "Console Splitter" driver. It is used to draw on all
        // screens at the same time and doesn't represent a real hardware device.
        if (!dpp)
            continue;

        ...

Having only one supported mode of 1x120 doesn't make sense, verify that your structures/protocols are properly defined.
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Re: Strange GOP handle

Post by nexos »

That makes sense. I'll check on why it only reports on that resolution
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
User avatar
zaval
Member
Member
Posts: 656
Joined: Fri Feb 17, 2017 4:01 pm
Location: Ukraine, Bachmut
Contact:

Re: Strange GOP handle

Post by zaval »

Also, some firmwares expose funny bugs on that instance. e.g. my old laptop HP Probook 4530s. This handle's GOP instance doesn't cause drawing, when using its Blt() even though the latter returns success. But the drawing appears on the screen after the loader exits to the fw, for short duration before the fw's Boot Manager redraws its own UI. You also can make it stay for longer, just don't turn off the event on the redrawing callback. :mrgreen:


To kzinti, I am wondering, what made you include that code into your loader? I am asking because for the vast majority of machines, both VMs and real hardware this no DevicePath instance handle works just as fine as the other one. For me, only for the aforementioned laptop it didn't. I didn't see any hints on this in the spec. Without them this trickery looks like a bitter experience, trial and error. I refused to insert this hack, thinking it's just an oddity of a particular FW on a particular group of one vendor hw. What inspired to you insert it?

Also, interesting to note, that the spec says, all the handles must have Device Path instance installed. This weirdo handle returns EFI_NOT_SUPPORTED btw. even the reference implementation screws the spec up.
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).
kzinti
Member
Member
Posts: 898
Joined: Mon Feb 02, 2015 7:11 pm

Re: Strange GOP handle

Post by kzinti »

zaval wrote:To kzinti, I am wondering, what made you include that code into your loader?
I am simply doing this to enumerate available display devices that can be used by my kernel. At this time I only have a generic display driver that needs memory-mapped framebuffers.

I discovered this "fake display" while attempting to retrieve EDID data for each display. IIRC, it doesn't have any.
User avatar
zaval
Member
Member
Posts: 656
Joined: Fri Feb 17, 2017 4:01 pm
Location: Ukraine, Bachmut
Contact:

Re: Strange GOP handle

Post by zaval »

I see, thank you. Well, I just pass the framebuffer base in the loader block so far. :D
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Re: Strange GOP handle

Post by nexos »

The only problem with checking if the handle has a device path is that U-Boot (oddly) appears to not put device paths on any GOP handles. Which IMO is a bug on their part.
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
User avatar
zaval
Member
Member
Posts: 656
Joined: Fri Feb 17, 2017 4:01 pm
Location: Ukraine, Bachmut
Contact:

Re: Strange GOP handle

Post by zaval »

nexos wrote:The only problem with checking if the handle has a device path is that U-Boot (oddly) appears to not put device paths on any GOP handles. Which IMO is a bug on their part.
If so, it is certainly a bug. Are you sure, uboot doesn't put a DPP instance at any GOP handles?

After this topic kicked in, I gave it a thought and decided to add filtering out this DDP-less handle in my code. Now my work HP Probook 4530s happily paints the Boot Screen,
Image
but I realized, this new code wouldn't paint anything on "powered by uboot" :mrgreen: ARM machines. Which I can't test now on my own, unfortunately.
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).
User avatar
zaval
Member
Member
Posts: 656
Joined: Fri Feb 17, 2017 4:01 pm
Location: Ukraine, Bachmut
Contact:

Re: Strange GOP handle

Post by zaval »

btw, nexos, in addition to the previous question, could you please tell the board(s), which you've experienced this behavior with? I went through the list of defconfigs in mainline uboot and was shocked to see, that basically only some rk3399 ones have GOP support. Personally, I worked with an exactly such one - Rock Pi 4B, but I believed, there are more SoCs having this level of support. thanks edk2 ports start to appear.
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Re: Strange GOP handle

Post by nexos »

I've personally only tested U-Boot in a QEMU virtual machine on RISC-V. It was using VGA as the display hardware. I'll have to fire up an ARM virtual machine with U-Boot to test it. Normally I test ARM with EDK2 as it superior in almost every way (IMO).
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
Post Reply