aboutsummaryrefslogtreecommitdiff
path: root/target/unicore32
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2017-10-30 10:11:22 +0000
committerPeter Maydell <peter.maydell@linaro.org>2017-10-30 10:11:22 +0000
commitab752f237d755897735dc755182f60af39cbc5b6 (patch)
treec7c3ad0f9daf8405cf475730801421b5643e75f5 /target/unicore32
parent953e35f69c302522c280e8d4e05995afc31da051 (diff)
parent1a26f46692320f1981c95967e0d5af4443b5f0b1 (diff)
Merge remote-tracking branch 'remotes/ehabkost/tags/x86-and-machine-pull-request' into staging
x86/cpu/numa queue, 2017-10-27 # gpg: Signature made Fri 27 Oct 2017 15:17:12 BST # gpg: using RSA key 0x2807936F984DC5A6 # gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>" # Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF D1AA 2807 936F 984D C5A6 * remotes/ehabkost/tags/x86-and-machine-pull-request: (39 commits) x86: Skip check apic_id_limit for Xen numa: fixup parsed NumaNodeOptions earlier mips: r4k: replace cpu_model with cpu_type mips: mipssim: replace cpu_model with cpu_type mips: Magnum/Acer Pica 61: replace cpu_model with cpu_type mips: fulong2e: replace cpu_model with cpu_type mips: malta/boston: replace cpu_model with cpu_type mips: use object_new() instead of gnew()+object_initialize() sparc: leon3: use generic cpu_model parsing sparc: sparc: use generic cpu_model parsing sparc: sun4u/sun4v/niagara: use generic cpu_model parsing sparc: cleanup cpu type name composition tricore: use generic cpu_model parsing tricore: cleanup cpu type name composition unicore32: use generic cpu_model parsing unicore32: cleanup cpu type name composition xtensa: lx60/lx200/ml605/kc705: use generic cpu_model parsing xtensa: sim: use generic cpu_model parsing xtensa: cleanup cpu type name composition sh4: remove SuperHCPUClass::name field ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'target/unicore32')
-rw-r--r--target/unicore32/cpu.c61
-rw-r--r--target/unicore32/cpu.h3
2 files changed, 23 insertions, 41 deletions
diff --git a/target/unicore32/cpu.c b/target/unicore32/cpu.c
index 526604ff78..17dc1504d7 100644
--- a/target/unicore32/cpu.c
+++ b/target/unicore32/cpu.c
@@ -44,7 +44,7 @@ static ObjectClass *uc32_cpu_class_by_name(const char *cpu_model)
ObjectClass *oc;
char *typename;
- typename = g_strdup_printf("%s-" TYPE_UNICORE32_CPU, cpu_model);
+ typename = g_strdup_printf(UNICORE32_CPU_TYPE_NAME("%s"), cpu_model);
oc = object_class_by_name(typename);
g_free(typename);
if (oc != NULL && (!object_class_dynamic_cast(oc, TYPE_UNICORE32_CPU) ||
@@ -54,11 +54,6 @@ static ObjectClass *uc32_cpu_class_by_name(const char *cpu_model)
return oc;
}
-typedef struct UniCore32CPUInfo {
- const char *name;
- void (*instance_init)(Object *obj);
-} UniCore32CPUInfo;
-
static void unicore_ii_cpu_initfn(Object *obj)
{
UniCore32CPU *cpu = UNICORE32_CPU(obj);
@@ -90,11 +85,6 @@ static void uc32_any_cpu_initfn(Object *obj)
set_snan_bit_is_one(1, &env->ucf64.fp_status);
}
-static const UniCore32CPUInfo uc32_cpus[] = {
- { .name = "UniCore-II", .instance_init = unicore_ii_cpu_initfn },
- { .name = "any", .instance_init = uc32_any_cpu_initfn },
-};
-
static void uc32_cpu_realizefn(DeviceState *dev, Error **errp)
{
CPUState *cs = CPU(dev);
@@ -160,36 +150,25 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *data)
dc->vmsd = &vmstate_uc32_cpu;
}
-static void uc32_register_cpu_type(const UniCore32CPUInfo *info)
-{
- TypeInfo type_info = {
- .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);
-}
+#define DEFINE_UNICORE32_CPU_TYPE(cpu_model, initfn) \
+ { \
+ .parent = TYPE_UNICORE32_CPU, \
+ .instance_init = initfn, \
+ .name = UNICORE32_CPU_TYPE_NAME(cpu_model), \
+ }
-static const TypeInfo uc32_cpu_type_info = {
- .name = TYPE_UNICORE32_CPU,
- .parent = TYPE_CPU,
- .instance_size = sizeof(UniCore32CPU),
- .instance_init = uc32_cpu_initfn,
- .abstract = true,
- .class_size = sizeof(UniCore32CPUClass),
- .class_init = uc32_cpu_class_init,
+static const TypeInfo uc32_cpu_type_infos[] = {
+ {
+ .name = TYPE_UNICORE32_CPU,
+ .parent = TYPE_CPU,
+ .instance_size = sizeof(UniCore32CPU),
+ .instance_init = uc32_cpu_initfn,
+ .abstract = true,
+ .class_size = sizeof(UniCore32CPUClass),
+ .class_init = uc32_cpu_class_init,
+ },
+ DEFINE_UNICORE32_CPU_TYPE("UniCore-II", unicore_ii_cpu_initfn),
+ DEFINE_UNICORE32_CPU_TYPE("any", uc32_any_cpu_initfn),
};
-static void uc32_cpu_register_types(void)
-{
- int i;
-
- type_register_static(&uc32_cpu_type_info);
- for (i = 0; i < ARRAY_SIZE(uc32_cpus); i++) {
- uc32_register_cpu_type(&uc32_cpus[i]);
- }
-}
-
-type_init(uc32_cpu_register_types)
+DEFINE_TYPES(uc32_cpu_type_infos)
diff --git a/target/unicore32/cpu.h b/target/unicore32/cpu.h
index 7724108281..3dc6fbc6c7 100644
--- a/target/unicore32/cpu.h
+++ b/target/unicore32/cpu.h
@@ -167,6 +167,9 @@ static inline int cpu_mmu_index(CPUUniCore32State *env, bool ifetch)
#define cpu_init(cpu_model) cpu_generic_init(TYPE_UNICORE32_CPU, cpu_model)
+#define UNICORE32_CPU_TYPE_SUFFIX "-" TYPE_UNICORE32_CPU
+#define UNICORE32_CPU_TYPE_NAME(model) model UNICORE32_CPU_TYPE_SUFFIX
+
static inline void cpu_get_tb_cpu_state(CPUUniCore32State *env, target_ulong *pc,
target_ulong *cs_base, uint32_t *flags)
{