Patchwork [qom-cpu,v2,5/8] target-lm32: Update VMStateDescription to LM32CPU

login
register
mail settings
Submitter Andreas Färber
Date Feb. 18, 2013, 7:42 p.m.
Message ID <1361216553-4549-6-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/221524/
State New
Headers show

Comments

Andreas Färber - Feb. 18, 2013, 7:42 p.m.
Expose vmstate_cpu as vmstate_lm32_cpu and hook it up to CPUClass::vmsd.
Adapt VMState fields to LM32CPU. Drop cpu_{save,load}().

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 target-lm32/cpu-qom.h |    6 ++++++
 target-lm32/cpu.c     |    2 ++
 target-lm32/cpu.h     |    2 --
 target-lm32/machine.c |   36 +++++++++++++-----------------------
 4 Dateien geändert, 21 Zeilen hinzugefügt(+), 25 Zeilen entfernt(-)
Juan Quintela - Feb. 22, 2013, 1:10 p.m.
Andreas Färber <afaerber@suse.de> wrote:
> Expose vmstate_cpu as vmstate_lm32_cpu and hook it up to CPUClass::vmsd.
> Adapt VMState fields to LM32CPU. Drop cpu_{save,load}().
>
> Signed-off-by: Andreas Färber <afaerber@suse.de>

Reviewed-by: Juan Quintela <quintela@redhat.com>

Patch

diff --git a/target-lm32/cpu-qom.h b/target-lm32/cpu-qom.h
index d7525b3..23c605e 100644
--- a/target-lm32/cpu-qom.h
+++ b/target-lm32/cpu-qom.h
@@ -69,5 +69,11 @@  static inline LM32CPU *lm32_env_get_cpu(CPULM32State *env)
 
 #define ENV_GET_CPU(e) CPU(lm32_env_get_cpu(e))
 
+#ifdef CONFIG_USER_ONLY
+#define vmstate_lm32_cpu vmstate_dummy
+#else
+extern const struct VMStateDescription vmstate_lm32_cpu;
+#endif
+
 
 #endif
diff --git a/target-lm32/cpu.c b/target-lm32/cpu.c
index a2badb5..0f443b9 100644
--- a/target-lm32/cpu.c
+++ b/target-lm32/cpu.c
@@ -83,6 +83,8 @@  static void lm32_cpu_class_init(ObjectClass *oc, void *data)
 
     lcc->parent_reset = cc->reset;
     cc->reset = lm32_cpu_reset;
+
+    cc->vmsd = &vmstate_lm32_cpu;
 }
 
 static const TypeInfo lm32_cpu_type_info = {
diff --git a/target-lm32/cpu.h b/target-lm32/cpu.h
index 6948d0e..e0bbe04 100644
--- a/target-lm32/cpu.h
+++ b/target-lm32/cpu.h
@@ -212,8 +212,6 @@  static inline CPULM32State *cpu_init(const char *cpu_model)
 #define cpu_gen_code cpu_lm32_gen_code
 #define cpu_signal_handler cpu_lm32_signal_handler
 
-#define CPU_SAVE_VERSION 1
-
 int cpu_lm32_handle_mmu_fault(CPULM32State *env, target_ulong address, int rw,
                               int mmu_idx);
 #define cpu_handle_mmu_fault cpu_lm32_handle_mmu_fault
diff --git a/target-lm32/machine.c b/target-lm32/machine.c
index 6802e81..aa4a9e1 100644
--- a/target-lm32/machine.c
+++ b/target-lm32/machine.c
@@ -1,33 +1,23 @@ 
 #include "hw/hw.h"
 #include "hw/boards.h"
 
-static const VMStateDescription vmstate_cpu = {
+const VMStateDescription vmstate_lm32_cpu = {
     .name = "cpu",
-    .version_id = CPU_SAVE_VERSION,
+    .version_id = 1,
     .minimum_version_id = 1,
     .minimum_version_id_old = 1,
     .fields      = (VMStateField[]) {
-        VMSTATE_UINT32_ARRAY(regs, CPULM32State, 32),
-        VMSTATE_UINT32(pc, CPULM32State),
-        VMSTATE_UINT32(ie, CPULM32State),
-        VMSTATE_UINT32(icc, CPULM32State),
-        VMSTATE_UINT32(dcc, CPULM32State),
-        VMSTATE_UINT32(cc, CPULM32State),
-        VMSTATE_UINT32(eba, CPULM32State),
-        VMSTATE_UINT32(dc, CPULM32State),
-        VMSTATE_UINT32(deba, CPULM32State),
-        VMSTATE_UINT32_ARRAY(bp, CPULM32State, 4),
-        VMSTATE_UINT32_ARRAY(wp, CPULM32State, 4),
+        VMSTATE_UINT32_ARRAY(env.regs, LM32CPU, 32),
+        VMSTATE_UINT32(env.pc, LM32CPU),
+        VMSTATE_UINT32(env.ie, LM32CPU),
+        VMSTATE_UINT32(env.icc, LM32CPU),
+        VMSTATE_UINT32(env.dcc, LM32CPU),
+        VMSTATE_UINT32(env.cc, LM32CPU),
+        VMSTATE_UINT32(env.eba, LM32CPU),
+        VMSTATE_UINT32(env.dc, LM32CPU),
+        VMSTATE_UINT32(env.deba, LM32CPU),
+        VMSTATE_UINT32_ARRAY(env.bp, LM32CPU, 4),
+        VMSTATE_UINT32_ARRAY(env.wp, LM32CPU, 4),
         VMSTATE_END_OF_LIST()
     }
 };
-
-void cpu_save(QEMUFile *f, void *opaque)
-{
-    vmstate_save_state(f, &vmstate_cpu, opaque);
-}
-
-int cpu_load(QEMUFile *f, void *opaque, int version_id)
-{
-    return vmstate_load_state(f, &vmstate_cpu, opaque, version_id);
-}