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
| Kind | Layout | Validation |
|---|---|---|
| BIOS | flat image ending at 0x10_0000 | power-of-two size, reset vector at size - 16 |
| option ROM | starts at 0xC_0000 | 0x55AA 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ยง
- Bios
Info - Validated BIOS image description.
- Firmware
Config - Tunables a firmware image needs from the machine description.
- Firmware
Layout - Result of installing a firmware image in a world.
- Option
RomInfo - Validated option-ROM description.
Enumsยง
- Firmware
Error - 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 (
1in the first nibble). - CMOS_
BOOTFLA G1 - CMOS register holding the high nibble of the QEMU/SeaBIOS boot order.
- CMOS_
BOOTFLA G2 - 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.