Skip to content

Commit

Permalink
target/riscv: Validate misa_mxl_max only once
Browse files Browse the repository at this point in the history
misa_mxl_max is now a class member and initialized only once for each
class. This also moves the initialization of gdb_core_xml_file which
will be referenced before realization in the future.

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Message-Id: <20240103173349.398526-26-alex.bennee@linaro.org>
Message-Id: <20231213-riscv-v7-4-a760156a337f@daynix.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
  • Loading branch information
akihikodaki authored and stsquad committed Jan 15, 2024
1 parent 13b5ebd commit 623a92a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
21 changes: 21 additions & 0 deletions target/riscv/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1292,6 +1292,26 @@ static const MISAExtInfo misa_ext_info_arr[] = {
MISA_EXT_INFO(RVG, "g", "General purpose (IMAFD_Zicsr_Zifencei)"),
};

static void riscv_cpu_validate_misa_mxl(RISCVCPUClass *mcc)
{
CPUClass *cc = CPU_CLASS(mcc);

/* Validate that MISA_MXL is set properly. */
switch (mcc->misa_mxl_max) {
#ifdef TARGET_RISCV64
case MXL_RV64:
case MXL_RV128:
cc->gdb_core_xml_file = "riscv-64bit-cpu.xml";
break;
#endif
case MXL_RV32:
cc->gdb_core_xml_file = "riscv-32bit-cpu.xml";
break;
default:
g_assert_not_reached();
}
}

static int riscv_validate_misa_info_idx(uint32_t bit)
{
int idx;
Expand Down Expand Up @@ -1833,6 +1853,7 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data)
RISCVCPUClass *mcc = RISCV_CPU_CLASS(c);

mcc->misa_mxl_max = (uint32_t)(uintptr_t)data;
riscv_cpu_validate_misa_mxl(mcc);
}

static void riscv_isa_string_ext(RISCVCPU *cpu, char **isa_str,
Expand Down
23 changes: 0 additions & 23 deletions target/riscv/tcg/tcg-cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,27 +268,6 @@ static void riscv_cpu_validate_misa_priv(CPURISCVState *env, Error **errp)
}
}

static void riscv_cpu_validate_misa_mxl(RISCVCPU *cpu)
{
RISCVCPUClass *mcc = RISCV_CPU_GET_CLASS(cpu);
CPUClass *cc = CPU_CLASS(mcc);

/* Validate that MISA_MXL is set properly. */
switch (mcc->misa_mxl_max) {
#ifdef TARGET_RISCV64
case MXL_RV64:
case MXL_RV128:
cc->gdb_core_xml_file = "riscv-64bit-cpu.xml";
break;
#endif
case MXL_RV32:
cc->gdb_core_xml_file = "riscv-32bit-cpu.xml";
break;
default:
g_assert_not_reached();
}
}

static void riscv_cpu_validate_priv_spec(RISCVCPU *cpu, Error **errp)
{
CPURISCVState *env = &cpu->env;
Expand Down Expand Up @@ -935,8 +914,6 @@ static bool tcg_cpu_realize(CPUState *cs, Error **errp)
return false;
}

riscv_cpu_validate_misa_mxl(cpu);

#ifndef CONFIG_USER_ONLY
CPURISCVState *env = &cpu->env;
Error *local_err = NULL;
Expand Down

0 comments on commit 623a92a

Please sign in to comment.