summaryrefslogtreecommitdiffstats
path: root/scripts/boot.sh
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xscripts/boot.sh100
1 files changed, 100 insertions, 0 deletions
diff --git a/scripts/boot.sh b/scripts/boot.sh
new file mode 100755
index 0000000..1e3f739
--- /dev/null
+++ b/scripts/boot.sh
@@ -0,0 +1,100 @@
1#!/usr/bin/env bash
2#
3# scripts/boot.sh — quick direct boot in QEMU (dev loop)
4#
5# Fastest iteration: boots the kernel directly as BOOTX64.EFI via QEMU's
6# FAT driver, skipping the bootloader entirely.
7#
8# Usage:
9# ./scripts/boot.sh [--gui] [--debug] [--release] [--mem 512M] [--smp 2]
10#
11# Boot chain: firmware → rsnix (direct)
12# Full chain: use ./scripts/boot-image.sh (firmware → rsboot → rsnix)
13#
14# Keybindings:
15# Ctrl-A X — quit
16# Ctrl-A C — QEMU monitor
17#
18# Environment:
19# OVMF path to OVMF firmware (default: /usr/share/edk2/x64/OVMF.4m.fd)
20# MEM memory size (default: 256M)
21# SMP CPU count (default: 1)
22#
23set -euo pipefail
24
25SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
26PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
27
28cd "$PROJECT_DIR"
29
30ESP_DIR="$PROJECT_DIR/esp"
31
32# ---- config ----
33OVMF="${OVMF:-/usr/share/edk2/x64/OVMF.4m.fd}"
34MEM="${MEM:-256M}"
35SMP="${SMP:-1}"
36PROFILE="debug"
37CARGO_FLAGS=""
38GUI=""
39DEBUG=""
40
41# ---- args ----
42while [ $# -gt 0 ]; do
43 case "$1" in
44 --gui | -g) GUI="-vga std" ;;
45 --debug | -d) DEBUG="-s -S" ;;
46 --release | -r)
47 PROFILE="release"
48 CARGO_FLAGS="--release"
49 ;;
50 --mem)
51 shift
52 MEM="$1"
53 ;;
54 --smp)
55 shift
56 SMP="$1"
57 ;;
58 --help | -h)
59 head -20 "$0" | grep "^#" | sed 's/^# //'
60 exit 0
61 ;;
62 *)
63 echo "unknown: $1"
64 exit 1
65 ;;
66 esac
67 shift
68done
69
70OUT_DIR="target/x86_64-unknown-uefi/$PROFILE"
71KERNEL="$OUT_DIR/rsdos.efi"
72
73# ---- build ----
74echo "=== Building kernel ($PROFILE) ==="
75cargo build --package rsdos --target x86_64-unknown-uefi $CARGO_FLAGS
76
77# ---- deploy ----
78mkdir -p "$ESP_DIR/EFI/BOOT"
79cp "$KERNEL" "$ESP_DIR/EFI/BOOT/BOOTX64.EFI"
80echo " kernel: $(ls -lh "$KERNEL" | awk '{print $5}')"
81
82# ---- boot ----
83echo ""
84echo "=== Booting (direct: firmware → rsnix) ==="
85echo " ovmf: $OVMF"
86echo " mem: $MEM smp: $SMP"
87echo " gui: $([ -n "$GUI" ] && echo yes || echo no)"
88echo " gdb: $([ -n "$DEBUG" ] && echo ':1234' || echo off)"
89echo ""
90
91exec qemu-system-x86_64 \
92 -bios "$OVMF" \
93 -drive file=fat:rw:"$ESP_DIR",format=raw \
94 -serial stdio \
95 -m "$MEM" \
96 -machine q35 \
97 -cpu qemu64 \
98 -no-reboot \
99 -smp "$SMP" \
100 $GUI $DEBUG