summaryrefslogtreecommitdiffstats
path: root/rsnix/src/ahci.rs
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-08-01 18:25:55 +0200
committersalmonik <salmonik@tuta.io>2026-08-01 18:25:55 +0200
commit1ea2f68e6a9af135e6cb3274fdf28d4ddc5812d5 (patch)
treef28246586e387293d0c8beaf6b445210aaab8c48 /rsnix/src/ahci.rs
parentklog/tty/pager: no more truncated lines — full lines flow, terminal wraps (diff)
downloadrs-dos-1ea2f68e6a9af135e6cb3274fdf28d4ddc5812d5.tar.gz
rs-dos-1ea2f68e6a9af135e6cb3274fdf28d4ddc5812d5.zip
fix pi-lens warnings: unwraps, shell SC2046, dup code (fmtbuf/scripts/hexdump/cat/ahci/pci)
- memory.rs: self-test Layout::from_size_align no longer panics — the test fails cleanly on an invalid layout - fat.rs: v() no longer unwraps the active-volume slot — invariant violation logs + halts instead of panicking mid-disk-io - strbuf: shared FmtBuf replaces the duplicated PanicBuf/FmtBuf (main.rs + sched.rs) - test-disk.sh: SC2046 — conditional --fresh arg no longer relies on word splitting - scripts: boot.sh/boot-image.sh share lib-boot-args.sh (dup args loop) - shell: cat/hexdump stdin pairs unified with Option<&str> marker; hexdump format_row folded into format_partial - ahci: read/write_sectors unified behind dma_sectors - pci: config_read/write share config_addr
Diffstat (limited to 'rsnix/src/ahci.rs')
-rw-r--r--rsnix/src/ahci.rs18
1 files changed, 10 insertions, 8 deletions
diff --git a/rsnix/src/ahci.rs b/rsnix/src/ahci.rs
index 72da07d..a77b341 100644
--- a/rsnix/src/ahci.rs
+++ b/rsnix/src/ahci.rs
@@ -510,22 +510,24 @@ fn active() -> Option<&'static Disk> {
510 disks().get(unsafe { ACTIVE }).and_then(|d| d.as_ref()) 510 disks().get(unsafe { ACTIVE }).and_then(|d| d.as_ref())
511} 511}
512 512
513/// DMA `count` sectors starting at `lba` into the selected disk's buffer. 513/// Bounds-checked DMA of `count` sectors starting at `lba` into/out of the
514pub fn read_sectors(lba: u64, count: u32) -> Result<(), ()> { 514/// selected disk's buffer (single code path for both directions).
515fn dma_sectors(lba: u64, count: u32, cmd: u8, write: bool) -> Result<(), ()> {
515 let d = active().ok_or(())?; 516 let d = active().ok_or(())?;
516 if lba + count as u64 > d.sectors { 517 if lba + count as u64 > d.sectors {
517 return Err(()); 518 return Err(());
518 } 519 }
519 issue(d, ATA_READ_DMA_EXT, lba, count, false) 520 issue(d, cmd, lba, count, write)
521}
522
523/// DMA `count` sectors starting at `lba` into the selected disk's buffer.
524pub fn read_sectors(lba: u64, count: u32) -> Result<(), ()> {
525 dma_sectors(lba, count, ATA_READ_DMA_EXT, false)
520} 526}
521 527
522/// DMA `count` sectors starting at `lba` out of the selected disk's buffer. 528/// DMA `count` sectors starting at `lba` out of the selected disk's buffer.
523pub fn write_sectors(lba: u64, count: u32) -> Result<(), ()> { 529pub fn write_sectors(lba: u64, count: u32) -> Result<(), ()> {
524 let d = active().ok_or(())?; 530 dma_sectors(lba, count, ATA_WRITE_DMA_EXT, true)
525 if lba + count as u64 > d.sectors {
526 return Err(());
527 }
528 issue(d, ATA_WRITE_DMA_EXT, lba, count, true)
529} 531}
530 532
531/// Pointer to the selected disk's 4 KiB DMA buffer. 533/// Pointer to the selected disk's 4 KiB DMA buffer.