aboutsummaryrefslogtreecommitdiff
path: root/target/m68k
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/m68k
parent953e35f69c302522c280e8d4e05995afc31da051 (diff)
parent1a26f46692320f1981c95967e0d5af4443b5f0b1 (diff)
downloadqemu-ab752f237d755897735dc755182f60af39cbc5b6.zip
qemu-ab752f237d755897735dc755182f60af39cbc5b6.tar.gz
qemu-ab752f237d755897735dc755182f60af39cbc5b6.tar.bz2
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/m68k')
-rw-r--r--target/m68k/cpu.c75
-rw-r--r--target/m68k/cpu.h3
2 files changed, 30 insertions, 48 deletions
diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c
index 5da19e5..0a3dd83 100644
--- a/target/m68k/cpu.c
+++ b/target/m68k/cpu.c
@@ -87,7 +87,7 @@ static ObjectClass *m68k_cpu_class_by_name(const char *cpu_model)
ObjectClass *oc;
char *typename;
- typename = g_strdup_printf("%s-" TYPE_M68K_CPU, cpu_model);
+ typename = g_strdup_printf(M68K_CPU_TYPE_NAME("%s"), cpu_model);
oc = object_class_by_name(typename);
g_free(typename);
if (oc != NULL && (object_class_dynamic_cast(oc, TYPE_M68K_CPU) == NULL ||
@@ -202,23 +202,6 @@ static void any_cpu_initfn(Object *obj)
m68k_set_feature(env, M68K_FEATURE_WORD_INDEX);
}
-typedef struct M68kCPUInfo {
- const char *name;
- void (*instance_init)(Object *obj);
-} M68kCPUInfo;
-
-static const M68kCPUInfo m68k_cpus[] = {
- { .name = "m68000", .instance_init = m68000_cpu_initfn },
- { .name = "m68020", .instance_init = m68020_cpu_initfn },
- { .name = "m68030", .instance_init = m68030_cpu_initfn },
- { .name = "m68040", .instance_init = m68040_cpu_initfn },
- { .name = "m68060", .instance_init = m68060_cpu_initfn },
- { .name = "m5206", .instance_init = m5206_cpu_initfn },
- { .name = "m5208", .instance_init = m5208_cpu_initfn },
- { .name = "cfv4e", .instance_init = cfv4e_cpu_initfn },
- { .name = "any", .instance_init = any_cpu_initfn },
-};
-
static void m68k_cpu_realizefn(DeviceState *dev, Error **errp)
{
CPUState *cs = CPU(dev);
@@ -290,36 +273,32 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data)
dc->vmsd = &vmstate_m68k_cpu;
}
-static void register_cpu_type(const M68kCPUInfo *info)
-{
- TypeInfo type_info = {
- .parent = TYPE_M68K_CPU,
- .instance_init = info->instance_init,
- };
-
- type_info.name = g_strdup_printf("%s-" TYPE_M68K_CPU, info->name);
- type_register(&type_info);
- g_free((void *)type_info.name);
-}
+#define DEFINE_M68K_CPU_TYPE(cpu_model, initfn) \
+ { \
+ .name = M68K_CPU_TYPE_NAME(cpu_model), \
+ .instance_init = initfn, \
+ .parent = TYPE_M68K_CPU, \
+ }
-static const TypeInfo m68k_cpu_type_info = {
- .name = TYPE_M68K_CPU,
- .parent = TYPE_CPU,
- .instance_size = sizeof(M68kCPU),
- .instance_init = m68k_cpu_initfn,
- .abstract = true,
- .class_size = sizeof(M68kCPUClass),
- .class_init = m68k_cpu_class_init,
+static const TypeInfo m68k_cpus_type_infos[] = {
+ { /* base class should be registered first */
+ .name = TYPE_M68K_CPU,
+ .parent = TYPE_CPU,
+ .instance_size = sizeof(M68kCPU),
+ .instance_init = m68k_cpu_initfn,
+ .abstract = true,
+ .class_size = sizeof(M68kCPUClass),
+ .class_init = m68k_cpu_class_init,
+ },
+ DEFINE_M68K_CPU_TYPE("m68000", m68000_cpu_initfn),
+ DEFINE_M68K_CPU_TYPE("m68020", m68020_cpu_initfn),
+ DEFINE_M68K_CPU_TYPE("m68030", m68030_cpu_initfn),
+ DEFINE_M68K_CPU_TYPE("m68040", m68040_cpu_initfn),
+ DEFINE_M68K_CPU_TYPE("m68060", m68060_cpu_initfn),
+ DEFINE_M68K_CPU_TYPE("m5206", m5206_cpu_initfn),
+ DEFINE_M68K_CPU_TYPE("m5208", m5208_cpu_initfn),
+ DEFINE_M68K_CPU_TYPE("cfv4e", cfv4e_cpu_initfn),
+ DEFINE_M68K_CPU_TYPE("any", any_cpu_initfn),
};
-static void m68k_cpu_register_types(void)
-{
- int i;
-
- type_register_static(&m68k_cpu_type_info);
- for (i = 0; i < ARRAY_SIZE(m68k_cpus); i++) {
- register_cpu_type(&m68k_cpus[i]);
- }
-}
-
-type_init(m68k_cpu_register_types)
+DEFINE_TYPES(m68k_cpus_type_infos)
diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h
index d936547..afae5f6 100644
--- a/target/m68k/cpu.h
+++ b/target/m68k/cpu.h
@@ -323,6 +323,9 @@ void register_m68k_insns (CPUM68KState *env);
#define cpu_init(cpu_model) cpu_generic_init(TYPE_M68K_CPU, cpu_model)
+#define M68K_CPU_TYPE_SUFFIX "-" TYPE_M68K_CPU
+#define M68K_CPU_TYPE_NAME(model) model M68K_CPU_TYPE_SUFFIX
+
#define cpu_signal_handler cpu_m68k_signal_handler
#define cpu_list m68k_cpu_list