[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] target/rx/cpu: Use address_space_ldl() to read reset vector addr
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH] target/rx/cpu: Use address_space_ldl() to read reset vector address |
Date: |
Sun, 15 Mar 2020 14:48:59 +0100 |
From: Philippe Mathieu-Daudé <address@hidden>
The RX code flash is not a Masked ROM but a EEPROM (electrically
erasable programmable flash memory).
When implementing the flash hardware, the rom_ptr() returns NULL
and the reset vector is not set.
Instead, use the address_space ld/st API to fetch the reset vector
address from the code flash.
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
Based-on: <address@hidden>
Same issue might occurs in Cortex-M arm_cpu_reset()
---
target/rx/cpu.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/target/rx/cpu.c b/target/rx/cpu.c
index 9c224a273c..d3bd09e753 100644
--- a/target/rx/cpu.c
+++ b/target/rx/cpu.c
@@ -26,6 +26,8 @@
#include "hw/loader.h"
#include "fpu/softfloat.h"
+#define CPU_RESET_VECTOR 0xfffffffc
+
static void rx_cpu_set_pc(CPUState *cs, vaddr value)
{
RXCPU *cpu = RXCPU(cs);
@@ -51,17 +53,13 @@ static void rx_cpu_reset(CPUState *s)
RXCPU *cpu = RXCPU(s);
RXCPUClass *rcc = RXCPU_GET_CLASS(cpu);
CPURXState *env = &cpu->env;
- uint32_t *resetvec;
rcc->parent_reset(s);
memset(env, 0, offsetof(CPURXState, end_reset_fields));
- resetvec = rom_ptr(0xfffffffc, 4);
- if (resetvec) {
- /* In the case of kernel, it is ignored because it is not set. */
- env->pc = ldl_p(resetvec);
- }
+ env->pc = address_space_ldl(cpu_get_address_space(s, 0),
+ CPU_RESET_VECTOR, MEMTXATTRS_UNSPECIFIED,
NULL);
rx_cpu_unpack_psw(env, 0, 1);
env->regs[0] = env->isp = env->usp = 0;
env->fpsw = 0;
--
2.21.1
- [PATCH] target/rx/cpu: Use address_space_ldl() to read reset vector address,
Philippe Mathieu-Daudé <=