target-arm: Move TCG initialization to ARMCPU initfn

Ensures that a QOM-created ARMCPU is usable.

Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
Andreas Färber 2013-01-19 07:37:45 +01:00
parent 5f6c964389
commit 79614b781d
2 changed files with 6 additions and 6 deletions

View File

@ -135,10 +135,16 @@ static inline void set_feature(CPUARMState *env, int feature)
static void arm_cpu_initfn(Object *obj) static void arm_cpu_initfn(Object *obj)
{ {
ARMCPU *cpu = ARM_CPU(obj); ARMCPU *cpu = ARM_CPU(obj);
static bool inited;
cpu_exec_init(&cpu->env); cpu_exec_init(&cpu->env);
cpu->cp_regs = g_hash_table_new_full(g_int_hash, g_int_equal, cpu->cp_regs = g_hash_table_new_full(g_int_hash, g_int_equal,
g_free, g_free); g_free, g_free);
if (tcg_enabled() && !inited) {
inited = true;
arm_translate_init();
}
} }
static void arm_cpu_finalizefn(Object *obj) static void arm_cpu_finalizefn(Object *obj)

View File

@ -1263,7 +1263,6 @@ ARMCPU *cpu_arm_init(const char *cpu_model)
ARMCPU *cpu; ARMCPU *cpu;
CPUARMState *env; CPUARMState *env;
ObjectClass *oc; ObjectClass *oc;
static int inited = 0;
oc = cpu_class_by_name(TYPE_ARM_CPU, cpu_model); oc = cpu_class_by_name(TYPE_ARM_CPU, cpu_model);
if (!oc) { if (!oc) {
@ -1276,11 +1275,6 @@ ARMCPU *cpu_arm_init(const char *cpu_model)
/* TODO this should be set centrally, once possible */ /* TODO this should be set centrally, once possible */
object_property_set_bool(OBJECT(cpu), true, "realized", NULL); object_property_set_bool(OBJECT(cpu), true, "realized", NULL);
if (tcg_enabled() && !inited) {
inited = 1;
arm_translate_init();
}
return cpu; return cpu;
} }