Skip to main content

Module firmware

Module firmware 

Source
Expand description

s9vm : generic guest-firmware images (SeaBIOS and other BIOS ROMs).

A world can boot either the s9vm stub firmware built by [biosrom] or a real firmware image supplied by the caller. This module owns the second path and makes it reusable: it validates a flat BIOS image and its optional VGA option ROM, places them at the PC-compatible addresses, and returns the reset state the vCPU must start from.

ยงImage kinds

KindLayoutValidation
BIOSflat image ending at 0x10_0000power-of-two size, reset vector at size - 16
option ROMstarts at 0xC_00000x55AA signature, size code, checksum zero

A BIOS image is not an option ROM: QEMU-style BIOSes such as SeaBIOS carry no 0x55AA trailer. The classic x86 reset vector is the far jump at 0xF000:0xFFF0 (linear 0xFFFF0), which is the 16 bytes at the end of the image; validate_bios checks that jump and FirmwareLayout exposes the linear address the vCPU must start at.

ยงExample

โ“˜
let layout = firmware::install_seabios(&mut memory, firmware::FirmwareConfig::freedos())?;
let guest = layout.reset_state();

The caller maps the memory windows first: the BIOS at layout.bios_base..0x10_0000, the option ROM at layout.option_rom_base..+option_rom_len, and the low RAM the firmware sizes from CMOS. Nothing in this module touches the world: it only writes through RomMemory.

Re-exportsยง

use alloc::vec; ๐Ÿ”’
use alloc::vec; ๐Ÿ”’
use alloc::vec::Vec; ๐Ÿ”’
use super::biosrom::RomMemory; ๐Ÿ”’
use super::biosrom::SECTOR_SIZE; ๐Ÿ”’

Structsยง

BiosInfo
Validated BIOS image description.
FirmwareConfig
Tunables a firmware image needs from the machine description.
FirmwareLayout
Result of installing a firmware image in a world.
OptionRomInfo
Validated option-ROM description.

Enumsยง

FirmwareError
Why a firmware image was rejected.

Constantsยง

BIOS_TOP
Top of the 1 MiB legacy address space; the BIOS image ends here.
BOOT_ORDER_FLOPPY_FIRST
Boot-order value selecting the floppy first (1 in the first nibble).
CMOS_BOOTFLAG1
CMOS register holding the high nibble of the QEMU/SeaBIOS boot order.
CMOS_BOOTFLAG2
CMOS register holding the low byte of the QEMU/SeaBIOS boot order.
CMOS_EXTMEM_HIGH
CMOS register holding the high byte of the extended-memory size.
CMOS_EXTMEM_LOW
CMOS register holding the low byte of the extended-memory size.
CMOS_FLOPPY_TYPE
CMOS register holding the floppy drive types (high nibble = drive A).
FLOPPY_TYPE_1_44M
CMOS value advertising one 1.44 MiB drive as drive A (4 << 4).
MAX_BIOS_LEN
Largest accepted BIOS image (256 KiB).
MIN_BIOS_LEN
Smallest accepted BIOS image (32 KiB).
OPTION_ROM_BASE
Conventional base of the option-ROM scan window.
OPTION_ROM_END
End of the option-ROM scan window (the BIOS window starts here).
OPTION_ROM_ENTRY_OFFSET
Offset of the option-ROM initialisation entry point.
OPTION_ROM_SIGNATURE
Option-ROM signature.
OPTION_ROM_SIZE_OFFSET
Offset of the option-ROM size code, in 512-byte units.
RESET_IP
Instruction pointer of the reset vector inside RESET_SEGMENT.
RESET_LINEAR
Linear address of the reset vector (0xF000:0xFFF0).
RESET_SEGMENT
Real-mode segment of the reset vector.
RESET_VECTOR_LEN
Number of bytes at the end of a BIOS image holding the reset vector.

Functionsยง

checksum
Modulo-256 sum of bytes.
flat_image_with_bios
Builds a flat zero image with the given BIOS placed at its final address.
install
Installs a validated BIOS image and an optional VGA option ROM.
install_seabios
Installs the bundled SeaBIOS images with the FreeDOS configuration.
reset_vector
Reads the validated reset vector bytes as (offset, segment).
seabios_image
SeaBIOS 1.17.0 flat BIOS image (bios.bin, 256 KiB).
seabios_vga_rom
SeaVGABIOS standard-VGA option ROM shipped with SeaBIOS 1.17.0.
validate_bios
Validates a flat BIOS image and computes its placement.
validate_option_rom
Validates an option ROM and computes its placement.