1
2#ifndef _LINUX_INTERRUPT_H
3#define _LINUX_INTERRUPT_H
4
5#include <linux/kernel.h>
6#include <linux/linkage.h>
7#include <linux/bitops.h>
8#include <linux/preempt.h>
9#include <linux/cpumask.h>
10#include <linux/irqreturn.h>
11#include <linux/irqnr.h>
12#include <linux/hardirq.h>
13#include <linux/sched.h>
14#include <linux/irqflags.h>
15#include <linux/smp.h>
16#include <linux/percpu.h>
17
18#include <asm/atomic.h>
19#include <asm/ptrace.h>
20#include <asm/system.h>
21
22
23
24
25
26
27
28
29#define IRQF_TRIGGER_NONE 0x00000000
30#define IRQF_TRIGGER_RISING 0x00000001
31#define IRQF_TRIGGER_FALLING 0x00000002
32#define IRQF_TRIGGER_HIGH 0x00000004
33#define IRQF_TRIGGER_LOW 0x00000008
34#define IRQF_TRIGGER_MASK (IRQF_TRIGGER_HIGH | IRQF_TRIGGER_LOW | \
35 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING)
36#define IRQF_TRIGGER_PROBE 0x00000010
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53#define IRQF_DISABLED 0x00000020
54#define IRQF_SAMPLE_RANDOM 0x00000040
55#define IRQF_SHARED 0x00000080
56#define IRQF_PROBE_SHARED 0x00000100
57#define IRQF_TIMER 0x00000200
58#define IRQF_PERCPU 0x00000400
59#define IRQF_NOBALANCING 0x00000800
60#define IRQF_IRQPOLL 0x00001000
61
62typedef irqreturn_t (*irq_handler_t)(int, void *);
63
64struct irqaction {
65 irq_handler_t handler;
66 unsigned long flags;
67 cpumask_t mask;
68 const char *name;
69 void *dev_id;
70 struct irqaction *next;
71 int irq;
72 struct proc_dir_entry *dir;
73};
74
75extern irqreturn_t no_action(int cpl, void *dev_id);
76extern int __must_check request_irq(unsigned int, irq_handler_t handler,
77 unsigned long, const char *, void *);
78extern void free_irq(unsigned int, void *);
79
80struct device;
81
82extern int __must_check devm_request_irq(struct device *dev, unsigned int irq,
83 irq_handler_t handler, unsigned long irqflags,
84 const char *devname, void *dev_id);
85extern void devm_free_irq(struct device *dev, unsigned int irq, void *dev_id);
86
87
88
89
90
91
92
93
94
95
96
97
98
99#ifdef CONFIG_LOCKDEP
100# define local_irq_enable_in_hardirq() do { } while (0)
101#else
102# define local_irq_enable_in_hardirq() local_irq_enable()
103#endif
104
105extern void disable_irq_nosync(unsigned int irq);
106extern void disable_irq(unsigned int irq);
107extern void enable_irq(unsigned int irq);
108
109#if defined(CONFIG_SMP) && defined(CONFIG_GENERIC_HARDIRQS)
110
111extern cpumask_var_t irq_default_affinity;
112
113extern int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask);
114extern int irq_can_set_affinity(unsigned int irq);
115extern int irq_select_affinity(unsigned int irq);
116
117#else
118
119static inline int irq_set_affinity(unsigned int irq, const struct cpumask *m)
120{
121 return -EINVAL;
122}
123
124static inline int irq_can_set_affinity(unsigned int irq)
125{
126 return 0;
127}
128
129static inline int irq_select_affinity(unsigned int irq) { return 0; }
130
131#endif
132
133#ifdef CONFIG_GENERIC_HARDIRQS
134
135
136
137
138
139
140
141
142
143
144
145static inline void disable_irq_nosync_lockdep(unsigned int irq)
146{
147 disable_irq_nosync(irq);
148#ifdef CONFIG_LOCKDEP
149 local_irq_disable();
150#endif
151}
152
153static inline void disable_irq_nosync_lockdep_irqsave(unsigned int irq, unsigned long *flags)
154{
155 disable_irq_nosync(irq);
156#ifdef CONFIG_LOCKDEP
157 local_irq_save(*flags);
158#endif
159}
160
161static inline void disable_irq_lockdep(unsigned int irq)
162{
163 disable_irq(irq);
164#ifdef CONFIG_LOCKDEP
165 local_irq_disable();
166#endif
167}
168
169static inline void enable_irq_lockdep(unsigned int irq)
170{
171#ifdef CONFIG_LOCKDEP
172 local_irq_enable();
173#endif
174 enable_irq(irq);
175}
176
177static inline void enable_irq_lockdep_irqrestore(unsigned int irq, unsigned long *flags)
178{
179#ifdef CONFIG_LOCKDEP
180 local_irq_restore(*flags);
181#endif
182 enable_irq(irq);
183}
184
185
186extern int set_irq_wake(unsigned int irq, unsigned int on);
187
188static inline int enable_irq_wake(unsigned int irq)
189{
190 return set_irq_wake(irq, 1);
191}
192
193static inline int disable_irq_wake(unsigned int irq)
194{
195 return set_irq_wake(irq, 0);
196}
197
198#else
199
200
201
202
203
204#ifndef CONFIG_LOCKDEP
205# define disable_irq_nosync_lockdep(irq) disable_irq_nosync(irq)
206# define disable_irq_nosync_lockdep_irqsave(irq, flags) \
207 disable_irq_nosync(irq)
208# define disable_irq_lockdep(irq) disable_irq(irq)
209# define enable_irq_lockdep(irq) enable_irq(irq)
210# define enable_irq_lockdep_irqrestore(irq, flags) \
211 enable_irq(irq)
212# endif
213
214static inline int enable_irq_wake(unsigned int irq)
215{
216 return 0;
217}
218
219static inline int disable_irq_wake(unsigned int irq)
220{
221 return 0;
222}
223#endif
224
225#ifndef __ARCH_SET_SOFTIRQ_PENDING
226#define set_softirq_pending(x) (local_softirq_pending() = (x))
227#define or_softirq_pending(x) (local_softirq_pending() |= (x))
228#endif
229
230
231
232
233
234
235
236#ifndef hard_irq_disable
237#define hard_irq_disable() do { } while(0)
238#endif
239
240
241
242
243
244
245
246enum
247{
248 HI_SOFTIRQ=0,
249 TIMER_SOFTIRQ,
250 NET_TX_SOFTIRQ,
251 NET_RX_SOFTIRQ,
252 BLOCK_SOFTIRQ,
253 TASKLET_SOFTIRQ,
254 SCHED_SOFTIRQ,
255 HRTIMER_SOFTIRQ,
256 RCU_SOFTIRQ,
257
258 NR_SOFTIRQS
259};
260
261
262
263
264
265struct softirq_action
266{
267 void (*action)(struct softirq_action *);
268};
269
270asmlinkage void do_softirq(void);
271asmlinkage void __do_softirq(void);
272extern void open_softirq(int nr, void (*action)(struct softirq_action *));
273extern void softirq_init(void);
274#define __raise_softirq_irqoff(nr) do { or_softirq_pending(1UL << (nr)); } while (0)
275extern void raise_softirq_irqoff(unsigned int nr);
276extern void raise_softirq(unsigned int nr);
277
278
279
280
281
282
283
284
285DECLARE_PER_CPU(struct list_head [NR_SOFTIRQS], softirq_work_list);
286
287
288
289
290extern void send_remote_softirq(struct call_single_data *cp, int cpu, int softirq);
291
292
293
294
295extern void __send_remote_softirq(struct call_single_data *cp, int cpu,
296 int this_cpu, int softirq);
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318struct tasklet_struct
319{
320 struct tasklet_struct *next;
321 unsigned long state;
322 atomic_t count;
323 void (*func)(unsigned long);
324 unsigned long data;
325};
326
327#define DECLARE_TASKLET(name, func, data) \
328struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(0), func, data }
329
330#define DECLARE_TASKLET_DISABLED(name, func, data) \
331struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(1), func, data }
332
333
334enum
335{
336 TASKLET_STATE_SCHED,
337 TASKLET_STATE_RUN
338};
339
340#ifdef CONFIG_SMP
341static inline int tasklet_trylock(struct tasklet_struct *t)
342{
343 return !test_and_set_bit(TASKLET_STATE_RUN, &(t)->state);
344}
345
346static inline void tasklet_unlock(struct tasklet_struct *t)
347{
348 smp_mb__before_clear_bit();
349 clear_bit(TASKLET_STATE_RUN, &(t)->state);
350}
351
352static inline void tasklet_unlock_wait(struct tasklet_struct *t)
353{
354 while (test_bit(TASKLET_STATE_RUN, &(t)->state)) { barrier(); }
355}
356#else
357#define tasklet_trylock(t) 1
358#define tasklet_unlock_wait(t) do { } while (0)
359#define tasklet_unlock(t) do { } while (0)
360#endif
361
362extern void __tasklet_schedule(struct tasklet_struct *t);
363
364static inline void tasklet_schedule(struct tasklet_struct *t)
365{
366 if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
367 __tasklet_schedule(t);
368}
369
370extern void __tasklet_hi_schedule(struct tasklet_struct *t);
371
372static inline void tasklet_hi_schedule(struct tasklet_struct *t)
373{
374 if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
375 __tasklet_hi_schedule(t);
376}
377
378
379static inline void tasklet_disable_nosync(struct tasklet_struct *t)
380{
381 atomic_inc(&t->count);
382 smp_mb__after_atomic_inc();
383}
384
385static inline void tasklet_disable(struct tasklet_struct *t)
386{
387 tasklet_disable_nosync(t);
388 tasklet_unlock_wait(t);
389 smp_mb();
390}
391
392static inline void tasklet_enable(struct tasklet_struct *t)
393{
394 smp_mb__before_atomic_dec();
395 atomic_dec(&t->count);
396}
397
398static inline void tasklet_hi_enable(struct tasklet_struct *t)
399{
400 smp_mb__before_atomic_dec();
401 atomic_dec(&t->count);
402}
403
404extern void tasklet_kill(struct tasklet_struct *t);
405extern void tasklet_kill_immediate(struct tasklet_struct *t, unsigned int cpu);
406extern void tasklet_init(struct tasklet_struct *t,
407 void (*func)(unsigned long), unsigned long data);
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437#if defined(CONFIG_GENERIC_HARDIRQS) && !defined(CONFIG_GENERIC_IRQ_PROBE)
438static inline unsigned long probe_irq_on(void)
439{
440 return 0;
441}
442static inline int probe_irq_off(unsigned long val)
443{
444 return 0;
445}
446static inline unsigned int probe_irq_mask(unsigned long val)
447{
448 return 0;
449}
450#else
451extern unsigned long probe_irq_on(void);
452extern int probe_irq_off(unsigned long);
453extern unsigned int probe_irq_mask(unsigned long);
454#endif
455
456#ifdef CONFIG_PROC_FS
457
458extern void init_irq_proc(void);
459#else
460static inline void init_irq_proc(void)
461{
462}
463#endif
464
465int show_interrupts(struct seq_file *p, void *v);
466
467struct irq_desc;
468
469extern int early_irq_init(void);
470extern int arch_early_irq_init(void);
471extern int arch_init_chip_data(struct irq_desc *desc, int cpu);
472
473#endif
474