diff mbox

[RFC,5/5] hw/intc/arm_gicv3_common: Add vmstate descriptors

Message ID 1456172720-12650-6-git-send-email-peter.maydell@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Peter Maydell Feb. 22, 2016, 8:25 p.m. UTC
From: Pavel Fedin <p.fedin@samsung.com>

Add state structure descriptors and actually enable live migration.

In order to describe fixed-size bitmaps, VMSTATE_BITMAP_STATIC() macro is
introduced.

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
[PMM: Adjust to renamed struct fields]
---
 hw/intc/arm_gicv3_common.c  | 45 ++++++++++++++++++++++++++++++++++++++++++++-
 include/migration/vmstate.h |  9 +++++++++
 2 files changed, 53 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c
index a1ce4c1..e1078a5 100644
--- a/hw/intc/arm_gicv3_common.c
+++ b/hw/intc/arm_gicv3_common.c
@@ -48,11 +48,54 @@  static int gicv3_post_load(void *opaque, int version_id)
     return 0;
 }
 
+static const VMStateDescription vmstate_gicv3_cpu = {
+    .name = "arm_gicv3_cpu",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINT32(level, GICv3CPUState),
+        VMSTATE_UINT32(gicr_ctlr, GICv3CPUState),
+        VMSTATE_UINT32(gicr_waker, GICv3CPUState),
+        VMSTATE_UINT64(gicr_propbaser, GICv3CPUState),
+        VMSTATE_UINT64(gicr_pendbaser, GICv3CPUState),
+        VMSTATE_UINT32(gicr_igroupr0, GICv3CPUState),
+        VMSTATE_UINT32(gicr_ienabler0, GICv3CPUState),
+        VMSTATE_UINT32(gicr_ipendr0, GICv3CPUState),
+        VMSTATE_UINT32(gicr_iactiver0, GICv3CPUState),
+        VMSTATE_UINT32(gicr_icfgr0, GICv3CPUState),
+        VMSTATE_UINT32(gicr_icfgr1, GICv3CPUState),
+        VMSTATE_UINT8_ARRAY(gicr_ipriorityr, GICv3CPUState, GIC_INTERNAL),
+        VMSTATE_UINT64_ARRAY(icc_ctlr_el1, GICv3CPUState, 2),
+        VMSTATE_UINT64(icc_pmr_el1, GICv3CPUState),
+        VMSTATE_UINT64_ARRAY(icc_bpr, GICv3CPUState, 2),
+        VMSTATE_UINT64_2DARRAY(icc_ap1r, GICv3CPUState, 4, 2),
+        VMSTATE_UINT64(icc_igrpen0_el1, GICv3CPUState),
+        VMSTATE_UINT64(icc_igrpen1_el1, GICv3CPUState),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 static const VMStateDescription vmstate_gicv3 = {
     .name = "arm_gicv3",
-    .unmigratable = 1,
+    .version_id = 1,
+    .minimum_version_id = 1,
     .pre_save = gicv3_pre_save,
     .post_load = gicv3_post_load,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINT32(gicd_ctlr, GICv3State),
+        VMSTATE_BITMAP_STATIC(group, GICv3State , 0, GICV3_MAXSPI),
+        VMSTATE_BITMAP_STATIC(enabled, GICv3State , 0, GICV3_MAXSPI),
+        VMSTATE_BITMAP_STATIC(pending, GICv3State , 0, GICV3_MAXSPI),
+        VMSTATE_BITMAP_STATIC(active, GICv3State , 0, GICV3_MAXSPI),
+        VMSTATE_BITMAP_STATIC(level, GICv3State , 0, GICV3_MAXSPI),
+        VMSTATE_BITMAP_STATIC(edge_trigger, GICv3State , 0, GICV3_MAXSPI),
+        VMSTATE_UINT8_ARRAY(gicd_ipriority, GICv3State, GICV3_MAXSPI),
+        VMSTATE_UINT8_ARRAY(gicd_itargetsr, GICv3State, GICV3_MAXSPI),
+        VMSTATE_UINT64_ARRAY(gicd_irouter, GICv3State, GICV3_MAXSPI),
+        VMSTATE_STRUCT_VARRAY_POINTER_UINT32(cpu, GICv3State, num_cpu,
+                                             vmstate_gicv3_cpu, GICv3CPUState),
+        VMSTATE_END_OF_LIST()
+    }
 };
 
 void gicv3_init_irqs_and_mmio(GICv3State *s, qemu_irq_handler handler,
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index ecc4992..934809a 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -564,6 +564,15 @@  extern const VMStateInfo vmstate_info_bitmap;
     .offset       = offsetof(_state, _field),                        \
 }
 
+#define VMSTATE_BITMAP_STATIC(_field, _state, _version, _size) {     \
+    .name         = (stringify(_field)),                             \
+    .version_id   = (_version),                                      \
+    .size         = (_size),                                         \
+    .info         = &vmstate_info_bitmap,                            \
+    .flags        = VMS_BUFFER,                                      \
+    .offset       = offsetof(_state, _field),                        \
+}
+
 /* _f : field name
    _f_n : num of elements field_name
    _n : num of elements