qtest/ahci: add ahci_write_fis
authorJohn Snow <jsnow@redhat.com>
Thu, 5 Feb 2015 17:41:21 +0000 (12:41 -0500)
committerStefan Hajnoczi <stefanha@redhat.com>
Mon, 16 Feb 2015 15:07:17 +0000 (15:07 +0000)
Similar to ahci_set_command_header, add a helper that takes an
in-memory representation of a command FIS and writes it to guest
memory, handling endianness as-needed.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1423158090-25580-11-git-send-email-jsnow@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
tests/ahci-test.c
tests/libqos/ahci.c
tests/libqos/ahci.h

index 211274e8c3471470d86d9273fc7006150607916b..658956d6a19b64e7072c6664b3a3f9b30ad873ae 100644 (file)
@@ -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));
index 8ecfdd30d847269400f58faae716ef76306a031c..1294f8083cef5c8802e7e4e1a85a9aeb0f909ecd 100644 (file)
@@ -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;
index 0837bf503260544242146306d2ad4cd1a850e2d3..83a62acf4449ed01edebad84171bed0c6ab0b255 100644 (file)
@@ -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