From f45dbb078633494f36292e00a4b204a88134c0ca Mon Sep 17 00:00:00 2001 From: salmonik Date: Sat, 1 Aug 2026 15:01:16 +0200 Subject: CONTEXT.md: runtime device detection milestone + QEMU hotplug testability notes --- CONTEXT.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/CONTEXT.md b/CONTEXT.md index fd83245..aa2392e 100644 --- a/CONTEXT.md +++ b/CONTEXT.md @@ -294,6 +294,42 @@ Workspace of four crates, all built for the `x86_64-unknown-uefi` target: temporary 140-line boot loop (128 kept / 40 dropped, seq 40..167, oldest live line correct — loop reverted after the test). +✅ **Runtime device detection (hotplug rescan)** — the boot discovery + pipeline is now re-runnable and diffed against live hardware: + +- `ahci`: stores ABAR/port bitmap; `poll_dirty()` is a cheap per-port + `PxSSTS.DET == 3` probe (safe on every prompt), `rescan()` starts + newly-present ports (full `start_port` bring-up) and tombstones + slots of removed ones. **Slots never shift** — indices stay stable + so VFS disk handles and `ACTIVE` selection keep working; `select()` + rejects tombstones. +- `fat`: `Volume` gains a `mounted` flag; `rescan()` unmounts volumes + whose disk left and mounts every disk without a mounted volume + (which also re-tries mounts that failed at boot, e.g. a non-FAT + disk replaced by a FAT one). UID dedup ignores tombstones, so a + re-plugged disk keeps its `/disk/` name. +- `fs`: the init mount loop is factored into `rescan_disks()`, which + lazily creates `/disk`, ensures a mount node per mounted volume and + tombstones nodes of unmounted ones — `cat /disk//…` fails + cleanly with "no such file". +- shell: `rescan` command plus an automatic deep rescan before each + prompt whenever `poll_dirty()` sees a change; a one-line summary + reports added/removed counts. All rescan events flow through + `serial_println!` so they land in klog (`ahci: port N up`, `fat: + mounted …`) — the boot log doubles as a device log. + + **QEMU testability reality (verified)**: PCIe ADD works end-to-end + (`-device pcie-root-port,id=rp1` at boot, monitor `device_add + e1000e,bus=rp1` → the kernel's `pci` re-scan sees it; q35 root bus + itself rejects hotplug, root ports are required). Disk hotplug is + **not** QEMU-modelable: the ich9-ahci's IDE buses refuse + `device_add ide-hd` ("Bus 'ide.N' does not support hotplugging") and + `drive_add if=ide` ("Can't hot-add drive to type 1"); PCIe + `device_del` is a guest-cooperative protocol (the device stays in + config space until the guest powers off the slot), so removal is + also untestable in QEMU. The disk arrival/removal path (PxSSTS + based) is verified on real hardware instead. + ## Known issues / perf notes - **Scroll cost** — scrolling still shifts the whole framebuffer (a -- cgit v1.2.3