| Submitter | Andreas Färber |
|---|---|
| Date | Jan. 20, 2013, 7:22 a.m. |
| Message ID | <1358666571-1737-28-git-send-email-afaerber@suse.de> |
| Download | mbox | patch |
| Permalink | /patch/213937/ |
| State | New |
| Headers | show |
Comments
> -----邮件原件----- > 发件人: Andreas Färber [mailto:afaerber@suse.de] > 发送时间: Sunday, January 20, 2013 15:23 > 收件人: qemu-devel@nongnu.org > 抄送: Andreas Färber; Guan Xuetao (maintainer:UniCore32) > 主题: [RFC qom-cpu v2 27/28] target-unicore32: Move TCG initialization to > UniCore32CPU initfn > > Normalize the "inited" logic and add a tcg_enabled() check to suppress it for > qtest. > > Ensures that a QOM-created UniCore32CPU is usable. > > Signed-off-by: Andreas Färber <afaerber@suse.de> Acked-by: Guan Xuetao <gxt@mprc.pku.edu.cn> > --- > target-unicore32/cpu.c | 6 ++++++ > target-unicore32/helper.c | 6 ------ > 2 Dateien geändert, 6 Zeilen hinzugefügt(+), 6 Zeilen entfernt(-) > > diff --git a/target-unicore32/cpu.c b/target-unicore32/cpu.c index > bf33326..7f8dc15 100644 > --- a/target-unicore32/cpu.c > +++ b/target-unicore32/cpu.c > @@ -75,6 +75,7 @@ static void uc32_cpu_initfn(Object *obj) { > UniCore32CPU *cpu = UNICORE32_CPU(obj); > CPUUniCore32State *env = &cpu->env; > + static bool inited; > > cpu_exec_init(env); > env->cpu_model_str = object_get_typename(obj); @@ -88,6 +89,11 @@ > static void uc32_cpu_initfn(Object *obj) #endif > > tlb_flush(env, 1); > + > + if (tcg_enabled() && !inited) { > + inited = true; > + uc32_translate_init(); > + } > } > > static void uc32_cpu_class_init(ObjectClass *oc, void *data) diff --git > a/target-unicore32/helper.c b/target-unicore32/helper.c index > 173579a..357cc8b 100644 > --- a/target-unicore32/helper.c > +++ b/target-unicore32/helper.c > @@ -29,7 +29,6 @@ CPUUniCore32State *uc32_cpu_init(const char > *cpu_model) { > UniCore32CPU *cpu; > CPUUniCore32State *env; > - static int inited = 1; > > if (object_class_by_name(cpu_model) == NULL) { > return NULL; > @@ -37,11 +36,6 @@ CPUUniCore32State *uc32_cpu_init(const char > *cpu_model) > cpu = UNICORE32_CPU(object_new(cpu_model)); > env = &cpu->env; > > - if (inited) { > - inited = 0; > - uc32_translate_init(); > - } > - > object_property_set_bool(OBJECT(cpu), true, "realized", NULL); > > return env; > -- > 1.7.10.4
Patch
diff --git a/target-unicore32/cpu.c b/target-unicore32/cpu.c index bf33326..7f8dc15 100644 --- a/target-unicore32/cpu.c +++ b/target-unicore32/cpu.c @@ -75,6 +75,7 @@ static void uc32_cpu_initfn(Object *obj) { UniCore32CPU *cpu = UNICORE32_CPU(obj); CPUUniCore32State *env = &cpu->env; + static bool inited; cpu_exec_init(env); env->cpu_model_str = object_get_typename(obj); @@ -88,6 +89,11 @@ static void uc32_cpu_initfn(Object *obj) #endif tlb_flush(env, 1); + + if (tcg_enabled() && !inited) { + inited = true; + uc32_translate_init(); + } } static void uc32_cpu_class_init(ObjectClass *oc, void *data) diff --git a/target-unicore32/helper.c b/target-unicore32/helper.c index 173579a..357cc8b 100644 --- a/target-unicore32/helper.c +++ b/target-unicore32/helper.c @@ -29,7 +29,6 @@ CPUUniCore32State *uc32_cpu_init(const char *cpu_model) { UniCore32CPU *cpu; CPUUniCore32State *env; - static int inited = 1; if (object_class_by_name(cpu_model) == NULL) { return NULL; @@ -37,11 +36,6 @@ CPUUniCore32State *uc32_cpu_init(const char *cpu_model) cpu = UNICORE32_CPU(object_new(cpu_model)); env = &cpu->env; - if (inited) { - inited = 0; - uc32_translate_init(); - } - object_property_set_bool(OBJECT(cpu), true, "realized", NULL); return env;
Normalize the "inited" logic and add a tcg_enabled() check to suppress it for qtest. Ensures that a QOM-created UniCore32CPU is usable. Signed-off-by: Andreas Färber <afaerber@suse.de> --- target-unicore32/cpu.c | 6 ++++++ target-unicore32/helper.c | 6 ------ 2 Dateien geändert, 6 Zeilen hinzugefügt(+), 6 Zeilen entfernt(-)