On 30/01/2015 19:41, John Snow wrote:
> +/* Set the #cx'th command of port #px. */
> +void ahci_set_command_header(AHCIQState *ahci, uint8_t px,
> + uint8_t cx, AHCICommandHeader *cmd)
> +{
> + uint64_t ba = ahci->port[px].clb;
> + ba += cx * sizeof(AHCICommandHeader);
> +
> + cmd->flags = cpu_to_le16(cmd->flags);
> + cmd->prdtl = cpu_to_le16(cmd->prdtl);
> + cmd->prdbc = cpu_to_le32(cmd->prdbc);
> + cmd->ctba = cpu_to_le64(cmd->ctba);
Modifying cmd is uglyish, and especially it might hide bugs that only
happen on big endian system. Please copy to a local AHCICommandHeader
variable before adjusting for host endianness.
Paolo
> + memwrite(ba, cmd, sizeof(AHCICommandHeader));
> +}