~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Linux/include/linux/interrupt.h

Version: ~ [ 2.4.0 ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* interrupt.h */
  2 #ifndef _LINUX_INTERRUPT_H
  3 #define _LINUX_INTERRUPT_H
  4 
  5 #include <linux/config.h>
  6 #include <linux/kernel.h>
  7 #include <linux/smp.h>
  8 #include <linux/cache.h>
  9 
 10 #include <asm/bitops.h>
 11 #include <asm/atomic.h>
 12 #include <asm/ptrace.h>
 13 
 14 struct irqaction {
 15         void (*handler)(int, void *, struct pt_regs *);
 16         unsigned long flags;
 17         unsigned long mask;
 18         const char *name;
 19         void *dev_id;
 20         struct irqaction *next;
 21 };
 22 
 23 
 24 /* Who gets which entry in bh_base.  Things which will occur most often
 25    should come first */
 26    
 27 enum {
 28         TIMER_BH = 0,
 29         TQUEUE_BH,
 30         DIGI_BH,
 31         SERIAL_BH,
 32         RISCOM8_BH,
 33         SPECIALIX_BH,
 34         AURORA_BH,
 35         ESP_BH,
 36         SCSI_BH,
 37         IMMEDIATE_BH,
 38         CYCLADES_BH,
 39         CM206_BH,
 40         JS_BH,
 41         MACSERIAL_BH,
 42         ISICOM_BH
 43 };
 44 
 45 #include <asm/hardirq.h>
 46 #include <asm/softirq.h>
 47 
 48 
 49 
 50 /* PLEASE, avoid to allocate new softirqs, if you need not _really_ high
 51    frequency threaded job scheduling. For almost all the purposes
 52    tasklets are more than enough. F.e. all serial device BHs et
 53    al. should be converted to tasklets, not to softirqs.
 54  */
 55 
 56 enum
 57 {
 58         HI_SOFTIRQ=0,
 59         NET_TX_SOFTIRQ,
 60         NET_RX_SOFTIRQ,
 61         TASKLET_SOFTIRQ
 62 };
 63 
 64 /* softirq mask and active fields moved to irq_cpustat_t in
 65  * asm/hardirq.h to get better cache usage.  KAO
 66  */
 67 
 68 struct softirq_action
 69 {
 70         void    (*action)(struct softirq_action *);
 71         void    *data;
 72 };
 73 
 74 asmlinkage void do_softirq(void);
 75 extern void open_softirq(int nr, void (*action)(struct softirq_action*), void *data);
 76 
 77 static inline void __cpu_raise_softirq(int cpu, int nr)
 78 {
 79         softirq_active(cpu) |= (1<<nr);
 80 }
 81 
 82 
 83 /* I do not want to use atomic variables now, so that cli/sti */
 84 static inline void raise_softirq(int nr)
 85 {
 86         unsigned long flags;
 87 
 88         local_irq_save(flags);
 89         __cpu_raise_softirq(smp_processor_id(), nr);
 90         local_irq_restore(flags);
 91 }
 92 
 93 extern void softirq_init(void);
 94 
 95 
 96 
 97 /* Tasklets --- multithreaded analogue of BHs.
 98 
 99    Main feature differing them of generic softirqs: tasklet
100    is running only on one CPU simultaneously.
101 
102    Main feature differing them of BHs: different tasklets
103    may be run simultaneously on different CPUs.
104 
105    Properties:
106    * If tasklet_schedule() is called, then tasklet is guaranteed
107      to be executed on some cpu at least once after this.
108    * If the tasklet is already scheduled, but its excecution is still not
109      started, it will be executed only once.
110    * If this tasklet is already running on another CPU (or schedule is called
111      from tasklet itself), it is rescheduled for later.
112    * Tasklet is strictly serialized wrt itself, but not
113      wrt another tasklets. If client needs some intertask synchronization,
114      he makes it with spinlocks.
115  */
116 
117 struct tasklet_struct
118 {
119         struct tasklet_struct *next;
120         unsigned long state;
121         atomic_t count;
122         void (*func)(unsigned long);
123         unsigned long data;
124 };
125 
126 #define DECLARE_TASKLET(name, func, data) \
127 struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(0), func, data }
128 
129 #define DECLARE_TASKLET_DISABLED(name, func, data) \
130 struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(1), func, data }
131 
132 
133 enum
134 {
135         TASKLET_STATE_SCHED,    /* Tasklet is scheduled for execution */
136         TASKLET_STATE_RUN       /* Tasklet is running (SMP only) */
137 };
138 
139 struct tasklet_head
140 {
141         struct tasklet_struct *list;
142 } __attribute__ ((__aligned__(SMP_CACHE_BYTES)));
143 
144 extern struct tasklet_head tasklet_vec[NR_CPUS];
145 extern struct tasklet_head tasklet_hi_vec[NR_CPUS];
146 
147 #ifdef CONFIG_SMP
148 #define tasklet_trylock(t) (!test_and_set_bit(TASKLET_STATE_RUN, &(t)->state))
149 #define tasklet_unlock_wait(t) while (test_bit(TASKLET_STATE_RUN, &(t)->state)) { /* NOTHING */ }
150 #define tasklet_unlock(t) clear_bit(TASKLET_STATE_RUN, &(t)->state)
151 #else
152 #define tasklet_trylock(t) 1
153 #define tasklet_unlock_wait(t) do { } while (0)
154 #define tasklet_unlock(t) do { } while (0)
155 #endif
156 
157 static inline void tasklet_schedule(struct tasklet_struct *t)
158 {
159         if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state)) {
160                 int cpu = smp_processor_id();
161                 unsigned long flags;
162 
163                 local_irq_save(flags);
164                 t->next = tasklet_vec[cpu].list;
165                 tasklet_vec[cpu].list = t;
166                 __cpu_raise_softirq(cpu, TASKLET_SOFTIRQ);
167                 local_irq_restore(flags);
168         }
169 }
170 
171 static inline void tasklet_hi_schedule(struct tasklet_struct *t)
172 {
173         if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state)) {
174                 int cpu = smp_processor_id();
175                 unsigned long flags;
176 
177                 local_irq_save(flags);
178                 t->next = tasklet_hi_vec[cpu].list;
179                 tasklet_hi_vec[cpu].list = t;
180                 __cpu_raise_softirq(cpu, HI_SOFTIRQ);
181                 local_irq_restore(flags);
182         }
183 }
184 
185 
186 static inline void tasklet_disable_nosync(struct tasklet_struct *t)
187 {
188         atomic_inc(&t->count);
189 }
190 
191 static inline void tasklet_disable(struct tasklet_struct *t)
192 {
193         tasklet_disable_nosync(t);
194         tasklet_unlock_wait(t);
195 }
196 
197 static inline void tasklet_enable(struct tasklet_struct *t)
198 {
199         atomic_dec(&t->count);
200 }
201 
202 extern void tasklet_kill(struct tasklet_struct *t);
203 extern void tasklet_init(struct tasklet_struct *t,
204                          void (*func)(unsigned long), unsigned long data);
205 
206 #ifdef CONFIG_SMP
207 
208 #define SMP_TIMER_NAME(name) name##__thr
209 
210 #define SMP_TIMER_DEFINE(name, task) \
211 DECLARE_TASKLET(task, name##__thr, 0); \
212 static void name (unsigned long dummy) \
213 { \
214         tasklet_schedule(&(task)); \
215 }
216 
217 #else /* CONFIG_SMP */
218 
219 #define SMP_TIMER_NAME(name) name
220 #define SMP_TIMER_DEFINE(name, task)
221 
222 #endif /* CONFIG_SMP */
223 
224 
225 /* Old BH definitions */
226 
227 extern struct tasklet_struct bh_task_vec[];
228 
229 /* It is exported _ONLY_ for wait_on_irq(). */
230 extern spinlock_t global_bh_lock;
231 
232 static inline void mark_bh(int nr)
233 {
234         tasklet_hi_schedule(bh_task_vec+nr);
235 }
236 
237 extern void init_bh(int nr, void (*routine)(void));
238 extern void remove_bh(int nr);
239 
240 
241 /*
242  * Autoprobing for irqs:
243  *
244  * probe_irq_on() and probe_irq_off() provide robust primitives
245  * for accurate IRQ probing during kernel initialization.  They are
246  * reasonably simple to use, are not "fooled" by spurious interrupts,
247  * and, unlike other attempts at IRQ probing, they do not get hung on
248  * stuck interrupts (such as unused PS2 mouse interfaces on ASUS boards).
249  *
250  * For reasonably foolproof probing, use them as follows:
251  *
252  * 1. clear and/or mask the device's internal interrupt.
253  * 2. sti();
254  * 3. irqs = probe_irq_on();      // "take over" all unassigned idle IRQs
255  * 4. enable the device and cause it to trigger an interrupt.
256  * 5. wait for the device to interrupt, using non-intrusive polling or a delay.
257  * 6. irq = probe_irq_off(irqs);  // get IRQ number, 0=none, negative=multiple
258  * 7. service the device to clear its pending interrupt.
259  * 8. loop again if paranoia is required.
260  *
261  * probe_irq_on() returns a mask of allocated irq's.
262  *
263  * probe_irq_off() takes the mask as a parameter,
264  * and returns the irq number which occurred,
265  * or zero if none occurred, or a negative irq number
266  * if more than one irq occurred.
267  */
268 extern unsigned long probe_irq_on(void);        /* returns 0 on failure */
269 extern int probe_irq_off(unsigned long);        /* returns 0 or negative on failure */
270 extern unsigned int probe_irq_mask(unsigned long);      /* returns mask of ISA interrupts */
271 
272 #endif
273 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.