aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2025-02-06 13:12:09 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2025-05-20 08:18:42 +0200
commit71fb3aa5ebba5ba822371f864a12dbcded08147d (patch)
tree5489f04286e8862962318c75d24b73837fe75765
parent80b22be3820f1076d9de1b1f1646ae6b352d7675 (diff)
downloadqemu-71fb3aa5ebba5ba822371f864a12dbcded08147d.zip
qemu-71fb3aa5ebba5ba822371f864a12dbcded08147d.tar.gz
qemu-71fb3aa5ebba5ba822371f864a12dbcded08147d.tar.bz2
target/riscv: introduce RISCVCPUDef
Start putting all the CPU definitions in a struct. Later this will replace instance_init functions with declarative code, for now just remove the ugly cast of class_data. Reviewed-by: Alistair Francis <alistair23@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--target/riscv/cpu.c27
-rw-r--r--target/riscv/cpu.h4
2 files changed, 22 insertions, 9 deletions
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index 54a996c..6e92fbb 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -3073,8 +3073,9 @@ static void riscv_cpu_common_class_init(ObjectClass *c, const void *data)
static void riscv_cpu_class_init(ObjectClass *c, const void *data)
{
RISCVCPUClass *mcc = RISCV_CPU_CLASS(c);
+ const RISCVCPUDef *def = data;
- mcc->misa_mxl_max = (RISCVMXL)GPOINTER_TO_UINT(data);
+ mcc->misa_mxl_max = def->misa_mxl_max;
riscv_cpu_validate_misa_mxl(mcc);
}
@@ -3170,40 +3171,48 @@ void riscv_isa_write_fdt(RISCVCPU *cpu, void *fdt, char *nodename)
}
#endif
-#define DEFINE_DYNAMIC_CPU(type_name, misa_mxl_max, initfn) \
+#define DEFINE_DYNAMIC_CPU(type_name, misa_mxl_max_, initfn) \
{ \
.name = (type_name), \
.parent = TYPE_RISCV_DYNAMIC_CPU, \
.instance_init = (initfn), \
.class_init = riscv_cpu_class_init, \
- .class_data = GUINT_TO_POINTER(misa_mxl_max) \
+ .class_data = &(const RISCVCPUDef) { \
+ .misa_mxl_max = (misa_mxl_max_), \
+ }, \
}
-#define DEFINE_VENDOR_CPU(type_name, misa_mxl_max, initfn) \
+#define DEFINE_VENDOR_CPU(type_name, misa_mxl_max_, initfn) \
{ \
.name = (type_name), \
.parent = TYPE_RISCV_VENDOR_CPU, \
.instance_init = (initfn), \
.class_init = riscv_cpu_class_init, \
- .class_data = GUINT_TO_POINTER(misa_mxl_max) \
+ .class_data = &(const RISCVCPUDef) { \
+ .misa_mxl_max = (misa_mxl_max_), \
+ }, \
}
-#define DEFINE_BARE_CPU(type_name, misa_mxl_max, initfn) \
+#define DEFINE_BARE_CPU(type_name, misa_mxl_max_, initfn) \
{ \
.name = (type_name), \
.parent = TYPE_RISCV_BARE_CPU, \
.instance_init = (initfn), \
.class_init = riscv_cpu_class_init, \
- .class_data = GUINT_TO_POINTER(misa_mxl_max) \
+ .class_data = &(const RISCVCPUDef) { \
+ .misa_mxl_max = (misa_mxl_max_), \
+ }, \
}
-#define DEFINE_PROFILE_CPU(type_name, misa_mxl_max, initfn) \
+#define DEFINE_PROFILE_CPU(type_name, misa_mxl_max_, initfn) \
{ \
.name = (type_name), \
.parent = TYPE_RISCV_BARE_CPU, \
.instance_init = (initfn), \
.class_init = riscv_cpu_class_init, \
- .class_data = GUINT_TO_POINTER(misa_mxl_max) \
+ .class_data = &(const RISCVCPUDef) { \
+ .misa_mxl_max = (misa_mxl_max_), \
+ }, \
}
static const TypeInfo riscv_cpu_type_infos[] = {
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
index 731ea25..9de3f71 100644
--- a/target/riscv/cpu.h
+++ b/target/riscv/cpu.h
@@ -538,6 +538,10 @@ struct ArchCPU {
const GPtrArray *decoders;
};
+typedef struct RISCVCPUDef {
+ RISCVMXL misa_mxl_max; /* max mxl for this cpu */
+} RISCVCPUDef;
+
/**
* RISCVCPUClass:
* @parent_realize: The parent class' realize handler.