qemu-ppc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-ppc] [PATCH v3 28/35] intc: introduce a CPUIntc interface


From: Cédric Le Goater
Subject: [Qemu-ppc] [PATCH v3 28/35] intc: introduce a CPUIntc interface
Date: Thu, 19 Apr 2018 14:43:24 +0200

which we will use in the sPAPR machine to reset the interrupt
controller of each CPU at the KVM level.

Signed-off-by: Cédric Le Goater <address@hidden>
---
 hw/intc/intc.c         | 26 ++++++++++++++++++++++++++
 include/hw/intc/intc.h | 21 +++++++++++++++++++++
 2 files changed, 47 insertions(+)

diff --git a/hw/intc/intc.c b/hw/intc/intc.c
index 2e1e29e753a1..bb08ff51596a 100644
--- a/hw/intc/intc.c
+++ b/hw/intc/intc.c
@@ -32,10 +32,36 @@ static const TypeInfo intctrl_info = {
     .class_size = sizeof(InterruptStatsProviderClass),
 };
 
+static const TypeInfo cpu_intc_info = {
+    .name = TYPE_CPU_INTC,
+    .parent = TYPE_INTERFACE,
+    .class_size = sizeof(CPUIntcClass),
+};
+
 static void intc_register_types(void)
 {
+    type_register_static(&cpu_intc_info);
     type_register_static(&intctrl_info);
 }
 
 type_init(intc_register_types)
 
+void cpu_intc_disconnect(CPUIntc *intc, Error **errp)
+{
+    CPUIntcClass *cic;
+
+    cic = CPU_INTC_GET_CLASS(intc);
+    if (cic->disconnect) {
+        cic->disconnect(intc, errp);
+    }
+}
+
+void cpu_intc_connect(CPUIntc *intc, Error **errp)
+{
+    CPUIntcClass *cic;
+
+    cic = CPU_INTC_GET_CLASS(intc);
+    if (cic->connect) {
+        cic->connect(intc, errp);
+    }
+}
diff --git a/include/hw/intc/intc.h b/include/hw/intc/intc.h
index 27d9828943ae..3536e7d57ffd 100644
--- a/include/hw/intc/intc.h
+++ b/include/hw/intc/intc.h
@@ -30,4 +30,25 @@ typedef struct InterruptStatsProviderClass {
     void (*print_info)(InterruptStatsProvider *obj, Monitor *mon);
 } InterruptStatsProviderClass;
 
+#define TYPE_CPU_INTC "cpu-intc"
+#define CPU_INTC(obj)                                     \
+    OBJECT_CHECK(CPUIntc, (obj), TYPE_CPU_INTC)
+#define CPU_INTC_CLASS(klass)                                     \
+    OBJECT_CLASS_CHECK(CPUIntcClass, (klass), TYPE_CPU_INTC)
+#define CPU_INTC_GET_CLASS(obj)                                   \
+    OBJECT_GET_CLASS(CPUIntcClass, (obj), TYPE_CPU_INTC)
+
+typedef struct CPUIntc {
+    Object parent;
+} CPUIntc;
+
+typedef struct CPUIntcClass {
+    InterfaceClass parent;
+    void (*connect)(CPUIntc *icp, Error **errp);
+    void (*disconnect)(CPUIntc *icp, Error **errp);
+} CPUIntcClass;
+
+void cpu_intc_disconnect(CPUIntc *intc, Error **errp);
+void cpu_intc_connect(CPUIntc *intc, Error **errp);
+
 #endif
-- 
2.13.6




reply via email to

[Prev in Thread] Current Thread [Next in Thread]