@@ -7,6 +7,7 @@
#include "qemu/osdep.h"
#include "hw/boards.h"
+#include "qemu/error-report.h"
#include "hw/intc/loongarch_ipi.h"
#include "target/loongarch/cpu.h"
@@ -60,12 +61,39 @@ static int loongarch_cpu_by_arch_id(LoongsonIPICommonState *lics,
return MEMTX_ERROR;
}
+static void loongarch_cpu_plug(HotplugHandler *hotplug_dev,
+ DeviceState *dev, Error **errp)
+{
+ Object *obj = OBJECT(dev);
+
+ if (!object_dynamic_cast(obj, TYPE_LOONGARCH_CPU)) {
+ warn_report("LoongArch IPI: Invalid %s device type",
+ object_get_typename(obj));
+ return;
+ }
+}
+
+static void loongarch_cpu_unplug(HotplugHandler *hotplug_dev,
+ DeviceState *dev, Error **errp)
+{
+ Object *obj = OBJECT(dev);
+
+ if (!object_dynamic_cast(obj, TYPE_LOONGARCH_CPU)) {
+ warn_report("LoongArch IPI: Invalid %s device type",
+ object_get_typename(obj));
+ return;
+ }
+}
+
static void loongarch_ipi_class_init(ObjectClass *klass, void *data)
{
LoongsonIPICommonClass *licc = LOONGSON_IPI_COMMON_CLASS(klass);
+ HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass);
licc->get_iocsr_as = get_iocsr_as;
licc->cpu_by_arch_id = loongarch_cpu_by_arch_id;
+ hc->plug = loongarch_cpu_plug;
+ hc->unplug = loongarch_cpu_unplug;
}
static const TypeInfo loongarch_ipi_types[] = {
@@ -73,6 +101,10 @@ static const TypeInfo loongarch_ipi_types[] = {
.name = TYPE_LOONGARCH_IPI,
.parent = TYPE_LOONGSON_IPI_COMMON,
.class_init = loongarch_ipi_class_init,
+ .interfaces = (InterfaceInfo[]) {
+ { TYPE_HOTPLUG_HANDLER },
+ { }
+ }
}
};
LoongArch ipi can send interrupt to multiple CPUs, interrupt routing to CPU comes from destination physical cpu id. Here hotplug interface is added for IPI object, sot that logic cpu mapping from physical cpu id can be setup. Here only basic hotplug framework is added, it is stub function. Signed-off-by: Bibo Mao <maobibo@loongson.cn> --- hw/intc/loongarch_ipi.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)