This source file includes following definitions.
- do_bottom_half
- do_IRQ
- do_fast_IRQ
- irqaction
- request_irq
- free_irq
- math_error_irq
- no_action
- init_IRQ
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 #include <linux/ptrace.h>
26 #include <linux/errno.h>
27 #include <linux/signal.h>
28 #include <linux/sched.h>
29 #include <linux/interrupt.h>
30
31 #include <asm/system.h>
32 #include <asm/io.h>
33 #include <asm/irq.h>
34
35 #define CR0_NE 32
36
37 static unsigned char cache_21 = 0xff;
38 static unsigned char cache_A1 = 0xff;
39
40 unsigned long intr_count = 0;
41 unsigned long bh_active = 0;
42 unsigned long bh_mask = 0xFFFFFFFF;
43 struct bh_struct bh_base[32];
44
45
46
47
48
49
50 extern "C" void do_bottom_half(void)
51 {
52 unsigned long active;
53 unsigned long mask, left;
54 struct bh_struct *bh;
55
56 bh = bh_base;
57 active = bh_active & bh_mask;
58 for (mask = 1, left = ~0 ; left & active ; bh++,mask += mask,left += left) {
59 if (mask & active) {
60 void (*fn)(void *);
61 bh_active &= ~mask;
62 fn = bh->routine;
63 if (!fn)
64 goto bad_bh;
65 fn(bh->data);
66 }
67 }
68 return;
69 bad_bh:
70 printk ("irq.c:bad bottom half entry\n");
71 }
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88 BUILD_IRQ(FIRST,0,0x01)
89 BUILD_IRQ(FIRST,1,0x02)
90 BUILD_IRQ(FIRST,2,0x04)
91 BUILD_IRQ(FIRST,3,0x08)
92 BUILD_IRQ(FIRST,4,0x10)
93 BUILD_IRQ(FIRST,5,0x20)
94 BUILD_IRQ(FIRST,6,0x40)
95 BUILD_IRQ(FIRST,7,0x80)
96 BUILD_IRQ(SECOND,8,0x01)
97 BUILD_IRQ(SECOND,9,0x02)
98 BUILD_IRQ(SECOND,10,0x04)
99 BUILD_IRQ(SECOND,11,0x08)
100 BUILD_IRQ(SECOND,12,0x10)
101 BUILD_IRQ(SECOND,13,0x20)
102 BUILD_IRQ(SECOND,14,0x40)
103 BUILD_IRQ(SECOND,15,0x80)
104
105
106
107
108
109 static void (*interrupt[16])(void) = {
110 IRQ0_interrupt, IRQ1_interrupt, IRQ2_interrupt, IRQ3_interrupt,
111 IRQ4_interrupt, IRQ5_interrupt, IRQ6_interrupt, IRQ7_interrupt,
112 IRQ8_interrupt, IRQ9_interrupt, IRQ10_interrupt, IRQ11_interrupt,
113 IRQ12_interrupt, IRQ13_interrupt, IRQ14_interrupt, IRQ15_interrupt
114 };
115
116 static void (*fast_interrupt[16])(void) = {
117 fast_IRQ0_interrupt, fast_IRQ1_interrupt,
118 fast_IRQ2_interrupt, fast_IRQ3_interrupt,
119 fast_IRQ4_interrupt, fast_IRQ5_interrupt,
120 fast_IRQ6_interrupt, fast_IRQ7_interrupt,
121 fast_IRQ8_interrupt, fast_IRQ9_interrupt,
122 fast_IRQ10_interrupt, fast_IRQ11_interrupt,
123 fast_IRQ12_interrupt, fast_IRQ13_interrupt,
124 fast_IRQ14_interrupt, fast_IRQ15_interrupt
125 };
126
127 static void (*bad_interrupt[16])(void) = {
128 bad_IRQ0_interrupt, bad_IRQ1_interrupt,
129 bad_IRQ2_interrupt, bad_IRQ3_interrupt,
130 bad_IRQ4_interrupt, bad_IRQ5_interrupt,
131 bad_IRQ6_interrupt, bad_IRQ7_interrupt,
132 bad_IRQ8_interrupt, bad_IRQ9_interrupt,
133 bad_IRQ10_interrupt, bad_IRQ11_interrupt,
134 bad_IRQ12_interrupt, bad_IRQ13_interrupt,
135 bad_IRQ14_interrupt, bad_IRQ15_interrupt
136 };
137
138
139
140
141 static struct sigaction irq_sigaction[16] = {
142 { NULL, 0, 0, NULL }, { NULL, 0, 0, NULL },
143 { NULL, 0, 0, NULL }, { NULL, 0, 0, NULL },
144 { NULL, 0, 0, NULL }, { NULL, 0, 0, NULL },
145 { NULL, 0, 0, NULL }, { NULL, 0, 0, NULL },
146 { NULL, 0, 0, NULL }, { NULL, 0, 0, NULL },
147 { NULL, 0, 0, NULL }, { NULL, 0, 0, NULL },
148 { NULL, 0, 0, NULL }, { NULL, 0, 0, NULL },
149 { NULL, 0, 0, NULL }, { NULL, 0, 0, NULL }
150 };
151
152
153
154
155
156
157
158
159 extern "C" void do_IRQ(int irq, struct pt_regs * regs)
160 {
161 struct sigaction * sa = irq + irq_sigaction;
162
163 sa->sa_handler((int) regs);
164 }
165
166
167
168
169
170
171 extern "C" void do_fast_IRQ(int irq)
172 {
173 struct sigaction * sa = irq + irq_sigaction;
174
175 sa->sa_handler(irq);
176 }
177
178 int irqaction(unsigned int irq, struct sigaction * new_sa)
179 {
180 struct sigaction * sa;
181 unsigned long flags;
182
183 if (irq > 15)
184 return -EINVAL;
185 sa = irq + irq_sigaction;
186 if (sa->sa_mask)
187 return -EBUSY;
188 if (!new_sa->sa_handler)
189 return -EINVAL;
190 save_flags(flags);
191 cli();
192 *sa = *new_sa;
193 sa->sa_mask = 1;
194 if (sa->sa_flags & SA_INTERRUPT)
195 set_intr_gate(0x20+irq,fast_interrupt[irq]);
196 else
197 set_intr_gate(0x20+irq,interrupt[irq]);
198 if (irq < 8) {
199 cache_21 &= ~(1<<irq);
200 outb(cache_21,0x21);
201 } else {
202 cache_21 &= ~(1<<2);
203 cache_A1 &= ~(1<<(irq-8));
204 outb(cache_21,0x21);
205 outb(cache_A1,0xA1);
206 }
207 restore_flags(flags);
208 return 0;
209 }
210
211 int request_irq(unsigned int irq, void (*handler)(int))
212 {
213 struct sigaction sa;
214
215 sa.sa_handler = handler;
216 sa.sa_flags = 0;
217 sa.sa_mask = 0;
218 sa.sa_restorer = NULL;
219 return irqaction(irq,&sa);
220 }
221
222 void free_irq(unsigned int irq)
223 {
224 struct sigaction * sa = irq + irq_sigaction;
225 unsigned long flags;
226
227 if (irq > 15) {
228 printk("Trying to free IRQ%d\n",irq);
229 return;
230 }
231 if (!sa->sa_mask) {
232 printk("Trying to free free IRQ%d\n",irq);
233 return;
234 }
235 save_flags(flags);
236 cli();
237 if (irq < 8) {
238 cache_21 |= 1 << irq;
239 outb(cache_21,0x21);
240 } else {
241 cache_A1 |= 1 << (irq-8);
242 outb(cache_A1,0xA1);
243 }
244 set_intr_gate(0x20+irq,bad_interrupt[irq]);
245 sa->sa_handler = NULL;
246 sa->sa_flags = 0;
247 sa->sa_mask = 0;
248 sa->sa_restorer = NULL;
249 restore_flags(flags);
250 }
251
252
253
254
255
256
257
258
259
260
261
262
263 static void math_error_irq(int cpl)
264 {
265 outb(0,0xF0);
266 if (ignore_irq13)
267 return;
268 math_error();
269 }
270
271 static void no_action(int cpl) { }
272
273 static struct sigaction ignore_IRQ = {
274 no_action,
275 0,
276 SA_INTERRUPT,
277 NULL
278 };
279
280 void init_IRQ(void)
281 {
282 int i;
283
284 for (i = 0; i < 16 ; i++)
285 set_intr_gate(0x20+i,bad_interrupt[i]);
286 if (irqaction(2,&ignore_IRQ))
287 printk("Unable to get IRQ2 for cascade\n");
288 if (request_irq(13,math_error_irq))
289 printk("Unable to get IRQ13 for math-error handler\n");
290
291
292 for (i = 0; i < 32; i++) {
293 bh_base[i].routine = NULL;
294 bh_base[i].data = NULL;
295 }
296 bh_active = 0;
297 intr_count = 0;
298 }