summaryrefslogtreecommitdiffstats
path: root/scripts/boot-image.sh
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xscripts/boot-image.sh87
1 files changed, 87 insertions, 0 deletions
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 @@
1#!/usr/bin/env bash
2#
3# scripts/boot-image.sh — boot rs-dos full chain disk image in QEMU
4#
5# Builds the image first if needed, then boots with UEFI firmware through
6# the real boot chain: firmware → rsboot → rsnix kernel.
7#
8# Usage:
9# ./scripts/boot-image.sh [--gui] [--debug] [--mem 512M] [--smp 2]
10#
11# Keybindings:
12# Ctrl-A X — quit
13# Ctrl-A C — QEMU monitor
14#
15# Environment:
16# OVMF path to OVMF firmware (default: /usr/share/edk2/x64/OVMF.4m.fd)
17# MEM memory size (default: 256M)
18# SMP CPU count (default: 1)
19#
20set -euo pipefail
21
22SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
23PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
24
25cd "$PROJECT_DIR"
26
27IMAGE="rs-dos.img"
28
29# ---- config ----
30OVMF="${OVMF:-/usr/share/edk2/x64/OVMF.4m.fd}"
31MEM="${MEM:-256M}"
32SMP="${SMP:-1}"
33GUI=""
34DEBUG=""
35
36# ---- args ----
37while [ $# -gt 0 ]; do
38 case "$1" in
39 --gui | -g) GUI="-vga std" ;;
40 --debug | -d) DEBUG="-s -S" ;;
41 --mem)
42 shift
43 MEM="$1"
44 ;;
45 --smp)
46 shift
47 SMP="$1"
48 ;;
49 --help | -h)
50 head -20 "$0" | grep "^#" | sed 's/^# //'
51 exit 0
52 ;;
53 *)
54 echo "unknown: $1"
55 exit 1
56 ;;
57 esac
58 shift
59done
60
61# ---- build image if missing ----
62if [ ! -f "$IMAGE" ]; then
63 echo "Image not found, building..."
64 "$SCRIPT_DIR/build-image.sh"
65fi
66
67# ---- boot ----
68echo ""
69echo "=== Booting (full chain: firmware → rsboot → rsnix) ==="
70echo " image: $IMAGE"
71echo " ovmf: $OVMF"
72echo " mem: $MEM smp: $SMP"
73echo " gui: $([ -n "$GUI" ] && echo yes || echo no)"
74echo " gdb: $([ -n "$DEBUG" ] && echo ':1234' || echo off)"
75echo ""
76
77exec qemu-system-x86_64 \
78 -bios "$OVMF" \
79 -drive file="$IMAGE",format=raw,if=none,id=hd \
80 -device ide-hd,drive=hd \
81 -serial stdio \
82 -m "$MEM" \
83 -machine q35 \
84 -cpu qemu64 \
85 -no-reboot \
86 -smp "$SMP" \
87 $GUI $DEBUG