From: Eric Auger <eric.auger@linaro.org>
To: eric.auger@st.com, eric.auger@linaro.org, qemu-devel@nongnu.org,
alex.williamson@redhat.com, peter.maydell@linaro.org,
agraf@suse.de, pbonzini@redhat.com
Cc: kvmarm@lists.cs.columbia.edu, patches@linaro.org
Subject: [PATCH 1/2] irq: add get_gsi callback
Date: Thu, 23 Apr 2015 09:49:36 +0100 [thread overview]
Message-ID: <1429778977-1632-2-git-send-email-eric.auger@linaro.org> (raw)
In-Reply-To: <1429778977-1632-1-git-send-email-eric.auger@linaro.org>
Add a new IRQState get_gsi_cb field, corresponding to a callback
that transforms the interrupt controller pin number into a global
system interrupt number.
A setter is introduced for the interrupt controller to populate the
callback. Also add a public function that calls this callback.
Signed-off-by: Eric Auger <eric.auger@linaro.org>
---
hw/core/irq.c | 20 ++++++++++++++++++++
include/hw/irq.h | 8 ++++++++
2 files changed, 28 insertions(+)
diff --git a/hw/core/irq.c b/hw/core/irq.c
index 8a62a36..7eeb742 100644
--- a/hw/core/irq.c
+++ b/hw/core/irq.c
@@ -31,6 +31,7 @@ struct IRQState {
Object parent_obj;
qemu_irq_handler handler;
+ qemu_irq_get_gsi_t get_gsi_cb;
void *opaque;
int n;
};
@@ -144,6 +145,25 @@ void qemu_irq_intercept_in(qemu_irq *gpio_in, qemu_irq_handler handler, int n)
}
}
+int qemu_irq_set_get_gsi_cb(qemu_irq irq, qemu_irq_get_gsi_t cb)
+{
+ if (!irq) {
+ return -ENXIO;
+ }
+
+ irq->get_gsi_cb = cb;
+ return 0;
+}
+
+int qemu_irq_get_gsi(qemu_irq irq)
+{
+ if (!irq) {
+ return -ENXIO;
+ }
+
+ return irq->get_gsi_cb(irq->n);
+}
+
static const TypeInfo irq_type_info = {
.name = TYPE_IRQ,
.parent = TYPE_OBJECT,
diff --git a/include/hw/irq.h b/include/hw/irq.h
index 4c4c2ea..658b8f2 100644
--- a/include/hw/irq.h
+++ b/include/hw/irq.h
@@ -8,6 +8,7 @@
typedef struct IRQState *qemu_irq;
typedef void (*qemu_irq_handler)(void *opaque, int n, int level);
+typedef int (*qemu_irq_get_gsi_t)(int pin);
void qemu_set_irq(qemu_irq irq, int level);
@@ -62,4 +63,11 @@ qemu_irq *qemu_irq_proxy(qemu_irq **target, int n);
on an existing vector of qemu_irq. */
void qemu_irq_intercept_in(qemu_irq *gpio_in, qemu_irq_handler handler, int n);
+/* sets the get_gsi callback (function that converts the interrupt
+ controller pin into a global system interrupt number */
+int qemu_irq_set_get_gsi_cb(qemu_irq irq, qemu_irq_get_gsi_t cb);
+
+/* returns the gsi associated to a qemu_irq handle */
+int qemu_irq_get_gsi(qemu_irq irq);
+
#endif
--
1.8.3.2
next prev parent reply other threads:[~2015-04-23 8:41 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-23 8:49 [PATCH 0/2] irq: add get_gsi callback Eric Auger
2015-04-23 8:49 ` Eric Auger [this message]
2015-04-23 8:49 ` [PATCH 2/2] intc: arm_gic_kvm: set the " Eric Auger
2015-04-23 9:30 ` [PATCH 0/2] irq: add " Paolo Bonzini
2015-04-23 9:40 ` Eric Auger
2015-04-23 9:58 ` Paolo Bonzini
2015-04-23 11:25 ` Eric Auger
2015-04-24 9:01 ` Eric Auger
2015-04-24 9:11 ` Paolo Bonzini
2015-04-24 9:18 ` Eric Auger
2015-04-24 9:29 ` Paolo Bonzini
2015-04-24 9:48 ` Eric Auger
2015-04-24 10:02 ` Paolo Bonzini
2015-04-24 11:59 ` Eric Auger
2015-04-24 12:04 ` Paolo Bonzini
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=1429778977-1632-2-git-send-email-eric.auger@linaro.org \
--to=eric.auger@linaro.org \
--cc=agraf@suse.de \
--cc=alex.williamson@redhat.com \
--cc=eric.auger@st.com \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=patches@linaro.org \
--cc=pbonzini@redhat.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