target/nios2: Rewrite interrupt handling

Previously, we would avoid setting CPU_INTERRUPT_HARD when interrupts
are disabled at a particular point in time, instead queuing the value
into cpu->irq_pending.  This is more complicated than required.

Instead, set CPU_INTERRUPT_HARD any time there is a pending interrupt,
and exclusively check for interrupts disabled in nios2_cpu_exec_interrupt.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson 2022-02-26 01:56:15 -10:00
parent 8d8d73b551
commit b72c9d5951
5 changed files with 9 additions and 36 deletions

View file

@ -73,12 +73,9 @@ static void nios2_cpu_set_irq(void *opaque, int irq, int level)
env->regs[CR_IPENDING] = deposit32(env->regs[CR_IPENDING], irq, 1, !!level);
env->irq_pending = env->regs[CR_IPENDING] & env->regs[CR_IENABLE];
if (env->irq_pending && (env->regs[CR_STATUS] & CR_STATUS_PIE)) {
env->irq_pending = 0;
if (env->regs[CR_IPENDING]) {
cpu_interrupt(cs, CPU_INTERRUPT_HARD);
} else if (!env->irq_pending) {
} else {
cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD);
}
}
@ -134,7 +131,8 @@ static bool nios2_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
CPUNios2State *env = &cpu->env;
if ((interrupt_request & CPU_INTERRUPT_HARD) &&
(env->regs[CR_STATUS] & CR_STATUS_PIE)) {
(env->regs[CR_STATUS] & CR_STATUS_PIE) &&
(env->regs[CR_IPENDING] & env->regs[CR_IENABLE])) {
cs->exception_index = EXCP_IRQ;
nios2_cpu_do_interrupt(cs);
return true;