1
2#ifndef _LINUX_INTERRUPT_H
3#define _LINUX_INTERRUPT_H
4
5#include <linux/config.h>
6#include <linux/kernel.h>
7#include <linux/smp.h>
8#include <linux/cache.h>
9
10#include <asm/bitops.h>
11#include <asm/atomic.h>
12#include <asm/ptrace.h>
13#include <asm/system.h>
14
15struct irqaction {
16 void (*handler)(int, void *, struct pt_regs *);
17 unsigned long flags;
18 unsigned long mask;
19 const char *name;
20 void *dev_id;
21 struct irqaction *next;
22};
23
24
25
26
27
28enum {
29 TIMER_BH = 0,
30 TQUEUE_BH,
31 DIGI_BH,
32 SERIAL_BH,
33 RISCOM8_BH,
34 SPECIALIX_BH,
35 AURORA_BH,
36 ESP_BH,
37 SCSI_BH,
38 IMMEDIATE_BH,
39 CYCLADES_BH,
40 CM206_BH,
41 JS_BH,
42 MACSERIAL_BH,
43 ISICOM_BH
44};
45
46#include <asm/hardirq.h>
47#include <asm/softirq.h>
48
49
50
51
52
53
54
55
56
57enum
58{
59 HI_SOFTIRQ=0,
60 NET_TX_SOFTIRQ,
61 NET_RX_SOFTIRQ,
62 TASKLET_SOFTIRQ
63};
64
65
66
67
68
69struct softirq_action
70{
71 void (*action)(struct softirq_action *);
72 void *data;
73};
74
75asmlinkage void do_softirq(void);
76extern void open_softirq(int nr, void (*action)(struct softirq_action*), void *data);
77extern void softirq_init(void);
78#define __cpu_raise_softirq(cpu, nr) do { softirq_pending(cpu) |= 1UL << (nr); } while (0)
79extern void FASTCALL(cpu_raise_softirq(unsigned int cpu, unsigned int nr));
80extern void FASTCALL(raise_softirq(unsigned int nr));
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104struct tasklet_struct
105{
106 struct tasklet_struct *next;
107 unsigned long state;
108 atomic_t count;
109 void (*func)(unsigned long);
110 unsigned long data;
111};
112
113#define DECLARE_TASKLET(name, func, data) \
114struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(0), func, data }
115
116#define DECLARE_TASKLET_DISABLED(name, func, data) \
117struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(1), func, data }
118
119
120enum
121{
122 TASKLET_STATE_SCHED,
123 TASKLET_STATE_RUN
124};
125
126struct tasklet_head
127{
128 struct tasklet_struct *list;
129} __attribute__ ((__aligned__(SMP_CACHE_BYTES)));
130
131extern struct tasklet_head tasklet_vec[NR_CPUS];
132extern struct tasklet_head tasklet_hi_vec[NR_CPUS];
133
134#ifdef CONFIG_SMP
135static inline int tasklet_trylock(struct tasklet_struct *t)
136{
137 return !test_and_set_bit(TASKLET_STATE_RUN, &(t)->state);
138}
139
140static inline void tasklet_unlock(struct tasklet_struct *t)
141{
142 smp_mb__before_clear_bit();
143 clear_bit(TASKLET_STATE_RUN, &(t)->state);
144}
145
146static inline void tasklet_unlock_wait(struct tasklet_struct *t)
147{
148 while (test_bit(TASKLET_STATE_RUN, &(t)->state)) { barrier(); }
149}
150#else
151#define tasklet_trylock(t) 1
152#define tasklet_unlock_wait(t) do { } while (0)
153#define tasklet_unlock(t) do { } while (0)
154#endif
155
156extern void FASTCALL(__tasklet_schedule(struct tasklet_struct *t));
157
158static inline void tasklet_schedule(struct tasklet_struct *t)
159{
160 if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
161 __tasklet_schedule(t);
162}
163
164extern void FASTCALL(__tasklet_hi_schedule(struct tasklet_struct *t));
165
166static inline void tasklet_hi_schedule(struct tasklet_struct *t)
167{
168 if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
169 __tasklet_hi_schedule(t);
170}
171
172
173static inline void tasklet_disable_nosync(struct tasklet_struct *t)
174{
175 atomic_inc(&t->count);
176 smp_mb__after_atomic_inc();
177}
178
179static inline void tasklet_disable(struct tasklet_struct *t)
180{
181 tasklet_disable_nosync(t);
182 tasklet_unlock_wait(t);
183 smp_mb();
184}
185
186static inline void tasklet_enable(struct tasklet_struct *t)
187{
188 smp_mb__before_atomic_dec();
189 atomic_dec(&t->count);
190}
191
192static inline void tasklet_hi_enable(struct tasklet_struct *t)
193{
194 smp_mb__before_atomic_dec();
195 atomic_dec(&t->count);
196}
197
198extern void tasklet_kill(struct tasklet_struct *t);
199extern void tasklet_init(struct tasklet_struct *t,
200 void (*func)(unsigned long), unsigned long data);
201
202#ifdef CONFIG_SMP
203
204#define SMP_TIMER_NAME(name) name##__thr
205
206#define SMP_TIMER_DEFINE(name, task) \
207DECLARE_TASKLET(task, name##__thr, 0); \
208static void name (unsigned long dummy) \
209{ \
210 tasklet_schedule(&(task)); \
211}
212
213#else
214
215#define SMP_TIMER_NAME(name) name
216#define SMP_TIMER_DEFINE(name, task)
217
218#endif
219
220
221
222
223extern struct tasklet_struct bh_task_vec[];
224
225
226extern spinlock_t global_bh_lock;
227
228static inline void mark_bh(int nr)
229{
230 tasklet_hi_schedule(bh_task_vec+nr);
231}
232
233extern void init_bh(int nr, void (*routine)(void));
234extern void remove_bh(int nr);
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264extern unsigned long probe_irq_on(void);
265extern int probe_irq_off(unsigned long);
266extern unsigned int probe_irq_mask(unsigned long);
267
268#endif
269