Table of Contents

Firmware handoff

The kernel is not the first software to run on the machine. The UEFI firmware runs before the bootloader, and by the time it hands over it has configured much of the hardware for its own use. It has enumerated PCI, given the bridges their bus numbers and every function's BARs an address (PCI), and enabled the devices it booted from. Through its Graphics Output Protocol it has set a display mode and left a linear framebuffer on screen, whose address, size and pixel layout the bootloader passes on to the kernel. Tables describing what cannot be discovered reach the kernel the same way: ACPI on PCs and ARM servers, a device tree on many ARM boards (buses).

A kernel can redo this work or build on it. Building on it saves work, the display mode above all: setting a mode means programming the display timing and bringing up the link to the monitor, which the firmware has already done. The price is that the kernel inherits devices that may still be active, with bus mastering on and DMA running, or a USB controller the firmware still uses to emulate a PS/2 keyboard.

The trap is a legacy boot. With its CSM (compatibility support module), UEFI firmware emulates an old PC BIOS, and the display is left in VGA mode instead of on a linear framebuffer, so a driver that expects the firmware's surface finds none.

In the driver kit, the PCI host driver builds on what the firmware left: it keeps the firmware's bus numbers and BAR assignment rather than redoing them. The kit turns a function's bus mastering and interrupts off before the first probe, so that no driver sees a device the firmware left running, and puts the firmware's settings back when no driver binds it (The PCI access object). The bootloader's framebuffer is published as a display named framebuffer, and withdrawn when a driver binds the PCI function whose memory holds it (Publishing a device). AmdDcnDriver and IntelGraphicsDriver keep the UEFI mode, decline after a CSM boot, and put the firmware's surface back on screen in OnDetach (The display drivers).