UEFI Video after ExitBootServices()
Posted: Tue Jun 18, 2013 7:17 pm
The topic of video services after invocation of ExitBootServices() from a UEFI application has been discussed at some length in a few other posts. Having read through those posts and having spent some time writing a UEFI application using the EDK2 kit targeting the virtualized UEFI firmware provided on VMWare Workstation 9, I am seeking some additional clarification.
The UEFI specification states (spec 2.3.1D, section 2.3.4) that, when building for x86-64, the boot state is uniprocessor, long mode, paging enabled with all pages identity mapped, and selectors flat. If I write directly to 0xb8000 before or after ExitBootServices(), no output is produced. This is not surprising, and presumably implies that the VGA subsystem has not been initialized by UEFI. For giggles, immediately after ExitBootServices(), I manually attempted to initialize VGA using code lifted directly from coreboot. After this, a write to 0xb8000 again produced no output.
I assume that after ExitBootServices(), the system state is the same as before invocation of that method (i.e., uniprocessor, long mode, paging enabled with all pages identity mapped, flat selectors, and so forth). Without any video output, this is challenging to test. I further presume that the code I lifted from coreboot can be used to initialize VGA on my virtualized system (perhaps a bold assumption). If these two assumptions are true, then I suspect VGA can actually only be initialized when the system is in real-mode.
So:
Question 1: after ExitBootServices(), is the system in the state described in section 2.3.4?
Question 2: is it the case that the VGA subsystem can only be initialized in real-mode?
If I accept that VGA and its relatives (e.g., VESA) are not the best or right way for basic video when using UEFI firmware to boot, what is the alternative? I assume there are two possibilities: 1. there is a different standard that is generally supported across cards; and/or 2. one must write drivers for each card type. It seems, from the "Accelerated Graphic Cards" wiki entry that, although many modern cards support acceleration for OpenGL, the actual driver interface is not standardized. In the absence of a cross-card standard interface for graphics or text, it seems that one is left with option #2. I assume, based on the aforementioned posts, that this is the only option. UDI certainly looks interesting, because it allows one to leverage the work done by others ... possibly even in cases where one can get nothing but binaries from the card manufacturers? At any rate, VMWare does provide what appears to be reasonable documenation for their virtualized video adapter, at least for basic 2D rendering, and I'm willing to give writing a driver a go.
So:
Question 3: Are there standards other than VGA and VESA that can be used across most modern graphics cards to do basic 2D graphics output?
Question 4: If not, when using UEFI firmware, is the only option at this point to write a driver for the video hardware being used?
This is my first post, and although I've spent some time writing a (very) basic hobby OS for ia32 using GRUB and a system booting from a BIOS, this is my first expedition into the world of x86-64 and UEFI. One wonders if biting off both simultaneously provides a bit much to chew. In any case, if my phrasing is unclear, my markup is broken, or my questions are naive, I do apologize. Any and all assistance is appreciated.
The UEFI specification states (spec 2.3.1D, section 2.3.4) that, when building for x86-64, the boot state is uniprocessor, long mode, paging enabled with all pages identity mapped, and selectors flat. If I write directly to 0xb8000 before or after ExitBootServices(), no output is produced. This is not surprising, and presumably implies that the VGA subsystem has not been initialized by UEFI. For giggles, immediately after ExitBootServices(), I manually attempted to initialize VGA using code lifted directly from coreboot. After this, a write to 0xb8000 again produced no output.
I assume that after ExitBootServices(), the system state is the same as before invocation of that method (i.e., uniprocessor, long mode, paging enabled with all pages identity mapped, flat selectors, and so forth). Without any video output, this is challenging to test. I further presume that the code I lifted from coreboot can be used to initialize VGA on my virtualized system (perhaps a bold assumption). If these two assumptions are true, then I suspect VGA can actually only be initialized when the system is in real-mode.
So:
Question 1: after ExitBootServices(), is the system in the state described in section 2.3.4?
Question 2: is it the case that the VGA subsystem can only be initialized in real-mode?
If I accept that VGA and its relatives (e.g., VESA) are not the best or right way for basic video when using UEFI firmware to boot, what is the alternative? I assume there are two possibilities: 1. there is a different standard that is generally supported across cards; and/or 2. one must write drivers for each card type. It seems, from the "Accelerated Graphic Cards" wiki entry that, although many modern cards support acceleration for OpenGL, the actual driver interface is not standardized. In the absence of a cross-card standard interface for graphics or text, it seems that one is left with option #2. I assume, based on the aforementioned posts, that this is the only option. UDI certainly looks interesting, because it allows one to leverage the work done by others ... possibly even in cases where one can get nothing but binaries from the card manufacturers? At any rate, VMWare does provide what appears to be reasonable documenation for their virtualized video adapter, at least for basic 2D rendering, and I'm willing to give writing a driver a go.
So:
Question 3: Are there standards other than VGA and VESA that can be used across most modern graphics cards to do basic 2D graphics output?
Question 4: If not, when using UEFI firmware, is the only option at this point to write a driver for the video hardware being used?
This is my first post, and although I've spent some time writing a (very) basic hobby OS for ia32 using GRUB and a system booting from a BIOS, this is my first expedition into the world of x86-64 and UEFI. One wonders if biting off both simultaneously provides a bit much to chew. In any case, if my phrasing is unclear, my markup is broken, or my questions are naive, I do apologize. Any and all assistance is appreciated.