Statistics
| Branch: | Revision:

root / hw / mips_int.c @ 24c7b0e3

History | View | Annotate | Download (925 Bytes)

1 4de9b249 ths
#include "vl.h"
2 4de9b249 ths
#include "cpu.h"
3 4de9b249 ths
4 4de9b249 ths
/* Raise IRQ to CPU if necessary. It must be called every time the active
5 4de9b249 ths
   IRQ may change */
6 4de9b249 ths
void cpu_mips_update_irq(CPUState *env)
7 4de9b249 ths
{
8 24c7b0e3 ths
    if ((env->CP0_Status & (1 << CP0St_IE)) &&
9 24c7b0e3 ths
        !(env->CP0_Status & (1 << CP0St_EXL)) &&
10 24c7b0e3 ths
        !(env->CP0_Status & (1 << CP0St_ERL)) &&
11 24c7b0e3 ths
        !(env->hflags & MIPS_HFLAG_DM)) {
12 24c7b0e3 ths
        if ((env->CP0_Status & env->CP0_Cause & CP0Ca_IP_mask) &&
13 24c7b0e3 ths
            !(env->interrupt_request & CPU_INTERRUPT_HARD)) {
14 4de9b249 ths
            cpu_interrupt(env, CPU_INTERRUPT_HARD);
15 4de9b249 ths
        }
16 24c7b0e3 ths
    } else
17 4de9b249 ths
        cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
18 4de9b249 ths
}
19 4de9b249 ths
20 4de9b249 ths
void cpu_mips_irq_request(void *opaque, int irq, int level)
21 4de9b249 ths
{
22 39d51eb8 ths
    CPUState *env = (CPUState *)opaque;
23 4de9b249 ths
24 39d51eb8 ths
    if (irq < 0 || irq > 7)
25 4de9b249 ths
        return;
26 4de9b249 ths
27 4de9b249 ths
    if (level) {
28 39d51eb8 ths
        env->CP0_Cause |= 1 << (irq + CP0Ca_IP);
29 4de9b249 ths
    } else {
30 39d51eb8 ths
        env->CP0_Cause &= ~(1 << (irq +CP0Ca_IP));
31 4de9b249 ths
    }
32 4de9b249 ths
    cpu_mips_update_irq(env);
33 4de9b249 ths
}