2

I have a question regarding the AHCI spec:

Is the variable pDmaXferCnt in the port used when the transfer is a DMA write or read?

The description in the spec seems to indicate that it isn't, but the PRDs are used instead. But how does the HBA know how much data is to be sent or received to/from a SATA device? This information will be available in the sector count of a H2D FIS, but unless I have overlooked it there doesn't seem to be a register of variable that holds this value. The DX:transmit state also seems to indicate that pDmaXferCnt will have a set value, yet I can’t see where it would be set for a DMA read/write operation.

Thanks

nemo
  • 55,207
  • 13
  • 135
  • 135

1 Answers1

0

From the spec: "Implementation Note: HBA state variables are used to describe the required externally visible behavior. Implementations are not required to have internal state values that directly correspond to these variables." - meaning you (maybe) won't find the pDmaXferCnt externally in a register.

There is another way to track the count though.

Under the HBA Memory Space Usage part of the AHCI spec, there are the data structures of the command list (list of command headers) and the command table (pointed to by the command header, each command table is a command to be sent). These are both accessible to the HBA.

In the command header in DW0 is the PRDTL - which is the count of how many PRD's to be used in the transfer.

Now in the actual command table that the command header points to, contains the actual PRD's, in each PRD is their own DBC or data byte count (amount of data in bytes to be DMA'd at the location specified in DBA). So if you take the each of the PRD's * there own DBC's and add them up you'll get the amount of data to be transfered.

Alternately in the in the command header DW1 is the PRDBC which is the count of bytes transfered, so you could check that after the command.

HBA - Host Bus Adapter

PRDTL - Physical Region Descriptor Table Length

PRD - Physical Region Descriptor (tracks where in physical memory and the count of bytes is to be transfered)

DBC - data byte count (inside a PRD)

DBA - data base address (physical address inside a PRD)

PRDBC - Physical Region Descriptor Byte Count

DMA - direct memory access

For more reading: http://www.intel.com/content/www/us/en/io/serial-ata/serial-ata-ahci-spec-rev1-3-1.html

enter image description here

enter image description here

Coach Chuck
  • 106
  • 1
  • 3