aboutsummaryrefslogtreecommitdiff
path: root/hw/intc
diff options
context:
space:
mode:
authorBibo Mao <maobibo@loongson.cn>2025-01-10 16:38:42 +0800
committerBibo Mao <maobibo@loongson.cn>2025-03-05 09:39:17 +0800
commit8e63a7a7c2227ed014d55717c3a4de90bff426a8 (patch)
tree6e87dfcf1ec5d959e76177c2f673b269a9701d07 /hw/intc
parente45c96b7d62513327324e801c325b5b6530f8e4a (diff)
downloadqemu-8e63a7a7c2227ed014d55717c3a4de90bff426a8.zip
qemu-8e63a7a7c2227ed014d55717c3a4de90bff426a8.tar.gz
qemu-8e63a7a7c2227ed014d55717c3a4de90bff426a8.tar.bz2
hw/intc/loongarch_extioi: Implment cpu hotplug interface
When cpu is added, connect extioi gpio irq to CPU irq pin. Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Diffstat (limited to 'hw/intc')
-rw-r--r--hw/intc/loongarch_extioi_common.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/hw/intc/loongarch_extioi_common.c b/hw/intc/loongarch_extioi_common.c
index 19e19a9..ff3974f 100644
--- a/hw/intc/loongarch_extioi_common.c
+++ b/hw/intc/loongarch_extioi_common.c
@@ -12,28 +12,73 @@
#include "migration/vmstate.h"
#include "target/loongarch/cpu.h"
+static ExtIOICore *loongarch_extioi_get_cpu(LoongArchExtIOICommonState *s,
+ DeviceState *dev)
+{
+ CPUClass *k = CPU_GET_CLASS(dev);
+ uint64_t arch_id = k->get_arch_id(CPU(dev));
+ int i;
+
+ for (i = 0; i < s->num_cpu; i++) {
+ if (s->cpu[i].arch_id == arch_id) {
+ return &s->cpu[i];
+ }
+ }
+
+ return NULL;
+}
+
static void loongarch_extioi_cpu_plug(HotplugHandler *hotplug_dev,
DeviceState *dev, Error **errp)
{
+ LoongArchExtIOICommonState *s = LOONGARCH_EXTIOI_COMMON(hotplug_dev);
Object *obj = OBJECT(dev);
+ ExtIOICore *core;
+ int pin, index;
if (!object_dynamic_cast(obj, TYPE_LOONGARCH_CPU)) {
warn_report("LoongArch extioi: Invalid %s device type",
object_get_typename(obj));
return;
}
+
+ core = loongarch_extioi_get_cpu(s, dev);
+ if (!core) {
+ return;
+ }
+
+ core->cpu = CPU(dev);
+ index = core - s->cpu;
+
+ /*
+ * connect extioi irq to the cpu irq
+ * cpu_pin[LS3A_INTC_IP + 2 : 2] <= intc_pin[LS3A_INTC_IP : 0]
+ */
+ for (pin = 0; pin < LS3A_INTC_IP; pin++) {
+ qdev_connect_gpio_out(DEVICE(s), index * LS3A_INTC_IP + pin,
+ qdev_get_gpio_in(dev, pin + 2));
+ }
}
static void loongarch_extioi_cpu_unplug(HotplugHandler *hotplug_dev,
DeviceState *dev, Error **errp)
{
+ LoongArchExtIOICommonState *s = LOONGARCH_EXTIOI_COMMON(hotplug_dev);
Object *obj = OBJECT(dev);
+ ExtIOICore *core;
if (!object_dynamic_cast(obj, TYPE_LOONGARCH_CPU)) {
warn_report("LoongArch extioi: Invalid %s device type",
object_get_typename(obj));
return;
}
+
+ core = loongarch_extioi_get_cpu(s, dev);
+ if (!core) {
+ return;
+ }
+
+ core->cpu = NULL;
}
static void loongarch_extioi_common_realize(DeviceState *dev, Error **errp)