Page 1 of 1

How did UEFI or legacy BIOS access video ROM?

Posted: Sat May 04, 2024 8:29 am
by wishedtobe
I think it is possible to use GOP after exiting boot services by pretending your program as UEFI and execute the video expansion ROM.But how does UEFI execute it?By the way,I found that my video card's expansion ROM contains nothing except a great deal of 0xff.I found the ROM header 0xaa55 in the mapping area of its BAR.Then I started wondering what the BIOS did.Many thanks for your answer.

Re: How did UEFI or legacy BIOS access video ROM?

Posted: Tue Jun 11, 2024 4:34 pm
by Octocontrabass
wishedtobe wrote:But how does UEFI execute it?
It works the same as any other EFI driver. The UEFI specification explains it in more detail.
wishedtobe wrote:By the way,I found that my video card's expansion ROM contains nothing except a great deal of 0xff.
Is it an onboard video device? Onboard devices usually don't have option ROMs attached to them. The option ROM (or at least the EFI driver) will be packed inside the main UEFI ROM.
wishedtobe wrote:I found the ROM header 0xaa55 in the mapping area of its BAR.
Which BAR? The ROM BAR is separate from the usual BARs, and it'll be disabled by default. You'll have to enable it and assign an address that doesn't conflict with anything before you can read the ROM.

Re: How did UEFI or legacy BIOS access video ROM?

Posted: Tue Jun 11, 2024 5:00 pm
by zaval
wishedtobe wrote: I think it is possible to use GOP after exiting boot services by pretending your program as UEFI and execute the video expansion ROM.
You don't need to pretend anything, rather opposite, - read the spec and you'll know, how one could use GOP correctly, without pretending. If by "using" GOP, you mean being able to call the protocol's functions after ExitBootServices(), then, no, you can't do it, at least because all the protocols code and data belong to the EfiBootServicesCode and EfiBootServicesData types and after ExitBootServices(), your OS is free to use these pages as it wants, they won't be properly mapped in the new address space anyway and overall, Boot Services have shutdown themselves and aren't accessible for many reasons, hidden behind implementation details. If you mean accessing the framebuffer, reported by GOP, with the set resolution, then you can access it, given you mapped it correctly in your environment address space (virtual, process, processor, whatever you call it).
But how does UEFI execute it?By the way,I found that my video card's expansion ROM contains nothing except a great deal of 0xff.I found the ROM header 0xaa55 in the mapping area of its BAR.Then I started wondering what the BIOS did.Many thanks for your answer.
On UEFI platforms, you don't have to bother with all this - expansion ROM etc, just use GOP reported resources. Only when your fully fledged display controller driver is ready to get its hands dirty in handling its hardware, you start to worry about proper setting/configuring the hardware in question, reading its specification, given such exists. :mrgreen:
Of course, if your goal is a normal OS, not some frankenstein, that would want to "pretend" of being a UEFI application or something else.