#!/usr/bin/env bash # # scripts/boot-image.sh — boot rs-dos full chain disk image in QEMU # # Builds the image first if needed, then boots with UEFI firmware through # the real boot chain: firmware → rsboot → rsnix kernel. # # Usage: # ./scripts/boot-image.sh [--gui] [--debug] [--mem 512M] [--smp 2] # # Keybindings: # Ctrl-A X — quit # Ctrl-A C — QEMU monitor # # Environment: # OVMF path to OVMF firmware (default: /usr/share/edk2/x64/OVMF.4m.fd) # MEM memory size (default: 256M) # SMP CPU count (default: 1) # set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" PROJECT_DIR="$(dirname "$SCRIPT_DIR")" cd "$PROJECT_DIR" IMAGE="rs-dos.img" # ---- config ---- OVMF="${OVMF:-/usr/share/edk2/x64/OVMF.4m.fd}" MEM="${MEM:-256M}" SMP="${SMP:-1}" GUI="" DEBUG="" # ---- args ---- source "$SCRIPT_DIR/lib-boot-args.sh" parse_boot_args "$@" # ---- build image if missing ---- if [ ! -f "$IMAGE" ]; then echo "Image not found, building..." "$SCRIPT_DIR/build-image.sh" fi # ---- boot ---- echo "" echo "=== Booting (full chain: firmware → rsboot → rsnix) ===" echo " image: $IMAGE" echo " ovmf: $OVMF" echo " mem: $MEM smp: $SMP" echo " gui: $([ -n "$GUI" ] && echo yes || echo no)" echo " gdb: $([ -n "$DEBUG" ] && echo ':1234' || echo off)" echo "" exec qemu-system-x86_64 \ -bios "$OVMF" \ -drive file="$IMAGE",format=raw,if=none,id=hd \ -device ide-hd,drive=hd \ -serial stdio \ -m "$MEM" \ -machine q35 \ -cpu qemu64 \ -no-reboot \ -smp "$SMP" \ $GUI $DEBUG