@@ -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,
@@ -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
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(+)