Expand description
AHCI (Advanced Host Controller Interface) driver : AHCI spec 1.3.1
PCI: class=0x01 (Mass Storage), subclass=0x06 (SATA), prog_if=0x01 MMIO base: BAR5 (ABAR)
Per-port memory layout (packed into one 4 KB page): [0x000..0x3FF] Command List (1024 B, 32 × 32-byte headers) [0x400..0x4FF] FIS receive (256 B) [0x500..0x5FF] Command table (128 B header + 1 × 16-byte PRDT)
§IRQ-driven completion (DRV-02 v2)
When a task context exists (current_task_id() is Some), commands are
completed via interrupt + WaitQueue::wait_until() so the issuing task
blocks without busy-spinning. During early boot (no task yet) the legacy
polling path is used as a fallback.
Per-port statics (indexed by port_num 0..32) are used so the IRQ handler
can signal completion without acquiring any slow lock:
PORT_VIRT[n]: MMIO virtual address of port n registersPORT_SLOT0_DONE[n]: set by IRQ handler when slot-0 completesPORT_SLOT0_ERROR[n]: set by IRQ handler when a task-file error firesPORT_WQ[n]: WaitQueue; issuing task blocks here
Re-exports§
pub use super::virtio_block::BlockDevice;pub use super::virtio_block::BlockError;pub use super::virtio_block::SECTOR_SIZE;
Structs§
Enums§
Constants§
- ATA_
IDENTIFY 🔒 - ATA_
READ_ 🔒DMA_ EXT - ATA_
WRITE_ 🔒DMA_ EXT - CLB_OFF 🔒
- CMDH_
CTBA 🔒 - CMDH_
CTBAU 🔒 - CMDH_
FLAGS 🔒 - CMDH_
PRDTL 🔒 - CMD_CR 🔒
- CMD_FR 🔒
- CMD_FRE 🔒
- CMD_ST 🔒
- CTAB_
CFIS 🔒 - CTAB_
OFF 🔒 - CTAB_
PRDT 🔒 - EFAULT 🔒
- FB_OFF 🔒
- FIS_CMD 🔒
- FIS_
CNT_ 🔒HI - FIS_
CNT_ 🔒LO - FIS_
C_ 🔒BIT - FIS_
DEVICE 🔒 - FIS_
FLAGS 🔒 - FIS_
LBA0 🔒 - FIS_
LBA1 🔒 - FIS_
LBA2 🔒 - FIS_
LBA3 🔒 - FIS_
LBA4 🔒 - FIS_
LBA5 🔒 - FIS_
LBA_ 🔒MODE - FIS_
TYPE 🔒 - FIS_
TYPE_ 🔒H2D - GHC_AE 🔒
- GHC_HR 🔒
- GHC_IE 🔒
- HBA_GHC 🔒
- HBA_IS 🔒
- HBA_PI 🔒
- PORT_CI 🔒
- PORT_
CLB 🔒 - PORT_
CLBU 🔒 - PORT_
CMD 🔒 - PORT_FB 🔒
- PORT_
FBU 🔒 - PORT_IE 🔒
- PORT_IS 🔒
- PORT_
SERR 🔒 - PORT_
SIG 🔒 - PORT_
SSTS 🔒 - PORT_
TFD 🔒 - PXIE_
DHRE 🔒 - PXIE_
TFEE 🔒 - PXIS_
TFES 🔒 - SIG_
SATA 🔒 - SSTS_
DET_ 🔒COMM - SSTS_
DET_ 🔒MASK - TFD_BSY 🔒
- TFD_DRQ 🔒
Statics§
- AHCI 🔒
- AHCI_
ABAR_ 🔒VIRT - AHCI ABAR virtual address : written once during init, read by IRQ handler.
- AHCI_
IRQ_ LINE - PCI interrupt line used by this controller.
- PENDING_
ASYNC_ 🔒READ_ COMPLETIONS - PORT_
ASYNC_ 🔒ACTIVE - Whether an async operation is in-flight on this port’s slot 0.
- PORT_
ASYNC_ 🔒BUF_ VADDR - User virtual address where read data must be copied (0 = write op).
- PORT_
ASYNC_ 🔒DMA_ PTR - Raw pointer to a leaked
Box<DmaBuffer>held until IRQ completion. 0 means no buffer. Freed insidehandle_interrupt()viaBox::from_raw(). - PORT_
ASYNC_ 🔒IS_ WRITE - Whether the in-flight async command is a write operation.
- PORT_
ASYNC_ 🔒LEN - Number of bytes transferred.
- PORT_
ASYNC_ 🔒RING_ ID - Ring id to push the completion CQE into (0 = no async pending).
- PORT_
ASYNC_ 🔒USER_ DATA - User-data token echoed in the completion CQE.
- PORT_
SLOT0_ 🔒DONE - Per-port slot-0 completion flags : set by IRQ handler, cleared by consumer.
- PORT_
SLOT0_ 🔒ERROR - Per-port slot-0 error flags : set by IRQ handler on task-file error.
- PORT_
VIRT 🔒 - Per-port MMIO virtual addresses : written once during init.
- PORT_WQ 🔒
- Per-port wait queues : tasks block here while waiting for IRQ completion.
Functions§
- discard_
deferred_ 🔒async_ read_ completions - flush_
deferred_ 🔒async_ read_ completions - get_
device - Return a reference to the first usable AHCI controller, if any.
- handle_
interrupt - Called from the IDT AHCI IRQ handler.
- init
- Scan the PCI bus for an AHCI controller and initialise it.
- port_
enable_ 🔒irq - Enable interrupts for a port (DHRE = DMA completion, TFEE = errors).
- port_
rebase 🔒 - Rebase port: assign our CLB/FB buffers then start the port.
- port_
start 🔒 - Performs the port start operation.
- port_
stop 🔒 - Performs the port stop operation.
- rd32 🔒 ⚠
- Performs the rd32 operation.
- submit_
async_ 🔒cmd - Submit a command asynchronously ; returns immediately without blocking.
- submit_
async_ 🔒storage_ op - Public entry point called from
async_io::dispatch. - submit_
cmd 🔒 - Performs the submit cmd operation.
- wr32 🔒 ⚠
- Performs the wr32 operation.