Statistics
| Branch: | Revision:

root / hw / mips / mips_int.c @ f81222bc

History | View | Annotate | Download (2 kB)

1 7b9cbadb Aurelien Jarno
/*
2 7b9cbadb Aurelien Jarno
 * QEMU MIPS interrupt support
3 7b9cbadb Aurelien Jarno
 *
4 7b9cbadb Aurelien Jarno
 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 7b9cbadb Aurelien Jarno
 * of this software and associated documentation files (the "Software"), to deal
6 7b9cbadb Aurelien Jarno
 * in the Software without restriction, including without limitation the rights
7 7b9cbadb Aurelien Jarno
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 7b9cbadb Aurelien Jarno
 * copies of the Software, and to permit persons to whom the Software is
9 7b9cbadb Aurelien Jarno
 * furnished to do so, subject to the following conditions:
10 7b9cbadb Aurelien Jarno
 *
11 7b9cbadb Aurelien Jarno
 * The above copyright notice and this permission notice shall be included in
12 7b9cbadb Aurelien Jarno
 * all copies or substantial portions of the Software.
13 7b9cbadb Aurelien Jarno
 *
14 7b9cbadb Aurelien Jarno
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 7b9cbadb Aurelien Jarno
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 7b9cbadb Aurelien Jarno
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 7b9cbadb Aurelien Jarno
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 7b9cbadb Aurelien Jarno
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 7b9cbadb Aurelien Jarno
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 7b9cbadb Aurelien Jarno
 * THE SOFTWARE.
21 7b9cbadb Aurelien Jarno
 */
22 7b9cbadb Aurelien Jarno
23 83c9f4ca Paolo Bonzini
#include "hw/hw.h"
24 0d09e41a Paolo Bonzini
#include "hw/mips/cpudevs.h"
25 4de9b249 ths
#include "cpu.h"
26 4de9b249 ths
27 d537cf6c pbrook
static void cpu_mips_irq_request(void *opaque, int irq, int level)
28 4de9b249 ths
{
29 d8ed887b Andreas Färber
    MIPSCPU *cpu = opaque;
30 d8ed887b Andreas Färber
    CPUMIPSState *env = &cpu->env;
31 d8ed887b Andreas Färber
    CPUState *cs = CPU(cpu);
32 4de9b249 ths
33 39d51eb8 ths
    if (irq < 0 || irq > 7)
34 4de9b249 ths
        return;
35 4de9b249 ths
36 4de9b249 ths
    if (level) {
37 39d51eb8 ths
        env->CP0_Cause |= 1 << (irq + CP0Ca_IP);
38 4de9b249 ths
    } else {
39 a4bc3afc ths
        env->CP0_Cause &= ~(1 << (irq + CP0Ca_IP));
40 4de9b249 ths
    }
41 36388314 Edgar E. Iglesias
42 36388314 Edgar E. Iglesias
    if (env->CP0_Cause & CP0Ca_IP_mask) {
43 c3affe56 Andreas Färber
        cpu_interrupt(cs, CPU_INTERRUPT_HARD);
44 36388314 Edgar E. Iglesias
    } else {
45 d8ed887b Andreas Färber
        cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD);
46 36388314 Edgar E. Iglesias
    }
47 4de9b249 ths
}
48 d537cf6c pbrook
49 61c56c8c Andreas Färber
void cpu_mips_irq_init_cpu(CPUMIPSState *env)
50 d537cf6c pbrook
{
51 d537cf6c pbrook
    qemu_irq *qi;
52 d537cf6c pbrook
    int i;
53 d537cf6c pbrook
54 d8ed887b Andreas Färber
    qi = qemu_allocate_irqs(cpu_mips_irq_request, mips_env_get_cpu(env), 8);
55 d537cf6c pbrook
    for (i = 0; i < 8; i++) {
56 d537cf6c pbrook
        env->irq[i] = qi[i];
57 d537cf6c pbrook
    }
58 d537cf6c pbrook
}
59 5dc5d9f0 Aurelien Jarno
60 61c56c8c Andreas Färber
void cpu_mips_soft_irq(CPUMIPSState *env, int irq, int level)
61 5dc5d9f0 Aurelien Jarno
{
62 5dc5d9f0 Aurelien Jarno
    if (irq < 0 || irq > 2) {
63 5dc5d9f0 Aurelien Jarno
        return;
64 5dc5d9f0 Aurelien Jarno
    }
65 5dc5d9f0 Aurelien Jarno
66 5dc5d9f0 Aurelien Jarno
    qemu_set_irq(env->irq[irq], level);
67 5dc5d9f0 Aurelien Jarno
}