[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 18/18] target/sparc: Make SPARC_CPU common to new SPARC32_CPU/SPA
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH 18/18] target/sparc: Make SPARC_CPU common to new SPARC32_CPU/SPARC64_CPU types |
Date: |
Tue, 10 Oct 2023 11:29:00 +0200 |
"target/foo/cpu-qom.h" can not use any target specific definitions.
Currently "target/sparc/cpu-qom.h" defines TYPE_SPARC_CPU
depending on the sparc(32)/sparc64 build type. This doesn't
scale in a heterogeneous context where we need to access both
types concurrently.
In order to do that, introduce the new SPARC32_CPU / SPARC64_CPU
types, both inheriting a common TYPE_SPARC_CPU base type.
Keep the current CPU types registered in sparc_register_cpudef_type()
as 32 or 64-bit, depending on the binary built.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/sparc/cpu-qom.h | 9 ++++-----
target/sparc/cpu.h | 3 +++
target/sparc/cpu.c | 12 +++++++++++-
3 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/target/sparc/cpu-qom.h b/target/sparc/cpu-qom.h
index 86b24a254a..d08fbd4ddc 100644
--- a/target/sparc/cpu-qom.h
+++ b/target/sparc/cpu-qom.h
@@ -23,13 +23,12 @@
#include "hw/core/cpu.h"
#include "qom/object.h"
-#ifdef TARGET_SPARC64
-#define TYPE_SPARC_CPU "sparc64-cpu"
-#else
#define TYPE_SPARC_CPU "sparc-cpu"
-#endif
+#define TYPE_SPARC32_CPU "sparc32-cpu"
+#define TYPE_SPARC64_CPU "sparc64-cpu"
-OBJECT_DECLARE_CPU_TYPE(SPARCCPU, SPARCCPUClass, SPARC_CPU)
+OBJECT_DECLARE_CPU_TYPE(SPARC32CPU, SPARCCPUClass, SPARC32_CPU)
+OBJECT_DECLARE_CPU_TYPE(SPARC64CPU, SPARCCPUClass, SPARC64_CPU)
#define SPARC_CPU_TYPE_SUFFIX "-" TYPE_SPARC_CPU
#define SPARC_CPU_TYPE_NAME(model) model SPARC_CPU_TYPE_SUFFIX
diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h
index 924e83b9ce..0f94e5a442 100644
--- a/target/sparc/cpu.h
+++ b/target/sparc/cpu.h
@@ -12,6 +12,9 @@
#define TARGET_DPREGS 32
#endif
+/* Abstract QOM SPARC CPU, not exposed to other targets */
+OBJECT_DECLARE_CPU_TYPE(SPARCCPU, SPARCCPUClass, SPARC_CPU)
+
/*#define EXCP_INTERRUPT 0x100*/
/* Windowed register indexes. */
diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c
index 1e66413e94..7d060ba488 100644
--- a/target/sparc/cpu.c
+++ b/target/sparc/cpu.c
@@ -934,6 +934,12 @@ static const TypeInfo sparc_cpu_types[] = {
.abstract = true,
.class_size = sizeof(SPARCCPUClass),
.class_init = sparc_cpu_class_init,
+ }, {
+ .name = TYPE_SPARC32_CPU,
+ .parent = TYPE_SPARC_CPU,
+ }, {
+ .name = TYPE_SPARC64_CPU,
+ .parent = TYPE_SPARC_CPU,
}
};
@@ -950,7 +956,11 @@ static void sparc_register_cpudef_type(const struct
sparc_def_t *def)
char *typename = sparc_cpu_type_name(def->name);
TypeInfo ti = {
.name = typename,
- .parent = TYPE_SPARC_CPU,
+#ifdef TARGET_SPARC64
+ .parent = TYPE_SPARC64_CPU,
+#else
+ .parent = TYPE_SPARC32_CPU,
+#endif
.class_init = sparc_cpu_cpudef_class_init,
.class_data = (void *)def,
};
--
2.41.0
- Re: [PATCH 10/18] target/riscv: Inline target specific TYPE_RISCV_CPU_BASE definition, (continued)
- [PATCH 09/18] target/i386: Inline target specific TARGET_DEFAULT_CPU_TYPE definition, Philippe Mathieu-Daudé, 2023/10/10
- [PATCH 12/18] target/mips: Declare CPU QOM types using DEFINE_TYPES() macro, Philippe Mathieu-Daudé, 2023/10/10
- [PATCH 11/18] target/i386: Declare CPU QOM types using DEFINE_TYPES() macro, Philippe Mathieu-Daudé, 2023/10/10
- [PATCH 13/18] target/ppc: Declare CPU QOM types using DEFINE_TYPES() macro, Philippe Mathieu-Daudé, 2023/10/10
- [PATCH 14/18] target/sparc: Declare CPU QOM types using DEFINE_TYPES() macro, Philippe Mathieu-Daudé, 2023/10/10
- [PATCH 15/18] cpus: Open code OBJECT_DECLARE_TYPE() in OBJECT_DECLARE_CPU_TYPE(), Philippe Mathieu-Daudé, 2023/10/10
- [PATCH 16/18] target/i386: Make X86_CPU common to new I386_CPU / X86_64_CPU types, Philippe Mathieu-Daudé, 2023/10/10
- [PATCH 17/18] target/mips: Make MIPS_CPU common to new MIPS32_CPU / MIPS64_CPU types, Philippe Mathieu-Daudé, 2023/10/10
- [PATCH 18/18] target/sparc: Make SPARC_CPU common to new SPARC32_CPU/SPARC64_CPU types,
Philippe Mathieu-Daudé <=