From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50358) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJQR6-0000Y8-8U for qemu-devel@nongnu.org; Thu, 05 Feb 2015 12:41:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YJQQy-0004pq-IP for qemu-devel@nongnu.org; Thu, 05 Feb 2015 12:41:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55942) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJQQy-0004pV-BC for qemu-devel@nongnu.org; Thu, 05 Feb 2015 12:41:44 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t15HfhgG026376 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 5 Feb 2015 12:41:43 -0500 From: John Snow Date: Thu, 5 Feb 2015 12:41:21 -0500 Message-Id: <1423158090-25580-11-git-send-email-jsnow@redhat.com> In-Reply-To: <1423158090-25580-1-git-send-email-jsnow@redhat.com> References: <1423158090-25580-1-git-send-email-jsnow@redhat.com> Subject: [Qemu-devel] [PATCH v3 10/19] qtest/ahci: add ahci_write_fis List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: famz@redhat.com, mst@redhat.com, armbru@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, John Snow 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 --- tests/ahci-test.c | 2 +- tests/libqos/ahci.c | 14 ++++++++++++++ tests/libqos/ahci.h | 3 ++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/ahci-test.c b/tests/ahci-test.c index 211274e..658956d 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 36a7c93..ac32849 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 0837bf5..83a62ac 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 -- 1.9.3