Patchwork [v3,2/3] target-lm32: QOM'ify CPU init

login
register
mail settings
Submitter Andreas Färber
Date April 11, 2012, 11:19 p.m.
Message ID <1334186378-10904-3-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/151927/
State New
Headers show

Comments

Andreas Färber - April 11, 2012, 11:19 p.m.
Move code from cpu_lm32_init() to an initfn; call cpu_reset()
instead of cpu_state_reset().

Signed-off-by: Andreas Färber <afaerber@suse.de>
Acked-by: Michael Walle <michael@walle.cc>
---
 target-lm32/cpu.c    |   13 +++++++++++++
 target-lm32/helper.c |    3 ---
 2 files changed, 13 insertions(+), 3 deletions(-)

Patch

diff --git a/target-lm32/cpu.c b/target-lm32/cpu.c
index 4ce7e3b..70251d0 100644
--- a/target-lm32/cpu.c
+++ b/target-lm32/cpu.c
@@ -34,6 +34,18 @@  static void lm32_cpu_reset(CPUState *s)
     cpu_state_reset(env);
 }
 
+static void lm32_cpu_initfn(Object *obj)
+{
+    LM32CPU *cpu = LM32_CPU(obj);
+    CPULM32State *env = &cpu->env;
+
+    cpu_exec_init(env);
+
+    env->flags = 0;
+
+    cpu_reset(CPU(cpu));
+}
+
 static void lm32_cpu_class_init(ObjectClass *oc, void *data)
 {
     LM32CPUClass *lcc = LM32_CPU_CLASS(oc);
@@ -47,6 +59,7 @@  static const TypeInfo lm32_cpu_type_info = {
     .name = TYPE_LM32_CPU,
     .parent = TYPE_CPU,
     .instance_size = sizeof(LM32CPU),
+    .instance_init = lm32_cpu_initfn,
     .abstract = false,
     .class_size = sizeof(LM32CPUClass),
     .class_init = lm32_cpu_class_init,
diff --git a/target-lm32/helper.c b/target-lm32/helper.c
index 3cf86d7..9de777f 100644
--- a/target-lm32/helper.c
+++ b/target-lm32/helper.c
@@ -211,10 +211,7 @@  CPULM32State *cpu_lm32_init(const char *cpu_model)
     env->num_bps = def->num_breakpoints;
     env->num_wps = def->num_watchpoints;
     env->cfg = cfg_by_def(def);
-    env->flags = 0;
 
-    cpu_exec_init(env);
-    cpu_state_reset(env);
     qemu_init_vcpu(env);
 
     if (tcg_enabled() && !tcg_initialized) {