@@ -66,6 +66,26 @@ enum {
NUM_REGS = 16,
};
+enum {
+ /*
+ * The Fixed Vector Table begins at 0xffffff80 and contains 32 entries,
+ * most of which are reserved.
+ */
+ EXCP_PRIVILEGED = 20,
+ EXCP_ACCESS = 21,
+ EXCP_UNDEFINED = 23,
+ EXCP_FPU = 25,
+ EXCP_NMI = 30,
+ EXCP_RESET = 31,
+
+ /*
+ * The Relocatable Vector Table begins at env->intb and
+ * contains 256 entries.
+ */
+ EXCP_INTB_0 = 0x100,
+ EXCP_INTB_255 = EXCP_INTB_0 + 255,
+};
+
typedef struct CPUArchState {
/* CPU registers */
uint32_t regs[NUM_REGS]; /* general registers */
@@ -83,36 +83,43 @@ void rx_cpu_do_interrupt(CPUState *cs)
}
} else {
uint32_t vec = cs->exception_index;
- const char *expname = "unknown exception";
+ const char *expname;
env->isp -= 4;
cpu_stl_data(env, env->isp, save_psw);
env->isp -= 4;
cpu_stl_data(env, env->isp, env->pc);
- if (vec < 0x100) {
+ if (vec < EXCP_INTB_0) {
env->pc = cpu_ldl_data(env, 0xffffff80 + vec * 4);
} else {
- env->pc = cpu_ldl_data(env, env->intb + (vec & 0xff) * 4);
+ env->pc = cpu_ldl_data(env, env->intb + (vec - EXCP_INTB_0) * 4);
}
switch (vec) {
- case 20:
+ case EXCP_PRIVILEGED:
expname = "privilege violation";
break;
- case 21:
+ case EXCP_ACCESS:
expname = "access exception";
break;
- case 23:
+ case EXCP_UNDEFINED:
expname = "illegal instruction";
break;
- case 25:
+ case EXCP_FPU:
expname = "fpu exception";
break;
- case 30:
+ case EXCP_NMI:
expname = "non-maskable interrupt";
break;
- case 0x100 ... 0x1ff:
+ case EXCP_RESET:
+ expname = "reset interrupt";
+ break;
+ case EXCP_INTB_0 ... EXCP_INTB_255:
expname = "unconditional trap";
+ break;
+ default:
+ expname = "unknown exception";
+ break;
}
qemu_log_mask(CPU_LOG_INT, "exception 0x%02x [%s] raised\n",
(vec & 0xff), expname);
@@ -114,7 +114,7 @@ static void update_fpsw(CPURXState *env, float32 ret, uintptr_t retaddr)
enable = FIELD_EX32(env->fpsw, FPSW, ENABLE);
enable |= 1 << 5; /* CE always enabled */
if (cause & enable) {
- raise_exception(env, 21, retaddr);
+ raise_exception(env, EXCP_FPU, retaddr);
}
}
}
@@ -420,8 +420,7 @@ uint32_t helper_divu(CPURXState *env, uint32_t num, uint32_t den)
/* exception */
static inline G_NORETURN
-void raise_exception(CPURXState *env, int index,
- uintptr_t retaddr)
+void raise_exception(CPURXState *env, int index, uintptr_t retaddr)
{
CPUState *cs = env_cpu(env);
@@ -431,17 +430,17 @@ void raise_exception(CPURXState *env, int index,
G_NORETURN void helper_raise_privilege_violation(CPURXState *env)
{
- raise_exception(env, 20, GETPC());
+ raise_exception(env, EXCP_PRIVILEGED, GETPC());
}
G_NORETURN void helper_raise_access_fault(CPURXState *env)
{
- raise_exception(env, 21, GETPC());
+ raise_exception(env, EXCP_ACCESS, GETPC());
}
G_NORETURN void helper_raise_illegal_instruction(CPURXState *env)
{
- raise_exception(env, 23, GETPC());
+ raise_exception(env, EXCP_UNDEFINED, GETPC());
}
G_NORETURN void helper_wait(CPURXState *env)
@@ -456,10 +455,10 @@ G_NORETURN void helper_wait(CPURXState *env)
G_NORETURN void helper_rxint(CPURXState *env, uint32_t vec)
{
- raise_exception(env, 0x100 + vec, 0);
+ raise_exception(env, EXCP_INTB_0 + vec, 0);
}
G_NORETURN void helper_rxbrk(CPURXState *env)
{
- raise_exception(env, 0x100, 0);
+ raise_exception(env, EXCP_INTB_0, 0);
}
Provide EXCP_* names to the fixed and relocatable vector table entries. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- target/rx/cpu.h | 20 ++++++++++++++++++++ target/rx/helper.c | 25 ++++++++++++++++--------- target/rx/op_helper.c | 15 +++++++-------- 3 files changed, 43 insertions(+), 17 deletions(-)