This source file includes following definitions.
- disable_irq
- enable_irq
- get_irq_list
- ack_irq
- mask_irq
- unmask_irq
- request_irq
- free_irq
- handle_nmi
- unexpected_irq
- handle_irq
- device_interrupt
- isa_device_interrupt
- cabriolet_and_eb66p_device_interrupt
- eb66_and_eb64p_device_interrupt
- srm_device_interrupt
- probe_irq_on
- probe_irq_off
- machine_check
- do_entInt
- init_IRQ
1
2
3
4
5
6
7
8
9
10
11
12
13 #include <linux/config.h>
14 #include <linux/ptrace.h>
15 #include <linux/errno.h>
16 #include <linux/kernel_stat.h>
17 #include <linux/signal.h>
18 #include <linux/sched.h>
19 #include <linux/interrupt.h>
20
21 #include <asm/system.h>
22 #include <asm/io.h>
23 #include <asm/irq.h>
24 #include <asm/bitops.h>
25 #include <asm/dma.h>
26
27 static unsigned char cache_21 = 0xff;
28 static unsigned char cache_A1 = 0xff;
29
30 #if defined(CONFIG_ALPHA_CABRIOLET) || defined(CONFIG_ALPHA_EB66P)
31 static unsigned char cache_804 = 0xef;
32 static unsigned char cache_805 = 0xff;
33 static unsigned char cache_806 = 0xff;
34 #elif defined(CONFIG_ALPHA_EB66) || defined(CONFIG_ALPHA_EB64P)
35 static unsigned char cache_26 = 0xdf;
36 static unsigned char cache_27 = 0xff;
37 #endif
38
39 void disable_irq(unsigned int irq_nr)
40 {
41 unsigned long flags;
42 unsigned char mask;
43
44 save_flags(flags);
45 cli();
46 mask = 1 << (irq_nr & 7);
47
48 if (irq_nr < 8) {
49 cache_21 |= mask;
50 outb(cache_21,0x21);
51 } else if (irq_nr < 16) {
52 cache_A1 |= mask;
53 outb(cache_A1,0xA1);
54 #if defined(CONFIG_ALPHA_CABRIOLET) || defined(CONFIG_ALPHA_EB66P)
55 } else if (irq_nr < 24) {
56 cache_804 |= mask;
57 outb(cache_804, 0x804);
58 } else if (irq_nr < 32) {
59 cache_805 |= mask;
60 outb(cache_805, 0x805);
61 } else {
62 cache_806 |= mask;
63 outb(cache_806, 0x806);
64 #elif defined(CONFIG_ALPHA_EB66) || defined(CONFIG_ALPHA_EB64P)
65 } else if (irq_nr < 24) {
66 cache_26 |= mask;
67 outb(cache_26, 0x26);
68 } else {
69 cache_27 |= mask;
70 outb(cache_27, 0x27);
71 #endif
72 }
73 restore_flags(flags);
74 }
75
76 void enable_irq(unsigned int irq_nr)
77 {
78 unsigned long flags;
79 unsigned char mask;
80
81 mask = ~(1 << (irq_nr & 7));
82 save_flags(flags);
83 cli();
84
85 if (irq_nr < 8) {
86 cache_21 &= mask;
87 outb(cache_21,0x21);
88 } else if (irq_nr < 16) {
89 cache_A1 &= mask;
90 outb(cache_A1,0xA1);
91 #if defined(CONFIG_ALPHA_CABRIOLET) || defined(CONFIG_ALPHA_EB66P)
92 } else if (irq_nr < 24) {
93 cache_804 &= mask;
94 outb(cache_804, 0x804);
95 } else if (irq_nr < 32) {
96 cache_805 &= mask;
97 outb(cache_805, 0x805);
98 } else {
99 cache_806 &= mask;
100 outb(cache_806, 0x806);
101 #elif defined(CONFIG_ALPHA_EB66) || defined(CONFIG_ALPHA_EB64P)
102 } else if (irq_nr < 24) {
103 cache_26 &= mask;
104 outb(cache_26, 0x26);
105 } else {
106 cache_27 &= mask;
107 outb(cache_27, 0x27);
108 #endif
109 }
110 restore_flags(flags);
111 }
112
113
114
115
116 struct irqaction {
117 void (*handler)(int, struct pt_regs *);
118 unsigned long flags;
119 unsigned long mask;
120 const char *name;
121 };
122
123 static struct irqaction irq_action[NR_IRQS];
124
125 int get_irq_list(char *buf)
126 {
127 int i, len = 0;
128 struct irqaction * action = irq_action;
129
130 for (i = 0 ; i < NR_IRQS ; i++, action++) {
131 if (!action->handler)
132 continue;
133 len += sprintf(buf+len, "%2d: %8d %c %s\n",
134 i, kstat.interrupts[i],
135 (action->flags & SA_INTERRUPT) ? '+' : ' ',
136 action->name);
137 }
138 return len;
139 }
140
141 static inline void ack_irq(int irq)
142 {
143 if (irq < 16) {
144
145
146 if (irq > 7) {
147 outb(0xE0 | (irq - 8), 0xa0);
148 irq = 2;
149 }
150
151 outb(0xE0 | irq, 0x20);
152 }
153 }
154
155 static inline void mask_irq(int irq)
156 {
157 unsigned char mask;
158
159 mask = 1 << (irq & 7);
160 if (irq < 8) {
161 cache_21 |= mask;
162 outb(cache_21, 0x21);
163 } else if (irq < 16) {
164 cache_A1 |= mask;
165 outb(cache_A1, 0xA1);
166 #if defined(CONFIG_ALPHA_CABRIOLET) || defined(CONFIG_ALPHA_EB66P)
167 } else if (irq < 24) {
168 cache_804 |= mask;
169 outb(cache_804, 0x804);
170 } else if (irq < 32) {
171 cache_805 |= mask;
172 outb(cache_805, 0x805);
173 } else {
174 cache_806 |= mask;
175 outb(cache_806, 0x806);
176 #elif defined(CONFIG_ALPHA_EB66) || defined(CONFIG_ALPHA_EB66P)
177 } else if (irq < 24) {
178 cache_26 |= mask;
179 outb(cache_26, 0x26);
180 } else {
181 cache_27 |= mask;
182 outb(cache_27, 0x27);
183 #endif
184 }
185 }
186
187 static inline void unmask_irq(unsigned long irq)
188 {
189 unsigned char mask = ~(1 << (irq & 7));
190
191 if (irq < 8) {
192 cache_21 &= mask;
193 outb(cache_21, 0x21);
194 } else if (irq < 16) {
195 cache_A1 &= mask;
196 outb(cache_A1, 0xA1);
197 #if defined(CONFIG_ALPHA_CABRIOLET) || defined(CONFIG_ALPHA_EB66P)
198 } else if (irq < 24) {
199 cache_804 &= mask;
200 outb(cache_804, 0x804);
201 } else if (irq < 32) {
202 cache_805 &= mask;
203 outb(cache_805, 0x805);
204 } else {
205 cache_806 &= mask;
206 outb(cache_806, 0x806);
207 #elif defined(CONFIG_ALPHA_EB66) || defined(CONFIG_ALPHA_EB66P)
208 } else if (irq < 24) {
209 cache_26 &= mask;
210 outb(cache_26, 0x26);
211 } else {
212 cache_27 &= mask;
213 outb(cache_27, 0x27);
214 #endif
215 }
216 }
217
218 int request_irq(unsigned int irq, void (*handler)(int, struct pt_regs *),
219 unsigned long irqflags, const char * devname)
220 {
221 struct irqaction * action;
222 unsigned long flags;
223
224 if (irq >= NR_IRQS)
225 return -EINVAL;
226 action = irq + irq_action;
227 if (action->handler)
228 return -EBUSY;
229 if (!handler)
230 return -EINVAL;
231 save_flags(flags);
232 cli();
233 action->handler = handler;
234 action->flags = irqflags;
235 action->mask = 0;
236 action->name = devname;
237 enable_irq(irq);
238 if (irq >= 8 && irq < 16) {
239 enable_irq(2);
240 }
241 restore_flags(flags);
242 return 0;
243 }
244
245 void free_irq(unsigned int irq)
246 {
247 struct irqaction * action = irq + irq_action;
248 unsigned long flags;
249
250 if (irq >= NR_IRQS) {
251 printk("Trying to free IRQ%d\n", irq);
252 return;
253 }
254 if (!action->handler) {
255 printk("Trying to free free IRQ%d\n", irq);
256 return;
257 }
258 save_flags(flags);
259 cli();
260 mask_irq(irq);
261 action->handler = NULL;
262 action->flags = 0;
263 action->mask = 0;
264 action->name = NULL;
265 restore_flags(flags);
266 }
267
268 static inline void handle_nmi(struct pt_regs * regs)
269 {
270 printk("Whee.. NMI received. Probable hardware error\n");
271 printk("61=%02x, 461=%02x\n", inb(0x61), inb(0x461));
272 }
273
274 static void unexpected_irq(int irq, struct pt_regs * regs)
275 {
276 int i;
277
278 printk("IO device interrupt, irq = %d\n", irq);
279 printk("PC = %016lx PS=%04lx\n", regs->pc, regs->ps);
280 printk("Expecting: ");
281 for (i = 0; i < 16; i++)
282 if (irq_action[i].handler)
283 printk("[%s:%d] ", irq_action[i].name, i);
284 printk("\n");
285 printk("64=%02x, 60=%02x, 3fa=%02x 2fa=%02x\n",
286 inb(0x64), inb(0x60), inb(0x3fa), inb(0x2fa));
287 outb(0x0c, 0x3fc);
288 outb(0x0c, 0x2fc);
289 outb(0,0x61);
290 outb(0,0x461);
291 }
292
293 static inline void handle_irq(int irq, struct pt_regs * regs)
294 {
295 struct irqaction * action = irq + irq_action;
296
297 kstat.interrupts[irq]++;
298 if (!action->handler) {
299 unexpected_irq(irq, regs);
300 return;
301 }
302 action->handler(irq, regs);
303 }
304
305 static inline void device_interrupt(int irq, int ack, struct pt_regs * regs)
306 {
307 struct irqaction * action;
308
309 if ((unsigned) irq > NR_IRQS) {
310 printk("device_interrupt: unexpected interrupt %d\n", irq);
311 return;
312 }
313
314 kstat.interrupts[irq]++;
315 action = irq_action + irq;
316 #ifdef CONFIG_RANDOM
317 if (action->flags & SA_SAMPLE_RANDOM)
318 add_interrupt_randomness(irq);
319 #endif
320
321 if (action->flags & SA_INTERRUPT) {
322 action->handler(irq, regs);
323 ack_irq(ack);
324 return;
325 }
326
327
328
329
330
331
332
333
334
335 mask_irq(ack);
336 ack_irq(ack);
337 if (!action->handler)
338 return;
339 action->handler(irq, regs);
340 unmask_irq(ack);
341 }
342
343
344
345
346 static inline void isa_device_interrupt(unsigned long vector,
347 struct pt_regs * regs)
348 {
349 unsigned long pic;
350 int j;
351
352
353
354
355
356
357 pic = inb(0x20) | (inb(0xA0) << 8);
358 pic &= ~((cache_A1 << 8) | cache_21);
359 pic &= 0xFFFB;
360
361 while (pic) {
362 j = ffz(~pic);
363 pic &= pic - 1;
364 device_interrupt(j, j, regs);
365 }
366 }
367
368 static inline void cabriolet_and_eb66p_device_interrupt(unsigned long vector,
369 struct pt_regs * regs)
370 {
371 unsigned long pld;
372 unsigned int i;
373 unsigned long flags;
374
375 save_flags(flags);
376 cli();
377
378
379 pld = inb(0x804) | (inb(0x805) << 8) | (inb(0x806) << 16);
380
381
382
383
384
385 while (pld) {
386 i = ffz(~pld);
387 pld &= pld - 1;
388 if (i == 4) {
389 isa_device_interrupt(vector, regs);
390 } else {
391 device_interrupt(16 + i, 16 + i, regs);
392 }
393 }
394 restore_flags(flags);
395 }
396
397 static inline void eb66_and_eb64p_device_interrupt(unsigned long vector,
398 struct pt_regs * regs)
399 {
400 unsigned long pld;
401 unsigned int i;
402 unsigned long flags;
403
404 save_flags(flags);
405 cli();
406
407
408 pld = inb(0x26) | (inb(0x27) << 8);
409
410
411
412
413 while (pld) {
414 i = ffz(~pld);
415 pld &= pld - 1;
416
417 if (i == 5) {
418 isa_device_interrupt(vector, regs);
419 } else {
420 device_interrupt(16 + i, 16 + i, regs);
421 }
422 }
423 restore_flags(flags);
424 }
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449 static inline void srm_device_interrupt(unsigned long vector, struct pt_regs * regs)
450 {
451 int irq, ack;
452
453 ack = irq = (vector - 0x800) >> 4;
454
455 #ifdef CONFIG_ALPHA_JENSEN
456 switch (vector) {
457 case 0x660: handle_nmi(regs); return;
458
459 case 0x900: handle_irq(4, regs); return;
460 case 0x920: handle_irq(3, regs); return;
461 case 0x980: handle_irq(1, regs); return;
462 case 0x990: handle_irq(9, regs); return;
463 default:
464 if (vector > 0x900) {
465 printk("Unknown local interrupt %lx\n", vector);
466 }
467 }
468
469 if (irq == 1)
470 irq = 7;
471 #endif
472
473 device_interrupt(irq, ack, regs);
474 }
475
476 #if NR_IRQS > 64
477 # error Number of irqs limited to 64 due to interrupt-probing.
478 #endif
479
480
481
482
483 unsigned long probe_irq_on(void)
484 {
485 unsigned long irqs = 0, irqmask;
486 unsigned long delay;
487 unsigned int i;
488
489 for (i = NR_IRQS - 1; i > 0; i--) {
490 if (!irq_action[i].handler) {
491 enable_irq(i);
492 irqs |= (1 << i);
493 }
494 }
495
496
497 for (delay = jiffies + HZ/10; delay > jiffies; )
498 ;
499
500
501 irqmask = (((unsigned long)cache_A1)<<8) | (unsigned long) cache_21;
502 #if defined(CONFIG_ALPHA_CABRIOLET) || defined(CONFIG_ALPHA_EB66P)
503 irqmask |= ((((unsigned long)cache_804)<<16) |
504 (((unsigned long)cache_805)<<24) |
505 (((unsigned long)cache_806)<<24));
506 #elif defined(CONFIG_ALPHA_EB66) || defined(CONFIG_ALPHA_EB64P)
507 irqmask |= ((((unsigned long)cache_26)<<16) |
508 (((unsigned long)cache_27)<<24));
509 #endif
510 irqs &= ~irqmask;
511 return irqs;
512 }
513
514
515
516
517
518
519 int probe_irq_off(unsigned long irqs)
520 {
521 unsigned long irqmask;
522 int i;
523
524 irqmask = (((unsigned int)cache_A1)<<8) | (unsigned int)cache_21;
525 #if defined(CONFIG_ALPHA_CABRIOLET) || defined(CONFIG_ALPHA_EB66P)
526 irqmask |= ((((unsigned long)cache_804)<<16) |
527 (((unsigned long)cache_805)<<24) |
528 (((unsigned long)cache_806)<<24));
529 #elif defined(CONFIG_ALPHA_EB66) || defined(CONFIG_ALPHA_EB64P)
530 irqmask |= ((((unsigned long)cache_26)<<16) |
531 (((unsigned long)cache_27)<<24));
532 #endif
533 irqs &= irqmask;
534 if (!irqs)
535 return 0;
536 i = ffz(~irqs);
537 if (irqs != (1UL << i))
538 i = -i;
539 return i;
540 }
541
542 static void machine_check(unsigned long vector, unsigned long la, struct pt_regs * regs)
543 {
544 #if defined(CONFIG_ALPHA_LCA)
545 extern void lca_machine_check (unsigned long vector, unsigned long la,
546 struct pt_regs *regs);
547 lca_machine_check(vector, la, regs);
548 #elif defined(CONFIG_ALPHA_APECS)
549 extern void apecs_machine_check(unsigned long vector, unsigned long la,
550 struct pt_regs * regs);
551 apecs_machine_check(vector, la, regs);
552 #else
553 printk("Machine check\n");
554 #endif
555 }
556
557 asmlinkage void do_entInt(unsigned long type, unsigned long vector, unsigned long la_ptr,
558 unsigned long a3, unsigned long a4, unsigned long a5,
559 struct pt_regs regs)
560 {
561 switch (type) {
562 case 0:
563 printk("Interprocessor interrupt? You must be kidding\n");
564 break;
565 case 1:
566
567 handle_irq(0, ®s);
568 return;
569 case 2:
570 machine_check(vector, la_ptr, ®s);
571 break;
572 case 3:
573 #if defined(CONFIG_ALPHA_JENSEN) || defined(CONFIG_ALPHA_NONAME)
574 srm_device_interrupt(vector, ®s);
575 #elif defined(CONFIG_ALPHA_CABRIOLET) || defined(CONFIG_ALPHA_EB66P)
576 cabriolet_and_eb66p_device_interrupt(vector, ®s);
577 #elif defined(CONFIG_ALPHA_EB66) || defined(CONFIG_ALPHA_EB64P)
578 eb66_and_eb64p_device_interrupt(vector, ®s);
579 #endif
580 return;
581 case 4:
582 printk("Performance counter interrupt\n");
583 break;;
584 default:
585 printk("Hardware intr %ld %lx? Huh?\n", type, vector);
586 }
587 printk("PC = %016lx PS=%04lx\n", regs.pc, regs.ps);
588 }
589
590 extern asmlinkage void entInt(void);
591
592 void init_IRQ(void)
593 {
594 wrent(entInt, 0);
595 dma_outb(0, DMA1_RESET_REG);
596 dma_outb(0, DMA2_RESET_REG);
597 dma_outb(0, DMA1_CLR_MASK_REG);
598 dma_outb(0, DMA2_CLR_MASK_REG);
599 #if defined(CONFIG_ALPHA_CABRIOLET) || defined(CONFIG_ALPHA_EB66P)
600 outb(cache_804, 0x804);
601 outb(cache_805, 0x805);
602 outb(cache_806, 0x806);
603 #elif defined(CONFIG_ALPHA_EB66) || defined(CONFIG_ALPHA_EB64P)
604 outb(cache_26, 0x26);
605 outb(cache_27, 0x27);
606 #endif
607 }