From 0ace22d6f88692883584119c64ff010f4cee6738 Mon Sep 17 00:00:00 2001 From: salmonik Date: Fri, 31 Jul 2026 03:22:20 +0200 Subject: fix(rsdos): organizational changes --- scripts/boot.sh | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100755 scripts/boot.sh (limited to 'scripts/boot.sh') 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 @@ +#!/usr/bin/env bash +# +# scripts/boot.sh — quick direct boot in QEMU (dev loop) +# +# Fastest iteration: boots the kernel directly as BOOTX64.EFI via QEMU's +# FAT driver, skipping the bootloader entirely. +# +# Usage: +# ./scripts/boot.sh [--gui] [--debug] [--release] [--mem 512M] [--smp 2] +# +# Boot chain: firmware → rsnix (direct) +# Full chain: use ./scripts/boot-image.sh (firmware → rsboot → rsnix) +# +# 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" + +ESP_DIR="$PROJECT_DIR/esp" + +# ---- config ---- +OVMF="${OVMF:-/usr/share/edk2/x64/OVMF.4m.fd}" +MEM="${MEM:-256M}" +SMP="${SMP:-1}" +PROFILE="debug" +CARGO_FLAGS="" +GUI="" +DEBUG="" + +# ---- args ---- +while [ $# -gt 0 ]; do + case "$1" in + --gui | -g) GUI="-vga std" ;; + --debug | -d) DEBUG="-s -S" ;; + --release | -r) + PROFILE="release" + CARGO_FLAGS="--release" + ;; + --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 + +OUT_DIR="target/x86_64-unknown-uefi/$PROFILE" +KERNEL="$OUT_DIR/rsdos.efi" + +# ---- build ---- +echo "=== Building kernel ($PROFILE) ===" +cargo build --package rsdos --target x86_64-unknown-uefi $CARGO_FLAGS + +# ---- deploy ---- +mkdir -p "$ESP_DIR/EFI/BOOT" +cp "$KERNEL" "$ESP_DIR/EFI/BOOT/BOOTX64.EFI" +echo " kernel: $(ls -lh "$KERNEL" | awk '{print $5}')" + +# ---- boot ---- +echo "" +echo "=== Booting (direct: firmware → rsnix) ===" +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=fat:rw:"$ESP_DIR",format=raw \ + -serial stdio \ + -m "$MEM" \ + -machine q35 \ + -cpu qemu64 \ + -no-reboot \ + -smp "$SMP" \ + $GUI $DEBUG -- cgit v1.2.3