aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorBibo Mao <maobibo@loongson.cn>2024-09-18 11:50:49 +0800
committerBibo Mao <maobibo@loongson.cn>2024-12-19 15:23:29 +0800
commit36d31cf812848ee65ab03ca901e7b140f5538a7a (patch)
tree6474dba9ab266129d14dc6abfa655fcbca6c9965 /hw
parent8bf26a9ea3c8067e04c36b0280b219958955196c (diff)
downloadqemu-36d31cf812848ee65ab03ca901e7b140f5538a7a.zip
qemu-36d31cf812848ee65ab03ca901e7b140f5538a7a.tar.gz
qemu-36d31cf812848ee65ab03ca901e7b140f5538a7a.tar.bz2
hw/intc/loongarch_pch: Add pre_save and post_load interfaces
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>
Diffstat (limited to 'hw')
-rw-r--r--hw/intc/loongarch_pic_common.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/hw/intc/loongarch_pic_common.c b/hw/intc/loongarch_pic_common.c
index f97e383..bcb6b7b 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),