diff options
Diffstat (limited to 'scripts/qemu.sh')
| -rwxr-xr-x | scripts/qemu.sh | 99 |
1 files changed, 0 insertions, 99 deletions
diff --git a/scripts/qemu.sh b/scripts/qemu.sh deleted file mode 100755 index eeaf4de..0000000 --- a/scripts/qemu.sh +++ /dev/null | |||
| @@ -1,99 +0,0 @@ | |||
| 1 | #!/usr/bin/env bash | ||
| 2 | # ============================================================================= | ||
| 3 | # scripts/qemu.sh — flexible QEMU launcher for rs-dos | ||
| 4 | # | ||
| 5 | # Usage: | ||
| 6 | # ./scripts/qemu.sh # serial console (no graphics) | ||
| 7 | # ./scripts/qemu.sh --gui # graphical window | ||
| 8 | # ./scripts/qemu.sh --debug # GDB stub on :1234 | ||
| 9 | # ./scripts/qemu.sh --chain # full boot chain (firmware → rsboot → rsnix) | ||
| 10 | # ./scripts/qemu.sh --bios /path/to.fd # custom OVMF | ||
| 11 | # ./scripts/qemu.sh --mem 512M # memory size | ||
| 12 | # ./scripts/qemu.sh --smp 2 # SMP cores | ||
| 13 | # | ||
| 14 | # One image, one drive — the system image contains kernel + ESP + data. | ||
| 15 | # ============================================================================= | ||
| 16 | set -euo pipefail | ||
| 17 | |||
| 18 | SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" | ||
| 19 | PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" | ||
| 20 | cd "$PROJECT_DIR" | ||
| 21 | |||
| 22 | # Defaults | ||
| 23 | GUI_FLAG="" | ||
| 24 | DEBUG_FLAG="" | ||
| 25 | CHAIN_FLAG="" | ||
| 26 | OVMF="${OVMF:-/usr/share/edk2/x64/OVMF.4m.fd}" | ||
| 27 | MEM="${MEM:-256M}" | ||
| 28 | SMP="${SMP:-1}" | ||
| 29 | SYSTEM_IMG="${SYSTEM_IMG:-/tmp/system.img}" | ||
| 30 | |||
| 31 | # Pre-build | ||
| 32 | make all | ||
| 33 | |||
| 34 | # Parse args | ||
| 35 | while [ $# -gt 0 ]; do | ||
| 36 | case "$1" in | ||
| 37 | --gui | -g) | ||
| 38 | GUI_FLAG="-vga std" | ||
| 39 | shift | ||
| 40 | ;; | ||
| 41 | --debug | -d) | ||
| 42 | DEBUG_FLAG="-s -S" | ||
| 43 | shift | ||
| 44 | ;; | ||
| 45 | --chain | -c) | ||
| 46 | CHAIN_FLAG=1 | ||
| 47 | SYSTEM_IMG="${SYSTEM_IMG:-rs-dos.img}" | ||
| 48 | shift | ||
| 49 | ;; | ||
| 50 | --image | -i) | ||
| 51 | SYSTEM_IMG="$2" | ||
| 52 | shift 2 | ||
| 53 | ;; | ||
| 54 | --bios | -b) | ||
| 55 | OVMF="$2" | ||
| 56 | shift 2 | ||
| 57 | ;; | ||
| 58 | --mem) | ||
| 59 | MEM="$2" | ||
| 60 | shift 2 | ||
| 61 | ;; | ||
| 62 | --smp) | ||
| 63 | SMP="$2" | ||
| 64 | shift 2 | ||
| 65 | ;; | ||
| 66 | *) | ||
| 67 | echo "unknown: $1" | ||
| 68 | exit 1 | ||
| 69 | ;; | ||
| 70 | esac | ||
| 71 | done | ||
| 72 | |||
| 73 | # Stage system image if needed | ||
| 74 | if [ -n "$CHAIN_FLAG" ]; then | ||
| 75 | ./scripts/mksystem.sh --chain --gpt "$SYSTEM_IMG" | ||
| 76 | else | ||
| 77 | ./scripts/mksystem.sh "$SYSTEM_IMG" | ||
| 78 | fi | ||
| 79 | |||
| 80 | echo "" | ||
| 81 | echo "=== Booting ===" | ||
| 82 | echo " image: $SYSTEM_IMG" | ||
| 83 | echo " ovmf: $OVMF" | ||
| 84 | echo " mem: $MEM smp: $SMP" | ||
| 85 | echo " gui: $([ -n "$GUI_FLAG" ] && echo yes || echo no)" | ||
| 86 | echo " gdb: $([ -n "$DEBUG_FLAG" ] && echo ':1234' || echo off)" | ||
| 87 | echo "" | ||
| 88 | |||
| 89 | exec qemu-system-x86_64 \ | ||
| 90 | -bios "$OVMF" \ | ||
| 91 | -drive "file=$SYSTEM_IMG,format=raw,if=none,id=hd" \ | ||
| 92 | -device ide-hd,drive=hd \ | ||
| 93 | -serial stdio \ | ||
| 94 | -m "$MEM" \ | ||
| 95 | -machine q35 \ | ||
| 96 | -cpu qemu64 \ | ||
| 97 | -no-reboot \ | ||
| 98 | -smp "$SMP" \ | ||
| 99 | $GUI_FLAG $DEBUG_FLAG | ||
