hw/intc/loongson_ipi: Add load and save interface with ipi_common class

Add pre_save and post_load interfaces with ipi_common class, here only
framework ipi_common adds these interfaces. The defailed implementation
is LoongArchIPI child device in later.

Reviewed-by: Song Gao <gaosong@loongson.cn>
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Message-ID: <20250606063033.2557365-5-maobibo@loongson.cn>
Signed-off-by: Song Gao <gaosong@loongson.cn>
This commit is contained in:
Bibo Mao 2025-06-06 14:30:24 +08:00 committed by Song Gao
parent 412f655566
commit 14be318c95
2 changed files with 30 additions and 0 deletions

View file

@ -282,10 +282,38 @@ static void loongson_ipi_common_unrealize(DeviceState *dev)
g_free(s->cpu);
}
static int loongson_ipi_common_pre_save(void *opaque)
{
IPICore *ipicore = (IPICore *)opaque;
LoongsonIPICommonState *s = ipicore->ipi;
LoongsonIPICommonClass *licc = LOONGSON_IPI_COMMON_GET_CLASS(s);
if (licc->pre_save) {
return licc->pre_save(s);
}
return 0;
}
static int loongson_ipi_common_post_load(void *opaque, int version_id)
{
IPICore *ipicore = (IPICore *)opaque;
LoongsonIPICommonState *s = ipicore->ipi;
LoongsonIPICommonClass *licc = LOONGSON_IPI_COMMON_GET_CLASS(s);
if (licc->post_load) {
return licc->post_load(s, version_id);
}
return 0;
}
static const VMStateDescription vmstate_ipi_core = {
.name = "ipi-single",
.version_id = 2,
.minimum_version_id = 2,
.pre_save = loongson_ipi_common_pre_save,
.post_load = loongson_ipi_common_post_load,
.fields = (const VMStateField[]) {
VMSTATE_UINT32(status, IPICore),
VMSTATE_UINT32(en, IPICore),

View file

@ -48,6 +48,8 @@ struct LoongsonIPICommonClass {
AddressSpace *(*get_iocsr_as)(CPUState *cpu);
int (*cpu_by_arch_id)(LoongsonIPICommonState *lics, int64_t id,
int *index, CPUState **pcs);
int (*pre_save)(void *opaque);
int (*post_load)(void *opaque, int version_id);
};
MemTxResult loongson_ipi_core_readl(void *opaque, hwaddr addr, uint64_t *data,