Normalize the "inited" logic and add a tcg_enabled() check to suppress
it for qtest.
Ensures that a QOM-created UniCore32CPU is usable.
Acked-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Andreas Färber <afaerber@suse.de>
{
UniCore32CPU *cpu = UNICORE32_CPU(obj);
CPUUniCore32State *env = &cpu->env;
+ static bool inited;
cpu_exec_init(env);
#endif
tlb_flush(env, 1);
+
+ if (tcg_enabled() && !inited) {
+ inited = true;
+ uc32_translate_init();
+ }
}
static const VMStateDescription vmstate_uc32_cpu = {
UniCore32CPU *cpu;
CPUUniCore32State *env;
ObjectClass *oc;
- static int inited = 1;
oc = cpu_class_by_name(TYPE_UNICORE32_CPU, cpu_model);
if (oc == NULL) {
env = &cpu->env;
env->cpu_model_str = cpu_model;
- if (inited) {
- inited = 0;
- uc32_translate_init();
- }
-
object_property_set_bool(OBJECT(cpu), true, "realized", NULL);
return env;