diff options
| author | salmonik <salmonik@tuta.io> | 2026-07-31 03:22:20 +0200 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-07-31 03:22:20 +0200 |
| commit | 0ace22d6f88692883584119c64ff010f4cee6738 (patch) | |
| tree | 6f575f9088dec8bab90943d6c23e174bca183f0a /scripts/boot-image.sh | |
| parent | restructure: rsnix kernel + shell crate + rsdos entry point (diff) | |
| download | rs-dos-0ace22d6f88692883584119c64ff010f4cee6738.tar.gz rs-dos-0ace22d6f88692883584119c64ff010f4cee6738.zip | |
fix(rsdos): organizational changes
Diffstat (limited to '')
| -rwxr-xr-x | scripts/boot-image.sh | 87 |
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 | # | ||
| 20 | set -euo pipefail | ||
| 21 | |||
| 22 | SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" | ||
| 23 | PROJECT_DIR="$(dirname "$SCRIPT_DIR")" | ||
| 24 | |||
| 25 | cd "$PROJECT_DIR" | ||
| 26 | |||
| 27 | IMAGE="rs-dos.img" | ||
| 28 | |||
| 29 | # ---- config ---- | ||
| 30 | OVMF="${OVMF:-/usr/share/edk2/x64/OVMF.4m.fd}" | ||
| 31 | MEM="${MEM:-256M}" | ||
| 32 | SMP="${SMP:-1}" | ||
| 33 | GUI="" | ||
| 34 | DEBUG="" | ||
| 35 | |||
| 36 | # ---- args ---- | ||
| 37 | while [ $# -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 | ||
| 59 | done | ||
| 60 | |||
| 61 | # ---- build image if missing ---- | ||
| 62 | if [ ! -f "$IMAGE" ]; then | ||
| 63 | echo "Image not found, building..." | ||
| 64 | "$SCRIPT_DIR/build-image.sh" | ||
| 65 | fi | ||
| 66 | |||
| 67 | # ---- boot ---- | ||
| 68 | echo "" | ||
| 69 | echo "=== Booting (full chain: firmware → rsboot → rsnix) ===" | ||
| 70 | echo " image: $IMAGE" | ||
| 71 | echo " ovmf: $OVMF" | ||
| 72 | echo " mem: $MEM smp: $SMP" | ||
| 73 | echo " gui: $([ -n "$GUI" ] && echo yes || echo no)" | ||
| 74 | echo " gdb: $([ -n "$DEBUG" ] && echo ':1234' || echo off)" | ||
| 75 | echo "" | ||
| 76 | |||
| 77 | exec 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 | ||
