When software builds a command for the HBA to execute, it first finds an empty command slot by reading the PxCI and PxSACT registers for the port. An empty command slot has its respective bit cleared to 0 in both the PxCI and PxSACT registers. After a free slot (pFreeSlot notation), is found:
•Software builds a command frame information structure (FIS) in system memory at location PxCLB[CH(pFreeSlot)]:CFIS with the command type.
•If it is an ATAPI command, the ACMD field is filled in with the ATAPI command.
•Software builds a command header at PxCLB[CH(pFreeSlot)] with:
°PRDTL containing the number of entries in the PRD table.
°CFL set to the length of the command in the CFIS area.
°A bit set if it is an ATAPI command.
°W (Write) bit set if data is going to the device.
°P (Prefetch) bit optionally set.
°If a port multiplier is attached, the PMP field is set to the correct port multiplier port.
•If it is a queued command, software first sets PxSACT [DS (pFreeSlot)]. Software should only write new bits to set to 1; the previous register content of PxSACT should not be rewritten in the register write.
•Software sets PxCI [CI (pFreeSlot)] to indicate to the HBA that a command is active. Software should only write new bits to set to 1; the previous register content of PxCI should not be rewritten in the register write.