diff options
| author | salmonik <salmonik@tuta.io> | 2026-07-31 21:29:49 +0200 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-07-31 21:29:49 +0200 |
| commit | 3997ec4d2d7d6f69b08d0c04ce8de0df03c52a45 (patch) | |
| tree | 60c5b079103e74d919a32b24276c536e69ce82f7 /scripts/boot.sh | |
| parent | ahci: SATA driver + FAT32 persistent disk mounted at /disk (diff) | |
| download | rs-dos-3997ec4d2d7d6f69b08d0c04ce8de0df03c52a45.tar.gz rs-dos-3997ec4d2d7d6f69b08d0c04ce8de0df03c52a45.zip | |
ahci: scan all ports; fat: mount first valid FAT32 disk
The kernel previously started only AHCI port 0, so any launch where the
firmware/QEMU put something else on port 0 (e.g. the ESP from an implicit
-drive file=fat:rw:esp) left the real disk unnoticed: 'unsupported sector
size 0' and no mount.
- ahci.rs: enumerate CAP.NP/PI ports, start every port that links up
(empty ports settle at DET=0 and are skipped quickly), keep up to 8
disks, and expose disk_count()/select() for the filesystem
- fat.rs: try each disk in port order and mount the first valid FAT32
volume; non-FAT disks are logged and skipped
- scripts/boot.sh: attach the data disk on ide.0 and the ESP on ide.1
(DISK_IMG env var, default /tmp/disk.img), matching the Makefile
- Verified with the disk on port 0 (Makefile style), port 5 (old-style
command line), and with the ESP on port 0; fsck.fat stays clean
Diffstat (limited to 'scripts/boot.sh')
| -rwxr-xr-x | scripts/boot.sh | 20 |
1 files changed, 19 insertions, 1 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 \ |
