root / hw / irq.c @ 89fc88da
History | View | Annotate | Download (1.7 kB)
1 | d537cf6c | pbrook | /*
|
---|---|---|---|
2 | d537cf6c | pbrook | * QEMU IRQ/GPIO common code.
|
3 | 5fafdf24 | ths | *
|
4 | d537cf6c | pbrook | * Copyright (c) 2007 CodeSourcery.
|
5 | 5fafdf24 | ths | *
|
6 | d537cf6c | pbrook | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 | d537cf6c | pbrook | * of this software and associated documentation files (the "Software"), to deal
|
8 | d537cf6c | pbrook | * in the Software without restriction, including without limitation the rights
|
9 | d537cf6c | pbrook | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 | d537cf6c | pbrook | * copies of the Software, and to permit persons to whom the Software is
|
11 | d537cf6c | pbrook | * furnished to do so, subject to the following conditions:
|
12 | d537cf6c | pbrook | *
|
13 | d537cf6c | pbrook | * The above copyright notice and this permission notice shall be included in
|
14 | d537cf6c | pbrook | * all copies or substantial portions of the Software.
|
15 | d537cf6c | pbrook | *
|
16 | d537cf6c | pbrook | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 | d537cf6c | pbrook | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 | d537cf6c | pbrook | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 | d537cf6c | pbrook | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 | d537cf6c | pbrook | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 | d537cf6c | pbrook | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 | d537cf6c | pbrook | * THE SOFTWARE.
|
23 | d537cf6c | pbrook | */
|
24 | d537cf6c | pbrook | #include "vl.h" |
25 | d537cf6c | pbrook | |
26 | d537cf6c | pbrook | struct IRQState {
|
27 | d537cf6c | pbrook | qemu_irq_handler handler; |
28 | d537cf6c | pbrook | void *opaque;
|
29 | d537cf6c | pbrook | int n;
|
30 | d537cf6c | pbrook | }; |
31 | d537cf6c | pbrook | |
32 | d537cf6c | pbrook | void qemu_set_irq(qemu_irq irq, int level) |
33 | d537cf6c | pbrook | { |
34 | d537cf6c | pbrook | if (!irq)
|
35 | d537cf6c | pbrook | return;
|
36 | d537cf6c | pbrook | |
37 | d537cf6c | pbrook | irq->handler(irq->opaque, irq->n, level); |
38 | d537cf6c | pbrook | } |
39 | d537cf6c | pbrook | |
40 | d537cf6c | pbrook | qemu_irq *qemu_allocate_irqs(qemu_irq_handler handler, void *opaque, int n) |
41 | d537cf6c | pbrook | { |
42 | d537cf6c | pbrook | qemu_irq *s; |
43 | d537cf6c | pbrook | struct IRQState *p;
|
44 | d537cf6c | pbrook | int i;
|
45 | d537cf6c | pbrook | |
46 | d537cf6c | pbrook | s = (qemu_irq *)qemu_mallocz(sizeof(qemu_irq) * n);
|
47 | d537cf6c | pbrook | p = (struct IRQState *)qemu_mallocz(sizeof(struct IRQState) * n); |
48 | d537cf6c | pbrook | for (i = 0; i < n; i++) { |
49 | d537cf6c | pbrook | p->handler = handler; |
50 | d537cf6c | pbrook | p->opaque = opaque; |
51 | d537cf6c | pbrook | p->n = i; |
52 | d537cf6c | pbrook | s[i] = p; |
53 | d537cf6c | pbrook | p++; |
54 | d537cf6c | pbrook | } |
55 | d537cf6c | pbrook | return s;
|
56 | d537cf6c | pbrook | } |