ia64/xen-unstable

view xen/include/asm-ia64/linux-xen/linux/interrupt.h @ 19197:9e3be0660c1e

Cleanup naming for ia64 and x86 interrupt handling functions

- Append '_IRQ' to AUTO_ASSIGN, NEVER_ASSIGN, and FREE_TO_ASSIGN
- Rename {request,setup}_irq to {request,setup}_irq_vector
- Rename free_irq to release_irq_vector
- Add {request,setup,release}_irq wrappers for their
{request,setup,release}_irq_vector counterparts
- Added generic irq_to_vector inline for ia64
- Changed ia64 to use the new naming scheme

Signed-off-by: Espen Skoglund <espen.skoglund@netronome.com>
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Feb 12 10:48:55 2009 +0000 (2009-02-12)
parents 54167c319547
children
line source
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/linkage.h>
8 #include <linux/bitops.h>
9 #include <linux/preempt.h>
10 #include <linux/cpumask.h>
11 #include <linux/hardirq.h>
12 #include <asm/atomic.h>
13 #include <asm/ptrace.h>
14 #include <asm/system.h>
16 /*
17 * For 2.4.x compatibility, 2.4.x can use
18 *
19 * typedef void irqreturn_t;
20 * #define IRQ_NONE
21 * #define IRQ_HANDLED
22 * #define IRQ_RETVAL(x)
23 *
24 * To mix old-style and new-style irq handler returns.
25 *
26 * IRQ_NONE means we didn't handle it.
27 * IRQ_HANDLED means that we did have a valid interrupt and handled it.
28 * IRQ_RETVAL(x) selects on the two depending on x being non-zero (for handled)
29 */
30 #ifdef XEN
31 typedef void irqreturn_t;
32 #define IRQ_NONE
33 #define IRQ_HANDLED
34 #define IRQ_RETVAL(x)
35 #else
36 typedef int irqreturn_t;
37 #define IRQ_NONE (0)
38 #define IRQ_HANDLED (1)
39 #define IRQ_RETVAL(x) ((x) != 0)
40 #endif
42 #ifndef XEN
43 struct irqaction {
44 irqreturn_t (*handler)(int, void *, struct pt_regs *);
45 unsigned long flags;
46 cpumask_t mask;
47 const char *name;
48 void *dev_id;
49 struct irqaction *next;
50 int irq;
51 struct proc_dir_entry *dir;
52 };
54 extern irqreturn_t no_action(int cpl, void *dev_id, struct pt_regs *regs);
55 extern int request_irq_vector(unsigned int,
56 irqreturn_t (*handler)(int, void *, struct pt_regs *),
57 unsigned long, const char *, void *);
58 extern void release_irq_vector(unsigned int, void *);
59 #endif
62 #ifdef CONFIG_GENERIC_HARDIRQS
63 extern void disable_irq_nosync(unsigned int irq);
64 extern void disable_irq(unsigned int irq);
65 extern void enable_irq(unsigned int irq);
66 #endif
68 /*
69 * Temporary defines for UP kernels, until all code gets fixed.
70 */
71 #ifndef CONFIG_SMP
72 static inline void __deprecated cli(void)
73 {
74 local_irq_disable();
75 }
76 static inline void __deprecated sti(void)
77 {
78 local_irq_enable();
79 }
80 static inline void __deprecated save_flags(unsigned long *x)
81 {
82 local_save_flags(*x);
83 }
84 #define save_flags(x) save_flags(&x);
85 static inline void __deprecated restore_flags(unsigned long x)
86 {
87 local_irq_restore(x);
88 }
90 static inline void __deprecated save_and_cli(unsigned long *x)
91 {
92 local_irq_save(*x);
93 }
94 #define save_and_cli(x) save_and_cli(&x)
95 #endif /* CONFIG_SMP */
97 #ifndef XEN
98 /* SoftIRQ primitives. */
99 #define local_bh_disable() \
100 do { add_preempt_count(SOFTIRQ_OFFSET); barrier(); } while (0)
101 #define __local_bh_enable() \
102 do { barrier(); sub_preempt_count(SOFTIRQ_OFFSET); } while (0)
104 extern void local_bh_enable(void);
105 #endif
107 /* PLEASE, avoid to allocate new softirqs, if you need not _really_ high
108 frequency threaded job scheduling. For almost all the purposes
109 tasklets are more than enough. F.e. all serial device BHs et
110 al. should be converted to tasklets, not to softirqs.
111 */
113 #ifndef XEN
114 enum
115 {
116 HI_SOFTIRQ=0,
117 TIMER_SOFTIRQ,
118 NET_TX_SOFTIRQ,
119 NET_RX_SOFTIRQ,
120 SCSI_SOFTIRQ,
121 TASKLET_SOFTIRQ
122 };
123 #endif
125 /* softirq mask and active fields moved to irq_cpustat_t in
126 * asm/hardirq.h to get better cache usage. KAO
127 */
129 struct softirq_action
130 {
131 void (*action)(struct softirq_action *);
132 void *data;
133 };
135 asmlinkage void do_softirq(void);
136 #ifndef XEN
137 extern void open_softirq(int nr, void (*action)(struct softirq_action*), void *data);
138 #endif
139 extern void softirq_init(void);
140 #define __raise_softirq_irqoff(nr) do { local_softirq_pending() |= 1UL << (nr); } while (0)
141 extern void FASTCALL(raise_softirq_irqoff(unsigned int nr));
142 #ifndef XEN
143 extern void FASTCALL(raise_softirq(unsigned int nr));
144 #endif
147 #ifndef XEN
148 /* Tasklets --- multithreaded analogue of BHs.
150 Main feature differing them of generic softirqs: tasklet
151 is running only on one CPU simultaneously.
153 Main feature differing them of BHs: different tasklets
154 may be run simultaneously on different CPUs.
156 Properties:
157 * If tasklet_schedule() is called, then tasklet is guaranteed
158 to be executed on some cpu at least once after this.
159 * If the tasklet is already scheduled, but its excecution is still not
160 started, it will be executed only once.
161 * If this tasklet is already running on another CPU (or schedule is called
162 from tasklet itself), it is rescheduled for later.
163 * Tasklet is strictly serialized wrt itself, but not
164 wrt another tasklets. If client needs some intertask synchronization,
165 he makes it with spinlocks.
166 */
168 struct tasklet_struct
169 {
170 struct tasklet_struct *next;
171 unsigned long state;
172 atomic_t count;
173 void (*func)(unsigned long);
174 unsigned long data;
175 };
177 #define DECLARE_TASKLET(name, func, data) \
178 struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(0), func, data }
180 #define DECLARE_TASKLET_DISABLED(name, func, data) \
181 struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(1), func, data }
184 enum
185 {
186 TASKLET_STATE_SCHED, /* Tasklet is scheduled for execution */
187 TASKLET_STATE_RUN /* Tasklet is running (SMP only) */
188 };
190 #ifdef CONFIG_SMP
191 static inline int tasklet_trylock(struct tasklet_struct *t)
192 {
193 return !test_and_set_bit(TASKLET_STATE_RUN, &(t)->state);
194 }
196 static inline void tasklet_unlock(struct tasklet_struct *t)
197 {
198 smp_mb__before_clear_bit();
199 clear_bit(TASKLET_STATE_RUN, &(t)->state);
200 }
202 static inline void tasklet_unlock_wait(struct tasklet_struct *t)
203 {
204 while (test_bit(TASKLET_STATE_RUN, &(t)->state)) { barrier(); }
205 }
206 #else
207 #define tasklet_trylock(t) 1
208 #define tasklet_unlock_wait(t) do { } while (0)
209 #define tasklet_unlock(t) do { } while (0)
210 #endif
212 extern void FASTCALL(__tasklet_schedule(struct tasklet_struct *t));
214 static inline void tasklet_schedule(struct tasklet_struct *t)
215 {
216 if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
217 __tasklet_schedule(t);
218 }
220 extern void FASTCALL(__tasklet_hi_schedule(struct tasklet_struct *t));
222 static inline void tasklet_hi_schedule(struct tasklet_struct *t)
223 {
224 if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
225 __tasklet_hi_schedule(t);
226 }
229 static inline void tasklet_disable_nosync(struct tasklet_struct *t)
230 {
231 atomic_inc(&t->count);
232 smp_mb__after_atomic_inc();
233 }
235 static inline void tasklet_disable(struct tasklet_struct *t)
236 {
237 tasklet_disable_nosync(t);
238 tasklet_unlock_wait(t);
239 smp_mb();
240 }
242 static inline void tasklet_enable(struct tasklet_struct *t)
243 {
244 smp_mb__before_atomic_dec();
245 atomic_dec(&t->count);
246 }
248 static inline void tasklet_hi_enable(struct tasklet_struct *t)
249 {
250 smp_mb__before_atomic_dec();
251 atomic_dec(&t->count);
252 }
254 extern void tasklet_kill(struct tasklet_struct *t);
255 extern void tasklet_kill_immediate(struct tasklet_struct *t, unsigned int cpu);
256 extern void tasklet_init(struct tasklet_struct *t,
257 void (*func)(unsigned long), unsigned long data);
258 #endif
260 /*
261 * Autoprobing for irqs:
262 *
263 * probe_irq_on() and probe_irq_off() provide robust primitives
264 * for accurate IRQ probing during kernel initialization. They are
265 * reasonably simple to use, are not "fooled" by spurious interrupts,
266 * and, unlike other attempts at IRQ probing, they do not get hung on
267 * stuck interrupts (such as unused PS2 mouse interfaces on ASUS boards).
268 *
269 * For reasonably foolproof probing, use them as follows:
270 *
271 * 1. clear and/or mask the device's internal interrupt.
272 * 2. sti();
273 * 3. irqs = probe_irq_on(); // "take over" all unassigned idle IRQs
274 * 4. enable the device and cause it to trigger an interrupt.
275 * 5. wait for the device to interrupt, using non-intrusive polling or a delay.
276 * 6. irq = probe_irq_off(irqs); // get IRQ number, 0=none, negative=multiple
277 * 7. service the device to clear its pending interrupt.
278 * 8. loop again if paranoia is required.
279 *
280 * probe_irq_on() returns a mask of allocated irq's.
281 *
282 * probe_irq_off() takes the mask as a parameter,
283 * and returns the irq number which occurred,
284 * or zero if none occurred, or a negative irq number
285 * if more than one irq occurred.
286 */
288 #if defined(CONFIG_GENERIC_HARDIRQS) && !defined(CONFIG_GENERIC_IRQ_PROBE)
289 static inline unsigned long probe_irq_on(void)
290 {
291 return 0;
292 }
293 static inline int probe_irq_off(unsigned long val)
294 {
295 return 0;
296 }
297 static inline unsigned int probe_irq_mask(unsigned long val)
298 {
299 return 0;
300 }
301 #else
302 extern unsigned long probe_irq_on(void); /* returns 0 on failure */
303 extern int probe_irq_off(unsigned long); /* returns 0 or negative on failure */
304 extern unsigned int probe_irq_mask(unsigned long); /* returns mask of ISA interrupts */
305 #endif
307 #endif