mirror of
https://github.com/qemu/qemu.git
synced 2025-08-17 16:03:30 +00:00
hw/riscv: boot: Add a PLIC config string function
Add a generic function that can create the PLIC strings. Signed-off-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Message-id: 20211022060133.3045020-2-alistair.francis@opensource.wdc.com
This commit is contained in:
parent
9925c8bb81
commit
bf357e1d72
@ -38,6 +38,31 @@ bool riscv_is_32bit(RISCVHartArrayState *harts)
|
|||||||
return harts->harts[0].env.misa_mxl_max == MXL_RV32;
|
return harts->harts[0].env.misa_mxl_max == MXL_RV32;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the per-socket PLIC hart topology configuration string
|
||||||
|
* (caller must free with g_free())
|
||||||
|
*/
|
||||||
|
char *riscv_plic_hart_config_string(int hart_count)
|
||||||
|
{
|
||||||
|
g_autofree const char **vals = g_new(const char *, hart_count + 1);
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < hart_count; i++) {
|
||||||
|
CPUState *cs = qemu_get_cpu(i);
|
||||||
|
CPURISCVState *env = &RISCV_CPU(cs)->env;
|
||||||
|
|
||||||
|
if (riscv_has_ext(env, RVS)) {
|
||||||
|
vals[i] = "MS";
|
||||||
|
} else {
|
||||||
|
vals[i] = "M";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vals[i] = NULL;
|
||||||
|
|
||||||
|
/* g_strjoinv() obliges us to cast away const here */
|
||||||
|
return g_strjoinv(",", (char **)vals);
|
||||||
|
}
|
||||||
|
|
||||||
target_ulong riscv_calc_kernel_start_addr(RISCVHartArrayState *harts,
|
target_ulong riscv_calc_kernel_start_addr(RISCVHartArrayState *harts,
|
||||||
target_ulong firmware_end_addr) {
|
target_ulong firmware_end_addr) {
|
||||||
if (riscv_is_32bit(harts)) {
|
if (riscv_is_32bit(harts)) {
|
||||||
|
@ -31,6 +31,8 @@
|
|||||||
|
|
||||||
bool riscv_is_32bit(RISCVHartArrayState *harts);
|
bool riscv_is_32bit(RISCVHartArrayState *harts);
|
||||||
|
|
||||||
|
char *riscv_plic_hart_config_string(int hart_count);
|
||||||
|
|
||||||
target_ulong riscv_calc_kernel_start_addr(RISCVHartArrayState *harts,
|
target_ulong riscv_calc_kernel_start_addr(RISCVHartArrayState *harts,
|
||||||
target_ulong firmware_end_addr);
|
target_ulong firmware_end_addr);
|
||||||
target_ulong riscv_find_and_load_firmware(MachineState *machine,
|
target_ulong riscv_find_and_load_firmware(MachineState *machine,
|
||||||
|
Loading…
Reference in New Issue
Block a user