From: Michael Walle <michael@walle.cc>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Michael Walle <michael@walle.cc>,
Anthony Liguori <aliguori@amazon.com>
Subject: [Qemu-devel] [RFC PATCH] qtest: new functions for pulsed IRQs
Date: Wed, 25 Feb 2015 00:26:07 +0100 [thread overview]
Message-ID: <1424820367-25676-1-git-send-email-michael@walle.cc> (raw)
It is only possible to retrieve the current state of an interrupt line. But
there are devices which just pulses the interrupt line. Introduce a latch
which is set by qtest and which can be cleared by the test case.
Signed-off-by: Michael Walle <michael@walle.cc>
---
tests/libqtest.c | 19 +++++++++++++++++++
tests/libqtest.h | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+)
diff --git a/tests/libqtest.c b/tests/libqtest.c
index 9a92aa7..4707e9c 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -44,6 +44,7 @@ struct QTestState
int fd;
int qmp_fd;
bool irq_level[MAX_IRQ];
+ bool irq_latch[MAX_IRQ];
GString *rx;
pid_t qemu_pid; /* our child QEMU process */
struct sigaction sigact_old; /* restored on exit */
@@ -194,6 +195,7 @@ QTestState *qtest_init(const char *extra_args)
s->rx = g_string_new("");
for (i = 0; i < MAX_IRQ; i++) {
s->irq_level[i] = false;
+ s->irq_latch[i] = false;
}
/* Read the QMP greeting and then do the handshake */
@@ -314,6 +316,7 @@ redo:
if (strcmp(words[1], "raise") == 0) {
s->irq_level[irq] = true;
+ s->irq_latch[irq] = true;
} else {
s->irq_level[irq] = false;
}
@@ -466,6 +469,22 @@ bool qtest_get_irq(QTestState *s, int num)
return s->irq_level[num];
}
+bool qtest_get_irq_latched(QTestState *s, int num)
+{
+ g_assert_cmpint(num, <, MAX_IRQ);
+
+ /* dummy operation in order to make sure irq is up to date */
+ qtest_inb(s, 0);
+
+ return s->irq_latch[num];
+}
+
+void qtest_clear_irq_latch(QTestState *s, int num)
+{
+ g_assert_cmpint(num, <, MAX_IRQ);
+ s->irq_latch[num] = false;
+}
+
static int64_t qtest_clock_rsp(QTestState *s)
{
gchar **words;
diff --git a/tests/libqtest.h b/tests/libqtest.h
index e7413d5..8d21986 100644
--- a/tests/libqtest.h
+++ b/tests/libqtest.h
@@ -101,6 +101,24 @@ QDict *qtest_qmp_receive(QTestState *s);
bool qtest_get_irq(QTestState *s, int num);
/**
+ * qtest_get_irq_latched:
+ * @s: #QTestState instance to operate on.
+ * @num: Interrupt to observe.
+ *
+ * Returns: The latched state of the @num interrupt.
+ */
+bool qtest_get_irq_latched(QTestState *s, int num);
+
+/**
+ * qtest_clear_irq_latch:
+ * @s: #QTestState instance to operate on.
+ * @num: Interrupt to operate on.
+ *
+ * Clears the latch of the @num interrupt.
+ */
+void qtest_clear_irq_latch(QTestState *s, int num);
+
+/**
* qtest_irq_intercept_in:
* @s: #QTestState instance to operate on.
* @string: QOM path of a device.
@@ -408,6 +426,28 @@ static inline bool get_irq(int num)
}
/**
+ * get_irq_latched:
+ * @num: Interrupt to observe.
+ *
+ * Returns: The latched level of the @num interrupt.
+ */
+static inline bool get_irq_latched(int num)
+{
+ return qtest_get_irq_latched(global_qtest, num);
+}
+
+/**
+ * clear_irq_latch:
+ * @num: Interrupt to operate on.
+ *
+ * Clears the latch of the @num interrupt.
+ */
+static inline void clear_irq_latch(int num)
+{
+ return qtest_clear_irq_latch(global_qtest, num);
+}
+
+/**
* irq_intercept_in:
* @string: QOM path of a device.
*
--
2.1.4
reply other threads:[~2015-02-24 23:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1424820367-25676-1-git-send-email-michael@walle.cc \
--to=michael@walle.cc \
--cc=aliguori@amazon.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).