From 9813dc6ac3954d58ba16b3920556f106f97e1c67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20G=C3=B6rtz?= Date: Mon, 7 Jan 2019 15:23:47 +0000 Subject: qtest: Add set_irq_in command to set IRQ/GPIO level MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a new qtest command "set_irq_in" which allows to set qemu gpio lines to a given level. Based on https://lists.gnu.org/archive/html/qemu-devel/2012-12/msg02363.html which never got merged. Signed-off-by: Steffen Görtz Reviewed-by: Stefan Hajnoczi Reviewed-by: Thomas Huth Reviewed-by: Laurent Vivier Signed-off-by: Stefan Hajnoczi Message-id: 20190103091119.9367-2-stefanha@redhat.com Originally-by: Matthew Ogilvie Reviewed-by: Stefan Hajnoczi Reviewed-by: Thomas Huth Reviewed-by: Laurent Vivier Signed-off-by: Stefan Hajnoczi Signed-off-by: Peter Maydell --- tests/libqtest.c | 10 ++++++++++ tests/libqtest.h | 13 +++++++++++++ 2 files changed, 23 insertions(+) (limited to 'tests') diff --git a/tests/libqtest.c b/tests/libqtest.c index 1d75d3c936..55750dd68d 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -753,6 +753,16 @@ void qtest_irq_intercept_in(QTestState *s, const char *qom_path) qtest_rsp(s, 0); } +void qtest_set_irq_in(QTestState *s, const char *qom_path, const char *name, + int num, int level) +{ + if (!name) { + name = "unnamed-gpio-in"; + } + qtest_sendf(s, "set_irq_in %s %s %d %d\n", qom_path, name, num, level); + qtest_rsp(s, 0); +} + static void qtest_out(QTestState *s, const char *cmd, uint16_t addr, uint32_t value) { qtest_sendf(s, "%s 0x%x 0x%x\n", cmd, addr, value); diff --git a/tests/libqtest.h b/tests/libqtest.h index 9758c51be6..7ea94139b0 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -230,6 +230,19 @@ void qtest_irq_intercept_in(QTestState *s, const char *string); */ void qtest_irq_intercept_out(QTestState *s, const char *string); +/** + * qtest_set_irq_in: + * @s: QTestState instance to operate on. + * @string: QOM path of a device + * @name: IRQ name + * @irq: IRQ number + * @level: IRQ level + * + * Force given device/irq GPIO-in pin to the given level. + */ +void qtest_set_irq_in(QTestState *s, const char *string, const char *name, + int irq, int level); + /** * qtest_outb: * @s: #QTestState instance to operate on. -- cgit v1.2.3