summaryrefslogtreecommitdiffstats
path: root/scripts/boot.sh
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-08-27 18:35:59 +0200
committersalmonik <salmonik@tuta.io>2026-08-27 18:35:59 +0200
commitacd0fe1bc38746f36fff24a7497041e5c5010977 (patch)
tree5db6335b732409c7f180f8514196c52a7b88f434 /scripts/boot.sh
parentGUI: fire-and-forget spawn for /bin/gui binaries (diff)
downloadrs-dos-acd0fe1bc38746f36fff24a7497041e5c5010977.tar.gz
rs-dos-acd0fe1bc38746f36fff24a7497041e5c5010977.zip
scripts: migrate all QEMU/test scripts to single system image
boot.sh: replace esp/ + DISK_IMG with single SYSTEM_IMG on ide.0 (hooks into mksystem.sh --force for auto-staging). boot-image.sh: delegate to mksystem.sh --chain (build-image.sh deleted). build-image-release.sh: delegate to mksystem.sh --chain --gpt. qemu.sh: flexible launcher uses SYSTEM_IMG; --chain flag for full-chain build. test-disk.sh: drop ESP_DIR (mksystem.sh stages everything). test-fault.sh: boot system.img on ide.0 + CRASHLOG stick on ide.1; replace deleted mkdisk.sh with inline mkfs.fat. test-gfx.sh: system.img on ide.0, stage via mksystem.sh. test-mouse.sh: system.img on ide.0, stage via mksystem.sh. test-msg.sh: system.img on ide.0, stage via mksystem.sh. Makefile: remove stale build-image.sh/mkdisk.sh references from help; image target delegates to mksystem.sh --chain. All scripts syntax-checked (bash -n). build-image.sh and mkdisk.sh no longer referenced anywhere.
Diffstat (limited to 'scripts/boot.sh')
-rwxr-xr-xscripts/boot.sh47
1 files changed, 11 insertions, 36 deletions
diff --git a/scripts/boot.sh b/scripts/boot.sh
index 5b8e6fa..9c60dc9 100755
--- a/scripts/boot.sh
+++ b/scripts/boot.sh
@@ -2,8 +2,8 @@
2# 2#
3# scripts/boot.sh — quick direct boot in QEMU (dev loop) 3# scripts/boot.sh — quick direct boot in QEMU (dev loop)
4# 4#
5# Fastest iteration: boots the kernel directly as BOOTX64.EFI via QEMU's 5# Builds the kernel, stages the system image, and boots directly as
6# FAT driver, skipping the bootloader entirely. 6# BOOTX64.EFI via QEMU's FAT driver. One image = one drive.
7# 7#
8# Usage: 8# Usage:
9# ./scripts/boot.sh [--gui] [--debug] [--release] [--mem 512M] [--smp 2] 9# ./scripts/boot.sh [--gui] [--debug] [--release] [--mem 512M] [--smp 2]
@@ -19,26 +19,19 @@
19# OVMF path to OVMF firmware (default: /usr/share/edk2/x64/OVMF.4m.fd) 19# OVMF path to OVMF firmware (default: /usr/share/edk2/x64/OVMF.4m.fd)
20# MEM memory size (default: 256M) 20# MEM memory size (default: 256M)
21# SMP CPU count (default: 1) 21# SMP CPU count (default: 1)
22# DISK_IMG raw disk image attached as the SATA data disk (default: /tmp/disk.img) 22# SYSTEM_IMG system image path (default: /tmp/system.img)
23#
24# The data disk is pinned to AHCI port 0 (ide.0) and the ESP to port 1
25# (ide.1); the implicit `-drive file=fat:rw:esp` would otherwise grab
26# port 0 and the kernel would find the ESP where it expects a FAT32 disk.
27# 23#
28set -euo pipefail 24set -euo pipefail
29 25
30SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" 26SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
31PROJECT_DIR="$(dirname "$SCRIPT_DIR")" 27PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
32
33cd "$PROJECT_DIR" 28cd "$PROJECT_DIR"
34 29
35ESP_DIR="$PROJECT_DIR/esp"
36
37# ---- config ---- 30# ---- config ----
38OVMF="${OVMF:-/usr/share/edk2/x64/OVMF.4m.fd}" 31OVMF="${OVMF:-/usr/share/edk2/x64/OVMF.4m.fd}"
39MEM="${MEM:-256M}" 32MEM="${MEM:-256M}"
40SMP="${SMP:-1}" 33SMP="${SMP:-1}"
41DISK_IMG="${DISK_IMG:-/tmp/disk.img}" 34SYSTEM_IMG="${SYSTEM_IMG:-/tmp/system.img}"
42PROFILE="debug" 35PROFILE="debug"
43CARGO_FLAGS="" 36CARGO_FLAGS=""
44GUI="" 37GUI=""
@@ -46,7 +39,6 @@ DEBUG=""
46 39
47# ---- args ---- 40# ---- args ----
48source "$SCRIPT_DIR/lib-boot-args.sh" 41source "$SCRIPT_DIR/lib-boot-args.sh"
49# boot.sh-specific flags live here; everything else is shared.
50handle_arg() { 42handle_arg() {
51 case "$1" in 43 case "$1" in
52 --release | -r) 44 --release | -r)
@@ -62,46 +54,29 @@ handle_arg() {
62parse_boot_args "$@" 54parse_boot_args "$@"
63 55
64OUT_DIR="target/x86_64-unknown-uefi/$PROFILE" 56OUT_DIR="target/x86_64-unknown-uefi/$PROFILE"
65KERNEL="$OUT_DIR/rsdos.efi"
66 57
67# ---- build ---- 58# ---- build ----
68echo "=== Building kernel ($PROFILE) ===" 59echo "=== Building kernel ($PROFILE) ==="
69cargo build --package rsdos --target x86_64-unknown-uefi $CARGO_FLAGS 60cargo build --package rsdos --target x86_64-unknown-uefi $CARGO_FLAGS
70 61
71# ---- deploy ---- 62# ---- stage system image ----
72mkdir -p "$ESP_DIR/EFI/BOOT" 63echo "=== Staging system image ==="
73cp "$KERNEL" "$ESP_DIR/EFI/BOOT/BOOTX64.EFI" 64"$SCRIPT_DIR/mksystem.sh" --force "$SYSTEM_IMG"
74echo " kernel: $(ls -lh "$KERNEL" | awk '{print $5}')" 65echo " system image: $SYSTEM_IMG"
75 66
76# ---- boot ---- 67# ---- boot ----
77echo "" 68echo ""
78echo "=== Booting (direct: firmware → rsnix) ===" 69echo "=== Booting (direct: firmware → rsnix) ==="
79echo " ovmf: $OVMF" 70echo " ovmf: $OVMF"
80echo " mem: $MEM smp: $SMP" 71echo " mem: $MEM smp: $SMP"
81echo " disk: $([ -f "$DISK_IMG" ] && echo "$DISK_IMG" || echo "none ($DISK_IMG missing)")"
82echo " gui: $([ -n "$GUI" ] && echo yes || echo no)" 72echo " gui: $([ -n "$GUI" ] && echo yes || echo no)"
83echo " gdb: $([ -n "$DEBUG" ] && echo ':1234' || echo off)" 73echo " gdb: $([ -n "$DEBUG" ] && echo ':1234' || echo off)"
84echo "" 74echo ""
85 75
86if [ ! -f "$DISK_IMG" ]; then
87 echo " (creating missing disk image: $DISK_IMG)"
88 "$SCRIPT_DIR/mkdisk.sh" "$DISK_IMG"
89fi
90
91if [ -f "$DISK_IMG" ]; then
92 DISK_ARGS=(
93 -drive "file=$DISK_IMG,format=raw,if=none,id=disk"
94 -device ide-hd,drive=disk,bus=ide.0
95 )
96else
97 DISK_ARGS=()
98fi
99
100exec qemu-system-x86_64 \ 76exec qemu-system-x86_64 \
101 -bios "$OVMF" \ 77 -bios "$OVMF" \
102 "${DISK_ARGS[@]}" \ 78 -drive "file=$SYSTEM_IMG,format=raw,if=none,id=disk" \
103 -drive file=fat:rw:"$ESP_DIR",format=raw,if=none,id=esp \ 79 -device ide-hd,drive=disk,bus=ide.0 \
104 -device ide-hd,drive=esp,bus=ide.1 \
105 -serial stdio \ 80 -serial stdio \
106 -m "$MEM" \ 81 -m "$MEM" \
107 -machine q35 \ 82 -machine q35 \