Patchwork [5/5] target-xtensa: Start QOM'ifying CPU init

login
register
mail settings
Submitter Max Filippov
Date April 14, 2012, 1 a.m.
Message ID <1334365213-15986-6-git-send-email-jcmvbkbc@gmail.com>
Download mbox | patch
Permalink /patch/152466/
State New
Headers show

Comments

Max Filippov - April 14, 2012, 1 a.m.
From: Andreas Färber <afaerber@suse.de>

Move XtensaConfig-independent code from cpu_xtensa_init() into a
QOM initfn, as a start.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 target-xtensa/cpu.c    |    9 +++++++++
 target-xtensa/helper.c |    1 -
 2 files changed, 9 insertions(+), 1 deletions(-)

Patch

diff --git a/target-xtensa/cpu.c b/target-xtensa/cpu.c
index 55d2dea..97deacb 100644
--- a/target-xtensa/cpu.c
+++ b/target-xtensa/cpu.c
@@ -53,6 +53,14 @@  static void xtensa_cpu_reset(CPUState *s)
     reset_mmu(env);
 }
 
+static void xtensa_cpu_initfn(Object *obj)
+{
+    XtensaCPU *cpu = XTENSA_CPU(obj);
+    CPUXtensaState *env = &cpu->env;
+
+    cpu_exec_init(env);
+}
+
 static void xtensa_cpu_class_init(ObjectClass *oc, void *data)
 {
     CPUClass *cc = CPU_CLASS(oc);
@@ -66,6 +74,7 @@  static const TypeInfo xtensa_cpu_type_info = {
     .name = TYPE_XTENSA_CPU,
     .parent = TYPE_CPU,
     .instance_size = sizeof(XtensaCPU),
+    .instance_init = xtensa_cpu_initfn,
     .abstract = false,
     .class_size = sizeof(XtensaCPUClass),
     .class_init = xtensa_cpu_class_init,
diff --git a/target-xtensa/helper.c b/target-xtensa/helper.c
index 000f965..2094227 100644
--- a/target-xtensa/helper.c
+++ b/target-xtensa/helper.c
@@ -102,7 +102,6 @@  CPUXtensaState *cpu_xtensa_init(const char *cpu_model)
     cpu = XTENSA_CPU(object_new(TYPE_XTENSA_CPU));
     env = &cpu->env;
     env->config = config;
-    cpu_exec_init(env);
 
     if (!tcg_inited) {
         tcg_inited = 1;