Patchwork [RFC,qom-cpu-next,3/6] target-lm32: Update VMStateDescription to LM32CPU

login
register
mail settings
Submitter Andreas Färber
Date Feb. 2, 2013, 3:04 p.m.
Message ID <1359817456-25561-4-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/217669/
State New
Headers show

Comments

Andreas Färber - Feb. 2, 2013, 3:04 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 |    2 ++
 target-lm32/cpu.c     |    4 ++++
 target-lm32/cpu.h     |    2 --
 target-lm32/machine.c |   36 +++++++++++++-----------------------
 4 Dateien geändert, 19 Zeilen hinzugefügt(+), 25 Zeilen entfernt(-)

Patch

diff --git a/target-lm32/cpu-qom.h b/target-lm32/cpu-qom.h
index d7525b3..9dd9d66 100644
--- a/target-lm32/cpu-qom.h
+++ b/target-lm32/cpu-qom.h
@@ -69,5 +69,7 @@  static inline LM32CPU *lm32_env_get_cpu(CPULM32State *env)
 
 #define ENV_GET_CPU(e) CPU(lm32_env_get_cpu(e))
 
+extern const struct VMStateDescription vmstate_lm32_cpu;
+
 
 #endif
diff --git a/target-lm32/cpu.c b/target-lm32/cpu.c
index 5f16734..89c365b 100644
--- a/target-lm32/cpu.c
+++ b/target-lm32/cpu.c
@@ -81,6 +81,10 @@  static void lm32_cpu_class_init(ObjectClass *oc, void *data)
 
     lcc->parent_reset = cc->reset;
     cc->reset = lm32_cpu_reset;
+
+#ifndef CONFIG_USER_ONLY
+    cc->vmsd = &vmstate_lm32_cpu;
+#endif
 }
 
 static const TypeInfo lm32_cpu_type_info = {
diff --git a/target-lm32/cpu.h b/target-lm32/cpu.h
index 4e202db..65fc366 100644
--- a/target-lm32/cpu.h
+++ b/target-lm32/cpu.h
@@ -213,8 +213,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);
-}