-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathirq.h
49 lines (37 loc) · 910 Bytes
/
irq.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef QEMU_IRQ_H
#define QEMU_IRQ_H
#include <stdlib.h>
typedef void (*qemu_irq_handler)(void *opaque, int n, int level);
typedef struct IRQState {
// Object parent_obj;
qemu_irq_handler handler;
void *opaque;
int n;
}IRQState;
typedef struct IRQState *qemu_irq;
static inline qemu_irq qemu_allocate_irq(qemu_irq_handler handler, void *opaque, int n) {
struct IRQState *irq;
irq = (IRQState *)malloc(sizeof(IRQState));
irq->handler = handler;
irq->opaque = opaque;
irq->n = n;
return irq;
}
static inline void qemu_free_irq(qemu_irq irq) {
free(irq);
}
static inline void qemu_set_irq(qemu_irq irq, int level)
{
if (!irq)
return;
irq->handler(irq->opaque, irq->n, level);
}
static inline void qemu_irq_raise(qemu_irq irq)
{
qemu_set_irq(irq, 1);
}
static inline void qemu_irq_lower(qemu_irq irq)
{
qemu_set_irq(irq, 0);
}
#endif