Rearrange PCI host emulation code.
[qemu/mini2440.git] / hw / arm_pic.c
blobfbc2d67d0a08ab1defb716679570bdc826cf5de5
1 /*
2 * Generic ARM Programmable Interrupt Controller support.
4 * Copyright (c) 2006 CodeSourcery.
5 * Written by Paul Brook
7 * This code is licenced under the LGPL
8 */
10 #include "vl.h"
11 #include "arm_pic.h"
13 /* Stub functions for hardware that doesn't exist. */
14 void pic_set_irq(int irq, int level)
16 cpu_abort(cpu_single_env, "pic_set_irq");
19 void pic_info(void)
23 void irq_info(void)
28 void pic_set_irq_new(void *opaque, int irq, int level)
30 arm_pic_handler *p = (arm_pic_handler *)opaque;
31 /* Call the real handler. */
32 (*p)(opaque, irq, level);
35 /* Model the IRQ/FIQ CPU interrupt lines as a two input interrupt controller.
36 Input 0 is IRQ and input 1 is FIQ. */
37 typedef struct
39 arm_pic_handler handler;
40 CPUState *cpu_env;
41 } arm_pic_cpu_state;
43 static void arm_pic_cpu_handler(void *opaque, int irq, int level)
45 arm_pic_cpu_state *s = (arm_pic_cpu_state *)opaque;
46 switch (irq) {
47 case ARM_PIC_CPU_IRQ:
48 if (level)
49 cpu_interrupt(s->cpu_env, CPU_INTERRUPT_HARD);
50 else
51 cpu_reset_interrupt(s->cpu_env, CPU_INTERRUPT_HARD);
52 break;
53 case ARM_PIC_CPU_FIQ:
54 if (level)
55 cpu_interrupt(s->cpu_env, CPU_INTERRUPT_FIQ);
56 else
57 cpu_reset_interrupt(s->cpu_env, CPU_INTERRUPT_FIQ);
58 break;
59 default:
60 cpu_abort(s->cpu_env, "arm_pic_cpu_handler: Bad interrput line %d\n",
61 irq);
65 void *arm_pic_init_cpu(CPUState *env)
67 arm_pic_cpu_state *s;
69 s = (arm_pic_cpu_state *)malloc(sizeof(arm_pic_cpu_state));
70 s->handler = arm_pic_cpu_handler;
71 s->cpu_env = env;
72 return s;