2007-09-16 23:08:06 +02:00
|
|
|
/*
|
2006-04-09 03:32:52 +02:00
|
|
|
* Generic ARM Programmable Interrupt Controller support.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2006 CodeSourcery.
|
|
|
|
* Written by Paul Brook
|
|
|
|
*
|
2011-06-26 04:21:35 +02:00
|
|
|
* This code is licensed under the LGPL
|
2006-04-09 03:32:52 +02:00
|
|
|
*/
|
|
|
|
|
2013-02-04 15:40:22 +01:00
|
|
|
#include "hw/hw.h"
|
2013-04-09 16:26:55 +02:00
|
|
|
#include "hw/arm/arm.h"
|
2013-03-05 01:34:41 +01:00
|
|
|
#include "sysemu/kvm.h"
|
2006-04-09 03:32:52 +02:00
|
|
|
|
2007-04-07 20:14:41 +02:00
|
|
|
/* Input 0 is IRQ and input 1 is FIQ. */
|
2006-04-09 03:32:52 +02:00
|
|
|
static void arm_pic_cpu_handler(void *opaque, int irq, int level)
|
|
|
|
{
|
2012-05-14 04:21:52 +02:00
|
|
|
ARMCPU *cpu = opaque;
|
2013-01-17 22:30:20 +01:00
|
|
|
CPUState *cs = CPU(cpu);
|
2012-05-14 04:21:52 +02:00
|
|
|
|
2006-04-09 03:32:52 +02:00
|
|
|
switch (irq) {
|
|
|
|
case ARM_PIC_CPU_IRQ:
|
2013-01-17 22:30:20 +01:00
|
|
|
if (level) {
|
2013-01-18 15:03:43 +01:00
|
|
|
cpu_interrupt(cs, CPU_INTERRUPT_HARD);
|
2013-01-17 22:30:20 +01:00
|
|
|
} else {
|
|
|
|
cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD);
|
|
|
|
}
|
2006-04-09 03:32:52 +02:00
|
|
|
break;
|
|
|
|
case ARM_PIC_CPU_FIQ:
|
2013-01-17 22:30:20 +01:00
|
|
|
if (level) {
|
2013-01-18 15:03:43 +01:00
|
|
|
cpu_interrupt(cs, CPU_INTERRUPT_FIQ);
|
2013-01-17 22:30:20 +01:00
|
|
|
} else {
|
|
|
|
cpu_reset_interrupt(cs, CPU_INTERRUPT_FIQ);
|
|
|
|
}
|
2006-04-09 03:32:52 +02:00
|
|
|
break;
|
|
|
|
default:
|
2011-10-10 01:27:01 +02:00
|
|
|
hw_error("arm_pic_cpu_handler: Bad interrupt line %d\n", irq);
|
2006-04-09 03:32:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-05 01:34:41 +01:00
|
|
|
static void kvm_arm_pic_cpu_handler(void *opaque, int irq, int level)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_KVM
|
|
|
|
ARMCPU *cpu = opaque;
|
|
|
|
CPUState *cs = CPU(cpu);
|
|
|
|
int kvm_irq = KVM_ARM_IRQ_TYPE_CPU << KVM_ARM_IRQ_TYPE_SHIFT;
|
|
|
|
|
|
|
|
switch (irq) {
|
|
|
|
case ARM_PIC_CPU_IRQ:
|
|
|
|
kvm_irq |= KVM_ARM_IRQ_CPU_IRQ;
|
|
|
|
break;
|
|
|
|
case ARM_PIC_CPU_FIQ:
|
|
|
|
kvm_irq |= KVM_ARM_IRQ_CPU_FIQ;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
hw_error("kvm_arm_pic_cpu_handler: Bad interrupt line %d\n", irq);
|
|
|
|
}
|
|
|
|
kvm_irq |= cs->cpu_index << KVM_ARM_IRQ_VCPU_SHIFT;
|
|
|
|
kvm_set_irq(kvm_state, kvm_irq, level ? 1 : 0);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-05-14 04:21:52 +02:00
|
|
|
qemu_irq *arm_pic_init_cpu(ARMCPU *cpu)
|
2006-04-09 03:32:52 +02:00
|
|
|
{
|
2013-03-05 01:34:41 +01:00
|
|
|
if (kvm_enabled()) {
|
|
|
|
return qemu_allocate_irqs(kvm_arm_pic_cpu_handler, cpu, 2);
|
|
|
|
}
|
2012-05-14 04:21:52 +02:00
|
|
|
return qemu_allocate_irqs(arm_pic_cpu_handler, cpu, 2);
|
2006-04-09 03:32:52 +02:00
|
|
|
}
|