[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 07/18] hw/intc/loongarch_pch: Add pre_save and post_load interface
From: |
Bibo Mao |
Subject: |
[PULL 07/18] hw/intc/loongarch_pch: Add pre_save and post_load interfaces |
Date: |
Fri, 13 Dec 2024 17:40:16 +0800 |
Add vmstate pre_save and post_load interfaces, which can be used
by pic kvm driver in future.
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>
---
hw/intc/loongarch_pic_common.c | 26 ++++++++++++++++++++++++++
include/hw/intc/loongarch_pic_common.h | 2 ++
2 files changed, 28 insertions(+)
diff --git a/hw/intc/loongarch_pic_common.c b/hw/intc/loongarch_pic_common.c
index 28e9376557..a74b6c7b44 100644
--- a/hw/intc/loongarch_pic_common.c
+++ b/hw/intc/loongarch_pic_common.c
@@ -10,6 +10,30 @@
#include "hw/qdev-properties.h"
#include "migration/vmstate.h"
+static int loongarch_pic_pre_save(void *opaque)
+{
+ LoongArchPICCommonState *s = (LoongArchPICCommonState *)opaque;
+ LoongArchPICCommonClass *lpcc = LOONGARCH_PIC_COMMON_GET_CLASS(s);
+
+ if (lpcc->pre_save) {
+ return lpcc->pre_save(s);
+ }
+
+ return 0;
+}
+
+static int loongarch_pic_post_load(void *opaque, int version_id)
+{
+ LoongArchPICCommonState *s = (LoongArchPICCommonState *)opaque;
+ LoongArchPICCommonClass *lpcc = LOONGARCH_PIC_COMMON_GET_CLASS(s);
+
+ if (lpcc->post_load) {
+ return lpcc->post_load(s, version_id);
+ }
+
+ return 0;
+}
+
static void loongarch_pic_common_realize(DeviceState *dev, Error **errp)
{
LoongArchPICCommonState *s = LOONGARCH_PIC_COMMON(dev);
@@ -29,6 +53,8 @@ static const VMStateDescription vmstate_loongarch_pic_common
= {
.name = "loongarch_pch_pic",
.version_id = 1,
.minimum_version_id = 1,
+ .pre_save = loongarch_pic_pre_save,
+ .post_load = loongarch_pic_post_load,
.fields = (const VMStateField[]) {
VMSTATE_UINT64(int_mask, LoongArchPICCommonState),
VMSTATE_UINT64(htmsi_en, LoongArchPICCommonState),
diff --git a/include/hw/intc/loongarch_pic_common.h
b/include/hw/intc/loongarch_pic_common.h
index 0a1a28063c..43cce48978 100644
--- a/include/hw/intc/loongarch_pic_common.h
+++ b/include/hw/intc/loongarch_pic_common.h
@@ -76,5 +76,7 @@ struct LoongArchPICCommonClass {
SysBusDeviceClass parent_class;
DeviceRealize parent_realize;
+ int (*pre_save)(LoongArchPICCommonState *s);
+ int (*post_load)(LoongArchPICCommonState *s, int version_id);
};
#endif /* HW_LOONGARCH_PIC_COMMON_H */
--
2.43.5
- [PULL 00/18] loongarch-to-apply queue, Bibo Mao, 2024/12/13
- [PULL 05/18] hw/intc/loongarch_pch: Move some functions to file loongarch_pic_common, Bibo Mao, 2024/12/13
- [PULL 03/18] hw/intc/loongarch_pch: Merge instance_init() into realize(), Bibo Mao, 2024/12/13
- [PULL 01/18] include: Add loongarch_pic_common header file, Bibo Mao, 2024/12/13
- [PULL 07/18] hw/intc/loongarch_pch: Add pre_save and post_load interfaces,
Bibo Mao <=
- [PULL 02/18] include: Move struct LoongArchPCHPIC to loongarch_pic_common header file, Bibo Mao, 2024/12/13
- [PULL 08/18] hw/intc/loongarch_pch: Code cleanup about loongarch_pch_pic, Bibo Mao, 2024/12/13
- [PULL 06/18] hw/intc/loongarch_pch: Inherit from loongarch_pic_common, Bibo Mao, 2024/12/13
- [PULL 04/18] hw/intc/loongarch_pch: Rename LoongArchPCHPIC with LoongArchPICCommonState, Bibo Mao, 2024/12/13
- [PULL 09/18] include: Add loongarch_extioi_common header file, Bibo Mao, 2024/12/13
- [PULL 10/18] include: Move struct LoongArchExtIOI to header file loongarch_extioi_common, Bibo Mao, 2024/12/13
- [PULL 11/18] include: Rename LoongArchExtIOI with LoongArchExtIOICommonState, Bibo Mao, 2024/12/13
- [PULL 12/18] hw/intc/loongarch_extioi: Rename LoongArchExtIOI with LoongArchExtIOICommonState, Bibo Mao, 2024/12/13
- Re: [PULL 00/18] loongarch-to-apply queue, Stefan Hajnoczi, 2024/12/14