mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-09 10:34:58 -06:00
hw/intc/loongarch_ipi: Add reset support
Add reset support with ipi object, register reset callback and clear internal registers when virt machine resets. Signed-off-by: Bibo Mao <maobibo@loongson.cn> Reviewed-by: Song Gao <gaosong@loongson.cn>
This commit is contained in:
parent
5134cf9b5d
commit
36ad84ecb2
2 changed files with 30 additions and 0 deletions
|
@ -93,6 +93,32 @@ static void loongarch_ipi_realize(DeviceState *dev, Error **errp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void loongarch_ipi_reset_hold(Object *obj, ResetType type)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
LoongarchIPIClass *lic = LOONGARCH_IPI_GET_CLASS(obj);
|
||||||
|
LoongsonIPICommonState *lics = LOONGSON_IPI_COMMON(obj);
|
||||||
|
IPICore *core;
|
||||||
|
|
||||||
|
if (lic->parent_phases.hold) {
|
||||||
|
lic->parent_phases.hold(obj, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < lics->num_cpu; i++) {
|
||||||
|
core = lics->cpu + i;
|
||||||
|
/* IPI with targeted CPU available however not present */
|
||||||
|
if (!core->cpu) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
core->status = 0;
|
||||||
|
core->en = 0;
|
||||||
|
core->set = 0;
|
||||||
|
core->clear = 0;
|
||||||
|
memset(core->buf, 0, sizeof(core->buf));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void loongarch_ipi_cpu_plug(HotplugHandler *hotplug_dev,
|
static void loongarch_ipi_cpu_plug(HotplugHandler *hotplug_dev,
|
||||||
DeviceState *dev, Error **errp)
|
DeviceState *dev, Error **errp)
|
||||||
{
|
{
|
||||||
|
@ -145,10 +171,13 @@ static void loongarch_ipi_class_init(ObjectClass *klass, const void *data)
|
||||||
LoongsonIPICommonClass *licc = LOONGSON_IPI_COMMON_CLASS(klass);
|
LoongsonIPICommonClass *licc = LOONGSON_IPI_COMMON_CLASS(klass);
|
||||||
HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass);
|
HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass);
|
||||||
LoongarchIPIClass *lic = LOONGARCH_IPI_CLASS(klass);
|
LoongarchIPIClass *lic = LOONGARCH_IPI_CLASS(klass);
|
||||||
|
ResettableClass *rc = RESETTABLE_CLASS(klass);
|
||||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||||
|
|
||||||
device_class_set_parent_realize(dc, loongarch_ipi_realize,
|
device_class_set_parent_realize(dc, loongarch_ipi_realize,
|
||||||
&lic->parent_realize);
|
&lic->parent_realize);
|
||||||
|
resettable_class_set_parent_phases(rc, NULL, loongarch_ipi_reset_hold,
|
||||||
|
NULL, &lic->parent_phases);
|
||||||
licc->get_iocsr_as = get_iocsr_as;
|
licc->get_iocsr_as = get_iocsr_as;
|
||||||
licc->cpu_by_arch_id = loongarch_cpu_by_arch_id;
|
licc->cpu_by_arch_id = loongarch_cpu_by_arch_id;
|
||||||
hc->plug = loongarch_ipi_cpu_plug;
|
hc->plug = loongarch_ipi_cpu_plug;
|
||||||
|
|
|
@ -21,6 +21,7 @@ struct LoongarchIPIState {
|
||||||
struct LoongarchIPIClass {
|
struct LoongarchIPIClass {
|
||||||
LoongsonIPICommonClass parent_class;
|
LoongsonIPICommonClass parent_class;
|
||||||
DeviceRealize parent_realize;
|
DeviceRealize parent_realize;
|
||||||
|
ResettablePhases parent_phases;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue