boot: the BIOS loader is gone

1449 lines of boot/bios/, tools/sign.pl and tools/padstage2.pl, plus the
build rules, the disk image and the ISO entry that existed to carry them.

Everything since roughly 2012 boots UEFI, and CSM -- the firmware-side
BIOS emulation that lets a legacy loader run on such a machine at all --
has been going away since Intel dropped support for it in 2020. So this
is not a path being retired early; it is one whose remaining hardware is
already the exception.

The cost was never the code, it was the tax on everything near it. Stage
2 had a 65-sector ceiling it overflowed silently -- 25440 bytes against
24576 -- and because the kernel is written at sector 1 + STAGE2_SECTORS,
an overflowing loader was overwritten by the very kernel it was loading.
The resolution list could not be shared with UEFI either: VBE mode
setting is INT 10h, so matching it needed unreal mode, which is the
riskiest code in the tree for a feature that already worked elsewhere.

What replaces schos.img is the staged ESP, handed to QEMU as a virtual
FAT volume. That is a development arrangement and not an installable
disk; a real GPT image with a real FAT partition is the installer's job,
and until it exists nothing here writes a disk a machine boots unaided.
Secure Boot is untouched too -- the loader is unsigned.

The ISO keeps one El Torito entry, the FAT image holding loader and
kernel. It never booted from a USB stick via BIOS anyway: the firmware
presents the stick as a hard disk while stage2main.c read the kernel back
over ATAPI.

The 32-bit multiboot entry in entry.S now has no caller and is left in
place. Deleting kernel entry code is its own change with its own way of
failing silently, and it should not ride along with this one.

Ported with it: run.ps1, the six screenshot tools, and schcom_test.sh,
each with its own OVMF varstore copy so no run inherits another's UEFI
variables.

Two things this shook out. OVMF now belongs in `all`: nothing boots
without firmware, `make clean` wipes build/ including the copy fetched
from the host, and a clean followed by a build left every run script
throwing. And it cannot be listed as a prerequisite at the top of the
file -- make expands prerequisites when it reads the line, and
$(OVMF_CODE) is defined further down, so naming it there appends nothing
and says nothing.

Verified from a clean tree: 110 [ok] and no failures on the full suite,
the ISO boots with no hard disk attached, schfs-check passes, schcom's
end-to-end pixel test passes, and fbshot captures a real 1280x800 frame.
This commit is contained in:
Nexoniarz 2026-08-11 10:20:28 +02:00
commit 651899220c
23 changed files with 317 additions and 1826 deletions

21
run.ps1
View file

@ -45,7 +45,7 @@ if (-not (Test-Path $Qemu)) { throw "QEMU not found: $Qemu (install it, or pass
# The two images QEMU needs. Keep in sync with the 'qemu' target in the
# Makefile.
#
# hda the boot disk: bootblock, stage 2 and the kernel
# esp the staged EFI system partition: the loader and the kernel
# hdb the root filesystem, mounted as / by forkret()
#
# hdb was build/fs.img until SchFS became the root. Nothing builds fs.img on
@ -53,8 +53,10 @@ if (-not (Test-Path $Qemu)) { throw "QEMU not found: $Qemu (install it, or pass
# longer exists -- QEMU came up with no usable disk on device 1 and the kernel
# panicked with SCHFS_ROOT. That is the failure this script is supposed to
# prevent, so it is worth naming.
$hda = Join-Path $root 'schos.img'
$hdb = Join-Path $root 'build/schfs.img'
$esp = Join-Path $root 'build/esp'
$hdb = Join-Path $root 'build/schfs.img'
$code = Join-Path $root 'build/OVMF_CODE.fd'
$vars = Join-Path $root 'build/OVMF_VARS.fd'
if (-not $NoBuild) {
Write-Host '==> building (native, no WSL)' -ForegroundColor Cyan
@ -88,11 +90,16 @@ if (-not $NoBuild) {
if ($LASTEXITCODE -ne 0) { throw "build failed (exit $LASTEXITCODE)" }
}
foreach ($img in @($hda, $hdb)) {
foreach ($img in @($hdb, (Join-Path $esp 'EFI/BOOT/BOOTX64.EFI'))) {
if (-not (Test-Path $img)) {
throw "missing image: $img (run without -NoBuild, or: make)"
throw "missing: $img (run without -NoBuild, or: make)"
}
}
foreach ($f in @($code, $vars)) {
if (-not (Test-Path $f)) { throw "no $f -- run 'make qemu-uefi' once to fetch OVMF" }
}
$runVars = Join-Path $root 'build/run-OVMF_VARS.fd'
Copy-Item -Force $vars $runVars
# Guard against the exact failure this script exists to prevent: booting
# against a stale, empty or wrong-format root disk. The first uberblock sits in
@ -112,7 +119,9 @@ if ($buf[0] -ne 0x46 -or $buf[1] -ne 0x68 -or $buf[2] -ne 0x63 -or $buf[3] -ne 0
}
$qemuArgs = @(
'-drive', "file=$hda,format=raw,index=0,media=disk"
'-drive', "if=pflash,format=raw,unit=0,readonly=on,file=$code"
'-drive', "if=pflash,format=raw,unit=1,file=$runVars"
'-drive', "file=fat:rw:$esp,index=0,media=disk"
'-drive', "file=$hdb,format=raw,index=1,media=disk"
'-m', '1G'
'-smp', '2'