How did UEFI or legacy BIOS access video ROM?

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
wishedtobe
Member
Member
Posts: 25
Joined: Sat May 04, 2024 7:48 am
Libera.chat IRC: wishedtobe

How did UEFI or legacy BIOS access video ROM?

Post 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.
Octocontrabass
Member
Member
Posts: 5560
Joined: Mon Mar 25, 2013 7:01 pm

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

Post 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.
User avatar
zaval
Member
Member
Posts: 656
Joined: Fri Feb 17, 2017 4:01 pm
Location: Ukraine, Bachmut
Contact:

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

Post 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.
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).
Post Reply