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/linkage.h>
8#include <linux/bitops.h>
9#include <linux/preempt.h>
10#include <linux/cpumask.h>
11#include <asm/atomic.h>
12#include <asm/hardirq.h>
13#include <asm/ptrace.h>
14#include <asm/system.h>
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30typedef int irqreturn_t;
31
32#define IRQ_NONE (0)
33#define IRQ_HANDLED (1)
34#define IRQ_RETVAL(x) ((x) != 0)
35
36struct irqaction {
37 irqreturn_t (*handler)(int, void *, struct pt_regs *);
38 unsigned long flags;
39 cpumask_t mask;
40 const char *name;
41 void *dev_id;
42 struct irqaction *next;
43};
44
45extern irqreturn_t no_action(int cpl, void *dev_id, struct pt_regs *regs);
46extern int request_irq(unsigned int,
47 irqreturn_t (*handler)(int, void *, struct pt_regs *),
48 unsigned long, const char *, void *);
49extern void free_irq(unsigned int, void *);
50
51
52
53
54#ifndef CONFIG_SMP
55# define cli() local_irq_disable()
56# define sti() local_irq_enable()
57# define save_flags(x) local_save_flags(x)
58# define restore_flags(x) local_irq_restore(x)
59# define save_and_cli(x) local_irq_save(x)
60#endif
61
62
63#define local_bh_disable() \
64 do { preempt_count() += SOFTIRQ_OFFSET; barrier(); } while (0)
65#define __local_bh_enable() \
66 do { barrier(); preempt_count() -= SOFTIRQ_OFFSET; } while (0)
67
68extern void local_bh_enable(void);
69
70
71
72
73
74
75
76enum
77{
78 HI_SOFTIRQ=0,
79 TIMER_SOFTIRQ,
80 NET_TX_SOFTIRQ,
81 NET_RX_SOFTIRQ,
82 SCSI_SOFTIRQ,
83 TASKLET_SOFTIRQ
84};
85
86
87
88
89
90struct softirq_action
91{
92 void (*action)(struct softirq_action *);
93 void *data;
94};
95
96asmlinkage void do_softirq(void);
97extern void open_softirq(int nr, void (*action)(struct softirq_action*), void *data);
98extern void softirq_init(void);
99#define __raise_softirq_irqoff(nr) do { local_softirq_pending() |= 1UL << (nr); } while (0)
100extern void FASTCALL(raise_softirq_irqoff(unsigned int nr));
101extern void FASTCALL(raise_softirq(unsigned int nr));
102
103#ifndef invoke_softirq
104#define invoke_softirq() do_softirq()
105#endif
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128struct tasklet_struct
129{
130 struct tasklet_struct *next;
131 unsigned long state;
132 atomic_t count;
133 void (*func)(unsigned long);
134 unsigned long data;
135};
136
137#define DECLARE_TASKLET(name, func, data) \
138struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(0), func, data }
139
140#define DECLARE_TASKLET_DISABLED(name, func, data) \
141struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(1), func, data }
142
143
144enum
145{
146 TASKLET_STATE_SCHED,
147 TASKLET_STATE_RUN
148};
149
150#ifdef CONFIG_SMP
151static inline int tasklet_trylock(struct tasklet_struct *t)
152{
153 return !test_and_set_bit(TASKLET_STATE_RUN, &(t)->state);
154}
155
156static inline void tasklet_unlock(struct tasklet_struct *t)
157{
158 smp_mb__before_clear_bit();
159 clear_bit(TASKLET_STATE_RUN, &(t)->state);
160}
161
162static inline void tasklet_unlock_wait(struct tasklet_struct *t)
163{
164 while (test_bit(TASKLET_STATE_RUN, &(t)->state)) { barrier(); }
165}
166#else
167#define tasklet_trylock(t) 1
168#define tasklet_unlock_wait(t) do { } while (0)
169#define tasklet_unlock(t) do { } while (0)
170#endif
171
172extern void FASTCALL(__tasklet_schedule(struct tasklet_struct *t));
173
174static inline void tasklet_schedule(struct tasklet_struct *t)
175{
176 if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
177 __tasklet_schedule(t);
178}
179
180extern void FASTCALL(__tasklet_hi_schedule(struct tasklet_struct *t));
181
182static inline void tasklet_hi_schedule(struct tasklet_struct *t)
183{
184 if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
185 __tasklet_hi_schedule(t);
186}
187
188
189static inline void tasklet_disable_nosync(struct tasklet_struct *t)
190{
191 atomic_inc(&t->count);
192 smp_mb__after_atomic_inc();
193}
194
195static inline void tasklet_disable(struct tasklet_struct *t)
196{
197 tasklet_disable_nosync(t);
198 tasklet_unlock_wait(t);
199 smp_mb();
200}
201
202static inline void tasklet_enable(struct tasklet_struct *t)
203{
204 smp_mb__before_atomic_dec();
205 atomic_dec(&t->count);
206}
207
208static inline void tasklet_hi_enable(struct tasklet_struct *t)
209{
210 smp_mb__before_atomic_dec();
211 atomic_dec(&t->count);
212}
213
214extern void tasklet_kill(struct tasklet_struct *t);
215extern void tasklet_kill_immediate(struct tasklet_struct *t, unsigned int cpu);
216extern void tasklet_init(struct tasklet_struct *t,
217 void (*func)(unsigned long), unsigned long data);
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246extern unsigned long probe_irq_on(void);
247extern int probe_irq_off(unsigned long);
248extern unsigned int probe_irq_mask(unsigned long);
249
250#endif
251