mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
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>
This commit is contained in:
parent
b73cf9e93f
commit
872536bf5d
7 changed files with 332 additions and 29 deletions
|
@ -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') {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue