Updated binary toolchain for kernel 2.4 target (gcc 4.2.4, binutils 2.20.1)
[tomato.git] / tools / brcm / K24 / hndtools-mipsel-uclibc-4.2.4 / include / linux / interrupt.h
blobaa9bca0dcfcf4b8d9ae0f79cde66942e909eef72
1 /* interrupt.h */
2 #ifndef _LINUX_INTERRUPT_H
3 #define _LINUX_INTERRUPT_H
5 #include <linux/config.h>
6 #include <linux/kernel.h>
7 #include <linux/smp.h>
8 #include <linux/cache.h>
10 #include <asm/bitops.h>
11 #include <asm/atomic.h>
12 #include <asm/ptrace.h>
13 #include <asm/system.h>
15 /* For 2.6.x compatibility */
16 typedef void irqreturn_t;
17 #define IRQ_NONE
18 #define IRQ_HANDLED
19 #define IRQ_RETVAL(x)
21 struct irqaction {
22 void (*handler)(int, void *, struct pt_regs *);
23 unsigned long flags;
24 unsigned long mask;
25 const char *name;
26 void *dev_id;
27 struct irqaction *next;
31 /* Who gets which entry in bh_base. Things which will occur most often
32 should come first */
34 enum {
35 TIMER_BH = 0,
36 TQUEUE_BH,
37 DIGI_BH,
38 SERIAL_BH,
39 RISCOM8_BH,
40 SPECIALIX_BH,
41 AURORA_BH,
42 ESP_BH,
43 SCSI_BH,
44 IMMEDIATE_BH,
45 CYCLADES_BH,
46 CM206_BH,
47 JS_BH,
48 MACSERIAL_BH,
49 ISICOM_BH
52 #include <asm/hardirq.h>
53 #include <asm/softirq.h>
57 /* PLEASE, avoid to allocate new softirqs, if you need not _really_ high
58 frequency threaded job scheduling. For almost all the purposes
59 tasklets are more than enough. F.e. all serial device BHs et
60 al. should be converted to tasklets, not to softirqs.
63 enum
65 HI_SOFTIRQ=0,
66 NET_TX_SOFTIRQ,
67 NET_RX_SOFTIRQ,
68 TASKLET_SOFTIRQ
71 /* softirq mask and active fields moved to irq_cpustat_t in
72 * asm/hardirq.h to get better cache usage. KAO
75 struct softirq_action
77 void (*action)(struct softirq_action *);
78 void *data;
81 asmlinkage void do_softirq(void);
82 extern void open_softirq(int nr, void (*action)(struct softirq_action*), void *data);
83 extern void softirq_init(void);
84 #define __cpu_raise_softirq(cpu, nr) do { softirq_pending(cpu) |= 1UL << (nr); } while (0)
85 extern void FASTCALL(cpu_raise_softirq(unsigned int cpu, unsigned int nr));
86 extern void FASTCALL(raise_softirq(unsigned int nr));
90 /* Tasklets --- multithreaded analogue of BHs.
92 Main feature differing them of generic softirqs: tasklet
93 is running only on one CPU simultaneously.
95 Main feature differing them of BHs: different tasklets
96 may be run simultaneously on different CPUs.
98 Properties:
99 * If tasklet_schedule() is called, then tasklet is guaranteed
100 to be executed on some cpu at least once after this.
101 * If the tasklet is already scheduled, but its excecution is still not
102 started, it will be executed only once.
103 * If this tasklet is already running on another CPU (or schedule is called
104 from tasklet itself), it is rescheduled for later.
105 * Tasklet is strictly serialized wrt itself, but not
106 wrt another tasklets. If client needs some intertask synchronization,
107 he makes it with spinlocks.
110 struct tasklet_struct
112 struct tasklet_struct *next;
113 unsigned long state;
114 atomic_t count;
115 void (*func)(unsigned long);
116 unsigned long data;
119 #define DECLARE_TASKLET(name, func, data) \
120 struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(0), func, data }
122 #define DECLARE_TASKLET_DISABLED(name, func, data) \
123 struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(1), func, data }
126 enum
128 TASKLET_STATE_SCHED, /* Tasklet is scheduled for execution */
129 TASKLET_STATE_RUN /* Tasklet is running (SMP only) */
132 struct tasklet_head
134 struct tasklet_struct *list;
135 } __attribute__ ((__aligned__(SMP_CACHE_BYTES)));
137 extern struct tasklet_head tasklet_vec[NR_CPUS];
138 extern struct tasklet_head tasklet_hi_vec[NR_CPUS];
140 #ifdef CONFIG_SMP
141 static inline int tasklet_trylock(struct tasklet_struct *t)
143 return !test_and_set_bit(TASKLET_STATE_RUN, &(t)->state);
146 static inline void tasklet_unlock(struct tasklet_struct *t)
148 smp_mb__before_clear_bit();
149 clear_bit(TASKLET_STATE_RUN, &(t)->state);
152 static inline void tasklet_unlock_wait(struct tasklet_struct *t)
154 while (test_bit(TASKLET_STATE_RUN, &(t)->state)) { barrier(); }
156 #else
157 #define tasklet_trylock(t) 1
158 #define tasklet_unlock_wait(t) do { } while (0)
159 #define tasklet_unlock(t) do { } while (0)
160 #endif
162 extern void FASTCALL(__tasklet_schedule(struct tasklet_struct *t));
164 static inline void tasklet_schedule(struct tasklet_struct *t)
166 if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
167 __tasklet_schedule(t);
170 extern void FASTCALL(__tasklet_hi_schedule(struct tasklet_struct *t));
172 static inline void tasklet_hi_schedule(struct tasklet_struct *t)
174 if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
175 __tasklet_hi_schedule(t);
179 static inline void tasklet_disable_nosync(struct tasklet_struct *t)
181 atomic_inc(&t->count);
182 smp_mb__after_atomic_inc();
185 static inline void tasklet_disable(struct tasklet_struct *t)
187 tasklet_disable_nosync(t);
188 tasklet_unlock_wait(t);
189 smp_mb();
192 static inline void tasklet_enable(struct tasklet_struct *t)
194 smp_mb__before_atomic_dec();
195 atomic_dec(&t->count);
198 static inline void tasklet_hi_enable(struct tasklet_struct *t)
200 smp_mb__before_atomic_dec();
201 atomic_dec(&t->count);
204 extern void tasklet_kill(struct tasklet_struct *t);
205 extern void tasklet_init(struct tasklet_struct *t,
206 void (*func)(unsigned long), unsigned long data);
208 #ifdef CONFIG_SMP
210 #define SMP_TIMER_NAME(name) name##__thr
212 #define SMP_TIMER_DEFINE(name, task) \
213 DECLARE_TASKLET(task, name##__thr, 0); \
214 static void name (unsigned long dummy) \
216 tasklet_schedule(&(task)); \
219 #else /* CONFIG_SMP */
221 #define SMP_TIMER_NAME(name) name
222 #define SMP_TIMER_DEFINE(name, task)
224 #endif /* CONFIG_SMP */
227 /* Old BH definitions */
229 extern struct tasklet_struct bh_task_vec[];
231 /* It is exported _ONLY_ for wait_on_irq(). */
232 extern spinlock_t global_bh_lock;
234 static inline void mark_bh(int nr)
236 tasklet_hi_schedule(bh_task_vec+nr);
239 extern void init_bh(int nr, void (*routine)(void));
240 extern void remove_bh(int nr);
244 * Autoprobing for irqs:
246 * probe_irq_on() and probe_irq_off() provide robust primitives
247 * for accurate IRQ probing during kernel initialization. They are
248 * reasonably simple to use, are not "fooled" by spurious interrupts,
249 * and, unlike other attempts at IRQ probing, they do not get hung on
250 * stuck interrupts (such as unused PS2 mouse interfaces on ASUS boards).
252 * For reasonably foolproof probing, use them as follows:
254 * 1. clear and/or mask the device's internal interrupt.
255 * 2. sti();
256 * 3. irqs = probe_irq_on(); // "take over" all unassigned idle IRQs
257 * 4. enable the device and cause it to trigger an interrupt.
258 * 5. wait for the device to interrupt, using non-intrusive polling or a delay.
259 * 6. irq = probe_irq_off(irqs); // get IRQ number, 0=none, negative=multiple
260 * 7. service the device to clear its pending interrupt.
261 * 8. loop again if paranoia is required.
263 * probe_irq_on() returns a mask of allocated irq's.
265 * probe_irq_off() takes the mask as a parameter,
266 * and returns the irq number which occurred,
267 * or zero if none occurred, or a negative irq number
268 * if more than one irq occurred.
270 extern unsigned long probe_irq_on(void); /* returns 0 on failure */
271 extern int probe_irq_off(unsigned long); /* returns 0 or negative on failure */
272 extern unsigned int probe_irq_mask(unsigned long); /* returns mask of ISA interrupts */
274 #endif