diff options
Diffstat (limited to '')
| -rwxr-xr-x | scripts/boot.sh | 100 |
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 | # | ||
| 23 | set -euo pipefail | ||
| 24 | |||
| 25 | SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" | ||
| 26 | PROJECT_DIR="$(dirname "$SCRIPT_DIR")" | ||
| 27 | |||
| 28 | cd "$PROJECT_DIR" | ||
| 29 | |||
| 30 | ESP_DIR="$PROJECT_DIR/esp" | ||
| 31 | |||
| 32 | # ---- config ---- | ||
| 33 | OVMF="${OVMF:-/usr/share/edk2/x64/OVMF.4m.fd}" | ||
| 34 | MEM="${MEM:-256M}" | ||
| 35 | SMP="${SMP:-1}" | ||
| 36 | PROFILE="debug" | ||
| 37 | CARGO_FLAGS="" | ||
| 38 | GUI="" | ||
| 39 | DEBUG="" | ||
| 40 | |||
| 41 | # ---- args ---- | ||
| 42 | while [ $# -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 | ||
| 68 | done | ||
| 69 | |||
| 70 | OUT_DIR="target/x86_64-unknown-uefi/$PROFILE" | ||
| 71 | KERNEL="$OUT_DIR/rsdos.efi" | ||
| 72 | |||
| 73 | # ---- build ---- | ||
| 74 | echo "=== Building kernel ($PROFILE) ===" | ||
| 75 | cargo build --package rsdos --target x86_64-unknown-uefi $CARGO_FLAGS | ||
| 76 | |||
| 77 | # ---- deploy ---- | ||
| 78 | mkdir -p "$ESP_DIR/EFI/BOOT" | ||
| 79 | cp "$KERNEL" "$ESP_DIR/EFI/BOOT/BOOTX64.EFI" | ||
| 80 | echo " kernel: $(ls -lh "$KERNEL" | awk '{print $5}')" | ||
| 81 | |||
| 82 | # ---- boot ---- | ||
| 83 | echo "" | ||
| 84 | echo "=== Booting (direct: firmware → rsnix) ===" | ||
| 85 | echo " ovmf: $OVMF" | ||
| 86 | echo " mem: $MEM smp: $SMP" | ||
| 87 | echo " gui: $([ -n "$GUI" ] && echo yes || echo no)" | ||
| 88 | echo " gdb: $([ -n "$DEBUG" ] && echo ':1234' || echo off)" | ||
| 89 | echo "" | ||
| 90 | |||
| 91 | exec 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 | ||
