diff options
Diffstat (limited to 'rsnix/src/ahci.rs')
| -rw-r--r-- | rsnix/src/ahci.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/rsnix/src/ahci.rs b/rsnix/src/ahci.rs index 427345d..9a49431 100644 --- a/rsnix/src/ahci.rs +++ b/rsnix/src/ahci.rs | |||
| @@ -54,7 +54,6 @@ const ATA_WRITE_DMA_EXT: u8 = 0x35; | |||
| 54 | struct Disk { | 54 | struct Disk { |
| 55 | port: usize, // port register base = ABAR + 0x100 | 55 | port: usize, // port register base = ABAR + 0x100 |
| 56 | clb: usize, // command list, 1024 B (32 × 32 B), 256 B aligned | 56 | clb: usize, // command list, 1024 B (32 × 32 B), 256 B aligned |
| 57 | fis: usize, // FIS receive area, 256 B aligned | ||
| 58 | ct: usize, // command table, 256 B, 128 B aligned | 57 | ct: usize, // command table, 256 B, 128 B aligned |
| 59 | buf: usize, // 4 KiB DMA data buffer (page aligned) | 58 | buf: usize, // 4 KiB DMA data buffer (page aligned) |
| 60 | sectors: u64, // total sectors (LBA48 from IDENTIFY) | 59 | sectors: u64, // total sectors (LBA48 from IDENTIFY) |
| @@ -175,7 +174,6 @@ fn start_port(abar: usize, port_idx: u32) -> Option<Disk> { | |||
| 175 | let mut d = Disk { | 174 | let mut d = Disk { |
| 176 | port, | 175 | port, |
| 177 | clb, | 176 | clb, |
| 178 | fis, | ||
| 179 | ct, | 177 | ct, |
| 180 | buf, | 178 | buf, |
| 181 | sectors: 0, | 179 | sectors: 0, |
| @@ -389,8 +387,12 @@ fn issue(d: &Disk, cmd: u8, lba: u64, count: u32, write: bool) -> Result<(), ()> | |||
| 389 | Ok(()) | 387 | Ok(()) |
| 390 | } | 388 | } |
| 391 | 389 | ||
| 390 | fn disks() -> &'static mut [Option<Disk>; MAX_DISKS] { | ||
| 391 | unsafe { &mut *core::ptr::addr_of_mut!(DISKS) } | ||
| 392 | } | ||
| 393 | |||
| 392 | fn active() -> Option<&'static Disk> { | 394 | fn active() -> Option<&'static Disk> { |
| 393 | unsafe { DISKS.get(ACTIVE).and_then(|d| d.as_ref()) } | 395 | disks().get(unsafe { ACTIVE }).and_then(|d| d.as_ref()) |
| 394 | } | 396 | } |
| 395 | 397 | ||
| 396 | /// DMA `count` sectors starting at `lba` into the selected disk's buffer. | 398 | /// DMA `count` sectors starting at `lba` into the selected disk's buffer. |
