blob: 913e5cbdba6212d38025ee7cbc9a7191d80d2a8a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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
|