summaryrefslogtreecommitdiffstats
path: root/rsnix/src
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-08-01 15:08:29 +0200
committersalmonik <salmonik@tuta.io>2026-08-01 15:08:29 +0200
commitc04fc970e5d9b0c82ae2923af88ad870a74608af (patch)
tree2404ba05751397f5dcdc67e8275783147e22e469 /rsnix/src
parentCONTEXT.md: runtime device detection milestone + QEMU hotplug testability notes (diff)
downloadrs-dos-c04fc970e5d9b0c82ae2923af88ad870a74608af.tar.gz
rs-dos-c04fc970e5d9b0c82ae2923af88ad870a74608af.zip
rsnix: formatting
Diffstat (limited to '')
-rw-r--r--rsnix/src/ahci.rs16
-rw-r--r--rsnix/src/fat.rs10
2 files changed, 19 insertions, 7 deletions
diff --git a/rsnix/src/ahci.rs b/rsnix/src/ahci.rs
index 9ed803d..72da07d 100644
--- a/rsnix/src/ahci.rs
+++ b/rsnix/src/ahci.rs
@@ -262,10 +262,14 @@ pub fn init() -> bool {
262 continue; 262 continue;
263 } 263 }
264 let det = reg(abar as usize + PORT_BASE + port_idx as usize * PORT_STRIDE + P_SSTS) & 0xF; 264 let det = reg(abar as usize + PORT_BASE + port_idx as usize * PORT_STRIDE + P_SSTS) & 0xF;
265 unsafe { PORT_UP[port_idx as usize] = det == 3; } 265 unsafe {
266 PORT_UP[port_idx as usize] = det == 3;
267 }
266 if let Some(d) = start_port(abar as usize, port_idx) { 268 if let Some(d) = start_port(abar as usize, port_idx) {
267 // The device answered IDENTIFY — it's definitely present. 269 // The device answered IDENTIFY — it's definitely present.
268 unsafe { PORT_UP[port_idx as usize] = true; } 270 unsafe {
271 PORT_UP[port_idx as usize] = true;
272 }
269 if !place_disk(d) { 273 if !place_disk(d) {
270 crate::serial_println!("ahci: port {} up but disk table full", port_idx); 274 crate::serial_println!("ahci: port {} up but disk table full", port_idx);
271 } 275 }
@@ -341,7 +345,9 @@ pub fn rescan() -> (usize, usize) {
341 .iter() 345 .iter()
342 .position(|d| d.is_some_and(|d| d.port_idx == port_idx)); 346 .position(|d| d.is_some_and(|d| d.port_idx == port_idx));
343 let up_prev = unsafe { PORT_UP[port_idx as usize] }; 347 let up_prev = unsafe { PORT_UP[port_idx as usize] };
344 unsafe { PORT_UP[port_idx as usize] = up; } 348 unsafe {
349 PORT_UP[port_idx as usize] = up;
350 }
345 if up == up_prev { 351 if up == up_prev {
346 continue; 352 continue;
347 } 353 }
@@ -356,7 +362,9 @@ pub fn rescan() -> (usize, usize) {
356 } 362 }
357 } else if let Some(i) = slot { 363 } else if let Some(i) = slot {
358 // Removal: tombstone the slot; indices stay stable. 364 // Removal: tombstone the slot; indices stay stable.
359 unsafe { DISKS[i] = None; } 365 unsafe {
366 DISKS[i] = None;
367 }
360 crate::serial_println!("ahci: port {} down — device removed", port_idx); 368 crate::serial_println!("ahci: port {} down — device removed", port_idx);
361 removed += 1; 369 removed += 1;
362 } 370 }
diff --git a/rsnix/src/fat.rs b/rsnix/src/fat.rs
index ef75aa9..bad01cd 100644
--- a/rsnix/src/fat.rs
+++ b/rsnix/src/fat.rs
@@ -34,8 +34,8 @@ pub struct Entry {
34} 34}
35 35
36struct Volume { 36struct Volume {
37 disk: usize, // AHCI disk index this volume was mounted from 37 disk: usize, // AHCI disk index this volume was mounted from
38 uid: String, // unique mount name: "LABEL-XXXXXXXX" 38 uid: String, // unique mount name: "LABEL-XXXXXXXX"
39 mounted: bool, // still backed by a present disk (false = tombstoned) 39 mounted: bool, // still backed by a present disk (false = tombstoned)
40 sectors_per_cluster: u8, 40 sectors_per_cluster: u8,
41 reserved: u16, 41 reserved: u16,
@@ -217,7 +217,11 @@ fn is_eoc(c: u32) -> bool {
217 217
218fn next_cluster(c: u32) -> Result<u32, ()> { 218fn next_cluster(c: u32) -> Result<u32, ()> {
219 let n = read_fat_entry(c); 219 let n = read_fat_entry(c);
220 if is_eoc(n) { Err(()) } else { Ok(n) } 220 if is_eoc(n) {
221 Err(())
222 } else {
223 Ok(n)
224 }
221} 225}
222 226
223/// Allocate a fresh cluster: mark it EOC in the FAT and zero its data. 227/// Allocate a fresh cluster: mark it EOC in the FAT and zero its data.