I'm writing a driver in Linux for AHCI. I'm starting small with the Identify Device command. The command is processed but the drive, or the HBA (not sure yet), moves just 212 bytes and the PxTFD register for this port shows a status of 0x58. What possibilities exist for an explanation? It would appear that I'm populating the PxCLB registers correctlly (i.e. the Command List and Command Table for this command). I know that the FIS is correct according to the SATA command spec. I've looked at what I'm placing in each field and it would appear to be correct. For example, this is going into the only PRD entry for this command:
DEBUG 375 contents prdt[0] 0x38672000
DEBUG 376 contents prdt[1] 0x00000001
DEBUG 377 contents prdt[2] 0x00000000
DEBUG 378 contents prdt[3] 0x000001ff
The last line indicates 512 bytes should be transferred. The spec says that this field is 0 based and that bit 0 is always 1 indicating an even byte count. Thus 0x1ff = 511 which should be 512 bytes. This is what I'm pushing into the Command List entry
DEBUG 17 opts are 0x00010405
DEBUG 25 addr cmd_tbl ffff880086c60500
DEBUG 26 addr cmd_tbl_dma 0x86c60500
DEBUG 27 cmd hdr[0].opts 0x00010405
DEBUG 28 cmd hdr[0].status 0x00000000
DEBUG 29 cmd hdr[0].tbl_addr 0x86c60500
DEBUG 30 cmd hdr[0].tbl_addr_hi 0x0000000
The line stating opts is 0x00010405 means my PRDTL is 1 (a single PRD entry 0x10000), this is a command (0x0400) and the Command FIS is 5 DWORDs in length (0x05). The other lines were for my sanity making sure I'm placing the correct addresses where they need to be.
Everything appears to be in order yet, when the command executes, only 212 bytes are transferred as I see in my bus trace. Any insights?