Statistics
| Branch: | Revision:

root / hw / mips_int.c @ f0fc6f8f

History | View | Annotate | Download (1.1 kB)

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 d537cf6c pbrook
static 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 a4bc3afc ths
        env->CP0_Cause &= ~(1 << (irq + CP0Ca_IP));
31 4de9b249 ths
    }
32 4de9b249 ths
    cpu_mips_update_irq(env);
33 4de9b249 ths
}
34 d537cf6c pbrook
35 d537cf6c pbrook
void cpu_mips_irq_init_cpu(CPUState *env)
36 d537cf6c pbrook
{
37 d537cf6c pbrook
    qemu_irq *qi;
38 d537cf6c pbrook
    int i;
39 d537cf6c pbrook
40 d537cf6c pbrook
    qi = qemu_allocate_irqs(cpu_mips_irq_request, env, 8);
41 d537cf6c pbrook
    for (i = 0; i < 8; i++) {
42 d537cf6c pbrook
        env->irq[i] = qi[i];
43 d537cf6c pbrook
    }
44 d537cf6c pbrook
}