diff mbox

[15/19] hw: Add an IRQ interface

Message ID 1483111310-24808-16-git-send-email-minyard@acm.org
State New
Headers show

Commit Message

Corey Minyard Dec. 30, 2016, 3:21 p.m. UTC
From: Corey Minyard <cminyard@mvista.com>


This allows IRQs to be created that can be found by other devices
so they can be used without having a direct tie to the irq.

Signed-off-by: Corey Minyard <cminyard@mvista.com>

---
 hw/core/Makefile.objs |  1 +
 hw/core/irqif.c       | 39 +++++++++++++++++++++++++++++++++++++++
 include/hw/irqif.h    | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 89 insertions(+)
 create mode 100644 hw/core/irqif.c
 create mode 100644 include/hw/irqif.h

-- 
2.7.4
diff mbox

Patch

diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs
index a4c94e5..764af1c 100644
--- a/hw/core/Makefile.objs
+++ b/hw/core/Makefile.objs
@@ -6,6 +6,7 @@  common-obj-y += fw-path-provider.o
 common-obj-y += irq.o
 common-obj-y += hotplug.o
 obj-y += nmi.o
+common-obj-y += irqif.o
 
 common-obj-$(CONFIG_EMPTY_SLOT) += empty_slot.o
 common-obj-$(CONFIG_XILINX_AXI) += stream.o
diff --git a/hw/core/irqif.c b/hw/core/irqif.c
new file mode 100644
index 0000000..12449af
--- /dev/null
+++ b/hw/core/irqif.c
@@ -0,0 +1,39 @@ 
+/*
+ * Interrupt Interface class
+ *
+ * Copyright (c) 2015,2016 Corey Minyard, MontaVista Software, LLC
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/irqif.h"
+
+static TypeInfo irq_interface_type_info = {
+    .name = TYPE_IRQ_INTERFACE,
+    .parent = TYPE_INTERFACE,
+    .class_size = sizeof(IRQInterfaceClass),
+};
+
+static void ipmi_register_types(void)
+{
+    type_register_static(&irq_interface_type_info);
+}
+
+type_init(ipmi_register_types)
diff --git a/include/hw/irqif.h b/include/hw/irqif.h
new file mode 100644
index 0000000..d733363
--- /dev/null
+++ b/include/hw/irqif.h
@@ -0,0 +1,49 @@ 
+/*
+ * Interrupt Interface class
+ *
+ * Copyright (c) 2015,2016 Corey Minyard, MontaVista Software, LLC
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef HW_IRQIF_H
+#define HW_IRQIF_H
+
+#include "hw/hw.h"
+#include "hw/irq.h"
+
+#define TYPE_IRQ_INTERFACE "irq-interface"
+#define IRQ_INTERFACE(obj) \
+     INTERFACE_CHECK(IRQInterface, (obj), TYPE_IRQ_INTERFACE)
+#define IRQ_INTERFACE_CLASS(class) \
+     OBJECT_CLASS_CHECK(IRQInterfaceClass, (class), TYPE_IRQ_INTERFACE)
+#define IRQ_INTERFACE_GET_CLASS(class) \
+     OBJECT_GET_CLASS(IRQInterfaceClass, (class), TYPE_IRQ_INTERFACE)
+
+typedef struct IRQInterface {
+    Object parent;
+} IRQInterface;
+
+typedef struct IRQInterfaceClass {
+    InterfaceClass parent;
+
+    qemu_irq *(*get_irq)(struct IRQInterface *ii);
+} IRQInterfaceClass;
+
+#endif /* HW_IRQIF_H */