Patchwork [RFC,qom-cpu-next,4/6] target-alpha: Register VMStateDescription for AlphaCPU

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

Comments

Andreas Färber - Feb. 2, 2013, 3:04 p.m.
Commit b758aca1f6cdb175634812b79f5560c36c902d00 (target-alpha: Enable
the alpha-softmmu target.) introduced cpu_{save,load}() functions but
didn't define CPU_SAVE_VERSION, so they were never registered.

Drop cpu_{save,load}() and register the VMStateDescription via CPUClass.
This operates on the AlphaCPU object instead of CPUAlphaState.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 target-alpha/cpu-qom.h |    2 ++
 target-alpha/cpu.c     |    3 +++
 target-alpha/machine.c |   64 ++++++++++++++++++++++--------------------------
 3 Dateien geändert, 34 Zeilen hinzugefügt(+), 35 Zeilen entfernt(-)

Patch

diff --git a/target-alpha/cpu-qom.h b/target-alpha/cpu-qom.h
index c0f6c6d..2cf6511 100644
--- a/target-alpha/cpu-qom.h
+++ b/target-alpha/cpu-qom.h
@@ -72,5 +72,7 @@  static inline AlphaCPU *alpha_env_get_cpu(CPUAlphaState *env)
 
 #define ENV_GET_CPU(e) CPU(alpha_env_get_cpu(e))
 
+extern const struct VMStateDescription vmstate_alpha_cpu;
+
 
 #endif
diff --git a/target-alpha/cpu.c b/target-alpha/cpu.c
index 0cdae69..09f8cdc 100644
--- a/target-alpha/cpu.c
+++ b/target-alpha/cpu.c
@@ -261,6 +261,9 @@  static void alpha_cpu_class_init(ObjectClass *oc, void *data)
     dc->realize = alpha_cpu_realizefn;
 
     cc->class_by_name = alpha_cpu_class_by_name;
+#ifndef CONFIG_USER_ONLY
+    cc->vmsd = &vmstate_alpha_cpu;
+#endif
 }
 
 static const TypeInfo alpha_cpu_type_info = {
diff --git a/target-alpha/machine.c b/target-alpha/machine.c
index 1c9edd1..bdad91e 100644
--- a/target-alpha/machine.c
+++ b/target-alpha/machine.c
@@ -3,14 +3,18 @@ 
 
 static int get_fpcr(QEMUFile *f, void *opaque, size_t size)
 {
-    CPUAlphaState *env = opaque;
+    AlphaCPU *cpu = opaque;
+    CPUAlphaState *env = &cpu->env;
+
     cpu_alpha_store_fpcr(env, qemu_get_be64(f));
     return 0;
 }
 
 static void put_fpcr(QEMUFile *f, void *opaque, size_t size)
 {
-    CPUAlphaState *env = opaque;
+    AlphaCPU *cpu = opaque;
+    CPUAlphaState *env = &cpu->env;
+
     qemu_put_be64(f, cpu_alpha_load_fpcr(env));
 }
 
@@ -21,8 +25,8 @@  static const VMStateInfo vmstate_fpcr = {
 };
 
 static VMStateField vmstate_cpu_fields[] = {
-    VMSTATE_UINTTL_ARRAY(ir, CPUAlphaState, 31),
-    VMSTATE_UINTTL_ARRAY(fir, CPUAlphaState, 31),
+    VMSTATE_UINTTL_ARRAY(env.ir, AlphaCPU, 31),
+    VMSTATE_UINTTL_ARRAY(env.fir, AlphaCPU, 31),
     /* Save the architecture value of the fpcr, not the internally
        expanded version.  Since this architecture value does not
        exist in memory to be stored, this requires a but of hoop
@@ -37,51 +41,41 @@  static VMStateField vmstate_cpu_fields[] = {
         .flags = VMS_SINGLE,
         .offset = 0
     },
-    VMSTATE_UINTTL(pc, CPUAlphaState),
-    VMSTATE_UINTTL(unique, CPUAlphaState),
-    VMSTATE_UINTTL(lock_addr, CPUAlphaState),
-    VMSTATE_UINTTL(lock_value, CPUAlphaState),
+    VMSTATE_UINTTL(env.pc, AlphaCPU),
+    VMSTATE_UINTTL(env.unique, AlphaCPU),
+    VMSTATE_UINTTL(env.lock_addr, AlphaCPU),
+    VMSTATE_UINTTL(env.lock_value, AlphaCPU),
     /* Note that lock_st_addr is not saved; it is a temporary
        used during the execution of the st[lq]_c insns.  */
 
-    VMSTATE_UINT8(ps, CPUAlphaState),
-    VMSTATE_UINT8(intr_flag, CPUAlphaState),
-    VMSTATE_UINT8(pal_mode, CPUAlphaState),
-    VMSTATE_UINT8(fen, CPUAlphaState),
+    VMSTATE_UINT8(env.ps, AlphaCPU),
+    VMSTATE_UINT8(env.intr_flag, AlphaCPU),
+    VMSTATE_UINT8(env.pal_mode, AlphaCPU),
+    VMSTATE_UINT8(env.fen, AlphaCPU),
 
-    VMSTATE_UINT32(pcc_ofs, CPUAlphaState),
+    VMSTATE_UINT32(env.pcc_ofs, AlphaCPU),
 
-    VMSTATE_UINTTL(trap_arg0, CPUAlphaState),
-    VMSTATE_UINTTL(trap_arg1, CPUAlphaState),
-    VMSTATE_UINTTL(trap_arg2, CPUAlphaState),
+    VMSTATE_UINTTL(env.trap_arg0, AlphaCPU),
+    VMSTATE_UINTTL(env.trap_arg1, AlphaCPU),
+    VMSTATE_UINTTL(env.trap_arg2, AlphaCPU),
 
-    VMSTATE_UINTTL(exc_addr, CPUAlphaState),
-    VMSTATE_UINTTL(palbr, CPUAlphaState),
-    VMSTATE_UINTTL(ptbr, CPUAlphaState),
-    VMSTATE_UINTTL(vptptr, CPUAlphaState),
-    VMSTATE_UINTTL(sysval, CPUAlphaState),
-    VMSTATE_UINTTL(usp, CPUAlphaState),
+    VMSTATE_UINTTL(env.exc_addr, AlphaCPU),
+    VMSTATE_UINTTL(env.palbr, AlphaCPU),
+    VMSTATE_UINTTL(env.ptbr, AlphaCPU),
+    VMSTATE_UINTTL(env.vptptr, AlphaCPU),
+    VMSTATE_UINTTL(env.sysval, AlphaCPU),
+    VMSTATE_UINTTL(env.usp, AlphaCPU),
 
-    VMSTATE_UINTTL_ARRAY(shadow, CPUAlphaState, 8),
-    VMSTATE_UINTTL_ARRAY(scratch, CPUAlphaState, 24),
+    VMSTATE_UINTTL_ARRAY(env.shadow, AlphaCPU, 8),
+    VMSTATE_UINTTL_ARRAY(env.scratch, AlphaCPU, 24),
 
     VMSTATE_END_OF_LIST()
 };
 
-static const VMStateDescription vmstate_cpu = {
+const VMStateDescription vmstate_alpha_cpu = {
     .name = "cpu",
     .version_id = 1,
     .minimum_version_id = 1,
     .minimum_version_id_old = 1,
     .fields = vmstate_cpu_fields,
 };
-
-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);
-}