about loader & console

Toomas Soome tsoome at me.com
Mon Mar 2 08:47:50 UTC 2020


Hi!

I have been busy with other bits for some time, but now back to poking some bits.

What we have now (on current):

x86: 

vidconsole on BIOS systems. Text mode, the screen is managed by teken terminal emulator, we “draw” on vga text buffer. 
comconsole: serial port driver shared by BIOS and UEFI mode.
efi: Text mode, console “device” which can have gfx display, serial port or both connected as back end device, connection is done by the firmware. We write by using UEFI Simple Text Output Protocol. See also ConOut UEFI variable.

To manage the screen, the efi console also defaults to use teken terminal emulator, however, if the serial port is multiplexed to ConOut, we can not have “our” terminal emulator to draw the screen, as that would distort the serial console. And worse, at least some UEFI firmware implementations do not pass ESC code via simple text output protocol, causing the console being filled by broken CSI sequences.

arm: efi console is the same state as in x86, no serial driver to provide comconsole, the serial console is only available via redirection from firmware.

I actually do have basic comconsole implementation via UEFI Serial IO protocol, but unfortunately, the UEFI API does not provide good way to identify serial ports, we only do get array of handles of serial ports. The SIO handle is opaque.

What we want to get: 

We would like to have framebuffer console (at least on efi), where we do “draw” the glyphs and do not use simple text output protocol for console output. 

Why: this will allow us to provide more consistent screen output, draw images and we would not depend on simple text output any more.

UEFI gfx console is already built on framebuffer - on physical systems we do get FB address, size and few other attributes, and after passing this all to kernel, the kernel will draw the conole, as Simple Text Output Protocol is not available once we start the kernel.

To get this done, we need console font. To be able to output text, I do plan to build into loader binary the limited set (ascii + box drawing) 8x16 font, and once we have gained access to the disk, we will load best matching font for the current resolution. This makes first problem - we have font files in usr/share/vt/fonts, but there are too many options where the /usr might be, so we would need to copy some of those fonts to /boot tree. I’d use terminus fonts there for consistency (glyph range) for various glyph sizes. And the kernel default built in font is 8x16 terminus.

With ability to draw our glyphs, we can build console device list in console variable, just as it is currently done with x86 BIOS version. If we should still use the console name “efi” for FB console or leave efi for pure Simple Text Output based console, is something we would need to decide.

Once we can draw the FB console on UEFI, it is not too hard to add the implementation for BIOS VBE interface.

To sum it all up:

0. my assumption is/was that we do not change the name of the console driver, to keep the expected values people are used with. However, it is quite easy to introduce new console types, if needed.
1. We need to provide serial driver on all platforms.
2. Provide option to switch between “text” and gfx mode. In some systems (BIOS VGA) the gfx performance may be very low and text mode might be preferred. 
3. The screen updates are to be implemented via teken callback mechanism (as it is also done in kernel for that matter).
4. The support to display images is using pnglite (and therefore png format). Interpreters need updates to support the feature.

I actually do have the core implementation for UEFI already, but polishing it up will still get some time. Actually I am cheating there quite a bit because I have done all this work already once and now I am porting it to different terminal emulator.

I hope this writeup does give some light about what is happening in this area.

thanks,
toomas


More information about the freebsd-current mailing list