diff mbox

[v4,4/4] target-sh4: Introduce realizefn for SuperHCPU

Message ID 1335201310-6498-5-git-send-email-afaerber@suse.de
State New
Headers show

Commit Message

Andreas Färber April 23, 2012, 5:15 p.m. UTC
To avoid moving cpu_reset() into an initfn for some targets, prepare a
realizefn with the designated signature but leave it non-static and call
it explicitly.
Do not declare a local env variable to avoid an unused variable
warning for *-user: qemu_init_vcpu() is a no-op macro there.

It is safe to reorder cpu_reset() and cpu_register() since there is no
overlap in the fields they touch.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 target-sh4/cpu-qom.h   |    3 +++
 target-sh4/cpu.c       |    8 ++++++++
 target-sh4/translate.c |    3 +--
 3 files changed, 12 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/target-sh4/cpu-qom.h b/target-sh4/cpu-qom.h
index c41164a..acaedb8 100644
--- a/target-sh4/cpu-qom.h
+++ b/target-sh4/cpu-qom.h
@@ -21,6 +21,7 @@ 
 #define QEMU_SUPERH_CPU_QOM_H
 
 #include "qemu/cpu.h"
+#include "error.h"
 
 #define TYPE_SUPERH_CPU "superh-cpu"
 
@@ -66,5 +67,7 @@  static inline SuperHCPU *sh_env_get_cpu(CPUSH4State *env)
 
 #define ENV_GET_CPU(e) CPU(sh_env_get_cpu(e))
 
+void superh_cpu_realize(Object *obj, Error **errp);
+
 
 #endif
diff --git a/target-sh4/cpu.c b/target-sh4/cpu.c
index a1a177f..4fb4776 100644
--- a/target-sh4/cpu.c
+++ b/target-sh4/cpu.c
@@ -53,6 +53,14 @@  static void superh_cpu_reset(CPUState *s)
     set_default_nan_mode(1, &env->fp_status);
 }
 
+void superh_cpu_realize(Object *obj, Error **errp)
+{
+    SuperHCPU *cpu = SUPERH_CPU(obj);
+
+    cpu_reset(CPU(cpu));
+    qemu_init_vcpu(&cpu->env);
+}
+
 static void superh_cpu_initfn(Object *obj)
 {
     SuperHCPU *cpu = SUPERH_CPU(obj);
diff --git a/target-sh4/translate.c b/target-sh4/translate.c
index d25f0c5..bfb80ba 100644
--- a/target-sh4/translate.c
+++ b/target-sh4/translate.c
@@ -261,9 +261,8 @@  CPUSH4State *cpu_sh4_init(const char *cpu_model)
     env->features = def->features;
     sh4_translate_init();
     env->cpu_model_str = cpu_model;
-    cpu_reset(CPU(cpu));
     cpu_register(env, def);
-    qemu_init_vcpu(env);
+    superh_cpu_realize(OBJECT(cpu), NULL);
     return env;
 }