diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2017-10-30 10:11:22 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2017-10-30 10:11:22 +0000 |
commit | ab752f237d755897735dc755182f60af39cbc5b6 (patch) | |
tree | c7c3ad0f9daf8405cf475730801421b5643e75f5 /target/lm32 | |
parent | 953e35f69c302522c280e8d4e05995afc31da051 (diff) | |
parent | 1a26f46692320f1981c95967e0d5af4443b5f0b1 (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/lm32')
-rw-r--r-- | target/lm32/cpu.c | 74 | ||||
-rw-r--r-- | target/lm32/cpu.h | 3 |
2 files changed, 25 insertions, 52 deletions
diff --git a/target/lm32/cpu.c b/target/lm32/cpu.c index 7f3a292f2b..6f5c14767b 100644 --- a/target/lm32/cpu.c +++ b/target/lm32/cpu.c @@ -51,7 +51,7 @@ static void lm32_cpu_list_entry(gpointer data, gpointer user_data) const char *typename = object_class_get_name(oc); char *name; - name = g_strndup(typename, strlen(typename) - strlen("-" TYPE_LM32_CPU)); + name = g_strndup(typename, strlen(typename) - strlen(LM32_CPU_TYPE_SUFFIX)); (*s->cpu_fprintf)(s->file, " %s\n", name); g_free(name); } @@ -215,32 +215,12 @@ static void lm32_full_cpu_initfn(Object *obj) | LM32_FEATURE_CYCLE_COUNT; } -typedef struct LM32CPUInfo { - const char *name; - void (*initfn)(Object *obj); -} LM32CPUInfo; - -static const LM32CPUInfo lm32_cpus[] = { - { - .name = "lm32-basic", - .initfn = lm32_basic_cpu_initfn, - }, - { - .name = "lm32-standard", - .initfn = lm32_standard_cpu_initfn, - }, - { - .name = "lm32-full", - .initfn = lm32_full_cpu_initfn, - }, -}; - static ObjectClass *lm32_cpu_class_by_name(const char *cpu_model) { ObjectClass *oc; char *typename; - typename = g_strdup_printf("%s-" TYPE_LM32_CPU, cpu_model); + typename = g_strdup_printf(LM32_CPU_TYPE_NAME("%s"), cpu_model); oc = object_class_by_name(typename); g_free(typename); if (oc != NULL && (!object_class_dynamic_cast(oc, TYPE_LM32_CPU) || @@ -283,36 +263,26 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *data) cc->tcg_initialize = lm32_translate_init; } -static void lm32_register_cpu_type(const LM32CPUInfo *info) -{ - TypeInfo type_info = { - .parent = TYPE_LM32_CPU, - .instance_init = info->initfn, - }; - - type_info.name = g_strdup_printf("%s-" TYPE_LM32_CPU, info->name); - type_register(&type_info); - g_free((void *)type_info.name); -} +#define DEFINE_LM32_CPU_TYPE(cpu_model, initfn) \ + { \ + .parent = TYPE_LM32_CPU, \ + .name = LM32_CPU_TYPE_NAME(cpu_model), \ + .instance_init = initfn, \ + } -static const TypeInfo lm32_cpu_type_info = { - .name = TYPE_LM32_CPU, - .parent = TYPE_CPU, - .instance_size = sizeof(LM32CPU), - .instance_init = lm32_cpu_initfn, - .abstract = true, - .class_size = sizeof(LM32CPUClass), - .class_init = lm32_cpu_class_init, +static const TypeInfo lm32_cpus_type_infos[] = { + { /* base class should be registered first */ + .name = TYPE_LM32_CPU, + .parent = TYPE_CPU, + .instance_size = sizeof(LM32CPU), + .instance_init = lm32_cpu_initfn, + .abstract = true, + .class_size = sizeof(LM32CPUClass), + .class_init = lm32_cpu_class_init, + }, + DEFINE_LM32_CPU_TYPE("lm32-basic", lm32_basic_cpu_initfn), + DEFINE_LM32_CPU_TYPE("lm32-standard", lm32_standard_cpu_initfn), + DEFINE_LM32_CPU_TYPE("lm32-full", lm32_full_cpu_initfn), }; -static void lm32_cpu_register_types(void) -{ - int i; - - type_register_static(&lm32_cpu_type_info); - for (i = 0; i < ARRAY_SIZE(lm32_cpus); i++) { - lm32_register_cpu_type(&lm32_cpus[i]); - } -} - -type_init(lm32_cpu_register_types) +DEFINE_TYPES(lm32_cpus_type_infos) diff --git a/target/lm32/cpu.h b/target/lm32/cpu.h index de265b50d1..2279594f40 100644 --- a/target/lm32/cpu.h +++ b/target/lm32/cpu.h @@ -257,6 +257,9 @@ bool lm32_cpu_do_semihosting(CPUState *cs); #define cpu_init(cpu_model) cpu_generic_init(TYPE_LM32_CPU, cpu_model) +#define LM32_CPU_TYPE_SUFFIX "-" TYPE_LM32_CPU +#define LM32_CPU_TYPE_NAME(model) model LM32_CPU_TYPE_SUFFIX + #define cpu_list lm32_cpu_list #define cpu_signal_handler cpu_lm32_signal_handler |