From acd0fe1bc38746f36fff24a7497041e5c5010977 Mon Sep 17 00:00:00 2001 From: salmonik Date: Thu, 27 Aug 2026 18:35:59 +0200 Subject: scripts: migrate all QEMU/test scripts to single system image boot.sh: replace esp/ + DISK_IMG with single SYSTEM_IMG on ide.0 (hooks into mksystem.sh --force for auto-staging). boot-image.sh: delegate to mksystem.sh --chain (build-image.sh deleted). build-image-release.sh: delegate to mksystem.sh --chain --gpt. qemu.sh: flexible launcher uses SYSTEM_IMG; --chain flag for full-chain build. test-disk.sh: drop ESP_DIR (mksystem.sh stages everything). test-fault.sh: boot system.img on ide.0 + CRASHLOG stick on ide.1; replace deleted mkdisk.sh with inline mkfs.fat. test-gfx.sh: system.img on ide.0, stage via mksystem.sh. test-mouse.sh: system.img on ide.0, stage via mksystem.sh. test-msg.sh: system.img on ide.0, stage via mksystem.sh. Makefile: remove stale build-image.sh/mkdisk.sh references from help; image target delegates to mksystem.sh --chain. All scripts syntax-checked (bash -n). build-image.sh and mkdisk.sh no longer referenced anywhere. --- scripts/qemu.sh | 90 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 45 insertions(+), 45 deletions(-) (limited to 'scripts/qemu.sh') diff --git a/scripts/qemu.sh b/scripts/qemu.sh index b8997ba..eeaf4de 100755 --- a/scripts/qemu.sh +++ b/scripts/qemu.sh @@ -1,28 +1,32 @@ #!/usr/bin/env bash # ============================================================================= -# tools/qemu.sh — Run raisernics in QEMU with various options +# scripts/qemu.sh — flexible QEMU launcher for rs-dos # # Usage: -# ./tools/qemu.sh # serial console (no graphics) -# ./tools/qemu.sh --gui # graphical window -# ./tools/qemu.sh --debug # GDB stub on :1234 -# ./tools/qemu.sh --image foo.img # boot from raw disk image -# ./tools/qemu.sh --bios /path/to.fd # custom OVMF -# ./tools/qemu.sh --mem 512M # memory size -# ./tools/qemu.sh --smp 2 # SMP cores +# ./scripts/qemu.sh # serial console (no graphics) +# ./scripts/qemu.sh --gui # graphical window +# ./scripts/qemu.sh --debug # GDB stub on :1234 +# ./scripts/qemu.sh --chain # full boot chain (firmware → rsboot → rsnix) +# ./scripts/qemu.sh --bios /path/to.fd # custom OVMF +# ./scripts/qemu.sh --mem 512M # memory size +# ./scripts/qemu.sh --smp 2 # SMP cores +# +# One image, one drive — the system image contains kernel + ESP + data. # ============================================================================= set -euo pipefail -SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)" -cd "$SCRIPT_DIR" +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" +cd "$PROJECT_DIR" # Defaults GUI_FLAG="" DEBUG_FLAG="" -DRIVE_ARGS=(-drive file=fat:rw:esp,format=raw) +CHAIN_FLAG="" OVMF="${OVMF:-/usr/share/edk2/x64/OVMF.4m.fd}" MEM="${MEM:-256M}" SMP="${SMP:-1}" +SYSTEM_IMG="${SYSTEM_IMG:-/tmp/system.img}" # Pre-build make all @@ -38,12 +42,13 @@ while [ $# -gt 0 ]; do DEBUG_FLAG="-s -S" shift ;; + --chain | -c) + CHAIN_FLAG=1 + SYSTEM_IMG="${SYSTEM_IMG:-rs-dos.img}" + shift + ;; --image | -i) - _img_file="$(printf -- '-drive file=%s,format=raw,if=none,id=hd' "$2")" - # Explicit buses: data disk -> ide.0 (port 0), ESP -> ide.1. - DRIVE_ARGS=("$_img_file" '-device' 'ide-hd,drive=hd,bus=ide.0' - '-drive' 'file=fat:rw:esp,format=raw,if=none,id=esp' - '-device' 'ide-hd,drive=esp,bus=ide.1') + SYSTEM_IMG="$2" shift 2 ;; --bios | -b) @@ -58,42 +63,37 @@ while [ $# -gt 0 ]; do SMP="$2" shift 2 ;; - --help | -h) - head -20 "$0" | grep "^# " | sed 's/^# //' - exit 0 - ;; *) - echo "Unknown option: $1" + echo "unknown: $1" exit 1 ;; esac done -QEMU_CMD=( - qemu-system-x86_64 - -bios "$OVMF" - "${DRIVE_ARGS[@]}" - -serial stdio - -m "$MEM" - -machine q35 - -cpu qemu64 - -no-reboot - -smp "$SMP" -) - -[ -n "$GUI_FLAG" ] && QEMU_CMD+=("$GUI_FLAG") -if [ -n "$DEBUG_FLAG" ]; then - # Split the flag string safely into words - read -ra dbg <<<"$DEBUG_FLAG" - QEMU_CMD+=("${dbg[@]}") +# Stage system image if needed +if [ -n "$CHAIN_FLAG" ]; then + ./scripts/mksystem.sh --chain --gpt "$SYSTEM_IMG" +else + ./scripts/mksystem.sh "$SYSTEM_IMG" fi -echo " OVMF : $OVMF" -echo " Drive : ${DRIVE_ARGS[*]}" -echo " Mem : $MEM" -echo " SMP : $SMP" -echo " GDB : $([ -n "$DEBUG_FLAG" ] && echo ':1234' || echo 'off')" -echo " GUI : $([ -n "$GUI_FLAG" ] && echo 'yes' || echo 'no')" +echo "" +echo "=== Booting ===" +echo " image: $SYSTEM_IMG" +echo " ovmf: $OVMF" +echo " mem: $MEM smp: $SMP" +echo " gui: $([ -n "$GUI_FLAG" ] && echo yes || echo no)" +echo " gdb: $([ -n "$DEBUG_FLAG" ] && echo ':1234' || echo off)" echo "" -exec "${QEMU_CMD[@]}" +exec qemu-system-x86_64 \ + -bios "$OVMF" \ + -drive "file=$SYSTEM_IMG,format=raw,if=none,id=hd" \ + -device ide-hd,drive=hd \ + -serial stdio \ + -m "$MEM" \ + -machine q35 \ + -cpu qemu64 \ + -no-reboot \ + -smp "$SMP" \ + $GUI_FLAG $DEBUG_FLAG -- cgit v1.2.3