summaryrefslogtreecommitdiff
path: root/tests/libqtest.c
diff options
context:
space:
mode:
authorAndreas Färber <afaerber@suse.de>2013-02-16 22:44:03 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2013-02-18 08:39:10 -0600
commit872536bf5dfdf207d275cd627caec2aefb68aab9 (patch)
treedc65a96f89f6f0fa41c3f1298f8ad1e1748de961 /tests/libqtest.c
parentb73cf9e93f1c7fd6e949f71172c49848b4d70aa9 (diff)
downloadqemu-872536bf5dfdf207d275cd627caec2aefb68aab9.tar.gz
qemu-872536bf5dfdf207d275cd627caec2aefb68aab9.tar.bz2
qemu-872536bf5dfdf207d275cd627caec2aefb68aab9.zip
qtest: Add MMIO support
Introduce [qtest_]{read,write}[bwlq]() libqtest functions and corresponding QTest protocol commands to replace local versions in libi2c-omap.c. Also convert m48t59-test's cmos_{read,write}_mmio() to {read,write}b(). Signed-off-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Andreas Färber <afaerber@suse.de> Message-id: 1361051043-27944-4-git-send-email-afaerber@suse.de Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'tests/libqtest.c')
-rw-r--r--tests/libqtest.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/libqtest.c b/tests/libqtest.c
index da58ff5034..389596a055 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -3,10 +3,12 @@
*
* Copyright IBM, Corp. 2012
* Copyright Red Hat, Inc. 2012
+ * Copyright SUSE LINUX Products GmbH 2013
*
* Authors:
* Anthony Liguori <aliguori@us.ibm.com>
* Paolo Bonzini <pbonzini@redhat.com>
+ * Andreas Färber <afaerber@suse.de>
*
* This work is licensed under the terms of the GNU GPL, version 2 or later.
* See the COPYING file in the top-level directory.
@@ -437,6 +439,66 @@ uint32_t qtest_inl(QTestState *s, uint16_t addr)
return qtest_in(s, "inl", addr);
}
+static void qtest_write(QTestState *s, const char *cmd, uint64_t addr,
+ uint64_t value)
+{
+ qtest_sendf(s, "%s 0x%" PRIx64 " 0x%" PRIx64 "\n", cmd, addr, value);
+ qtest_rsp(s, 0);
+}
+
+void qtest_writeb(QTestState *s, uint64_t addr, uint8_t value)
+{
+ qtest_write(s, "writeb", addr, value);
+}
+
+void qtest_writew(QTestState *s, uint64_t addr, uint16_t value)
+{
+ qtest_write(s, "writew", addr, value);
+}
+
+void qtest_writel(QTestState *s, uint64_t addr, uint32_t value)
+{
+ qtest_write(s, "writel", addr, value);
+}
+
+void qtest_writeq(QTestState *s, uint64_t addr, uint64_t value)
+{
+ qtest_write(s, "writeq", addr, value);
+}
+
+static uint64_t qtest_read(QTestState *s, const char *cmd, uint64_t addr)
+{
+ gchar **args;
+ uint64_t value;
+
+ qtest_sendf(s, "%s 0x%" PRIx64 "\n", cmd, addr);
+ args = qtest_rsp(s, 2);
+ value = strtoull(args[1], NULL, 0);
+ g_strfreev(args);
+
+ return value;
+}
+
+uint8_t qtest_readb(QTestState *s, uint64_t addr)
+{
+ return qtest_read(s, "readb", addr);
+}
+
+uint16_t qtest_readw(QTestState *s, uint64_t addr)
+{
+ return qtest_read(s, "readw", addr);
+}
+
+uint32_t qtest_readl(QTestState *s, uint64_t addr)
+{
+ return qtest_read(s, "readl", addr);
+}
+
+uint64_t qtest_readq(QTestState *s, uint64_t addr)
+{
+ return qtest_read(s, "readq", addr);
+}
+
static int hex2nib(char ch)
{
if (ch >= '0' && ch <= '9') {