ths | 5fafdf2 | 2007-09-16 21:08:06 +0000 | [diff] [blame] | 1 | /* |
pbrook | cdbdb64 | 2006-04-09 01:32:52 +0000 | [diff] [blame] | 2 | * Generic ARM Programmable Interrupt Controller support. |
| 3 | * |
| 4 | * Copyright (c) 2006 CodeSourcery. |
| 5 | * Written by Paul Brook |
| 6 | * |
Matthew Fernandez | 8e31bf3 | 2011-06-26 12:21:35 +1000 | [diff] [blame] | 7 | * This code is licensed under the LGPL |
pbrook | cdbdb64 | 2006-04-09 01:32:52 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 10 | #include "hw.h" |
| 11 | #include "arm-misc.h" |
pbrook | cdbdb64 | 2006-04-09 01:32:52 +0000 | [diff] [blame] | 12 | |
pbrook | d537cf6 | 2007-04-07 18:14:41 +0000 | [diff] [blame] | 13 | /* Input 0 is IRQ and input 1 is FIQ. */ |
pbrook | cdbdb64 | 2006-04-09 01:32:52 +0000 | [diff] [blame] | 14 | static void arm_pic_cpu_handler(void *opaque, int irq, int level) |
| 15 | { |
Andreas Färber | 4bd7466 | 2012-05-14 04:21:52 +0200 | [diff] [blame] | 16 | ARMCPU *cpu = opaque; |
| 17 | CPUARMState *env = &cpu->env; |
| 18 | |
pbrook | cdbdb64 | 2006-04-09 01:32:52 +0000 | [diff] [blame] | 19 | switch (irq) { |
| 20 | case ARM_PIC_CPU_IRQ: |
| 21 | if (level) |
pbrook | d537cf6 | 2007-04-07 18:14:41 +0000 | [diff] [blame] | 22 | cpu_interrupt(env, CPU_INTERRUPT_HARD); |
pbrook | cdbdb64 | 2006-04-09 01:32:52 +0000 | [diff] [blame] | 23 | else |
pbrook | d537cf6 | 2007-04-07 18:14:41 +0000 | [diff] [blame] | 24 | cpu_reset_interrupt(env, CPU_INTERRUPT_HARD); |
pbrook | cdbdb64 | 2006-04-09 01:32:52 +0000 | [diff] [blame] | 25 | break; |
| 26 | case ARM_PIC_CPU_FIQ: |
| 27 | if (level) |
pbrook | d537cf6 | 2007-04-07 18:14:41 +0000 | [diff] [blame] | 28 | cpu_interrupt(env, CPU_INTERRUPT_FIQ); |
pbrook | cdbdb64 | 2006-04-09 01:32:52 +0000 | [diff] [blame] | 29 | else |
pbrook | d537cf6 | 2007-04-07 18:14:41 +0000 | [diff] [blame] | 30 | cpu_reset_interrupt(env, CPU_INTERRUPT_FIQ); |
pbrook | cdbdb64 | 2006-04-09 01:32:52 +0000 | [diff] [blame] | 31 | break; |
| 32 | default: |
Andreas Färber | 47601f2 | 2011-10-10 01:27:01 +0200 | [diff] [blame] | 33 | hw_error("arm_pic_cpu_handler: Bad interrupt line %d\n", irq); |
pbrook | cdbdb64 | 2006-04-09 01:32:52 +0000 | [diff] [blame] | 34 | } |
| 35 | } |
| 36 | |
Andreas Färber | 4bd7466 | 2012-05-14 04:21:52 +0200 | [diff] [blame] | 37 | qemu_irq *arm_pic_init_cpu(ARMCPU *cpu) |
pbrook | cdbdb64 | 2006-04-09 01:32:52 +0000 | [diff] [blame] | 38 | { |
Andreas Färber | 4bd7466 | 2012-05-14 04:21:52 +0200 | [diff] [blame] | 39 | return qemu_allocate_irqs(arm_pic_cpu_handler, cpu, 2); |
pbrook | cdbdb64 | 2006-04-09 01:32:52 +0000 | [diff] [blame] | 40 | } |