From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47984) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMJCH-00016Y-Hr for qemu-devel@nongnu.org; Fri, 13 Feb 2015 11:34:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YMJCB-0002jT-E6 for qemu-devel@nongnu.org; Fri, 13 Feb 2015 11:34:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56752) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMJCB-0002jJ-5P for qemu-devel@nongnu.org; Fri, 13 Feb 2015 11:34:23 -0500 From: Stefan Hajnoczi Date: Fri, 13 Feb 2015 16:24:29 +0000 Message-Id: <1423844701-21041-34-git-send-email-stefanha@redhat.com> In-Reply-To: <1423844701-21041-1-git-send-email-stefanha@redhat.com> References: <1423844701-21041-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PULL 33/65] libqos/ahci: add ahci command size setters List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , John Snow , Stefan Hajnoczi From: John Snow Adds setters for size, prd_size and both via set_sizes. Reviewed-by: Stefan Hajnoczi Signed-off-by: John Snow Message-id: 1423158090-25580-15-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi --- tests/libqos/ahci.c | 22 ++++++++++++++++++++++ tests/libqos/ahci.h | 4 ++++ 2 files changed, 26 insertions(+) diff --git a/tests/libqos/ahci.c b/tests/libqos/ahci.c index ce1f0ef..2a5d8c4 100644 --- a/tests/libqos/ahci.c +++ b/tests/libqos/ahci.c @@ -660,6 +660,28 @@ void ahci_command_set_buffer(AHCICommand *cmd, uint64_t buffer) cmd->buffer = buffer; } +void ahci_command_set_sizes(AHCICommand *cmd, uint64_t xbytes, + unsigned prd_size) +{ + /* Each PRD can describe up to 4MiB, and must not be odd. */ + g_assert_cmphex(prd_size, <=, 4096 * 1024); + g_assert_cmphex(prd_size & 0x01, ==, 0x00); + cmd->prd_size = prd_size; + cmd->xbytes = xbytes; + cmd->fis.count = (cmd->xbytes / AHCI_SECTOR_SIZE); + cmd->header.prdtl = size_to_prdtl(cmd->xbytes, cmd->prd_size); +} + +void ahci_command_set_size(AHCICommand *cmd, uint64_t xbytes) +{ + ahci_command_set_sizes(cmd, xbytes, cmd->prd_size); +} + +void ahci_command_set_prd_size(AHCICommand *cmd, unsigned prd_size) +{ + ahci_command_set_sizes(cmd, cmd->xbytes, prd_size); +} + void ahci_command_commit(AHCIQState *ahci, AHCICommand *cmd, uint8_t port) { uint16_t i, prdtl; diff --git a/tests/libqos/ahci.h b/tests/libqos/ahci.h index 26ccdd6..57ff344 100644 --- a/tests/libqos/ahci.h +++ b/tests/libqos/ahci.h @@ -533,6 +533,10 @@ void ahci_command_free(AHCICommand *cmd); /* Command adjustments */ void ahci_command_set_buffer(AHCICommand *cmd, uint64_t buffer); +void ahci_command_set_size(AHCICommand *cmd, uint64_t xbytes); +void ahci_command_set_prd_size(AHCICommand *cmd, unsigned prd_size); +void ahci_command_set_sizes(AHCICommand *cmd, uint64_t xbytes, + unsigned prd_size); /* Command Misc */ uint8_t ahci_command_slot(AHCICommand *cmd); -- 2.1.0