This is part of the code required to add the missing graphical console output when booting with UEFI. The scrolling performance is visibly very poor but will improve considerably once I have completed support for write combining (WC). This code shouldn't require much change for WC and I think it might be beneficial for Hurd users to make use of it earlier to test a UEFI boot on their machines. Also since this is a substantial change, although to code not in active use, it might take some time to agree to integration. Almost all of the patch is either new code or changes to unused code so there didn't seem much value in breaking it into a series of small patches.
I've added a configure option '--enable-immc' to include the immediate console within a gnumach build. The immediate console code is explicitly activated in c_boot_entry by assigning to 'romputc'. It is effectively deactivated when a true console is found later in the boot. The immediate console does not support input and uses the BIOS EGA video memory, which is assumed to be always available, to display characters. The true console display driver (kd) also uses the same EGA video memory but supports keyboard input. Once gnumach reaches cninit() there is therefore no reason to continue using the immediate console since the same features, and more, are available in the kd console. cons_conf.c includes the immediate console in the list of candidate consoles and it lists immc_cninit() before kdcninit(). These 2 console options have the same priority and so the immediate console is chosen during cninit(). Code within kdinit() deactivates the immediate console but kdinit() isn't called at all when there is an immediate console. I'm supposing that this is some historical anomaly. The immediate console is very useful for debugging early kernel problems that occur before cninit(). It helped me a lot whilst developing the multiboot2 but I'm not sure it classifies as an actual console. It might be better described as a display and I propose to remove it from the console list in cons_conf.c. It can be explicitly activated and deactivated similarly to now. UEFI does not support EGA video. It only offers a frame buffer which has to be mapped into the virtual memory space before it can be used. This is more complex than the EGA display whose memory is identity mapped throughout the lifetime of the immediate console. The physical address of the frame buffer can fall outside of the range currently mapped by x86_64/boothdr.S. It's necessary to find a virtual address range that is unused during early boot and explicitly map it. I wanted to keep the code for memory mapping as simple as possible since this is only a debugging tool for occasional use. Choosing a virtual address at the start of a PML4 entry that is not 0, and that is not the region including the kernel, is guaranteed to be 'free'. The immediate console mapping is removed long before any user process can run. This simple strategy requires one exclusive L3 page, one exclusive L2 page and several exclusive L1 pages to be setup trivially. This mapping is only used within: 1) the boothdr.S page tables from intial boot to pmap_set_page_dir() 2) the kernel_pmap until immc_disable() (just before cninit()). Any user of the frame buffer beyond this point can use existing kernel interfaces to map it within the normal kernel virtual address space. This will be made within kdinit() in a future patch. On many occasions whilst debugging multiboot2, for example, I was frustrated to lose the immediate console output when lines scrolled off the screen and gnumach successfully booted. At these times, the output could have been presented by the actual console anyway. I think it is more helpful for the immediate console output to be recreated by the true console once it starts. This requires a simple change to cnputc() to save the 'put' character even if romputc is active. A secondary benefit occurs if the screen or font sizes differ between the displays since the display is reset and redrawn completely. Note that, presently, CONSBUFSIZE (device/cons.h) is currently too small for this to be effective, due to the large volume of ACPI debug, but changing that locally to 8192 is sufficient. I've also tested that the immediate console still works on hurd-i386 and hurd-amd64 when using multiboot1 (no frame buffer). Mike.
