# coreboot/seabios architecture

> Architecture diagram of the GitHub repository coreboot/seabios, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/coreboot/seabios
- Repository: https://github.com/coreboot/seabios

## Overview

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: [`src/boot.c`](https://github.com/coreboot/seabios/blob/master/src/boot.c) (Boot Flow), [`src/bregs.h`](https://github.com/coreboot/seabios/blob/master/src/bregs.h) (BIOS ABI), [`src/fw/pciinit.c`](https://github.com/coreboot/seabios/blob/master/src/fw/pciinit.c) (FW Init), [`src/Kconfig`](https://github.com/coreboot/seabios/tree/master/src/Kconfig) (Kconfig)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_grp_core["Main BIOS"]
  node_n_entry["Entry & Layout<br/>firmware entry<br/>[romlayout.S]"]
  node_n_boot["Boot Flow<br/>boot orchestration<br/>[boot.c]"]
  node_n_mem[("Memory Core<br/>memory mgmt<br/>[malloc.c]")]
  node_n_cpu["CPU Helpers<br/>low-level x86<br/>[x86.c]"]
  node_n_bios["BIOS ABI<br/>interrupt services<br/>[bregs.h]"]
  node_n_data["ROM Data<br/>bios tables<br/>[biosvar.h]"]
  node_n_rom["ROM Assets<br/>rom loading<br/>[optionroms.c]"]
  node_n_disk["Disk Services<br/>block device ABI<br/>[block.c]"]
  node_n_tcg["Measured Boot<br/>TPM/TCG<br/>[tcgbios.c]"]
end

subgraph group_grp_hw["Hardware"]
  node_n_storage["Storage Stack<br/>device drivers<br/>[blockcmd.c]"]
  node_n_usb["USB Stack<br/>usb drivers<br/>[usb.c]"]
  node_n_pci["PCI Layer<br/>enumeration<br/>[pci.c]"]
  node_n_platform["Platform IO<br/>firmware devices<br/>[pic.c]"]
end

subgraph group_grp_fw["Platform FW"]
  node_n_fwinit["FW Init<br/>platform setup<br/>[pciinit.c]"]
  node_n_tables["Firmware Tables<br/>acpi/smbios<br/>[acpi.c]"]
  node_n_paravirt["Paravirt<br/>env integration<br/>[paravirt.c]"]
end

subgraph group_grp_vga["VGA BIOS"]
  node_n_vga_entry["VGA Entry<br/>video firmware<br/>[vgabios.c]"]
  node_n_vga_modes["VGA Modes<br/>display support<br/>[vbe.c]"]
  node_n_vga_hw["VGA HW<br/>chipset video<br/>[stdvga.c]"]
end

subgraph group_grp_build["Build System"]
  node_n_build["Build Tools<br/>build scripts<br/>[layoutrom.py]"]
  node_n_config["Kconfig<br/>config system"]
end

node_n_entry -->|"enters"| node_n_boot
node_n_entry -->|"sets mode"| node_n_cpu
node_n_boot -->|"uses"| node_n_mem
node_n_boot -->|"scans"| node_n_pci
node_n_boot -->|"loads"| node_n_rom
node_n_boot -->|"selects boot"| node_n_disk
node_n_bios -->|"exposes"| node_n_disk
node_n_bios -->|"exposes"| node_n_platform
node_n_bios -->|"publishes"| node_n_tables
node_n_bios -->|"includes"| node_n_tcg
node_n_mem -->|"stores"| node_n_data
node_n_fwinit -->|"builds"| node_n_tables
node_n_fwinit -->|"adapts to"| node_n_paravirt
node_n_fwinit -->|"initializes"| node_n_pci
node_n_fwinit -->|"loads"| node_n_rom
node_n_storage -->|"feeds"| node_n_disk
node_n_usb -->|"provides"| node_n_storage
node_n_pci -->|"enumerates"| node_n_storage
node_n_platform -->|"services"| node_n_bios
node_n_vga_entry -->|"uses"| node_n_vga_modes
node_n_vga_modes -->|"drives"| node_n_vga_hw
node_n_build -->|"generates"| node_n_entry
node_n_build -->|"consumes"| node_n_config
node_n_config -->|"configures"| node_n_boot
node_n_config -->|"configures"| node_n_vga_entry

click node_n_entry "https://github.com/coreboot/seabios/blob/master/src/romlayout.S"
click node_n_boot "https://github.com/coreboot/seabios/blob/master/src/boot.c"
click node_n_mem "https://github.com/coreboot/seabios/blob/master/src/malloc.c"
click node_n_cpu "https://github.com/coreboot/seabios/blob/master/src/x86.c"
click node_n_bios "https://github.com/coreboot/seabios/blob/master/src/bregs.h"
click node_n_data "https://github.com/coreboot/seabios/blob/master/src/biosvar.h"
click node_n_rom "https://github.com/coreboot/seabios/blob/master/src/optionroms.c"
click node_n_disk "https://github.com/coreboot/seabios/blob/master/src/block.c"
click node_n_tcg "https://github.com/coreboot/seabios/blob/master/src/tcgbios.c"
click node_n_fwinit "https://github.com/coreboot/seabios/blob/master/src/fw/pciinit.c"
click node_n_tables "https://github.com/coreboot/seabios/blob/master/src/fw/acpi.c"
click node_n_paravirt "https://github.com/coreboot/seabios/blob/master/src/fw/paravirt.c"
click node_n_storage "https://github.com/coreboot/seabios/blob/master/src/hw/blockcmd.c"
click node_n_usb "https://github.com/coreboot/seabios/blob/master/src/hw/usb.c"
click node_n_pci "https://github.com/coreboot/seabios/blob/master/src/hw/pci.c"
click node_n_platform "https://github.com/coreboot/seabios/blob/master/src/hw/pic.c"
click node_n_vga_entry "https://github.com/coreboot/seabios/blob/master/vgasrc/vgabios.c"
click node_n_vga_modes "https://github.com/coreboot/seabios/blob/master/vgasrc/vbe.c"
click node_n_vga_hw "https://github.com/coreboot/seabios/blob/master/vgasrc/stdvga.c"
click node_n_build "https://github.com/coreboot/seabios/blob/master/scripts/layoutrom.py"
click node_n_config "https://github.com/coreboot/seabios/tree/master/src/Kconfig"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_n_entry,node_n_boot,node_n_mem,node_n_cpu,node_n_bios,node_n_data,node_n_rom,node_n_disk,node_n_tcg toneBlue
class node_n_storage,node_n_usb,node_n_pci,node_n_platform toneAmber
class node_n_fwinit,node_n_tables,node_n_paravirt toneMint
class node_n_vga_entry,node_n_vga_modes,node_n_vga_hw toneRose
class node_n_build,node_n_config toneIndigo
```

## Components

### Main BIOS

Core SeaBIOS runtime and firmware services in src/

- [Entry & Layout](https://github.com/coreboot/seabios/blob/master/src/romlayout.S): firmware entry · Top-level assembly and ROM layout control how firmware is placed and entered. · `src/romlayout.S`
- [Boot Flow](https://github.com/coreboot/seabios/blob/master/src/boot.c): boot orchestration · POST, boot selection, resume, and runtime coordination. · `src/boot.c`
- [Memory Core](https://github.com/coreboot/seabios/blob/master/src/malloc.c): memory mgmt · Allocation, PMM, stack handling, and memory map data structures. · `src/malloc.c`
- [CPU Helpers](https://github.com/coreboot/seabios/blob/master/src/x86.c): low-level x86 · Real-mode and mixed-mode helpers, BIOS register/state abstractions, and x86 primitives. · `src/x86.c`
- [BIOS ABI](https://github.com/coreboot/seabios/blob/master/src/bregs.h): interrupt services · Legacy BIOS-facing services and shared firmware state interfaces. · `src/bregs.h`
- [ROM Data](https://github.com/coreboot/seabios/blob/master/src/biosvar.h): bios tables · Core BIOS data structures and firmware-visible tables. · `src/biosvar.h`
- [ROM Assets](https://github.com/coreboot/seabios/blob/master/src/optionroms.c): rom loading · Option ROM discovery, ROM-file loading, and related firmware payload handling. · `src/optionroms.c`
- [Disk Services](https://github.com/coreboot/seabios/blob/master/src/block.c): block device ABI · Common BIOS disk path that presents storage devices through legacy interfaces. · `src/block.c`
- [Measured Boot](https://github.com/coreboot/seabios/blob/master/src/tcgbios.c): TPM/TCG · TPM and TCG-related BIOS services and event support. · `src/tcgbios.c`

### Hardware

Device-class and transport drivers under src/hw/

- [Storage Stack](https://github.com/coreboot/seabios/blob/master/src/hw/blockcmd.c): device drivers · ATA, AHCI, NVMe, SCSI, USB mass storage, VirtIO block, and common block command paths. · `src/hw/blockcmd.c`
- [USB Stack](https://github.com/coreboot/seabios/blob/master/src/hw/usb.c): usb drivers · USB host controllers, hubs, HID, MSC/UAS, and USB transport glue. · `src/hw/usb.c`
- [PCI Layer](https://github.com/coreboot/seabios/blob/master/src/hw/pci.c): enumeration · PCI discovery, registers, and device access used by firmware and drivers. · `src/hw/pci.c`
- [Platform IO](https://github.com/coreboot/seabios/blob/master/src/hw/pic.c): firmware devices · 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](https://github.com/coreboot/seabios/blob/master/src/fw/pciinit.c): platform setup · Platform and chipset initialization, including ACPI/SMBIOS/PCI/SMM/ROM-file setup. · `src/fw/pciinit.c`
- [Firmware Tables](https://github.com/coreboot/seabios/blob/master/src/fw/acpi.c): acpi/smbios · Construction of ACPI, SMBIOS, MPTable, PIRQ, and related firmware tables. · `src/fw/acpi.c`
- [Paravirt](https://github.com/coreboot/seabios/blob/master/src/fw/paravirt.c): env integration · Coreboot, CSM, Xen, and other environment-specific integration layers. · `src/fw/paravirt.c`

### VGA BIOS

Separate VGA firmware image in vgasrc/

- [VGA Entry](https://github.com/coreboot/seabios/blob/master/vgasrc/vgabios.c): video firmware · VGA BIOS entry path and image-level initialization. · `vgasrc/vgabios.c`
- [VGA Modes](https://github.com/coreboot/seabios/blob/master/vgasrc/vbe.c): display support · Standard VGA/VBE mode tables, fonts, framebuffer helpers, and chipset-specific video support. · `vgasrc/vbe.c`
- [VGA HW](https://github.com/coreboot/seabios/blob/master/vgasrc/stdvga.c): chipset video · Hardware-specific VGA implementations and video BIOS integration points. · `vgasrc/stdvga.c`

### Build System

Layout, config, and image-generation tooling

- [Build Tools](https://github.com/coreboot/seabios/blob/master/scripts/layoutrom.py): build scripts · ROM layout, version stamping, checksumming, and verification scripts. · `scripts/layoutrom.py`
- [Kconfig](https://github.com/coreboot/seabios/tree/master/src/Kconfig): config system · Feature selection and build-time configuration for BIOS and VGA images. · `src/Kconfig`

## Connections

- 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.
