[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 07/40] target/arm: Create TYPE_ARM_V7M_CPU
From: |
Richard Henderson |
Subject: |
[RFC PATCH 07/40] target/arm: Create TYPE_ARM_V7M_CPU |
Date: |
Tue, 3 Jan 2023 10:16:13 -0800 |
Create a new intermediate abstract class for v7m, like we do for
aarch64. The initialization of ARMCPUClass.info follows the
concrete class, so remove that init from arm_v7m_class_init.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/arm/cpu-qom.h | 6 ++++++
target/arm/cpu_tcg.c | 36 ++++++++++++++++++++++--------------
2 files changed, 28 insertions(+), 14 deletions(-)
diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h
index 184b3e3726..ae31289582 100644
--- a/target/arm/cpu-qom.h
+++ b/target/arm/cpu-qom.h
@@ -26,6 +26,7 @@
struct arm_boot_info;
#define TYPE_ARM_CPU "arm-cpu"
+#define TYPE_ARM_V7M_CPU "arm-v7m-cpu"
#define TYPE_AARCH64_CPU "aarch64-cpu"
OBJECT_DECLARE_CPU_TYPE(ARMCPU, ARMCPUClass, ARM_CPU)
@@ -45,6 +46,11 @@ static inline void arm_cpu_register(const ARMCPUInfo *info)
arm_cpu_register_parent(info, TYPE_ARM_CPU);
}
+static inline void arm_v7m_cpu_register(const ARMCPUInfo *info)
+{
+ arm_cpu_register_parent(info, TYPE_ARM_V7M_CPU);
+}
+
static inline void aarch64_cpu_register(const ARMCPUInfo *info)
{
arm_cpu_register_parent(info, TYPE_AARCH64_CPU);
diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
index 568cbcfc52..d566a815d3 100644
--- a/target/arm/cpu_tcg.c
+++ b/target/arm/cpu_tcg.c
@@ -1056,10 +1056,8 @@ static const struct TCGCPUOps arm_v7m_tcg_ops = {
static void arm_v7m_class_init(ObjectClass *oc, void *data)
{
- ARMCPUClass *acc = ARM_CPU_CLASS(oc);
CPUClass *cc = CPU_CLASS(oc);
- acc->info = data;
#ifdef CONFIG_TCG
cc->tcg_ops = &arm_v7m_tcg_ops;
#endif /* CONFIG_TCG */
@@ -1149,18 +1147,6 @@ static const ARMCPUInfo arm_tcg_cpus[] = {
{ .name = "cortex-a8", .initfn = cortex_a8_initfn },
{ .name = "cortex-a9", .initfn = cortex_a9_initfn },
{ .name = "cortex-a15", .initfn = cortex_a15_initfn },
- { .name = "cortex-m0", .initfn = cortex_m0_initfn,
- .class_init = arm_v7m_class_init },
- { .name = "cortex-m3", .initfn = cortex_m3_initfn,
- .class_init = arm_v7m_class_init },
- { .name = "cortex-m4", .initfn = cortex_m4_initfn,
- .class_init = arm_v7m_class_init },
- { .name = "cortex-m7", .initfn = cortex_m7_initfn,
- .class_init = arm_v7m_class_init },
- { .name = "cortex-m33", .initfn = cortex_m33_initfn,
- .class_init = arm_v7m_class_init },
- { .name = "cortex-m55", .initfn = cortex_m55_initfn,
- .class_init = arm_v7m_class_init },
{ .name = "cortex-r5", .initfn = cortex_r5_initfn },
{ .name = "cortex-r5f", .initfn = cortex_r5f_initfn },
{ .name = "ti925t", .initfn = ti925t_initfn },
@@ -1187,6 +1173,24 @@ static const ARMCPUInfo arm_tcg_cpus[] = {
#endif
};
+static const ARMCPUInfo arm_v7m_tcg_cpus[] = {
+ { .name = "cortex-m0", .initfn = cortex_m0_initfn },
+ { .name = "cortex-m3", .initfn = cortex_m3_initfn },
+ { .name = "cortex-m4", .initfn = cortex_m4_initfn },
+ { .name = "cortex-m7", .initfn = cortex_m7_initfn },
+ { .name = "cortex-m33", .initfn = cortex_m33_initfn },
+ { .name = "cortex-m55", .initfn = cortex_m55_initfn },
+};
+
+static const TypeInfo arm_v7m_cpu_type_info = {
+ .name = TYPE_ARM_V7M_CPU,
+ .parent = TYPE_ARM_CPU,
+ .instance_size = sizeof(ARMCPU),
+ .abstract = true,
+ .class_size = sizeof(ARMCPUClass),
+ .class_init = arm_v7m_class_init,
+};
+
static const TypeInfo idau_interface_type_info = {
.name = TYPE_IDAU_INTERFACE,
.parent = TYPE_INTERFACE,
@@ -1197,10 +1201,14 @@ static void arm_tcg_cpu_register_types(void)
{
size_t i;
+ type_register_static(&arm_v7m_cpu_type_info);
type_register_static(&idau_interface_type_info);
for (i = 0; i < ARRAY_SIZE(arm_tcg_cpus); ++i) {
arm_cpu_register(&arm_tcg_cpus[i]);
}
+ for (i = 0; i < ARRAY_SIZE(arm_v7m_tcg_cpus); ++i) {
+ arm_v7m_cpu_register(&arm_v7m_tcg_cpus[i]);
+ }
}
type_init(arm_tcg_cpu_register_types)
--
2.34.1
- Re: [RFC PATCH 01/40] qdev: Don't always force the global property array non-null, (continued)
[RFC PATCH 18/40] target/arm: Create cpreg definition functions with GHashTable arg, Richard Henderson, 2023/01/03
[RFC PATCH 05/40] target/arm: Create arm_cpu_register_parent, Richard Henderson, 2023/01/03
[RFC PATCH 07/40] target/arm: Create TYPE_ARM_V7M_CPU,
Richard Henderson <=
[RFC PATCH 02/40] qom: Introduce class_late_init, Richard Henderson, 2023/01/03
[RFC PATCH 08/40] target/arm: Pass ARMCPUClass to ARMCPUInfo.class_init, Richard Henderson, 2023/01/03
[RFC PATCH 14/40] target/arm: Rename arm_cpu_mp_affinity, Richard Henderson, 2023/01/03
[RFC PATCH 10/40] target/arm: Copy dtb_compatible from ARMCPUClass, Richard Henderson, 2023/01/03
[RFC PATCH 13/40] hw/arm/bcm2836: Set mp-affinity property in realize, Richard Henderson, 2023/01/03