From: Chris Laplante <chris@laplante.io>
To: qemu-devel@nongnu.org
Cc: Joel Stanley <joel@jms.id.au>,
Peter Maydell <peter.maydell@linaro.org>,
qemu-arm@nongnu.org, Chris Laplante <chris@laplante.io>
Subject: [PATCH 2/6] qtest: implement named interception of out-GPIO
Date: Fri, 14 Jul 2023 23:27:21 +0000 [thread overview]
Message-ID: <20230714232659.76434-3-chris@laplante.io> (raw)
In-Reply-To: <20230714232659.76434-1-chris@laplante.io>
Adds qtest_irq_intercept_out_named method, which utilizes a new optional
name parameter to the irq_intercept_out qtest command.
Signed-off-by: Chris Laplante <chris@laplante.io>
---
softmmu/qtest.c | 39 ++++++++++++++++++++++++++-------------
tests/qtest/libqtest.c | 6 ++++++
tests/qtest/libqtest.h | 11 +++++++++++
3 files changed, 43 insertions(+), 13 deletions(-)
diff --git a/softmmu/qtest.c b/softmmu/qtest.c
index f8d764b719..7c3dea5760 100644
--- a/softmmu/qtest.c
+++ b/softmmu/qtest.c
@@ -388,8 +388,12 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
|| strcmp(words[0], "irq_intercept_in") == 0) {
DeviceState *dev;
NamedGPIOList *ngl;
+ bool is_named;
+ bool is_outbound;
g_assert(words[1]);
+ is_named = words[2] != NULL;
+ is_outbound = words[0][14] == 'o';
dev = DEVICE(object_resolve_path(words[1], NULL));
if (!dev) {
qtest_send_prefix(chr);
@@ -408,19 +412,28 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
}
QLIST_FOREACH(ngl, &dev->gpios, node) {
- /* We don't support intercept of named GPIOs yet */
- if (ngl->name) {
- continue;
- }
- if (words[0][14] == 'o') {
- int i;
- for (i = 0; i < ngl->num_out; ++i) {
- qemu_irq *disconnected = g_new0(qemu_irq, 1);
- qemu_irq icpt = qemu_allocate_irq(qtest_irq_handler,
- disconnected, i);
-
- *disconnected = qdev_intercept_gpio_out(dev, icpt,
- ngl->name, i);
+ /* We don't support inbound interception of named GPIOs yet */
+ if (is_outbound) {
+ if (is_named) {
+ if (ngl->name && strcmp(ngl->name, words[2]) == 0) {
+ qemu_irq *disconnected = g_new0(qemu_irq, 1);
+ qemu_irq icpt = qemu_allocate_irq(qtest_irq_handler,
+ disconnected, 0);
+
+ *disconnected = qdev_intercept_gpio_out(dev, icpt,
+ ngl->name, 0);
+ break;
+ }
+ } else if (!ngl->name) {
+ int i;
+ for (i = 0; i < ngl->num_out; ++i) {
+ qemu_irq *disconnected = g_new0(qemu_irq, 1);
+ qemu_irq icpt = qemu_allocate_irq(qtest_irq_handler,
+ disconnected, i);
+
+ *disconnected = qdev_intercept_gpio_out(dev, icpt,
+ ngl->name, i);
+ }
}
} else {
qemu_irq_intercept_in(ngl->in, qtest_irq_handler,
diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
index c22dfc30d3..471529e6cc 100644
--- a/tests/qtest/libqtest.c
+++ b/tests/qtest/libqtest.c
@@ -993,6 +993,12 @@ void qtest_irq_intercept_out(QTestState *s, const char *qom_path)
qtest_rsp(s);
}
+void qtest_irq_intercept_out_named(QTestState *s, const char *qom_path, const char *name)
+{
+ qtest_sendf(s, "irq_intercept_out %s %s\n", qom_path, name);
+ qtest_rsp(s);
+}
+
void qtest_irq_intercept_in(QTestState *s, const char *qom_path)
{
qtest_sendf(s, "irq_intercept_in %s\n", qom_path);
diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqtest.h
index 3a71bc45fc..e53e350e3a 100644
--- a/tests/qtest/libqtest.h
+++ b/tests/qtest/libqtest.h
@@ -371,6 +371,17 @@ void qtest_irq_intercept_in(QTestState *s, const char *string);
*/
void qtest_irq_intercept_out(QTestState *s, const char *string);
+/**
+ * qtest_irq_intercept_out_named:
+ * @s: #QTestState instance to operate on.
+ * @qom_path: QOM path of a device.
+ * @name: Name of the GPIO out pin
+ *
+ * Associate a qtest irq with the named GPIO-out pin of the device
+ * whose path is specified by @string and whose name is @name.
+ */
+void qtest_irq_intercept_out_named(QTestState *s, const char *qom_path, const char *name);
+
/**
* qtest_set_irq_in:
* @s: QTestState instance to operate on.
--
2.39.2
next prev parent reply other threads:[~2023-07-14 23:29 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-14 23:27 [PATCH 0/6] Add nRF51 DETECT signal with test Chris Laplante
2023-07-14 23:27 ` [PATCH 1/6] hw/gpio/nrf51: implement DETECT signal Chris Laplante
2023-07-24 16:10 ` Peter Maydell
2023-07-14 23:27 ` Chris Laplante [this message]
2023-07-14 23:27 ` [PATCH 3/6] qtest: bail from irq_intercept_in if name is specified Chris Laplante
2023-07-24 16:17 ` Peter Maydell
2023-07-14 23:27 ` [PATCH 4/6] qtest: factor out qtest_install_gpio_out_intercepts Chris Laplante
2023-07-24 16:18 ` Peter Maydell
2023-07-14 23:27 ` [PATCH 5/6] qtest: irq_intercept_[out/in]: return FAIL if no intercepts are installed Chris Laplante
2023-07-24 16:19 ` Peter Maydell
2023-07-25 4:03 ` Chris Laplante
2023-07-14 23:27 ` [PATCH 6/6] qtest: microbit-test: add tests for nRF51 DETECT Chris Laplante
2023-07-24 16:24 ` Peter Maydell
2023-07-24 16:27 ` [PATCH 0/6] Add nRF51 DETECT signal with test Peter Maydell
2023-07-25 3:24 ` Chris Laplante
2023-07-25 9:23 ` Peter Maydell
2023-07-26 2:58 ` Chris Laplante
2023-07-27 22:51 ` Chris Laplante
2023-07-28 9:32 ` Peter Maydell
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=20230714232659.76434-3-chris@laplante.io \
--to=chris@laplante.io \
--cc=joel@jms.id.au \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.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).