diff --git a/tests/ahci-test.c b/tests/ahci-test.c index 211274e8c3..658956d6a1 100644 --- a/tests/ahci-test.c +++ b/tests/ahci-test.c @@ -728,7 +728,7 @@ static void ahci_test_identify(AHCIQState *ahci) g_assert_cmphex(ahci_px_rreg(ahci, i, AHCI_PX_IS), ==, 0); /* Commit the Command FIS to the Command Table */ - memwrite(table, &fis, sizeof(fis)); + ahci_write_fis(ahci, &fis, table); /* Commit the PRD entry to the Command Table */ memwrite(table + 0x80, &prd, sizeof(prd)); diff --git a/tests/libqos/ahci.c b/tests/libqos/ahci.c index 8ecfdd30d8..1294f8083c 100644 --- a/tests/libqos/ahci.c +++ b/tests/libqos/ahci.c @@ -464,6 +464,20 @@ void ahci_destroy_command(AHCIQState *ahci, uint8_t port, uint8_t slot) ahci->port[port].prdtl[slot] = 0; } +void ahci_write_fis(AHCIQState *ahci, RegH2DFIS *fis, uint64_t addr) +{ + RegH2DFIS tmp = *fis; + + /* The auxiliary FIS fields are defined per-command and are not + * currently implemented in libqos/ahci.o, but may or may not need + * to be flipped. */ + + /* All other FIS fields are 8 bit and do not need to be flipped. */ + tmp.count = cpu_to_le16(tmp.count); + + memwrite(addr, &tmp, sizeof(tmp)); +} + unsigned ahci_pick_cmd(AHCIQState *ahci, uint8_t port) { unsigned i; diff --git a/tests/libqos/ahci.h b/tests/libqos/ahci.h index 0837bf5032..83a62acf44 100644 --- a/tests/libqos/ahci.h +++ b/tests/libqos/ahci.h @@ -393,7 +393,7 @@ typedef struct RegH2DFIS { uint8_t icc; uint8_t control; /* DW4 */ - uint32_t aux; + uint8_t aux[4]; } __attribute__((__packed__)) RegH2DFIS; /** @@ -515,6 +515,7 @@ void ahci_get_command_header(AHCIQState *ahci, uint8_t port, void ahci_set_command_header(AHCIQState *ahci, uint8_t port, uint8_t slot, AHCICommandHeader *cmd); void ahci_destroy_command(AHCIQState *ahci, uint8_t port, uint8_t slot); +void ahci_write_fis(AHCIQState *ahci, RegH2DFIS *fis, uint64_t addr); unsigned ahci_pick_cmd(AHCIQState *ahci, uint8_t port); #endif