Move code from cpu_mb_init() to a QOM initfn.

Signed-off-by: Andreas Färber <afaer...@suse.de>
---
 target-microblaze/cpu.c       |   12 ++++++++++++
 target-microblaze/translate.c |    3 ---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/target-microblaze/cpu.c b/target-microblaze/cpu.c
index 194131b..7fdc26c 100644
--- a/target-microblaze/cpu.c
+++ b/target-microblaze/cpu.c
@@ -82,6 +82,17 @@ static void mb_cpu_reset(CPUState *s)
 #endif
 }
 
+static void mb_cpu_initfn(Object *obj)
+{
+    MicroBlazeCPU *cpu = MICROBLAZE_CPU(obj);
+    CPUMBState *env = &cpu->env;
+
+    cpu_exec_init(env);
+
+    set_float_rounding_mode(float_round_nearest_even, &env->fp_status);
+    cpu_reset(CPU(cpu));
+}
+
 static void mb_cpu_class_init(ObjectClass *oc, void *data)
 {
     CPUClass *cc = CPU_CLASS(oc);
@@ -95,6 +106,7 @@ static const TypeInfo mb_cpu_type_info = {
     .name = TYPE_MICROBLAZE_CPU,
     .parent = TYPE_CPU,
     .instance_size = sizeof(MicroBlazeCPU),
+    .instance_init = mb_cpu_initfn,
     .class_size = sizeof(MicroBlazeCPUClass),
     .class_init = mb_cpu_class_init,
 };
diff --git a/target-microblaze/translate.c b/target-microblaze/translate.c
index 91149a3..6765599 100644
--- a/target-microblaze/translate.c
+++ b/target-microblaze/translate.c
@@ -1898,10 +1898,7 @@ CPUMBState *cpu_mb_init (const char *cpu_model)
     cpu = MICROBLAZE_CPU(object_new(TYPE_MICROBLAZE_CPU));
     env = &cpu->env;
 
-    cpu_exec_init(env);
-    cpu_reset(CPU(cpu));
     qemu_init_vcpu(env);
-    set_float_rounding_mode(float_round_nearest_even, &env->fp_status);
 
     if (tcg_initialized)
         return env;
-- 
1.7.7


Reply via email to