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