Message ID | 1359498429-24138-1-git-send-email-afaerber@suse.de |
---|---|
State | New |
Headers | show |
Am 29.01.2013 23:27, schrieb Andreas Färber: > In the initial conversion of CPU models to QOM types, model names were > mapped 1:1 to type names. As a side effect this gained us a type "any", > which is now a device. > > To avoid "-device any" silliness and to pave the way for compiling > multiple targets into one executable, adopt a <name>-<arch>-cpu scheme. > > No functional changes for -cpu arguments. > > Signed-off-by: Andreas Färber <afaerber@suse.de> > --- > v1 -> v2: > * Update env->cpu_model_str to cpu_model rather than the changing > object_get_typename(). Fixes cpu_copy() used by linux-user. Ping? I do not see an assertion with this patch and would like to include it in the full for 1.4 tonight if you don't object. Thanks, Andreas > target-unicore32/cpu.c | 9 ++++++--- > target-unicore32/helper.c | 1 + > 2 Dateien geändert, 7 Zeilen hinzugefügt(+), 3 Zeilen entfernt(-) > > diff --git a/target-unicore32/cpu.c b/target-unicore32/cpu.c > index c120440..9dc7da8 100644 > --- a/target-unicore32/cpu.c > +++ b/target-unicore32/cpu.c > @@ -25,12 +25,15 @@ static inline void set_feature(CPUUniCore32State *env, int feature) > static ObjectClass *uc32_cpu_class_by_name(const char *cpu_model) > { > ObjectClass *oc; > + char *typename; > > if (cpu_model == NULL) { > return NULL; > } > > - oc = object_class_by_name(cpu_model); > + typename = g_strdup_printf("%s-" TYPE_UNICORE32_CPU, cpu_model); > + oc = object_class_by_name(typename); > + g_free(typename); > if (oc != NULL && (!object_class_dynamic_cast(oc, TYPE_UNICORE32_CPU) || > object_class_is_abstract(oc))) { > oc = NULL; > @@ -83,7 +86,6 @@ static void uc32_cpu_initfn(Object *obj) > CPUUniCore32State *env = &cpu->env; > > cpu_exec_init(env); > - env->cpu_model_str = object_get_typename(obj); > > #ifdef CONFIG_USER_ONLY > env->uncached_asr = ASR_MODE_USER; > @@ -106,12 +108,13 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *data) > static void uc32_register_cpu_type(const UniCore32CPUInfo *info) > { > TypeInfo type_info = { > - .name = info->name, > .parent = TYPE_UNICORE32_CPU, > .instance_init = info->instance_init, > }; > > + type_info.name = g_strdup_printf("%s-" TYPE_UNICORE32_CPU, info->name); > type_register(&type_info); > + g_free((void *)type_info.name); > } > > static const TypeInfo uc32_cpu_type_info = { > diff --git a/target-unicore32/helper.c b/target-unicore32/helper.c > index 183b5b3..3a92232 100644 > --- a/target-unicore32/helper.c > +++ b/target-unicore32/helper.c > @@ -38,6 +38,7 @@ CPUUniCore32State *uc32_cpu_init(const char *cpu_model) > } > cpu = UNICORE32_CPU(object_new(object_class_get_name(oc))); > env = &cpu->env; > + env->cpu_model_str = cpu_model; > > if (inited) { > inited = 0; >
Am 31.01.2013 19:09, schrieb Andreas Färber: > Am 29.01.2013 23:27, schrieb Andreas Färber: >> In the initial conversion of CPU models to QOM types, model names were >> mapped 1:1 to type names. As a side effect this gained us a type "any", >> which is now a device. >> >> To avoid "-device any" silliness and to pave the way for compiling >> multiple targets into one executable, adopt a <name>-<arch>-cpu scheme. >> >> No functional changes for -cpu arguments. >> >> Signed-off-by: Andreas Färber <afaerber@suse.de> >> --- >> v1 -> v2: >> * Update env->cpu_model_str to cpu_model rather than the changing >> object_get_typename(). Fixes cpu_copy() used by linux-user. > > Ping? I do not see an assertion with this patch and would like to > include it in the [pull] for 1.4 tonight if you don't object. Applied to qom-cpu: https://github.com/afaerber/qemu-cpu/commits/qom-cpu Andreas > > Thanks, > Andreas
diff --git a/target-unicore32/cpu.c b/target-unicore32/cpu.c index c120440..9dc7da8 100644 --- a/target-unicore32/cpu.c +++ b/target-unicore32/cpu.c @@ -25,12 +25,15 @@ static inline void set_feature(CPUUniCore32State *env, int feature) static ObjectClass *uc32_cpu_class_by_name(const char *cpu_model) { ObjectClass *oc; + char *typename; if (cpu_model == NULL) { return NULL; } - oc = object_class_by_name(cpu_model); + typename = g_strdup_printf("%s-" TYPE_UNICORE32_CPU, cpu_model); + oc = object_class_by_name(typename); + g_free(typename); if (oc != NULL && (!object_class_dynamic_cast(oc, TYPE_UNICORE32_CPU) || object_class_is_abstract(oc))) { oc = NULL; @@ -83,7 +86,6 @@ static void uc32_cpu_initfn(Object *obj) CPUUniCore32State *env = &cpu->env; cpu_exec_init(env); - env->cpu_model_str = object_get_typename(obj); #ifdef CONFIG_USER_ONLY env->uncached_asr = ASR_MODE_USER; @@ -106,12 +108,13 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *data) static void uc32_register_cpu_type(const UniCore32CPUInfo *info) { TypeInfo type_info = { - .name = info->name, .parent = TYPE_UNICORE32_CPU, .instance_init = info->instance_init, }; + type_info.name = g_strdup_printf("%s-" TYPE_UNICORE32_CPU, info->name); type_register(&type_info); + g_free((void *)type_info.name); } static const TypeInfo uc32_cpu_type_info = { diff --git a/target-unicore32/helper.c b/target-unicore32/helper.c index 183b5b3..3a92232 100644 --- a/target-unicore32/helper.c +++ b/target-unicore32/helper.c @@ -38,6 +38,7 @@ CPUUniCore32State *uc32_cpu_init(const char *cpu_model) } cpu = UNICORE32_CPU(object_new(object_class_get_name(oc))); env = &cpu->env; + env->cpu_model_str = cpu_model; if (inited) { inited = 0;
In the initial conversion of CPU models to QOM types, model names were mapped 1:1 to type names. As a side effect this gained us a type "any", which is now a device. To avoid "-device any" silliness and to pave the way for compiling multiple targets into one executable, adopt a <name>-<arch>-cpu scheme. No functional changes for -cpu arguments. Signed-off-by: Andreas Färber <afaerber@suse.de> --- v1 -> v2: * Update env->cpu_model_str to cpu_model rather than the changing object_get_typename(). Fixes cpu_copy() used by linux-user. target-unicore32/cpu.c | 9 ++++++--- target-unicore32/helper.c | 1 + 2 Dateien geändert, 7 Zeilen hinzugefügt(+), 3 Zeilen entfernt(-)