aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/interrupt.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/interrupt.h')
-rw-r--r--include/linux/interrupt.h150
1 files changed, 128 insertions, 22 deletions
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 2c08fdc2bdf..d5afee95fd4 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -2,37 +2,67 @@
2#ifndef _LINUX_INTERRUPT_H 2#ifndef _LINUX_INTERRUPT_H
3#define _LINUX_INTERRUPT_H 3#define _LINUX_INTERRUPT_H
4 4
5#include <linux/config.h>
6#include <linux/kernel.h> 5#include <linux/kernel.h>
7#include <linux/linkage.h> 6#include <linux/linkage.h>
8#include <linux/bitops.h> 7#include <linux/bitops.h>
9#include <linux/preempt.h> 8#include <linux/preempt.h>
10#include <linux/cpumask.h> 9#include <linux/cpumask.h>
10#include <linux/irqreturn.h>
11#include <linux/hardirq.h> 11#include <linux/hardirq.h>
12#include <linux/sched.h> 12#include <linux/sched.h>
13#include <linux/irqflags.h>
13#include <asm/atomic.h> 14#include <asm/atomic.h>
14#include <asm/ptrace.h> 15#include <asm/ptrace.h>
15#include <asm/system.h> 16#include <asm/system.h>
16 17
17/* 18/*
18 * For 2.4.x compatibility, 2.4.x can use 19 * These correspond to the IORESOURCE_IRQ_* defines in
19 * 20 * linux/ioport.h to select the interrupt line behaviour. When
20 * typedef void irqreturn_t; 21 * requesting an interrupt without specifying a IRQF_TRIGGER, the
21 * #define IRQ_NONE 22 * setting should be assumed to be "as already configured", which
22 * #define IRQ_HANDLED 23 * may be as per machine or firmware initialisation.
23 * #define IRQ_RETVAL(x) 24 */
24 * 25#define IRQF_TRIGGER_NONE 0x00000000
25 * To mix old-style and new-style irq handler returns. 26#define IRQF_TRIGGER_RISING 0x00000001
27#define IRQF_TRIGGER_FALLING 0x00000002
28#define IRQF_TRIGGER_HIGH 0x00000004
29#define IRQF_TRIGGER_LOW 0x00000008
30#define IRQF_TRIGGER_MASK (IRQF_TRIGGER_HIGH | IRQF_TRIGGER_LOW | \
31 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING)
32#define IRQF_TRIGGER_PROBE 0x00000010
33
34/*
35 * These flags used only by the kernel as part of the
36 * irq handling routines.
26 * 37 *
27 * IRQ_NONE means we didn't handle it. 38 * IRQF_DISABLED - keep irqs disabled when calling the action handler
28 * IRQ_HANDLED means that we did have a valid interrupt and handled it. 39 * IRQF_SAMPLE_RANDOM - irq is used to feed the random generator
29 * IRQ_RETVAL(x) selects on the two depending on x being non-zero (for handled) 40 * IRQF_SHARED - allow sharing the irq among several devices
41 * IRQF_PROBE_SHARED - set by callers when they expect sharing mismatches to occur
42 * IRQF_TIMER - Flag to mark this interrupt as timer interrupt
30 */ 43 */
31typedef int irqreturn_t; 44#define IRQF_DISABLED 0x00000020
45#define IRQF_SAMPLE_RANDOM 0x00000040
46#define IRQF_SHARED 0x00000080
47#define IRQF_PROBE_SHARED 0x00000100
48#define IRQF_TIMER 0x00000200
49#define IRQF_PERCPU 0x00000400
32 50
33#define IRQ_NONE (0) 51/*
34#define IRQ_HANDLED (1) 52 * Migration helpers. Scheduled for removal in 1/2007
35#define IRQ_RETVAL(x) ((x) != 0) 53 * Do not use for new code !
54 */
55#define SA_INTERRUPT IRQF_DISABLED
56#define SA_SAMPLE_RANDOM IRQF_SAMPLE_RANDOM
57#define SA_SHIRQ IRQF_SHARED
58#define SA_PROBEIRQ IRQF_PROBE_SHARED
59#define SA_PERCPU IRQF_PERCPU
60
61#define SA_TRIGGER_LOW IRQF_TRIGGER_LOW
62#define SA_TRIGGER_HIGH IRQF_TRIGGER_HIGH
63#define SA_TRIGGER_FALLING IRQF_TRIGGER_FALLING
64#define SA_TRIGGER_RISING IRQF_TRIGGER_RISING
65#define SA_TRIGGER_MASK IRQF_TRIGGER_MASK
36 66
37struct irqaction { 67struct irqaction {
38 irqreturn_t (*handler)(int, void *, struct pt_regs *); 68 irqreturn_t (*handler)(int, void *, struct pt_regs *);
@@ -51,12 +81,90 @@ extern int request_irq(unsigned int,
51 unsigned long, const char *, void *); 81 unsigned long, const char *, void *);
52extern void free_irq(unsigned int, void *); 82extern void free_irq(unsigned int, void *);
53 83
84/*
85 * On lockdep we dont want to enable hardirqs in hardirq
86 * context. Use local_irq_enable_in_hardirq() to annotate
87 * kernel code that has to do this nevertheless (pretty much
88 * the only valid case is for old/broken hardware that is
89 * insanely slow).
90 *
91 * NOTE: in theory this might break fragile code that relies
92 * on hardirq delivery - in practice we dont seem to have such
93 * places left. So the only effect should be slightly increased
94 * irqs-off latencies.
95 */
96#ifdef CONFIG_LOCKDEP
97# define local_irq_enable_in_hardirq() do { } while (0)
98#else
99# define local_irq_enable_in_hardirq() local_irq_enable()
100#endif
54 101
55#ifdef CONFIG_GENERIC_HARDIRQS 102#ifdef CONFIG_GENERIC_HARDIRQS
56extern void disable_irq_nosync(unsigned int irq); 103extern void disable_irq_nosync(unsigned int irq);
57extern void disable_irq(unsigned int irq); 104extern void disable_irq(unsigned int irq);
58extern void enable_irq(unsigned int irq); 105extern void enable_irq(unsigned int irq);
106
107/*
108 * Special lockdep variants of irq disabling/enabling.
109 * These should be used for locking constructs that
110 * know that a particular irq context which is disabled,
111 * and which is the only irq-context user of a lock,
112 * that it's safe to take the lock in the irq-disabled
113 * section without disabling hardirqs.
114 *
115 * On !CONFIG_LOCKDEP they are equivalent to the normal
116 * irq disable/enable methods.
117 */
118static inline void disable_irq_nosync_lockdep(unsigned int irq)
119{
120 disable_irq_nosync(irq);
121#ifdef CONFIG_LOCKDEP
122 local_irq_disable();
59#endif 123#endif
124}
125
126static inline void disable_irq_lockdep(unsigned int irq)
127{
128 disable_irq(irq);
129#ifdef CONFIG_LOCKDEP
130 local_irq_disable();
131#endif
132}
133
134static inline void enable_irq_lockdep(unsigned int irq)
135{
136#ifdef CONFIG_LOCKDEP
137 local_irq_enable();
138#endif
139 enable_irq(irq);
140}
141
142/* IRQ wakeup (PM) control: */
143extern int set_irq_wake(unsigned int irq, unsigned int on);
144
145static inline int enable_irq_wake(unsigned int irq)
146{
147 return set_irq_wake(irq, 1);
148}
149
150static inline int disable_irq_wake(unsigned int irq)
151{
152 return set_irq_wake(irq, 0);
153}
154
155#else /* !CONFIG_GENERIC_HARDIRQS */
156/*
157 * NOTE: non-genirq architectures, if they want to support the lock
158 * validator need to define the methods below in their asm/irq.h
159 * files, under an #ifdef CONFIG_LOCKDEP section.
160 */
161# ifndef CONFIG_LOCKDEP
162# define disable_irq_nosync_lockdep(irq) disable_irq_nosync(irq)
163# define disable_irq_lockdep(irq) disable_irq(irq)
164# define enable_irq_lockdep(irq) enable_irq(irq)
165# endif
166
167#endif /* CONFIG_GENERIC_HARDIRQS */
60 168
61#ifndef __ARCH_SET_SOFTIRQ_PENDING 169#ifndef __ARCH_SET_SOFTIRQ_PENDING
62#define set_softirq_pending(x) (local_softirq_pending() = (x)) 170#define set_softirq_pending(x) (local_softirq_pending() = (x))
@@ -92,13 +200,11 @@ static inline void __deprecated save_and_cli(unsigned long *x)
92#define save_and_cli(x) save_and_cli(&x) 200#define save_and_cli(x) save_and_cli(&x)
93#endif /* CONFIG_SMP */ 201#endif /* CONFIG_SMP */
94 202
95/* SoftIRQ primitives. */ 203extern void local_bh_disable(void);
96#define local_bh_disable() \ 204extern void __local_bh_enable(void);
97 do { add_preempt_count(SOFTIRQ_OFFSET); barrier(); } while (0) 205extern void _local_bh_enable(void);
98#define __local_bh_enable() \
99 do { barrier(); sub_preempt_count(SOFTIRQ_OFFSET); } while (0)
100
101extern void local_bh_enable(void); 206extern void local_bh_enable(void);
207extern void local_bh_enable_ip(unsigned long ip);
102 208
103/* PLEASE, avoid to allocate new softirqs, if you need not _really_ high 209/* PLEASE, avoid to allocate new softirqs, if you need not _really_ high
104 frequency threaded job scheduling. For almost all the purposes 210 frequency threaded job scheduling. For almost all the purposes