ia64/xen-unstable

view xen/include/asm-ia64/linux-xen/linux/interrupt.h @ 9770:ced37bea0647

[IA64] FPH enabling + cleanup

Move contents of switch_to macro from xensystem.h to context_switch function.
Initialize FPU on all processors. FPH is always enabled in Xen.
Speed up context-switch (a little bit!) by not enabling/disabling FPH.
Cleanup (unused function/variablesi/fields, debug printf...)
vmx_ia64_switch_to removed (was unused).

Signed-off-by: Tristan Gingold <tristan.gingold@bull.net>
author awilliam@xenbuild.aw
date Tue Apr 25 22:35:41 2006 -0600 (2006-04-25)
parents 4443bad9a4a6
children 003157eafd66
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 typedef int irqreturn_t;
32 #define IRQ_NONE (0)
33 #define IRQ_HANDLED (1)
34 #define IRQ_RETVAL(x) ((x) != 0)
36 #ifndef XEN
37 struct irqaction {
38 irqreturn_t (*handler)(int, void *, struct pt_regs *);
39 unsigned long flags;
40 cpumask_t mask;
41 const char *name;
42 void *dev_id;
43 struct irqaction *next;
44 int irq;
45 struct proc_dir_entry *dir;
46 };
48 extern irqreturn_t no_action(int cpl, void *dev_id, struct pt_regs *regs);
49 extern int request_irq(unsigned int,
50 irqreturn_t (*handler)(int, void *, struct pt_regs *),
51 unsigned long, const char *, void *);
52 extern void free_irq(unsigned int, void *);
53 #endif
56 #ifdef CONFIG_GENERIC_HARDIRQS
57 extern void disable_irq_nosync(unsigned int irq);
58 extern void disable_irq(unsigned int irq);
59 extern void enable_irq(unsigned int irq);
60 #endif
62 /*
63 * Temporary defines for UP kernels, until all code gets fixed.
64 */
65 #ifndef CONFIG_SMP
66 static inline void __deprecated cli(void)
67 {
68 local_irq_disable();
69 }
70 static inline void __deprecated sti(void)
71 {
72 local_irq_enable();
73 }
74 static inline void __deprecated save_flags(unsigned long *x)
75 {
76 local_save_flags(*x);
77 }
78 #define save_flags(x) save_flags(&x);
79 static inline void __deprecated restore_flags(unsigned long x)
80 {
81 local_irq_restore(x);
82 }
84 static inline void __deprecated save_and_cli(unsigned long *x)
85 {
86 local_irq_save(*x);
87 }
88 #define save_and_cli(x) save_and_cli(&x)
89 #endif /* CONFIG_SMP */
91 #ifndef XEN
92 /* SoftIRQ primitives. */
93 #define local_bh_disable() \
94 do { add_preempt_count(SOFTIRQ_OFFSET); barrier(); } while (0)
95 #define __local_bh_enable() \
96 do { barrier(); sub_preempt_count(SOFTIRQ_OFFSET); } while (0)
98 extern void local_bh_enable(void);
99 #endif
101 /* PLEASE, avoid to allocate new softirqs, if you need not _really_ high
102 frequency threaded job scheduling. For almost all the purposes
103 tasklets are more than enough. F.e. all serial device BHs et
104 al. should be converted to tasklets, not to softirqs.
105 */
107 #ifndef XEN
108 enum
109 {
110 HI_SOFTIRQ=0,
111 TIMER_SOFTIRQ,
112 NET_TX_SOFTIRQ,
113 NET_RX_SOFTIRQ,
114 SCSI_SOFTIRQ,
115 TASKLET_SOFTIRQ
116 };
117 #endif
119 /* softirq mask and active fields moved to irq_cpustat_t in
120 * asm/hardirq.h to get better cache usage. KAO
121 */
123 struct softirq_action
124 {
125 void (*action)(struct softirq_action *);
126 void *data;
127 };
129 asmlinkage void do_softirq(void);
130 #ifndef XEN
131 extern void open_softirq(int nr, void (*action)(struct softirq_action*), void *data);
132 #endif
133 extern void softirq_init(void);
134 #define __raise_softirq_irqoff(nr) do { local_softirq_pending() |= 1UL << (nr); } while (0)
135 extern void FASTCALL(raise_softirq_irqoff(unsigned int nr));
136 #ifndef XEN
137 extern void FASTCALL(raise_softirq(unsigned int nr));
138 #endif
141 /* Tasklets --- multithreaded analogue of BHs.
143 Main feature differing them of generic softirqs: tasklet
144 is running only on one CPU simultaneously.
146 Main feature differing them of BHs: different tasklets
147 may be run simultaneously on different CPUs.
149 Properties:
150 * If tasklet_schedule() is called, then tasklet is guaranteed
151 to be executed on some cpu at least once after this.
152 * If the tasklet is already scheduled, but its excecution is still not
153 started, it will be executed only once.
154 * If this tasklet is already running on another CPU (or schedule is called
155 from tasklet itself), it is rescheduled for later.
156 * Tasklet is strictly serialized wrt itself, but not
157 wrt another tasklets. If client needs some intertask synchronization,
158 he makes it with spinlocks.
159 */
161 struct tasklet_struct
162 {
163 struct tasklet_struct *next;
164 unsigned long state;
165 atomic_t count;
166 void (*func)(unsigned long);
167 unsigned long data;
168 };
170 #define DECLARE_TASKLET(name, func, data) \
171 struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(0), func, data }
173 #define DECLARE_TASKLET_DISABLED(name, func, data) \
174 struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(1), func, data }
177 enum
178 {
179 TASKLET_STATE_SCHED, /* Tasklet is scheduled for execution */
180 TASKLET_STATE_RUN /* Tasklet is running (SMP only) */
181 };
183 #ifdef CONFIG_SMP
184 static inline int tasklet_trylock(struct tasklet_struct *t)
185 {
186 return !test_and_set_bit(TASKLET_STATE_RUN, &(t)->state);
187 }
189 static inline void tasklet_unlock(struct tasklet_struct *t)
190 {
191 smp_mb__before_clear_bit();
192 clear_bit(TASKLET_STATE_RUN, &(t)->state);
193 }
195 static inline void tasklet_unlock_wait(struct tasklet_struct *t)
196 {
197 while (test_bit(TASKLET_STATE_RUN, &(t)->state)) { barrier(); }
198 }
199 #else
200 #define tasklet_trylock(t) 1
201 #define tasklet_unlock_wait(t) do { } while (0)
202 #define tasklet_unlock(t) do { } while (0)
203 #endif
205 extern void FASTCALL(__tasklet_schedule(struct tasklet_struct *t));
207 static inline void tasklet_schedule(struct tasklet_struct *t)
208 {
209 if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
210 __tasklet_schedule(t);
211 }
213 extern void FASTCALL(__tasklet_hi_schedule(struct tasklet_struct *t));
215 static inline void tasklet_hi_schedule(struct tasklet_struct *t)
216 {
217 if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
218 __tasklet_hi_schedule(t);
219 }
222 static inline void tasklet_disable_nosync(struct tasklet_struct *t)
223 {
224 atomic_inc(&t->count);
225 smp_mb__after_atomic_inc();
226 }
228 static inline void tasklet_disable(struct tasklet_struct *t)
229 {
230 tasklet_disable_nosync(t);
231 tasklet_unlock_wait(t);
232 smp_mb();
233 }
235 static inline void tasklet_enable(struct tasklet_struct *t)
236 {
237 smp_mb__before_atomic_dec();
238 atomic_dec(&t->count);
239 }
241 static inline void tasklet_hi_enable(struct tasklet_struct *t)
242 {
243 smp_mb__before_atomic_dec();
244 atomic_dec(&t->count);
245 }
247 extern void tasklet_kill(struct tasklet_struct *t);
248 extern void tasklet_kill_immediate(struct tasklet_struct *t, unsigned int cpu);
249 extern void tasklet_init(struct tasklet_struct *t,
250 void (*func)(unsigned long), unsigned long data);
252 /*
253 * Autoprobing for irqs:
254 *
255 * probe_irq_on() and probe_irq_off() provide robust primitives
256 * for accurate IRQ probing during kernel initialization. They are
257 * reasonably simple to use, are not "fooled" by spurious interrupts,
258 * and, unlike other attempts at IRQ probing, they do not get hung on
259 * stuck interrupts (such as unused PS2 mouse interfaces on ASUS boards).
260 *
261 * For reasonably foolproof probing, use them as follows:
262 *
263 * 1. clear and/or mask the device's internal interrupt.
264 * 2. sti();
265 * 3. irqs = probe_irq_on(); // "take over" all unassigned idle IRQs
266 * 4. enable the device and cause it to trigger an interrupt.
267 * 5. wait for the device to interrupt, using non-intrusive polling or a delay.
268 * 6. irq = probe_irq_off(irqs); // get IRQ number, 0=none, negative=multiple
269 * 7. service the device to clear its pending interrupt.
270 * 8. loop again if paranoia is required.
271 *
272 * probe_irq_on() returns a mask of allocated irq's.
273 *
274 * probe_irq_off() takes the mask as a parameter,
275 * and returns the irq number which occurred,
276 * or zero if none occurred, or a negative irq number
277 * if more than one irq occurred.
278 */
280 #if defined(CONFIG_GENERIC_HARDIRQS) && !defined(CONFIG_GENERIC_IRQ_PROBE)
281 static inline unsigned long probe_irq_on(void)
282 {
283 return 0;
284 }
285 static inline int probe_irq_off(unsigned long val)
286 {
287 return 0;
288 }
289 static inline unsigned int probe_irq_mask(unsigned long val)
290 {
291 return 0;
292 }
293 #else
294 extern unsigned long probe_irq_on(void); /* returns 0 on failure */
295 extern int probe_irq_off(unsigned long); /* returns 0 or negative on failure */
296 extern unsigned int probe_irq_mask(unsigned long); /* returns mask of ISA interrupts */
297 #endif
299 #endif