Statistics
| Branch: | Revision:

root / hw / arm_pic.c @ cdbdb648

History | View | Annotate | Download (1.6 kB)

1
/* 
2
 * Generic ARM Programmable Interrupt Controller support.
3
 *
4
 * Copyright (c) 2006 CodeSourcery.
5
 * Written by Paul Brook
6
 *
7
 * This code is licenced under the LGPL
8
 */
9

    
10
#include "vl.h"
11
#include "arm_pic.h"
12

    
13
/* Stub functions for hardware that doesn't exist.  */
14
void pic_set_irq(int irq, int level)
15
{
16
    cpu_abort(cpu_single_env, "pic_set_irq");
17
}
18

    
19
void pic_info(void)
20
{
21
}
22

    
23
void irq_info(void)
24
{
25
}
26

    
27

    
28
void pic_set_irq_new(void *opaque, int irq, int level)
29
{
30
    arm_pic_handler *p = (arm_pic_handler *)opaque;
31
    /* Call the real handler.  */
32
    (*p)(opaque, irq, level);
33
}
34

    
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
38
{
39
    arm_pic_handler handler;
40
    CPUState *cpu_env;
41
} arm_pic_cpu_state;
42

    
43
static void arm_pic_cpu_handler(void *opaque, int irq, int level)
44
{
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);
62
    }
63
}
64

    
65
void *arm_pic_init_cpu(CPUState *env)
66
{
67
    arm_pic_cpu_state *s;
68
    
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;
73
}