Part2 ahci driver level
Each AHCI controller implements several sata ports, each port connects
to one SATA device.
AHCI driver needs to setup the command table for each port and use the
command table to issue read/write command to AHCI controller.
In libata, each ata port is represented by an ata_port struct, AHCI
driver has ahci_port_priv as driver private part, it mainly stores the
dma address for the command table.
ahci_port_start:
alloc memory used for dma (AHCI_PORT_PRIV_DMA_SZ bytes)
power up the port
start the port DMA engine
ahci_qc_prep:
ata_queued_cmd has all the needed info, including
ata_taskfile (read/write command, sector address)
scatter-gather list used for DMA
according to these info, ahci_qc_prep will setup the corresponding
command slot entry and the command table
1. convert taskfile to a command FIS
2. fill the PRDT according to the sg list in ata_queued_cmd
3. fill the command slot (point to the command table)
ahci_qc_issue:
Once the command slot and command table have been setup, driver will
setup the corresponding bit in PORT_CMD_ISSUE to tell the host
controller there is new command coming.
For NCQ command, driver needs to setup the corresponding bit in
PORT_SCR_ACT. Driver needs to test this register to know the
completion status of issued command, non-NCQ command should read
PORT_CMD_ISSUE instead (see the interrupt service routine
ahci_port_intr for details).
阅读(2964) | 评论(0) | 转发(0) |