Support different CPU types for the sifive_e machine
Subsystems (2)
cover Support different CPU types for the sifive_e machine
The purpose of this patch set is to allow the sifive_e machine to run with different CPU targets to enable different ISA entensions. To that end it also introduces a new sifive-e34 CPU type which provides the same ISA as sifive-e31, with the addition of the single precision floating-point extension (f). The default CPU for the sifive_e machine is unchanged.
A user can change the default CPU type by specifying it with the '-cpu' option on the command line.
Corey Wharton (2):
riscv: sifive_e: Support changing CPU type
target/riscv: Add a sifive-e34 cpu type
hw/riscv/sifive_e.c | 3 ++- target/riscv/cpu.c | 10 ++++++++++ target/riscv/cpu.h | 1 + 3 files changed, 13 insertions(+), 1 deletion(-)
Signature · 1 line
2.21.1
PATCH 1/2 riscv: sifive_e: Support changing CPU type
Allows the CPU to be changed from the default via the -cpu command line option.
--- hw/riscv/sifive_e.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/riscv/sifive_e.c +2 -1
@@ -123,7 +123,7 @@ static void riscv_sifive_e_soc_init(Object *obj)object_initialize_child (obj,"cpus" , &s->cpus,sizeof (s->cpus),TYPE_RISCV_HART_ARRAY , &error_abort,NULL ); -object_property_set_str (OBJECT (&s->cpus),SIFIVE_E_CPU ,"cpu-type" , +object_property_set_str (OBJECT (&s->cpus), ms->cpu_type,"cpu-type" , &error_abort);object_property_set_int (OBJECT (&s->cpus), ms->smp.cpus,"num-harts" , &error_abort);
@@ -220,6 +220,7 @@ static void riscv_sifive_e_machine_init(MachineClass *mc) mc->desc ="RISC-V Board compatible with SiFive E SDK" ; mc->init = riscv_sifive_e_init; mc->max_cpus =1 ; + mc->default_cpu_type =SIFIVE_E_CPU ; }DEFINE_MACHINE ("sifive_e" , riscv_sifive_e_machine_init)
Signature · 1 line
2.21.1
PATCH 2/2 target/riscv: Add a sifive-e34 cpu type
In reply to Corey WhartonThe sifive-e34 cpu type is the same as the sifive-e31 with the single precision floating-point extension enabled.
--- target/riscv/cpu.c | 10 ++++++++++ target/riscv/cpu.h | 1 + 2 files changed, 11 insertions(+)
target/riscv/cpu.c +10 -0
@@ -164,6 +164,15 @@ static void rv32imacu_nommu_cpu_init(Object *obj) set_feature(env, RISCV_FEATURE_PMP); } +static void rv32imafcu_nommu_cpu_init (Object *obj) +{ +CPURISCVState *env = &RISCV_CPU (obj)->env; +set_misa (env,RV32 |RVI |RVM |RVA |RVF |RVC ); +set_priv_version (env,PRIV_VERSION_1_10_0 ); +set_resetvec (env,DEFAULT_RSTVEC ); +set_feature (env,RISCV_FEATURE_PMP ); +} +#elif defined(TARGET_RISCV64)static void riscv_base64_cpu_init (Object *obj)
@@ -609,6 +618,7 @@ static const TypeInfo riscv_cpu_type_infos[] = {#if defined(TARGET_RISCV32 )DEFINE_CPU (TYPE_RISCV_CPU_BASE32 , riscv_base32_cpu_init),DEFINE_CPU (TYPE_RISCV_CPU_SIFIVE_E31 , rv32imacu_nommu_cpu_init), +DEFINE_CPU (TYPE_RISCV_CPU_SIFIVE_E34 , rv32imafcu_nommu_cpu_init),DEFINE_CPU (TYPE_RISCV_CPU_SIFIVE_U34 , rv32gcsu_priv1_10_0_cpu_init),/* Depreacted */ DEFINE_CPU(TYPE_RISCV_CPU_RV32IMACU_NOMMU, rv32imacu_nommu_cpu_init),
target/riscv/cpu.h +1 -0
@@ -36,6 +36,7 @@#define TYPE_RISCV_CPU_BASE32 RISCV_CPU_TYPE_NAME("rv32")#define TYPE_RISCV_CPU_BASE64 RISCV_CPU_TYPE_NAME("rv64")#define TYPE_RISCV_CPU_SIFIVE_E31 RISCV_CPU_TYPE_NAME("sifive-e31") +#define TYPE_RISCV_CPU_SIFIVE_E34 RISCV_CPU_TYPE_NAME("sifive-e34")#define TYPE_RISCV_CPU_SIFIVE_E51 RISCV_CPU_TYPE_NAME("sifive-e51")#define TYPE_RISCV_CPU_SIFIVE_U34 RISCV_CPU_TYPE_NAME("sifive-u34")#define TYPE_RISCV_CPU_SIFIVE_U54 RISCV_CPU_TYPE_NAME("sifive-u54")
Signature · 1 line
2.21.1