summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-07-31 21:29:49 +0200
committersalmonik <salmonik@tuta.io>2026-07-31 21:29:49 +0200
commit3997ec4d2d7d6f69b08d0c04ce8de0df03c52a45 (patch)
tree60c5b079103e74d919a32b24276c536e69ce82f7 /scripts
parentahci: SATA driver + FAT32 persistent disk mounted at /disk (diff)
downloadrs-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')
-rwxr-xr-xscripts/boot.sh20
-rwxr-xr-xscripts/qemu.sh4
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#
23set -euo pipefail 28set -euo pipefail
24 29
@@ -33,6 +38,7 @@ ESP_DIR="$PROJECT_DIR/esp"
33OVMF="${OVMF:-/usr/share/edk2/x64/OVMF.4m.fd}" 38OVMF="${OVMF:-/usr/share/edk2/x64/OVMF.4m.fd}"
34MEM="${MEM:-256M}" 39MEM="${MEM:-256M}"
35SMP="${SMP:-1}" 40SMP="${SMP:-1}"
41DISK_IMG="${DISK_IMG:-/tmp/disk.img}"
36PROFILE="debug" 42PROFILE="debug"
37CARGO_FLAGS="" 43CARGO_FLAGS=""
38GUI="" 44GUI=""
@@ -84,13 +90,25 @@ echo ""
84echo "=== Booting (direct: firmware → rsnix) ===" 90echo "=== Booting (direct: firmware → rsnix) ==="
85echo " ovmf: $OVMF" 91echo " ovmf: $OVMF"
86echo " mem: $MEM smp: $SMP" 92echo " mem: $MEM smp: $SMP"
93echo " disk: $([ -f "$DISK_IMG" ] && echo "$DISK_IMG" || echo "none ($DISK_IMG missing)")"
87echo " gui: $([ -n "$GUI" ] && echo yes || echo no)" 94echo " gui: $([ -n "$GUI" ] && echo yes || echo no)"
88echo " gdb: $([ -n "$DEBUG" ] && echo ':1234' || echo off)" 95echo " gdb: $([ -n "$DEBUG" ] && echo ':1234' || echo off)"
89echo "" 96echo ""
90 97
98if [ -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 )
103else
104 DISK_ARGS=()
105fi
106
91exec qemu-system-x86_64 \ 107exec 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 ;;