Patchwork [v3,3/4] target-ppc: Start QOM'ifying CPU init

login
register
mail settings
Submitter Andreas Färber
Date April 14, 2012, 12:14 a.m.
Message ID <1334362452-31624-4-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/152459/
State New
Headers show

Comments

Andreas Färber - April 14, 2012, 12:14 a.m.
Move code not dependent on ppc_def_t from cpu_ppc_init() into an initfn.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
[AF: Rebased on top of moved env->cpu_index fixup]
---
 target-ppc/helper.c         |    3 ++-
 target-ppc/translate_init.c |    9 +++++++++
 2 files changed, 11 insertions(+), 1 deletions(-)

Patch

diff --git a/target-ppc/helper.c b/target-ppc/helper.c
index 5fe587a..a7c7dbc 100644
--- a/target-ppc/helper.c
+++ b/target-ppc/helper.c
@@ -3196,10 +3196,11 @@  CPUPPCState *cpu_ppc_init (const char *cpu_model)
 
     cpu = POWERPC_CPU(object_new(TYPE_POWERPC_CPU));
     env = &cpu->env;
-    cpu_exec_init(env);
+
     if (tcg_enabled()) {
         ppc_translate_init();
     }
+
     env->cpu_model_str = cpu_model;
     cpu_ppc_register_internal(env, def);
 
diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index e4d15a5..5a7ac77 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -10217,6 +10217,14 @@  static void ppc_cpu_reset(CPUState *s)
     cpu_state_reset(env);
 }
 
+static void ppc_cpu_initfn(Object *obj)
+{
+    PowerPCCPU *cpu = POWERPC_CPU(obj);
+    CPUPPCState *env = &cpu->env;
+
+    cpu_exec_init(env);
+}
+
 static void ppc_cpu_class_init(ObjectClass *oc, void *data)
 {
     PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);
@@ -10230,6 +10238,7 @@  static const TypeInfo ppc_cpu_type_info = {
     .name = TYPE_POWERPC_CPU,
     .parent = TYPE_CPU,
     .instance_size = sizeof(PowerPCCPU),
+    .instance_init = ppc_cpu_initfn,
     .abstract = false,
     .class_size = sizeof(PowerPCCPUClass),
     .class_init = ppc_cpu_class_init,