Import 2.1.15
[davej-history.git] / include / linux / interrupt.h
blobe443fbf778e5cf2a3699ed9a8e65d184c82a7db3
1 /* interrupt.h */
2 #ifndef _LINUX_INTERRUPT_H
3 #define _LINUX_INTERRUPT_H
5 #include <linux/kernel.h>
6 #include <asm/bitops.h>
8 struct irqaction {
9 void(*handler)(int,void*,struct pt_regs *);
10 unsigned long flags;
11 unsigned long mask;
12 const char*name;
13 void*dev_id;
14 struct irqaction *next;
17 externunsigned long intr_count;
19 externint bh_mask_count[32];
20 externunsigned long bh_active;
21 externunsigned long bh_mask;
22 externvoid(*bh_base[32])(void);
24 asmlinkage voiddo_bottom_half(void);
26 /* Who gets which entry in bh_base. Things which will occur most often
27 should come first - in which case NET should be up the top with SERIAL/TQUEUE! */
29 enum{
30 TIMER_BH =0,
31 CONSOLE_BH,
32 TQUEUE_BH,
33 DIGI_BH,
34 SERIAL_BH,
35 RISCOM8_BH,
36 ESP_BH,
37 NET_BH,
38 IMMEDIATE_BH,
39 KEYBOARD_BH,
40 CYCLADES_BH,
41 CM206_BH
44 extern inlinevoidinit_bh(int nr,void(*routine)(void))
46 bh_base[nr] = routine;
47 bh_mask_count[nr] =0;
48 bh_mask |=1<< nr;
51 extern inlinevoidmark_bh(int nr)
53 set_bit(nr, &bh_active);
57 * These use a mask count to correctly handle
58 * nested disable/enable calls
60 extern inlinevoiddisable_bh(int nr)
62 bh_mask &= ~(1<< nr);
63 bh_mask_count[nr]++;
66 extern inlinevoidenable_bh(int nr)
68 if(!--bh_mask_count[nr])
69 bh_mask |=1<< nr;
73 * start_bh_atomic/end_bh_atomic also nest
74 * naturally by using a counter
76 extern inlinevoidstart_bh_atomic(void)
78 intr_count++;
79 barrier();
82 extern inlinevoidend_bh_atomic(void)
84 barrier();
85 intr_count--;
89 * Autoprobing for irqs:
91 * probe_irq_on() and probe_irq_off() provide robust primitives
92 * for accurate IRQ probing during kernel initialization. They are
93 * reasonably simple to use, are not "fooled" by spurious interrupts,
94 * and, unlike other attempts at IRQ probing, they do not get hung on
95 * stuck interrupts (such as unused PS2 mouse interfaces on ASUS boards).
97 * For reasonably foolproof probing, use them as follows:
99 * 1. clear and/or mask the device's internal interrupt.
100 * 2. sti();
101 * 3. irqs = probe_irq_on(); // "take over" all unassigned idle IRQs
102 * 4. enable the device and cause it to trigger an interrupt.
103 * 5. wait for the device to interrupt, using non-intrusive polling or a delay.
104 * 6. irq = probe_irq_off(irqs); // get IRQ number, 0=none, negative=multiple
105 * 7. service the device to clear its pending interrupt.
106 * 8. loop again if paranoia is required.
108 * probe_irq_on() returns a mask of allocated irq's.
110 * probe_irq_off() takes the mask as a parameter,
111 * and returns the irq number which occurred,
112 * or zero if none occurred, or a negative irq number
113 * if more than one irq occurred.
115 externunsigned longprobe_irq_on(void);/* returns 0 on failure */
116 externintprobe_irq_off(unsigned long);/* returns 0 or negative on failure */
118 #endif
close