aboutsummaryrefslogtreecommitdiff
path: root/hw/riscv/boot.c
diff options
context:
space:
mode:
authorAlistair Francis <alistair.francis@wdc.com>2020-12-16 10:23:08 -0800
committerAlistair Francis <alistair.francis@wdc.com>2020-12-17 21:56:44 -0800
commit3ed2b8ac2dacc22c088ec5793ecde31db2fa0414 (patch)
tree734bb793e6c561360a30de8ecca155ebf2db112a /hw/riscv/boot.c
parent094b072c6819f251e4cba608585f0f5f59259797 (diff)
downloadqemu-3ed2b8ac2dacc22c088ec5793ecde31db2fa0414.zip
qemu-3ed2b8ac2dacc22c088ec5793ecde31db2fa0414.tar.gz
qemu-3ed2b8ac2dacc22c088ec5793ecde31db2fa0414.tar.bz2
hw/riscv: Use the CPU to determine if 32-bit
Instead of using string compares to determine if a RISC-V machine is using 32-bit or 64-bit CPUs we can use the initalised CPUs. This avoids us having to maintain a list of CPU names to compare against. This commit also fixes the name of the function to match the riscv_cpu_is_32bit() function. Signed-off-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 8ab7614e5df93ab5267788b73dcd75f9f5615e82.1608142916.git.alistair.francis@wdc.com
Diffstat (limited to 'hw/riscv/boot.c')
-rw-r--r--hw/riscv/boot.c31
1 files changed, 10 insertions, 21 deletions
diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c
index 6bce6fb..83586ae 100644
--- a/hw/riscv/boot.c
+++ b/hw/riscv/boot.c
@@ -33,28 +33,16 @@
#include <libfdt.h>
-bool riscv_is_32_bit(MachineState *machine)
+bool riscv_is_32bit(RISCVHartArrayState harts)
{
- /*
- * To determine if the CPU is 32-bit we need to check a few different CPUs.
- *
- * If the CPU starts with rv32
- * If the CPU is a sifive 3 seriries CPU (E31, U34)
- * If it's the Ibex CPU
- */
- if (!strncmp(machine->cpu_type, "rv32", 4) ||
- (!strncmp(machine->cpu_type, "sifive", 6) &&
- machine->cpu_type[8] == '3') ||
- !strncmp(machine->cpu_type, "lowrisc-ibex", 12)) {
- return true;
- } else {
- return false;
- }
+ RISCVCPU hart = harts.harts[0];
+
+ return riscv_cpu_is_32bit(&hart.env);
}
-target_ulong riscv_calc_kernel_start_addr(MachineState *machine,
+target_ulong riscv_calc_kernel_start_addr(RISCVHartArrayState harts,
target_ulong firmware_end_addr) {
- if (riscv_is_32_bit(machine)) {
+ if (riscv_is_32bit(harts)) {
return QEMU_ALIGN_UP(firmware_end_addr, 4 * MiB);
} else {
return QEMU_ALIGN_UP(firmware_end_addr, 2 * MiB);
@@ -259,7 +247,8 @@ void riscv_rom_copy_firmware_info(MachineState *machine, hwaddr rom_base,
&address_space_memory);
}
-void riscv_setup_rom_reset_vec(MachineState *machine, hwaddr start_addr,
+void riscv_setup_rom_reset_vec(MachineState *machine, RISCVHartArrayState harts,
+ hwaddr start_addr,
hwaddr rom_base, hwaddr rom_size,
uint64_t kernel_entry,
uint32_t fdt_load_addr, void *fdt)
@@ -267,7 +256,7 @@ void riscv_setup_rom_reset_vec(MachineState *machine, hwaddr start_addr,
int i;
uint32_t start_addr_hi32 = 0x00000000;
- if (!riscv_is_32_bit(machine)) {
+ if (!riscv_is_32bit(harts)) {
start_addr_hi32 = start_addr >> 32;
}
/* reset vector */
@@ -284,7 +273,7 @@ void riscv_setup_rom_reset_vec(MachineState *machine, hwaddr start_addr,
0x00000000,
/* fw_dyn: */
};
- if (riscv_is_32_bit(machine)) {
+ if (riscv_is_32bit(harts)) {
reset_vec[3] = 0x0202a583; /* lw a1, 32(t0) */
reset_vec[4] = 0x0182a283; /* lw t0, 24(t0) */
} else {