How coreboot/seabios works
SeaBIOS is a legacy x86 firmware repository. Its job is to boot on PC-class machines, initialize basic hardware, expose BIOS interrupt services, and hand off to a bootable device or bootloader. The tree is split into the main BIOS image in src/ and a separate VGA BIOS image in vgasrc/.
The runtime model is firmware, not an OS: code runs very early on bare metal or in emulators like QEMU, mostly in 16-bit real mode with some mixed-mode helpers. The top-level assembly files and linker/layout scripts control how the ROM image is placed and how control enters the firmware.
src/ is the core BIOS subsystem. It contains boot flow, memory management, device enumeration, ROM handling, BIOS data structures, and service implementations. Key areas include boot.c, post.c, resume.c, system.c, x86.c, malloc.c, pmm.c, memmap.h, and BIOS-facing data abstractions in biosvar.h and bregs.h.
Hardware support is organized by device class in src/hw/. This is where SeaBIOS talks to storage controllers, USB, PCI, serial, timers, floppy, TPM, RTC, PS/2, and several virtualized or paravirtualized block-device paths. The storage path is especially important: ATA/AHCI/NVMe/SCSI/USB mass storage/VirtIO all feed into common block-device code so BIOS disk services can present a uniform boot interface.
Platform and chipset initialization lives in src/fw/. This layer builds the firmware tables and machine-specific setup used by the rest of the BIOS. It includes ACPI, SMBIOS, MPTable, PIRQ, coreboot integration, CSM support, Xen/paravirt support, PCI initialization, shadowing, SMM, and ROM file loading. This is the main boundary between SeaBIOS and the host firmware environment.
The boot path is data-driven and device-driven. After early CPU/memory setup, SeaBIOS scans hardware, loads option ROMs, constructs firmware tables, and selects a boot target. Option ROM support is explicit in src/optionroms.c and src/romfile*, allowing external device firmware to be discovered and executed during initialization.
Interrupt-style BIOS services are implemented as low-level entry points that service legacy callers from bootloaders and operating systems. These services cover disk access, keyboard/mouse, video hooks, serial console, power management, and tables for ACPI/SMBIOS/TCG/Multiboot. The code is structured around the classic BIOS contract rather than modern drivers or syscalls.
vgasrc/ is a second firmware image for video initialization and VGA compatibility. It contains the VGA BIOS entry path, standard VGA and VBE support, mode tables, font handling, framebuffer helpers, and chipset-specific VGA implementations. This is separate because video firmware is often built and linked differently from the main BIOS.
The repository depends on generated and assembled artifacts. scripts/ contains build-time tools for ROM layout, version stamping, checksumming, stack/layout verification, and Kconfig support. These scripts are part of the architecture because they generate offsets, ROM images, and consistency checks that the firmware binary depends on.
Configuration is managed with Kconfig. src/Kconfig and vgasrc/Kconfig, together with the scripts under scripts/kconfig/, define feature selection for different build targets and hardware capabilities. This is how SeaBIOS adapts to QEMU, coreboot, CSM, Xen, and other environments without changing the core source layout.
The main external interface is the firmware ABI exposed to firmware consumers and guest software: BIOS interrupts, option ROM execution, ACPI/SMBIOS/MPTable tables, boot device probing, and legacy console I/O. The project’s architecture is therefore centered on translating modern emulator/host hardware into these legacy interfaces while keeping the boot path deterministic and ROM-sized.
Main entry points: boot.c Boot Flow · bregs.h BIOS ABI · pciinit.c FW Init · Kconfig Kconfig
Components 21
Main BIOS
Core SeaBIOS runtime and firmware services in src/
- Entry & Layout · Top-level assembly and ROM layout control how firmware is placed and entered.
src/romlayout.S - Boot Flow · POST, boot selection, resume, and runtime coordination.
src/boot.c - Memory Core · Allocation, PMM, stack handling, and memory map data structures.
src/malloc.c - CPU Helpers · Real-mode and mixed-mode helpers, BIOS register/state abstractions, and x86 primitives.
src/x86.c - BIOS ABI · Legacy BIOS-facing services and shared firmware state interfaces.
src/bregs.h - ROM Data · Core BIOS data structures and firmware-visible tables.
src/biosvar.h - ROM Assets · Option ROM discovery, ROM-file loading, and related firmware payload handling.
src/optionroms.c - Disk Services · Common BIOS disk path that presents storage devices through legacy interfaces.
src/block.c - Measured Boot · TPM and TCG-related BIOS services and event support.
src/tcgbios.c
Hardware
Device-class and transport drivers under src/hw/
- Storage Stack · ATA, AHCI, NVMe, SCSI, USB mass storage, VirtIO block, and common block command paths.
src/hw/blockcmd.c - USB Stack · USB host controllers, hubs, HID, MSC/UAS, and USB transport glue.
src/hw/usb.c - PCI Layer · PCI discovery, registers, and device access used by firmware and drivers.
src/hw/pci.c - Platform IO · PIC, RTC, timers, serial console, PS/2, floppy, TPM, and other board-level I/O paths.
src/hw/pic.c
Platform FW
Platform-specific initialization and firmware table setup under src/fw/
- FW Init · Platform and chipset initialization, including ACPI/SMBIOS/PCI/SMM/ROM-file setup.
src/fw/pciinit.c - Firmware Tables · Construction of ACPI, SMBIOS, MPTable, PIRQ, and related firmware tables.
src/fw/acpi.c - Paravirt · Coreboot, CSM, Xen, and other environment-specific integration layers.
src/fw/paravirt.c
VGA BIOS
Separate VGA firmware image in vgasrc/
Build System
Layout, config, and image-generation tooling
- Build Tools · ROM layout, version stamping, checksumming, and verification scripts.
scripts/layoutrom.py - Kconfig · Feature selection and build-time configuration for BIOS and VGA images.
src/Kconfig
Connections 25
- Entry & Layout → Boot Flow: enters · Control transfers from ROM entry into boot/post flow.
- Entry & Layout → CPU Helpers: sets mode · Early assembly establishes execution state and helpers.
- Boot Flow → Memory Core: uses · Boot flow depends on memory allocation and layout.
- Boot Flow → PCI Layer: scans · Boot-time enumeration starts with PCI discovery.
- Boot Flow → ROM Assets: loads · Boot flow discovers and executes option ROMs.
- Boot Flow → Disk Services: selects boot · Boot logic chooses a bootable device path.
- BIOS ABI → Disk Services: exposes · Disk services are part of the BIOS interrupt ABI.
- BIOS ABI → Platform IO: exposes · Legacy interrupt services route to platform I/O handlers.
- BIOS ABI → Firmware Tables: publishes · Firmware-visible tables are exposed through the BIOS ABI.
- BIOS ABI → Measured Boot: includes · TPM/TCG services are part of the legacy firmware contract.
- Memory Core → ROM Data: stores · Shared BIOS data structures live in firmware memory.
- FW Init → Firmware Tables: builds · Platform code assembles ACPI/SMBIOS/MPTable and related tables.
- FW Init → Paravirt: adapts to · Initialization varies across coreboot, CSM, Xen, and paravirt targets.
- FW Init → PCI Layer: initializes · Platform setup configures PCI and chipset state.
- FW Init → ROM Assets: loads · Platform layer provides ROM file loading and shadowing support.
- Storage Stack → Disk Services: feeds · Device drivers funnel into the common BIOS disk interface.
- USB Stack → Storage Stack: provides · USB mass-storage paths connect into the storage stack.
- PCI Layer → Storage Stack: enumerates · PCI discovery activates storage and controller drivers.
- Platform IO → BIOS ABI: services · Board-level I/O backs legacy BIOS services.
- VGA Entry → VGA Modes: uses · VGA entry initializes mode tables and display services.
- VGA Modes → VGA HW: drives · Mode setup delegates to chipset-specific VGA implementations.
- Build Tools → Entry & Layout: generates · Build scripts compute ROM layout and entry placement.
- Build Tools → Kconfig: consumes · Build tooling reads configuration to shape the images.
- Kconfig → Boot Flow: configures · Kconfig selects firmware features and runtime behavior.
- Kconfig → VGA Entry: configures · Separate VGA image has its own configuration.