root / hw / mips_int.c @ ed23fbd9
History | View | Annotate | Download (1.1 kB)
1 | 87ecb68b | pbrook | #include "hw.h" |
---|---|---|---|
2 | 87ecb68b | pbrook | #include "mips.h" |
3 | 4de9b249 | ths | #include "cpu.h" |
4 | 4de9b249 | ths | |
5 | 4de9b249 | ths | /* Raise IRQ to CPU if necessary. It must be called every time the active
|
6 | 4de9b249 | ths | IRQ may change */
|
7 | 4de9b249 | ths | void cpu_mips_update_irq(CPUState *env)
|
8 | 4de9b249 | ths | { |
9 | 24c7b0e3 | ths | if ((env->CP0_Status & (1 << CP0St_IE)) && |
10 | 24c7b0e3 | ths | !(env->CP0_Status & (1 << CP0St_EXL)) &&
|
11 | 24c7b0e3 | ths | !(env->CP0_Status & (1 << CP0St_ERL)) &&
|
12 | 24c7b0e3 | ths | !(env->hflags & MIPS_HFLAG_DM)) { |
13 | 24c7b0e3 | ths | if ((env->CP0_Status & env->CP0_Cause & CP0Ca_IP_mask) &&
|
14 | 24c7b0e3 | ths | !(env->interrupt_request & CPU_INTERRUPT_HARD)) { |
15 | 4de9b249 | ths | cpu_interrupt(env, CPU_INTERRUPT_HARD); |
16 | 4de9b249 | ths | } |
17 | 24c7b0e3 | ths | } else
|
18 | 4de9b249 | ths | cpu_reset_interrupt(env, CPU_INTERRUPT_HARD); |
19 | 4de9b249 | ths | } |
20 | 4de9b249 | ths | |
21 | d537cf6c | pbrook | static void cpu_mips_irq_request(void *opaque, int irq, int level) |
22 | 4de9b249 | ths | { |
23 | 39d51eb8 | ths | CPUState *env = (CPUState *)opaque; |
24 | 4de9b249 | ths | |
25 | 39d51eb8 | ths | if (irq < 0 || irq > 7) |
26 | 4de9b249 | ths | return;
|
27 | 4de9b249 | ths | |
28 | 4de9b249 | ths | if (level) {
|
29 | 39d51eb8 | ths | env->CP0_Cause |= 1 << (irq + CP0Ca_IP);
|
30 | 4de9b249 | ths | } else {
|
31 | a4bc3afc | ths | env->CP0_Cause &= ~(1 << (irq + CP0Ca_IP));
|
32 | 4de9b249 | ths | } |
33 | 4de9b249 | ths | cpu_mips_update_irq(env); |
34 | 4de9b249 | ths | } |
35 | d537cf6c | pbrook | |
36 | d537cf6c | pbrook | void cpu_mips_irq_init_cpu(CPUState *env)
|
37 | d537cf6c | pbrook | { |
38 | d537cf6c | pbrook | qemu_irq *qi; |
39 | d537cf6c | pbrook | int i;
|
40 | d537cf6c | pbrook | |
41 | d537cf6c | pbrook | qi = qemu_allocate_irqs(cpu_mips_irq_request, env, 8);
|
42 | d537cf6c | pbrook | for (i = 0; i < 8; i++) { |
43 | d537cf6c | pbrook | env->irq[i] = qi[i]; |
44 | d537cf6c | pbrook | } |
45 | d537cf6c | pbrook | } |