target-sh4: Introduce QOM realizefn for SuperHCPU
authorAndreas Färber <afaerber@suse.de>
Mon, 23 Apr 2012 16:16:02 +0000 (18:16 +0200)
committerAndreas Färber <afaerber@suse.de>
Sat, 16 Feb 2013 13:50:57 +0000 (14:50 +0100)
Introduce a realizefn and set realized = true in cpu_sh4_init().

Signed-off-by: Andreas Färber <afaerber@suse.de>
target-sh4/cpu-qom.h
target-sh4/cpu.c
target-sh4/translate.c

index 09573c9c34f6e5a848c058914477bd48f8c1bbca..d368db1b0a4c0f45b0d98835292540086a9dfd28 100644 (file)
@@ -33,6 +33,7 @@
 
 /**
  * SuperHCPUClass:
+ * @parent_realize: The parent class' realize handler.
  * @parent_reset: The parent class' reset handler.
  *
  * A SuperH CPU model.
@@ -42,6 +43,7 @@ typedef struct SuperHCPUClass {
     CPUClass parent_class;
     /*< public >*/
 
+    DeviceRealize parent_realize;
     void (*parent_reset)(CPUState *cpu);
 } SuperHCPUClass;
 
index d2831226b9da918f6b841d9a859cfa1d9ee86d2f..c66442f445e87c817e3da487b231fbddeb64ed01 100644 (file)
@@ -54,6 +54,17 @@ static void superh_cpu_reset(CPUState *s)
     set_default_nan_mode(1, &env->fp_status);
 }
 
+static void superh_cpu_realizefn(DeviceState *dev, Error **errp)
+{
+    SuperHCPU *cpu = SUPERH_CPU(dev);
+    SuperHCPUClass *scc = SUPERH_CPU_GET_CLASS(dev);
+
+    cpu_reset(CPU(cpu));
+    qemu_init_vcpu(&cpu->env);
+
+    scc->parent_realize(dev, errp);
+}
+
 static void superh_cpu_initfn(Object *obj)
 {
     SuperHCPU *cpu = SUPERH_CPU(obj);
@@ -75,6 +86,9 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data)
     CPUClass *cc = CPU_CLASS(oc);
     SuperHCPUClass *scc = SUPERH_CPU_CLASS(oc);
 
+    scc->parent_realize = dc->realize;
+    dc->realize = superh_cpu_realizefn;
+
     scc->parent_reset = cc->reset;
     cc->reset = superh_cpu_reset;
 
index 260aaab5596194b638c7c67e9aa6aa06b65c1214..2409a103b25a59b7f7db9e3348dd11eede8df49f 100644 (file)
@@ -253,9 +253,10 @@ SuperHCPU *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);
+
+    object_property_set_bool(OBJECT(cpu), true, "realized", NULL);
+
     return cpu;
 }