From 0ace22d6f88692883584119c64ff010f4cee6738 Mon Sep 17 00:00:00 2001 From: salmonik Date: Fri, 31 Jul 2026 03:22:20 +0200 Subject: fix(rsdos): organizational changes --- scripts/boot-image.sh | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100755 scripts/boot-image.sh (limited to 'scripts/boot-image.sh') diff --git a/scripts/boot-image.sh b/scripts/boot-image.sh new file mode 100755 index 0000000..913e5cb --- /dev/null +++ b/scripts/boot-image.sh @@ -0,0 +1,87 @@ +#!/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 ---- +while [ $# -gt 0 ]; do + case "$1" in + --gui | -g) GUI="-vga std" ;; + --debug | -d) DEBUG="-s -S" ;; + --mem) + shift + MEM="$1" + ;; + --smp) + shift + SMP="$1" + ;; + --help | -h) + head -20 "$0" | grep "^#" | sed 's/^# //' + exit 0 + ;; + *) + echo "unknown: $1" + exit 1 + ;; + esac + shift +done + +# ---- 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 -- cgit v1.2.3