Patchwork [RFC,qom-cpu,07/15] target-lm32: Introduce QOM realizefn for LM32CPU

login
register
mail settings
Submitter Andreas Färber
Date Jan. 16, 2013, 5:32 a.m.
Message ID <1358314380-9400-8-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/212411/
State New
Headers show

Comments

Andreas Färber - Jan. 16, 2013, 5:32 a.m.
Introduce a realizefn and set realized = true in cpu_lm32_init().

Also move cpu_reset() call from initfn to realizefn.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 target-lm32/cpu.c    |   14 ++++++++++++--
 target-lm32/helper.c |    4 ++--
 2 Dateien geändert, 14 Zeilen hinzugefügt(+), 4 Zeilen entfernt(-)

Patch

diff --git a/target-lm32/cpu.c b/target-lm32/cpu.c
index eca2dca..dfca130 100644
--- a/target-lm32/cpu.c
+++ b/target-lm32/cpu.c
@@ -42,6 +42,15 @@  static void lm32_cpu_reset(CPUState *s)
     memset(env, 0, offsetof(CPULM32State, breakpoints));
 }
 
+static void lm32_cpu_realizefn(DeviceState *dev, Error **errp)
+{
+    LM32CPU *cpu = LM32_CPU(dev);
+
+    cpu_reset(CPU(cpu));
+
+    qemu_init_vcpu(&cpu->env);
+}
+
 static void lm32_cpu_initfn(Object *obj)
 {
     LM32CPU *cpu = LM32_CPU(obj);
@@ -50,14 +59,15 @@  static void lm32_cpu_initfn(Object *obj)
     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);
     CPUClass *cc = CPU_CLASS(oc);
+    DeviceClass *dc = DEVICE_CLASS(oc);
+
+    dc->realize = lm32_cpu_realizefn;
 
     lcc->parent_reset = cc->reset;
     cc->reset = lm32_cpu_reset;
diff --git a/target-lm32/helper.c b/target-lm32/helper.c
index d76ea3f..a6691ad 100644
--- a/target-lm32/helper.c
+++ b/target-lm32/helper.c
@@ -212,13 +212,13 @@  LM32CPU *cpu_lm32_init(const char *cpu_model)
     env->num_wps = def->num_watchpoints;
     env->cfg = cfg_by_def(def);
 
-    qemu_init_vcpu(env);
-
     if (tcg_enabled() && !tcg_initialized) {
         tcg_initialized = 1;
         lm32_translate_init();
     }
 
+    object_property_set_bool(OBJECT(cpu), true, "realized", NULL);
+
     return cpu;
 }