aboutsummaryrefslogtreecommitdiff
path: root/target/xtensa/helper.c
diff options
context:
space:
mode:
authorMax Filippov <jcmvbkbc@gmail.com>2019-01-13 19:51:54 -0800
committerMax Filippov <jcmvbkbc@gmail.com>2019-01-13 23:36:29 -0800
commit8d918d656a1c4bb2300928468e27c53d72420bb9 (patch)
treea6c32a713a3f862f0074949870958e9169b73ccc /target/xtensa/helper.c
parent8803bfea0ea6dee8f44e56775ed77eb4175bb916 (diff)
downloadqemu-8d918d656a1c4bb2300928468e27c53d72420bb9.zip
qemu-8d918d656a1c4bb2300928468e27c53d72420bb9.tar.gz
qemu-8d918d656a1c4bb2300928468e27c53d72420bb9.tar.bz2
target/xtensa: extract interrupt and exception helpers
Move helper functions related to interrupt and exception handling from op_helper.c and helper.c to exc_helper.c. No functional changes. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Diffstat (limited to 'target/xtensa/helper.c')
-rw-r--r--target/xtensa/helper.c127
1 files changed, 0 insertions, 127 deletions
diff --git a/target/xtensa/helper.c b/target/xtensa/helper.c
index c344241..2f1dec5 100644
--- a/target/xtensa/helper.c
+++ b/target/xtensa/helper.c
@@ -169,133 +169,6 @@ void xtensa_cpu_list(FILE *f, fprintf_function cpu_fprintf)
}
}
-#ifndef CONFIG_USER_ONLY
-
-static uint32_t relocated_vector(CPUXtensaState *env, uint32_t vector)
-{
- if (xtensa_option_enabled(env->config,
- XTENSA_OPTION_RELOCATABLE_VECTOR)) {
- return vector - env->config->vecbase + env->sregs[VECBASE];
- } else {
- return vector;
- }
-}
-
-/*!
- * Handle penging IRQ.
- * For the high priority interrupt jump to the corresponding interrupt vector.
- * For the level-1 interrupt convert it to either user, kernel or double
- * exception with the 'level-1 interrupt' exception cause.
- */
-static void handle_interrupt(CPUXtensaState *env)
-{
- int level = env->pending_irq_level;
-
- if (level > xtensa_get_cintlevel(env) &&
- level <= env->config->nlevel &&
- (env->config->level_mask[level] &
- env->sregs[INTSET] &
- env->sregs[INTENABLE])) {
- CPUState *cs = CPU(xtensa_env_get_cpu(env));
-
- if (level > 1) {
- env->sregs[EPC1 + level - 1] = env->pc;
- env->sregs[EPS2 + level - 2] = env->sregs[PS];
- env->sregs[PS] =
- (env->sregs[PS] & ~PS_INTLEVEL) | level | PS_EXCM;
- env->pc = relocated_vector(env,
- env->config->interrupt_vector[level]);
- } else {
- env->sregs[EXCCAUSE] = LEVEL1_INTERRUPT_CAUSE;
-
- if (env->sregs[PS] & PS_EXCM) {
- if (env->config->ndepc) {
- env->sregs[DEPC] = env->pc;
- } else {
- env->sregs[EPC1] = env->pc;
- }
- cs->exception_index = EXC_DOUBLE;
- } else {
- env->sregs[EPC1] = env->pc;
- cs->exception_index =
- (env->sregs[PS] & PS_UM) ? EXC_USER : EXC_KERNEL;
- }
- env->sregs[PS] |= PS_EXCM;
- }
- env->exception_taken = 1;
- }
-}
-
-/* Called from cpu_handle_interrupt with BQL held */
-void xtensa_cpu_do_interrupt(CPUState *cs)
-{
- XtensaCPU *cpu = XTENSA_CPU(cs);
- CPUXtensaState *env = &cpu->env;
-
- if (cs->exception_index == EXC_IRQ) {
- qemu_log_mask(CPU_LOG_INT,
- "%s(EXC_IRQ) level = %d, cintlevel = %d, "
- "pc = %08x, a0 = %08x, ps = %08x, "
- "intset = %08x, intenable = %08x, "
- "ccount = %08x\n",
- __func__, env->pending_irq_level, xtensa_get_cintlevel(env),
- env->pc, env->regs[0], env->sregs[PS],
- env->sregs[INTSET], env->sregs[INTENABLE],
- env->sregs[CCOUNT]);
- handle_interrupt(env);
- }
-
- switch (cs->exception_index) {
- case EXC_WINDOW_OVERFLOW4:
- case EXC_WINDOW_UNDERFLOW4:
- case EXC_WINDOW_OVERFLOW8:
- case EXC_WINDOW_UNDERFLOW8:
- case EXC_WINDOW_OVERFLOW12:
- case EXC_WINDOW_UNDERFLOW12:
- case EXC_KERNEL:
- case EXC_USER:
- case EXC_DOUBLE:
- case EXC_DEBUG:
- qemu_log_mask(CPU_LOG_INT, "%s(%d) "
- "pc = %08x, a0 = %08x, ps = %08x, ccount = %08x\n",
- __func__, cs->exception_index,
- env->pc, env->regs[0], env->sregs[PS], env->sregs[CCOUNT]);
- if (env->config->exception_vector[cs->exception_index]) {
- env->pc = relocated_vector(env,
- env->config->exception_vector[cs->exception_index]);
- env->exception_taken = 1;
- } else {
- qemu_log_mask(CPU_LOG_INT, "%s(pc = %08x) bad exception_index: %d\n",
- __func__, env->pc, cs->exception_index);
- }
- break;
-
- case EXC_IRQ:
- break;
-
- default:
- qemu_log("%s(pc = %08x) unknown exception_index: %d\n",
- __func__, env->pc, cs->exception_index);
- break;
- }
- check_interrupts(env);
-}
-#else
-void xtensa_cpu_do_interrupt(CPUState *cs)
-{
-}
-#endif
-
-bool xtensa_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
-{
- if (interrupt_request & CPU_INTERRUPT_HARD) {
- cs->exception_index = EXC_IRQ;
- xtensa_cpu_do_interrupt(cs);
- return true;
- }
- return false;
-}
-
#ifdef CONFIG_USER_ONLY
int xtensa_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int rw,