mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 01:33:56 -06:00
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>
This commit is contained in:
parent
e45c96b7d6
commit
8e63a7a7c2
1 changed files with 45 additions and 0 deletions
|
@ -12,28 +12,73 @@
|
||||||
#include "migration/vmstate.h"
|
#include "migration/vmstate.h"
|
||||||
#include "target/loongarch/cpu.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,
|
static void loongarch_extioi_cpu_plug(HotplugHandler *hotplug_dev,
|
||||||
DeviceState *dev, Error **errp)
|
DeviceState *dev, Error **errp)
|
||||||
{
|
{
|
||||||
|
LoongArchExtIOICommonState *s = LOONGARCH_EXTIOI_COMMON(hotplug_dev);
|
||||||
Object *obj = OBJECT(dev);
|
Object *obj = OBJECT(dev);
|
||||||
|
ExtIOICore *core;
|
||||||
|
int pin, index;
|
||||||
|
|
||||||
if (!object_dynamic_cast(obj, TYPE_LOONGARCH_CPU)) {
|
if (!object_dynamic_cast(obj, TYPE_LOONGARCH_CPU)) {
|
||||||
warn_report("LoongArch extioi: Invalid %s device type",
|
warn_report("LoongArch extioi: Invalid %s device type",
|
||||||
object_get_typename(obj));
|
object_get_typename(obj));
|
||||||
return;
|
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,
|
static void loongarch_extioi_cpu_unplug(HotplugHandler *hotplug_dev,
|
||||||
DeviceState *dev, Error **errp)
|
DeviceState *dev, Error **errp)
|
||||||
{
|
{
|
||||||
|
LoongArchExtIOICommonState *s = LOONGARCH_EXTIOI_COMMON(hotplug_dev);
|
||||||
Object *obj = OBJECT(dev);
|
Object *obj = OBJECT(dev);
|
||||||
|
ExtIOICore *core;
|
||||||
|
|
||||||
if (!object_dynamic_cast(obj, TYPE_LOONGARCH_CPU)) {
|
if (!object_dynamic_cast(obj, TYPE_LOONGARCH_CPU)) {
|
||||||
warn_report("LoongArch extioi: Invalid %s device type",
|
warn_report("LoongArch extioi: Invalid %s device type",
|
||||||
object_get_typename(obj));
|
object_get_typename(obj));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
core = loongarch_extioi_get_cpu(s, dev);
|
||||||
|
if (!core) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
core->cpu = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void loongarch_extioi_common_realize(DeviceState *dev, Error **errp)
|
static void loongarch_extioi_common_realize(DeviceState *dev, Error **errp)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue