Skip to contentSkip to conversation

hw/riscv: Setting address of vector reset is improved

PATCH In review Maksim Perov 2 participants 2 messages Aug 15, 2022 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/riscv: Setting address of vector reset is improved

Previously address is set by default value 0x1000 which is hardcoded in target/riscv/cpu_bits.h
If add to new RISC-V Machine in which ROM area is not based on 0x1000 address than there is problem of running simulation

---
 hw/riscv/boot.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/riscv/boot.c +4 -0
index 06b4fc5ac3..5e2438d39a 100644
@@ -327,6 +327,10 @@ void riscv_setup_rom_reset_vec(MachineState *machine, RISCVHartArrayState *harts
     riscv_rom_copy_firmware_info(machine, rom_base, rom_size, sizeof(reset_vec),
                                  kernel_entry);
 
+    /* change reset vector address */
+    for (i = 0; i < harts->num_harts; i++) {
+        harts->harts[i].env.resetvec = rom_base;
+    }
     return;
 }
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 14 lines · Maksim Perov

Previously address is set by default value 0x1000 which is hardcoded in target/riscv/cpu_bits.h
If add to new RISC-V Machine in which ROM area is not based on 0x1000 address than there is problem of running simulation

---
 hw/riscv/boot.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/riscv/boot.c +0 -0
index 06b4fc5ac3..5e2438d39a 100644

hw/riscv/boot.c void riscv_setup_rom_reset_vec(MachineState *machine, RISCVHartArrayState *harts · line 333

Quoted 7 lines
hw/riscv/boot.c +4 -0
@@ -327,6 +327,10 @@ void riscv_setup_rom_reset_vec(MachineState *machine, RISCVHartArrayState *harts
     riscv_rom_copy_firmware_info(machine, rom_base, rom_size, sizeof(reset_vec),
                                  kernel_entry);
 
+    /* change reset vector address */
+    for (i = 0; i < harts->num_harts; i++) {
+        harts->harts[i].env.resetvec = rom_base;
+    }

Thanks for the patch!

We don't want to do this though. The reset vector is part of the hardware design, we don't want to change the reset vector based on the software that is loaded.

The reset vector is exposed as a property (resetvec) and can be configured from a board. You could also configure it from the command line if you wanted to (although it might be overridden, I haven't checked).

Alistair

Quoted 7 lines
hw/riscv/boot.c +0 -1
     return;
 }
 
--

2.17.1