From 7958276c9f0d230053520ba20f2a00f5ecda18e4 Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 1 Nov 2026 15:53:29 +0100 Subject: scripts: rebuild the dev loop around build.sh/run.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `make` did not parse at all (missing separator at line 139), so every make target was dead. The folder also carried three overlapping launchers (boot.sh, qemu.sh, boot-image.sh) plus a fourth partial one in the Makefile, `cargo build --package rsdos` copy-pasted eight times, the QEMU invocation copy-pasted per script, and the test helpers (fail/wait_log/wait_qemu_exit/qemu_hmp) duplicated in five tests. New layout: - scripts/lib.sh: single config (image, OVMF, mem/smp), the one cargo invocation (build_all), the one QEMU shape (qemu_args), and the test harness (test_boot, wait_log, wait_qemu_exit, qemu_hmp, sendkeys) - scripts/build.sh: kernel + every bins/* in one pass - scripts/mksystem.sh: freshness-aware image build that now stages every bins/*.efi into /bin/cli|gui (they were never copied before) - scripts/run.sh: build + stage + boot in one command; --headless, --debug (GDB stub), --monitor (HMP socket), --fresh, --mem/--smp/ --bios/--image; on Wayland it auto-selects XWayland plus grab-on-hover so the mouse can be captured (Ctrl+Alt+G toggles) - scripts/tests/: the five automated tests on the shared harness - deleted: boot.sh, qemu.sh, boot-image.sh, lib-boot-args.sh, build-image-release.sh, build-bootloader.sh (rsboot chain dropped) The Makefile is now a thin wrapper: make run, make test, make system, make inspect, make help. Two-command flow: ./scripts/build.sh then ./scripts/run.sh (run.sh alone also works). Stale test assumptions fixed so the suite is green again: test-gfx waited for "gfx: check" while the shell prints "gfx check: PASS"; test-mouse/test-msg hardcoded msgrecv = task 3 (wm-input took slot 3 — ids are parsed from the log now); the queue-full probe targeted task 0, whose exec pump drains its own queue as completion codes (moved to the cursor task, which never recvs). Verified in QEMU: make test -> test-disk, test-gfx, test-mouse, test-msg, test-fault all PASS. --- CONTEXT.md | 51 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 11 deletions(-) (limited to 'CONTEXT.md') diff --git a/CONTEXT.md b/CONTEXT.md index 01f5c69..ec35e26 100644 --- a/CONTEXT.md +++ b/CONTEXT.md @@ -135,7 +135,10 @@ The single dd-able FAT filesystem image the build produces: bootloader, kernel, /bin, /etc and seed content on one volume. Imaging it onto a disk yields a complete installed system. Binaries live on the system image under /bin/cli and /bin/gui; the shell finds them by scanning mounted -volumes — no volume is privileged. +volumes — no volume is privileged. For user-facing paths, /bin is a +transparent VFS alias: `ls /bin/cli` resolves to the first mounted +volume whose root has \bin, so nobody needs /disk//bin/... (ADR +0006). ## Loader @@ -194,7 +197,18 @@ reaped) without taking the kernel down. Standalone project — no integration with the RNG initramfs build system. Testing via QEMU with OVMF. The kernel PE binary is placed on a FAT -image as `\bzImage` (matching rsbl's expected path). +image as `\bzImage` (matching rsbl's expected path) and also as +`\EFI\BOOT\BOOTX64.EFI` (what the firmware boots directly). + +Two commands, compile + boot: + +```sh +./scripts/build.sh # cargo build --workspace --target x86_64-unknown-uefi --release +./scripts/run.sh # stage /tmp/system.img if stale, then boot QEMU +``` + +(`./scripts/run.sh` alone does both; `--headless`, `--debug`, `--monitor`, +`--fresh` as per its `--help`. `make` / `make run` are thin aliases.) ## Versioning @@ -397,20 +411,35 @@ Workspace of four crates, all built for the `x86_64-unknown-uefi` target: The whole disk workflow is scripted (no manual mkfs/mcopy): -- `make disk` / `./scripts/mkdisk.sh` — create the FAT32 image with - `mkfs.fat -C` (the flag that actually creates the file; plain - `mkfs.fat` needs an existing file), label `RSDOS`, seed from - `seed/` via mtools; `--fresh` re-formats, `--size 128M` sizes it +- `./scripts/build.sh` — the single cargo invocation: kernel + + every `/bin` binary (`bins/*.efi`), release profile by default +- `./scripts/mksystem.sh` / `make system` — assemble the dd-able + FAT32 image (`mkfs.fat -C`, label `RSDOS`, seed from `seed/` via + mtools, stage `/bin/cli` + `/bin/gui`); rebuilt only when a + kernel/binary/seed file is newer than it, `--force` wipes runtime + data, `--gpt` wraps it for USB sticks +- `./scripts/run.sh` / `make run` — build + stage + boot QEMU + (`--headless`, `--debug` GDB stub, `--monitor` HMP socket, + `--fresh`, `--mem/--smp/--bios/--image`); the two-command flow is + `./scripts/build.sh && ./scripts/run.sh` - `make inspect` — `mdir -i` listing of the image (mtools) -- `make test-disk` / `./scripts/test-disk.sh` — full automated round - trip: build → deploy → ensure image → boot QEMU headless → drive +- `make test` — all automated round trips; each boots QEMU headless, + drives the shell via `sendkeys.py` through the monitor and asserts + on the serial log +- `./scripts/tests/test-disk.sh` / `make test-disk` — full automated + round trip: build → stage → boot QEMU headless → drive the shell via `sendkey` through the monitor (`ls /disk`, `mkdir`, `echo WRITING`, `cat`, `poweroff`) → fsck-clean check → `mtype` verifies the written file survived poweroff -- `./scripts/sendkeys.py` — types lines into the guest via the QEMU +- `./scripts/tests/sendkeys.py` — types lines into the guest via the QEMU monitor (`--sock`, US layout, named keys for punctuation; bare `-`/`.`/`/` are not valid sendkey names) + Shared config and helpers (image path, OVMF, QEMU flags, `build_all`, + `stage_image`, `test_boot`, `wait_log`, `fail`) live in + `scripts/lib.sh` — every script sources it; there is exactly one + `cargo build` and one QEMU invocation shape in the tree. + ✅ **`klog` kernel log ring** — a RAM ring of the last 128 serial log lines (128 chars each, ~16 KB), fed by `serial_println!` (one choke point — every boot/low-level message captured for free). Sequence @@ -806,7 +835,7 @@ Resolved this session: see intermediate steps of the filtering. - **`> >> < <<` are gone.** Keywords are the *only* redirection syntax; `>` is now ordinary text (`echo a > b` prints `a > b`). Collateral: - `scripts/test-disk.sh` and the `help` text must be rewritten to the + `scripts/tests/test-disk.sh` and the `help` text must be rewritten to the keyword syntax; the milestone bullets above describing `echo >`/`>>` record the old behavior (superseded by these notes). - **Quoting (C): `"..."` groups + literalizes; `\x` escapes one char.** @@ -888,7 +917,7 @@ Everything above is now implemented in `shell/src/lib.rs`: - **^D** — EOF everywhere, at the prompt it is a no-op (fresh prompt); ^C keeps line-cancel / stream-abort; `poweroff`/`exit` are the only shutdown verbs. -- **Collateral** — `help` text rewritten; `scripts/test-disk.sh` and +- **Collateral** — `help` text rewritten; `scripts/tests/test-disk.sh` and the `sendkeys.py` docstring updated to keyword syntax. Bugs found by QEMU verification and fixed: -- cgit v1.2.3