diff options
Diffstat (limited to '')
| -rwxr-xr-x | scripts/boot.sh | 20 | ||||
| -rwxr-xr-x | scripts/qemu.sh | 4 |
2 files changed, 21 insertions, 3 deletions
diff --git a/scripts/boot.sh b/scripts/boot.sh index 1e3f739..26064f9 100755 --- a/scripts/boot.sh +++ b/scripts/boot.sh | |||
| @@ -19,6 +19,11 @@ | |||
| 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) | ||
| 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. | ||
| 22 | # | 27 | # |
| 23 | set -euo pipefail | 28 | set -euo pipefail |
| 24 | 29 | ||
| @@ -33,6 +38,7 @@ ESP_DIR="$PROJECT_DIR/esp" | |||
| 33 | OVMF="${OVMF:-/usr/share/edk2/x64/OVMF.4m.fd}" | 38 | OVMF="${OVMF:-/usr/share/edk2/x64/OVMF.4m.fd}" |
| 34 | MEM="${MEM:-256M}" | 39 | MEM="${MEM:-256M}" |
| 35 | SMP="${SMP:-1}" | 40 | SMP="${SMP:-1}" |
| 41 | DISK_IMG="${DISK_IMG:-/tmp/disk.img}" | ||
| 36 | PROFILE="debug" | 42 | PROFILE="debug" |
| 37 | CARGO_FLAGS="" | 43 | CARGO_FLAGS="" |
| 38 | GUI="" | 44 | GUI="" |
| @@ -84,13 +90,25 @@ echo "" | |||
| 84 | echo "=== Booting (direct: firmware → rsnix) ===" | 90 | echo "=== Booting (direct: firmware → rsnix) ===" |
| 85 | echo " ovmf: $OVMF" | 91 | echo " ovmf: $OVMF" |
| 86 | echo " mem: $MEM smp: $SMP" | 92 | echo " mem: $MEM smp: $SMP" |
| 93 | echo " disk: $([ -f "$DISK_IMG" ] && echo "$DISK_IMG" || echo "none ($DISK_IMG missing)")" | ||
| 87 | echo " gui: $([ -n "$GUI" ] && echo yes || echo no)" | 94 | echo " gui: $([ -n "$GUI" ] && echo yes || echo no)" |
| 88 | echo " gdb: $([ -n "$DEBUG" ] && echo ':1234' || echo off)" | 95 | echo " gdb: $([ -n "$DEBUG" ] && echo ':1234' || echo off)" |
| 89 | echo "" | 96 | echo "" |
| 90 | 97 | ||
| 98 | if [ -f "$DISK_IMG" ]; then | ||
| 99 | DISK_ARGS=( | ||
| 100 | -drive "file=$DISK_IMG,format=raw,if=none,id=disk" | ||
| 101 | -device ide-hd,drive=disk,bus=ide.0 | ||
| 102 | ) | ||
| 103 | else | ||
| 104 | DISK_ARGS=() | ||
| 105 | fi | ||
| 106 | |||
| 91 | exec qemu-system-x86_64 \ | 107 | exec qemu-system-x86_64 \ |
| 92 | -bios "$OVMF" \ | 108 | -bios "$OVMF" \ |
| 93 | -drive file=fat:rw:"$ESP_DIR",format=raw \ | 109 | "${DISK_ARGS[@]}" \ |
| 110 | -drive file=fat:rw:"$ESP_DIR",format=raw,if=none,id=esp \ | ||
| 111 | -device ide-hd,drive=esp,bus=ide.1 \ | ||
| 94 | -serial stdio \ | 112 | -serial stdio \ |
| 95 | -m "$MEM" \ | 113 | -m "$MEM" \ |
| 96 | -machine q35 \ | 114 | -machine q35 \ |
diff --git a/scripts/qemu.sh b/scripts/qemu.sh index 123d9d0..b8997ba 100755 --- a/scripts/qemu.sh +++ b/scripts/qemu.sh | |||
| @@ -41,8 +41,8 @@ while [ $# -gt 0 ]; do | |||
| 41 | --image | -i) | 41 | --image | -i) |
| 42 | _img_file="$(printf -- '-drive file=%s,format=raw,if=none,id=hd' "$2")" | 42 | _img_file="$(printf -- '-drive file=%s,format=raw,if=none,id=hd' "$2")" |
| 43 | # Explicit buses: data disk -> ide.0 (port 0), ESP -> ide.1. | 43 | # Explicit buses: data disk -> ide.0 (port 0), ESP -> ide.1. |
| 44 | DRIVE_ARGS=("$_img_file" '-device' 'ide-hd,drive=hd,bus=ide.0' \ | 44 | DRIVE_ARGS=("$_img_file" '-device' 'ide-hd,drive=hd,bus=ide.0' |
| 45 | '-drive' 'file=fat:rw:esp,format=raw,if=none,id=esp' \ | 45 | '-drive' 'file=fat:rw:esp,format=raw,if=none,id=esp' |
| 46 | '-device' 'ide-hd,drive=esp,bus=ide.1') | 46 | '-device' 'ide-hd,drive=esp,bus=ide.1') |
| 47 | shift 2 | 47 | shift 2 |
| 48 | ;; | 48 | ;; |
