-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterrupt.c
More file actions
executable file
·74 lines (62 loc) · 1.19 KB
/
interrupt.c
File metadata and controls
executable file
·74 lines (62 loc) · 1.19 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "print.h"
#include "interrupt.h"
//static intr_handler vect_h[MAX_IRQ];
#define MAX_IRQ 32
struct IRQ_LIST irq_list[MAX_IRQ];
int handle_irq(int status)
{
printk("in irq handler ,received interrupt on line %d \n", status);
dump_cpsr(__func__);
return status;
}
int handle_fiq(int status)
{
printk("in fiq handler ,received interrupt on line %d \n", status);
dump_cpsr(__func__);
return status;
}
int request_irq(int irqno, int mode, intr_handler h)
{
if (irqno > MAX_IRQ) {
printk("Invalid irq no = %d\n");
return 0;
}
if (irq_list[irqno].no != 0){
printk("Irq is in use\n");
return 0;
}
irq_list[irqno].no = 1;
irq_list[irqno].h = h;
irq_list[irqno].mode = mode;
switch (mode) {
case IRQ_MODE:
enable_irq(1<<irqno);
break;
case FIQ_MODE:
enable_fiq(1<<irqno);
break;
#if 0
case VECTOR_MODE:
if (!vect_h[irqno]){
vect_h[irqno] = h;
/*able_fiq(1<<irqno);*/
ret = 1;
}
break;
#endif
default:
printk("Invalid mode\n");
break;
}
return 1;
}
void free_irq(int irqno)
{
if (irq_list[irqno].no != 1) {
printk("Irq is not registered\n");
return ;
}
irq_list[irqno].no = 0;
irq_list[irqno].h = 0;
irq_list[irqno].mode = 0;
}