blob: ffb4d4171a587249fa01acdc01ee06765a7b7a4b [file] [log] [blame]
ths5fafdf22007-09-16 21:08:06 +00001/*
pbrookcdbdb642006-04-09 01:32:52 +00002 * Generic ARM Programmable Interrupt Controller support.
3 *
4 * Copyright (c) 2006 CodeSourcery.
5 * Written by Paul Brook
6 *
Matthew Fernandez8e31bf32011-06-26 12:21:35 +10007 * This code is licensed under the LGPL
pbrookcdbdb642006-04-09 01:32:52 +00008 */
9
pbrook87ecb682007-11-17 17:14:51 +000010#include "hw.h"
11#include "arm-misc.h"
pbrookcdbdb642006-04-09 01:32:52 +000012
pbrookd537cf62007-04-07 18:14:41 +000013/* Input 0 is IRQ and input 1 is FIQ. */
pbrookcdbdb642006-04-09 01:32:52 +000014static void arm_pic_cpu_handler(void *opaque, int irq, int level)
15{
Andreas Färber4bd74662012-05-14 04:21:52 +020016 ARMCPU *cpu = opaque;
17 CPUARMState *env = &cpu->env;
18
pbrookcdbdb642006-04-09 01:32:52 +000019 switch (irq) {
20 case ARM_PIC_CPU_IRQ:
21 if (level)
pbrookd537cf62007-04-07 18:14:41 +000022 cpu_interrupt(env, CPU_INTERRUPT_HARD);
pbrookcdbdb642006-04-09 01:32:52 +000023 else
pbrookd537cf62007-04-07 18:14:41 +000024 cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
pbrookcdbdb642006-04-09 01:32:52 +000025 break;
26 case ARM_PIC_CPU_FIQ:
27 if (level)
pbrookd537cf62007-04-07 18:14:41 +000028 cpu_interrupt(env, CPU_INTERRUPT_FIQ);
pbrookcdbdb642006-04-09 01:32:52 +000029 else
pbrookd537cf62007-04-07 18:14:41 +000030 cpu_reset_interrupt(env, CPU_INTERRUPT_FIQ);
pbrookcdbdb642006-04-09 01:32:52 +000031 break;
32 default:
Andreas Färber47601f22011-10-10 01:27:01 +020033 hw_error("arm_pic_cpu_handler: Bad interrupt line %d\n", irq);
pbrookcdbdb642006-04-09 01:32:52 +000034 }
35}
36
Andreas Färber4bd74662012-05-14 04:21:52 +020037qemu_irq *arm_pic_init_cpu(ARMCPU *cpu)
pbrookcdbdb642006-04-09 01:32:52 +000038{
Andreas Färber4bd74662012-05-14 04:21:52 +020039 return qemu_allocate_irqs(arm_pic_cpu_handler, cpu, 2);
pbrookcdbdb642006-04-09 01:32:52 +000040}