Setting GOP mode after exiting Boot Services [UEFI]
Posted: Tue Mar 09, 2021 9:27 am
Hello! How to set GOP mode after exiting Boot Services?
The Place to Start for Operating System Developers
http://f.osdev.org/
There is! You start the kernel as an UEFI application. The kernel then sets the video mode and exits boot-services.Electrical wrote:So the only way to set video mode is to save RAM contents into a file, then restart the os change mode is bootloader and load the RAM contents?:( I thought there is an easier method
That's correct. If you want to change the video mode from the kernel, you will have to reboot and do it before exiting boot services. This is unless you have video drivers for your card that know how to change the video mode.Electrical wrote:So the only way to set video mode is to save RAM contents into a file, then restart the os change mode is bootloader and load the RAM contents?:( I thought there is an easier method
How is that solving anything for the OP? He asked how to change the video mode after exiting boot services.PeterX wrote:There is! You start the kernel as an UEFI application. The kernel then sets the video mode and exits boot-services.
Alternative: Use Grub and let it set the video mode.
He asked for a simple way and I answered. His first question is already answered.kzinti wrote:That's correct. If you want to change the video mode from the kernel, you will have to reboot and do it before exiting boot services. This is unless you have video drivers for your card that know how to change the video mode.Electrical wrote:So the only way to set video mode is to save RAM contents into a file, then restart the os change mode is bootloader and load the RAM contents?:( I thought there is an easier method
How is that solving anything for the OP? He asked how to change the video mode after exiting boot services.PeterX wrote:There is! You start the kernel as an UEFI application. The kernel then sets the video mode and exits boot-services.
Alternative: Use Grub and let it set the video mode.
The OP was asking how to change the video mode after exiting boot services. You answered by saying that he should change the video mode before exiting boot services.PeterX wrote:He asked for a simple way and I answered. His first question is already answered.
Yes you could do that . The problem is that you then have no control over your hardware management, including memory. So you won't get far .Electrical wrote:What if i didn't exit boot services? Would i be able to use uefi protocols and create syscalls?
Implement native video card drivers.Electrical wrote:So the only way to set video mode is to save RAM contents into a file, then restart the os change mode is bootloader and load the RAM contents?:( I thought there is an easier method
Well, yes and no. In theory it could be done, but in practice it comes at a too large price. Your kernel won't own the memory, it would have to rely on UEFI memory allocation (which is proven to be fragmenting badly), and it wouldn't be able to set up virtual memory (as UEFI boot services mandate identity mapping), essentially constricting the whole OS into a single, badly managed address space. And there's the question how your kernel could set up descriptor tables (some UEFI services use interrupts, and you can't expect anything from a firmware's IDT, same issue with GDT, you don't know what you got but you cannot use your own as that would break UEFI). So could be done, but questionable if worth it.Electrical wrote:What if i didn't exit boot services? Would i be able to use uefi protocols and create syscalls?
it's a wrong and bad approach. Boot Services were created only for the FW itself and for UEFI applications, mainly - OS Loaders. It's their purpose. All the services and protocols are for this only purpose. Answering your subject question, you have two choices:Electrical wrote: What if i didn't exit boot services? Would i be able to use uefi protocols and create syscalls?
as already pointed out, is useless or saying differently - such an overkill. instead, your UEFI OS Loader negotiates with the UEFI (through GOP) the desired (by your OS) resolution (from that limited set, available, don't expect the FW would be driving 8K ) and sets it up during its run (which is at the Boot Services stage). This is all you need and have in the 2nd variant. UEFI thinks the 1st is what happens (and it's reasonable, since the firmware interface spec cannot take into account this sweet combination of OS dev enthusiasts limited by the display controller vendors' unwillingness to open their manuals).So the only way to set video mode is to save RAM contents into a file, then restart the os change mode is bootloader and load the RAM contents?:( I thought there is an easier method
If you can find the option ROM containing the GOP driver, you can execute its code inside an emulated UEFI environment (which you have to write) and use it to control the display adapter that way.kzinti wrote:You can't. You have to do it before exiting boot services.
Although I am sure you are technically right, how realistic is it that the OP is going to explore this idea and succeed after he posted that question?Octocontrabass wrote:If you can find the option ROM containing the GOP driver, you can execute its code inside an emulated UEFI environment (which you have to write) and use it to control the display adapter that way.
UGA was designed to work like this, except with fewer dependencies so you don't need a whole emulated UEFI environment to use it.
Hello! I did as you said, but the ROM I read did not start with 0xaa55 as expected. Instead, it starts with a magic number and then all the rest are 0x55.And I read the real rom from the bar mapped space. Is this due to the graphics card itself or the PCI?Octocontrabass wrote:If you can find the option ROM containing the GOP driver, you can execute its code inside an emulated UEFI environment (which you have to write) and use it to control the display adapter that way.kzinti wrote:You can't. You have to do it before exiting boot services.
UGA was designed to work like this, except with fewer dependencies so you don't need a whole emulated UEFI environment to use it.