From dc23d2f22cafeb6b97ba460789a834a6c586314d Mon Sep 17 00:00:00 2001 From: salmonik Date: Fri, 31 Jul 2026 19:53:53 +0200 Subject: ahci: SATA driver + FAT32 persistent disk mounted at /disk - ahci.rs: polling AHCI on PCI class 1/6/1, bus mastering + ABAR map, port 0 up, IDENTIFY + READ/WRITE DMA EXT through one 4KiB DMA buffer - fat.rs: BPB parse, whole-FAT RAM cache with write-back to both copies, LFN read/write, dirs, multi-cluster files, FSInfo free-count sync, space-padded dot entries ('..' = cluster 0 under root), fsck-clean - fs.rs: /disk mount node + 24-slot ephemeral node pool; ls/cat/hexdump/ echo/mkdir/touch/rm/edit all work on disk paths unchanged - QEMU: explicit bus assignment (disk=ide.0, ESP=ide.1); the implicit fat:rw:esp drive was stealing AHCI port 0 - Debugged against QEMU source: header DW0 is CFL in bits 4:0 / PRDTL in bits 31:16 (Linux libahci layout), FIS count at bytes 12-13, device at byte 7; QEMU rejects H2D FIS flags bits 6:4, so direction is the header W bit only - Verified: full shell round-trip on /disk, reboot persistence (poweroff then mdir/mtype and a fresh boot), fsck.fat clean --- Makefile | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 1d60062..7701d9d 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,9 @@ export INITRD=$(ESP_DIR)/initramfs.cpio.gz export BOOTLOADER=rsboot/rsboot.efi export OVMF=/usr/share/edk2/x64/OVMF.4m.fd export BOOT_EFI=$(ESP_DIR)/EFI/BOOT/BOOTX64.EFI +# Attach a raw disk image as the SATA drive (disk.img -> ide.0, ESP -> ide.1). +# Create one with: mkfs.fat -F 32 -n RSDOS disk.img && mcopy -i disk.img files :: +export DISK_IMG ?= /tmp/disk.img .PHONY: all run run-gui clean image debug release fmt bootloader boot-image @@ -43,7 +46,10 @@ $(INITRD): | $(ESP_DIR) run: all qemu-system-x86_64 \ -bios $(OVMF) \ - -drive file=fat:rw:$(ESP_DIR),format=raw \ + -drive file=$(DISK_IMG),format=raw,if=none,id=disk \ + -device ide-hd,drive=disk,bus=ide.0 \ + -drive file=fat:rw:$(ESP_DIR),format=raw,if=none,id=esp \ + -device ide-hd,drive=esp,bus=ide.1 \ -serial stdio \ -m 256M \ -machine q35 \ @@ -54,7 +60,10 @@ run: all run-gui: all qemu-system-x86_64 \ -bios $(OVMF) \ - -drive file=fat:rw:$(ESP_DIR),format=raw \ + -drive file=$(DISK_IMG),format=raw,if=none,id=disk \ + -device ide-hd,drive=disk,bus=ide.0 \ + -drive file=fat:rw:$(ESP_DIR),format=raw,if=none,id=esp \ + -device ide-hd,drive=esp,bus=ide.1 \ -serial stdio \ -m 256M \ -machine q35 \ @@ -66,7 +75,10 @@ run-gui: all debug: all qemu-system-x86_64 \ -bios $(OVMF) \ - -drive file=fat:rw:$(ESP_DIR),format=raw \ + -drive file=$(DISK_IMG),format=raw,if=none,id=disk \ + -device ide-hd,drive=disk,bus=ide.0 \ + -drive file=fat:rw:$(ESP_DIR),format=raw,if=none,id=esp \ + -device ide-hd,drive=esp,bus=ide.1 \ -serial stdio \ -m 256M \ -machine q35 \ -- cgit v1.2.3