aboutsummaryrefslogtreecommitdiff
path: root/tests/libqos
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2015-02-05 12:41:27 -0500
committerStefan Hajnoczi <stefanha@redhat.com>2015-02-16 15:07:17 +0000
commitae029620173239f3643925299790ecc5e1d72db1 (patch)
tree0f8b5023f041258f0b265e36f018479d5c2eeee6 /tests/libqos
parent113221956cb819837dda5350e3f9d52819183805 (diff)
downloadqemu-ae029620173239f3643925299790ecc5e1d72db1.zip
qemu-ae029620173239f3643925299790ecc5e1d72db1.tar.gz
qemu-ae029620173239f3643925299790ecc5e1d72db1.tar.bz2
libqos/ahci: add ahci_io
ahci_io is a wrapper around ahci_guest_io that takes a pointer to host memory instead, and will create a guest memory buffer and copy the data to/from as needed and as appropriate for a read/write command, such that after a read, the guest data will be in a host buffer, and for a write, the data will be transmitted to guest memory prior to the block operation. Now that we have all the syntactic sugar functions in place for AHCI, we can convert the identify test to be very, very short. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1423158090-25580-17-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'tests/libqos')
-rw-r--r--tests/libqos/ahci.c25
-rw-r--r--tests/libqos/ahci.h2
2 files changed, 27 insertions, 0 deletions
diff --git a/tests/libqos/ahci.c b/tests/libqos/ahci.c
index 345d1f1..8522224 100644
--- a/tests/libqos/ahci.c
+++ b/tests/libqos/ahci.c
@@ -592,6 +592,31 @@ static AHCICommandProp *ahci_command_find(uint8_t command_name)
return NULL;
}
+/* Given a HOST buffer, create a buffer address and perform an IO operation. */
+void ahci_io(AHCIQState *ahci, uint8_t port, uint8_t ide_cmd,
+ void *buffer, size_t bufsize)
+{
+ uint64_t ptr;
+ AHCICommandProp *props;
+
+ props = ahci_command_find(ide_cmd);
+ g_assert(props);
+ ptr = ahci_alloc(ahci, bufsize);
+ g_assert(ptr);
+
+ if (props->write) {
+ memwrite(ptr, buffer, bufsize);
+ }
+
+ ahci_guest_io(ahci, port, ide_cmd, ptr, bufsize);
+
+ if (props->read) {
+ memread(ptr, buffer, bufsize);
+ }
+
+ ahci_free(ahci, ptr);
+}
+
/**
* Initializes a basic command header in memory.
* We assume that this is for an ATA command using RegH2DFIS.
diff --git a/tests/libqos/ahci.h b/tests/libqos/ahci.h
index 1206c7a..9133033 100644
--- a/tests/libqos/ahci.h
+++ b/tests/libqos/ahci.h
@@ -523,6 +523,8 @@ unsigned ahci_pick_cmd(AHCIQState *ahci, uint8_t port);
unsigned size_to_prdtl(unsigned bytes, unsigned bytes_per_prd);
void ahci_guest_io(AHCIQState *ahci, uint8_t port, uint8_t ide_cmd,
uint64_t gbuffer, size_t size);
+void ahci_io(AHCIQState *ahci, uint8_t port, uint8_t ide_cmd,
+ void *buffer, size_t bufsize);
/* Command Lifecycle */
AHCICommand *ahci_command_create(uint8_t command_name);