Setting GOP mode after exiting Boot Services [UEFI]
-
- Posts: 8
- Joined: Wed May 27, 2020 8:27 am
Setting GOP mode after exiting Boot Services [UEFI]
Hello! How to set GOP mode after exiting Boot Services?
Re: Setting GOP mode after exiting Boot Services [UEFI]
You can't. You have to do it before exiting boot services.
-
- Posts: 8
- Joined: Wed May 27, 2020 8:27 am
Re: Setting GOP mode after exiting Boot Services [UEFI]
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
Re: Setting GOP mode after exiting Boot Services [UEFI]
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
Alternative: Use Grub and let it set the video mode.
Re: Setting GOP mode after exiting Boot Services [UEFI]
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.
Re: Setting GOP mode after exiting Boot Services [UEFI]
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.
-
- Posts: 8
- Joined: Wed May 27, 2020 8:27 am
Re: Setting GOP mode after exiting Boot Services [UEFI]
What if i didn't exit boot services? Would i be able to use uefi protocols and create syscalls?
Re: Setting GOP mode after exiting Boot Services [UEFI]
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.
One of us is confused here.
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?
-
- Posts: 8
- Joined: Wed May 27, 2020 8:27 am
Re: Setting GOP mode after exiting Boot Services [UEFI]
Thank you for all your answers
Re: Setting GOP mode after exiting Boot Services [UEFI]
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?
Cheers,
bzt
Re: Setting GOP mode after exiting Boot Services [UEFI]
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?
1) if you have a documentation for the machine display controllers, your OS needs to have a driver for them - let's call it "video port driver". then you can do whatever that hardware is capable of.
2) if the above is luxury, you take the framebuffer handed off to your OS by the loader, taken from GOP and use it as is, that is - without the possibility to change the resolution and use other HW capabilities of the underlying device. this approach, below:
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
Nowadays, I see, 1024x768 is pretty common to expect to be set on real hardware. Thanks to the Windows bootmgr.efi, that stated, it wants such. even uboot's UEFI on ARM, sets this resolution. at least it was it, with those couple of machines, I was lucky to get working GOP on (Pine64+ (old versions of uboot though) and Rock Pi 4B).
-
- Member
- Posts: 5560
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Setting GOP mode after exiting Boot Services [UEFI]
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.
Re: Setting GOP mode after exiting Boot Services [UEFI]
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.
Also I am not sure that would qualify as "using the gop after exiting boot services".
-
- Member
- Posts: 25
- Joined: Sat May 04, 2024 7:48 am
- Libera.chat IRC: wishedtobe
Re: Setting GOP mode after exiting Boot Services [UEFI]
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.