Patchwork [RFC,qom-cpu,v2,17/28] target-arm: Move TCG initialization to ARMCPU initfn

login
register
mail settings
Submitter Andreas Färber
Date Jan. 20, 2013, 7:22 a.m.
Message ID <1358666571-1737-18-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/213935/
State New
Headers show

Comments

Andreas Färber - Jan. 20, 2013, 7:22 a.m.
Ensures that a QOM-created ARMCPU is usable.

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

Patch

diff --git a/target-arm/cpu.c b/target-arm/cpu.c
index 19d5ae4..8615068 100644
--- a/target-arm/cpu.c
+++ b/target-arm/cpu.c
@@ -135,10 +135,16 @@  static inline void set_feature(CPUARMState *env, int feature)
 static void arm_cpu_initfn(Object *obj)
 {
     ARMCPU *cpu = ARM_CPU(obj);
+    static bool inited;
 
     cpu_exec_init(&cpu->env);
     cpu->cp_regs = g_hash_table_new_full(g_int_hash, g_int_equal,
                                          g_free, g_free);
+
+    if (tcg_enabled() && !inited) {
+        inited = true;
+        arm_translate_init();
+    }
 }
 
 static void arm_cpu_finalizefn(Object *obj)
diff --git a/target-arm/helper.c b/target-arm/helper.c
index f412143..904859b 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -1262,7 +1262,6 @@  ARMCPU *cpu_arm_init(const char *cpu_model)
 {
     ARMCPU *cpu;
     CPUARMState *env;
-    static int inited = 0;
 
     if (!object_class_by_name(cpu_model)) {
         return NULL;
@@ -1274,11 +1273,6 @@  ARMCPU *cpu_arm_init(const char *cpu_model)
     /* TODO this should be set centrally, once possible */
     object_property_set_bool(OBJECT(cpu), true, "realized", NULL);
 
-    if (tcg_enabled() && !inited) {
-        inited = 1;
-        arm_translate_init();
-    }
-
     return cpu;
 }