qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC qom-cpu v2 7/8] target-openrisc: Register VMStateDescr


From: Andreas Färber
Subject: [Qemu-devel] [RFC qom-cpu v2 7/8] target-openrisc: Register VMStateDescription for OpenRISCCPU
Date: Mon, 18 Feb 2013 20:42:32 +0100

Since commit e67db06e9f6d7e514ee2a9b9b769ecd42977f6fb (target-or32: Add
target stubs and QOM cpu) a VMStateDescription existed, but
CPU_SAVE_VERSION was not set, so it was never registered.

Register it through CPUState.
Use a version_id of 1 and specify minimum versions as well.

Cc: Jia Liu <address@hidden>
Signed-off-by: Andreas Färber <address@hidden>
---
 target-openrisc/cpu.c     |    2 ++
 target-openrisc/cpu.h     |    6 +++++-
 target-openrisc/machine.c |   33 +++++++++++++--------------------
 3 Dateien geändert, 20 Zeilen hinzugefügt(+), 21 Zeilen entfernt(-)

diff --git a/target-openrisc/cpu.c b/target-openrisc/cpu.c
index 72d5e8d..5a7b495 100644
--- a/target-openrisc/cpu.c
+++ b/target-openrisc/cpu.c
@@ -19,6 +19,7 @@
 
 #include "cpu.h"
 #include "qemu-common.h"
+#include "migration/vmstate.h"
 
 /* CPUClass::reset() */
 static void openrisc_cpu_reset(CPUState *s)
@@ -148,6 +149,7 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void 
*data)
     cc->reset = openrisc_cpu_reset;
 
     cc->class_by_name = openrisc_cpu_class_by_name;
+    cc->vmsd = &vmstate_openrisc_cpu;
 }
 
 static void cpu_register(const OpenRISCCPUInfo *info)
diff --git a/target-openrisc/cpu.h b/target-openrisc/cpu.h
index 419f007..cb35ea3 100644
--- a/target-openrisc/cpu.h
+++ b/target-openrisc/cpu.h
@@ -357,7 +357,11 @@ int cpu_openrisc_signal_handler(int host_signum, void 
*pinfo, void *puc);
 #define cpu_handle_mmu_fault cpu_openrisc_handle_mmu_fault
 #define cpu_signal_handler cpu_openrisc_signal_handler
 
-#ifndef CONFIG_USER_ONLY
+#ifdef CONFIG_USER_ONLY
+#define vmstate_openrisc_cpu vmstate_dummy
+#else
+extern const struct VMStateDescription vmstate_openrisc_cpu;
+
 /* hw/openrisc_pic.c */
 void cpu_openrisc_pic_init(OpenRISCCPU *cpu);
 
diff --git a/target-openrisc/machine.c b/target-openrisc/machine.c
index cba9811..7d335e0 100644
--- a/target-openrisc/machine.c
+++ b/target-openrisc/machine.c
@@ -20,28 +20,21 @@
 #include "hw/hw.h"
 #include "hw/boards.h"
 
-static const VMStateDescription vmstate_cpu = {
+const VMStateDescription vmstate_openrisc_cpu = {
     .name = "cpu",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
-        VMSTATE_UINT32_ARRAY(gpr, CPUOpenRISCState, 32),
-        VMSTATE_UINT32(sr, CPUOpenRISCState),
-        VMSTATE_UINT32(epcr, CPUOpenRISCState),
-        VMSTATE_UINT32(eear, CPUOpenRISCState),
-        VMSTATE_UINT32(esr, CPUOpenRISCState),
-        VMSTATE_UINT32(fpcsr, CPUOpenRISCState),
-        VMSTATE_UINT32(pc, CPUOpenRISCState),
-        VMSTATE_UINT32(npc, CPUOpenRISCState),
-        VMSTATE_UINT32(ppc, CPUOpenRISCState),
+        VMSTATE_UINT32_ARRAY(env.gpr, OpenRISCCPU, 32),
+        VMSTATE_UINT32(env.sr, OpenRISCCPU),
+        VMSTATE_UINT32(env.epcr, OpenRISCCPU),
+        VMSTATE_UINT32(env.eear, OpenRISCCPU),
+        VMSTATE_UINT32(env.esr, OpenRISCCPU),
+        VMSTATE_UINT32(env.fpcsr, OpenRISCCPU),
+        VMSTATE_UINT32(env.pc, OpenRISCCPU),
+        VMSTATE_UINT32(env.npc, OpenRISCCPU),
+        VMSTATE_UINT32(env.ppc, OpenRISCCPU),
         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);
-}
-- 
1.7.10.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]