/* interrupt.h */
|
/* interrupt.h */
|
#ifndef _LINUX_INTERRUPT_H
|
#ifndef _LINUX_INTERRUPT_H
|
#define _LINUX_INTERRUPT_H
|
#define _LINUX_INTERRUPT_H
|
|
|
#include <linux/config.h>
|
#include <linux/config.h>
|
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
#include <linux/smp.h>
|
#include <linux/smp.h>
|
#include <linux/cache.h>
|
#include <linux/cache.h>
|
|
|
#include <asm/bitops.h>
|
#include <asm/bitops.h>
|
#include <asm/atomic.h>
|
#include <asm/atomic.h>
|
#include <asm/ptrace.h>
|
#include <asm/ptrace.h>
|
#include <asm/system.h>
|
#include <asm/system.h>
|
|
|
/* For 2.6.x compatibility */
|
/* For 2.6.x compatibility */
|
typedef void irqreturn_t;
|
typedef void irqreturn_t;
|
#define IRQ_NONE
|
#define IRQ_NONE
|
#define IRQ_HANDLED
|
#define IRQ_HANDLED
|
#define IRQ_RETVAL(x)
|
#define IRQ_RETVAL(x)
|
|
|
struct irqaction {
|
struct irqaction {
|
void (*handler)(int, void *, struct pt_regs *);
|
void (*handler)(int, void *, struct pt_regs *);
|
unsigned long flags;
|
unsigned long flags;
|
unsigned long mask;
|
unsigned long mask;
|
const char *name;
|
const char *name;
|
void *dev_id;
|
void *dev_id;
|
struct irqaction *next;
|
struct irqaction *next;
|
};
|
};
|
|
|
|
|
/* Who gets which entry in bh_base. Things which will occur most often
|
/* Who gets which entry in bh_base. Things which will occur most often
|
should come first */
|
should come first */
|
|
|
enum {
|
enum {
|
TIMER_BH = 0,
|
TIMER_BH = 0,
|
TQUEUE_BH,
|
TQUEUE_BH,
|
DIGI_BH,
|
DIGI_BH,
|
SERIAL_BH,
|
SERIAL_BH,
|
RISCOM8_BH,
|
RISCOM8_BH,
|
SPECIALIX_BH,
|
SPECIALIX_BH,
|
AURORA_BH,
|
AURORA_BH,
|
ESP_BH,
|
ESP_BH,
|
SCSI_BH,
|
SCSI_BH,
|
IMMEDIATE_BH,
|
IMMEDIATE_BH,
|
CYCLADES_BH,
|
CYCLADES_BH,
|
CM206_BH,
|
CM206_BH,
|
JS_BH,
|
JS_BH,
|
MACSERIAL_BH,
|
MACSERIAL_BH,
|
ISICOM_BH
|
ISICOM_BH
|
};
|
};
|
|
|
#include <asm/hardirq.h>
|
#include <asm/hardirq.h>
|
#include <asm/softirq.h>
|
#include <asm/softirq.h>
|
|
|
|
|
|
|
/* PLEASE, avoid to allocate new softirqs, if you need not _really_ high
|
/* PLEASE, avoid to allocate new softirqs, if you need not _really_ high
|
frequency threaded job scheduling. For almost all the purposes
|
frequency threaded job scheduling. For almost all the purposes
|
tasklets are more than enough. F.e. all serial device BHs et
|
tasklets are more than enough. F.e. all serial device BHs et
|
al. should be converted to tasklets, not to softirqs.
|
al. should be converted to tasklets, not to softirqs.
|
*/
|
*/
|
|
|
enum
|
enum
|
{
|
{
|
HI_SOFTIRQ=0,
|
HI_SOFTIRQ=0,
|
NET_TX_SOFTIRQ,
|
NET_TX_SOFTIRQ,
|
NET_RX_SOFTIRQ,
|
NET_RX_SOFTIRQ,
|
TASKLET_SOFTIRQ
|
TASKLET_SOFTIRQ
|
};
|
};
|
|
|
/* softirq mask and active fields moved to irq_cpustat_t in
|
/* softirq mask and active fields moved to irq_cpustat_t in
|
* asm/hardirq.h to get better cache usage. KAO
|
* asm/hardirq.h to get better cache usage. KAO
|
*/
|
*/
|
|
|
struct softirq_action
|
struct softirq_action
|
{
|
{
|
void (*action)(struct softirq_action *);
|
void (*action)(struct softirq_action *);
|
void *data;
|
void *data;
|
};
|
};
|
|
|
asmlinkage void do_softirq(void);
|
asmlinkage void do_softirq(void);
|
extern void open_softirq(int nr, void (*action)(struct softirq_action*), void *data);
|
extern void open_softirq(int nr, void (*action)(struct softirq_action*), void *data);
|
extern void softirq_init(void);
|
extern void softirq_init(void);
|
#define __cpu_raise_softirq(cpu, nr) do { softirq_pending(cpu) |= 1UL << (nr); } while (0)
|
#define __cpu_raise_softirq(cpu, nr) do { softirq_pending(cpu) |= 1UL << (nr); } while (0)
|
extern void FASTCALL(cpu_raise_softirq(unsigned int cpu, unsigned int nr));
|
extern void FASTCALL(cpu_raise_softirq(unsigned int cpu, unsigned int nr));
|
extern void FASTCALL(raise_softirq(unsigned int nr));
|
extern void FASTCALL(raise_softirq(unsigned int nr));
|
|
|
|
|
|
|
/* Tasklets --- multithreaded analogue of BHs.
|
/* Tasklets --- multithreaded analogue of BHs.
|
|
|
Main feature differing them of generic softirqs: tasklet
|
Main feature differing them of generic softirqs: tasklet
|
is running only on one CPU simultaneously.
|
is running only on one CPU simultaneously.
|
|
|
Main feature differing them of BHs: different tasklets
|
Main feature differing them of BHs: different tasklets
|
may be run simultaneously on different CPUs.
|
may be run simultaneously on different CPUs.
|
|
|
Properties:
|
Properties:
|
* If tasklet_schedule() is called, then tasklet is guaranteed
|
* If tasklet_schedule() is called, then tasklet is guaranteed
|
to be executed on some cpu at least once after this.
|
to be executed on some cpu at least once after this.
|
* If the tasklet is already scheduled, but its excecution is still not
|
* If the tasklet is already scheduled, but its excecution is still not
|
started, it will be executed only once.
|
started, it will be executed only once.
|
* If this tasklet is already running on another CPU (or schedule is called
|
* If this tasklet is already running on another CPU (or schedule is called
|
from tasklet itself), it is rescheduled for later.
|
from tasklet itself), it is rescheduled for later.
|
* Tasklet is strictly serialized wrt itself, but not
|
* Tasklet is strictly serialized wrt itself, but not
|
wrt another tasklets. If client needs some intertask synchronization,
|
wrt another tasklets. If client needs some intertask synchronization,
|
he makes it with spinlocks.
|
he makes it with spinlocks.
|
*/
|
*/
|
|
|
struct tasklet_struct
|
struct tasklet_struct
|
{
|
{
|
struct tasklet_struct *next;
|
struct tasklet_struct *next;
|
unsigned long state;
|
unsigned long state;
|
atomic_t count;
|
atomic_t count;
|
void (*func)(unsigned long);
|
void (*func)(unsigned long);
|
unsigned long data;
|
unsigned long data;
|
};
|
};
|
|
|
#define DECLARE_TASKLET(name, func, data) \
|
#define DECLARE_TASKLET(name, func, data) \
|
struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(0), func, data }
|
struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(0), func, data }
|
|
|
#define DECLARE_TASKLET_DISABLED(name, func, data) \
|
#define DECLARE_TASKLET_DISABLED(name, func, data) \
|
struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(1), func, data }
|
struct tasklet_struct name = { NULL, 0, ATOMIC_INIT(1), func, data }
|
|
|
|
|
enum
|
enum
|
{
|
{
|
TASKLET_STATE_SCHED, /* Tasklet is scheduled for execution */
|
TASKLET_STATE_SCHED, /* Tasklet is scheduled for execution */
|
TASKLET_STATE_RUN /* Tasklet is running (SMP only) */
|
TASKLET_STATE_RUN /* Tasklet is running (SMP only) */
|
};
|
};
|
|
|
struct tasklet_head
|
struct tasklet_head
|
{
|
{
|
struct tasklet_struct *list;
|
struct tasklet_struct *list;
|
} __attribute__ ((__aligned__(SMP_CACHE_BYTES)));
|
} __attribute__ ((__aligned__(SMP_CACHE_BYTES)));
|
|
|
extern struct tasklet_head tasklet_vec[NR_CPUS];
|
extern struct tasklet_head tasklet_vec[NR_CPUS];
|
extern struct tasklet_head tasklet_hi_vec[NR_CPUS];
|
extern struct tasklet_head tasklet_hi_vec[NR_CPUS];
|
|
|
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
static inline int tasklet_trylock(struct tasklet_struct *t)
|
static inline int tasklet_trylock(struct tasklet_struct *t)
|
{
|
{
|
return !test_and_set_bit(TASKLET_STATE_RUN, &(t)->state);
|
return !test_and_set_bit(TASKLET_STATE_RUN, &(t)->state);
|
}
|
}
|
|
|
static inline void tasklet_unlock(struct tasklet_struct *t)
|
static inline void tasklet_unlock(struct tasklet_struct *t)
|
{
|
{
|
smp_mb__before_clear_bit();
|
smp_mb__before_clear_bit();
|
clear_bit(TASKLET_STATE_RUN, &(t)->state);
|
clear_bit(TASKLET_STATE_RUN, &(t)->state);
|
}
|
}
|
|
|
static inline void tasklet_unlock_wait(struct tasklet_struct *t)
|
static inline void tasklet_unlock_wait(struct tasklet_struct *t)
|
{
|
{
|
while (test_bit(TASKLET_STATE_RUN, &(t)->state)) { barrier(); }
|
while (test_bit(TASKLET_STATE_RUN, &(t)->state)) { barrier(); }
|
}
|
}
|
#else
|
#else
|
#define tasklet_trylock(t) 1
|
#define tasklet_trylock(t) 1
|
#define tasklet_unlock_wait(t) do { } while (0)
|
#define tasklet_unlock_wait(t) do { } while (0)
|
#define tasklet_unlock(t) do { } while (0)
|
#define tasklet_unlock(t) do { } while (0)
|
#endif
|
#endif
|
|
|
extern void FASTCALL(__tasklet_schedule(struct tasklet_struct *t));
|
extern void FASTCALL(__tasklet_schedule(struct tasklet_struct *t));
|
|
|
static inline void tasklet_schedule(struct tasklet_struct *t)
|
static inline void tasklet_schedule(struct tasklet_struct *t)
|
{
|
{
|
if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
|
if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
|
__tasklet_schedule(t);
|
__tasklet_schedule(t);
|
}
|
}
|
|
|
extern void FASTCALL(__tasklet_hi_schedule(struct tasklet_struct *t));
|
extern void FASTCALL(__tasklet_hi_schedule(struct tasklet_struct *t));
|
|
|
static inline void tasklet_hi_schedule(struct tasklet_struct *t)
|
static inline void tasklet_hi_schedule(struct tasklet_struct *t)
|
{
|
{
|
if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
|
if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
|
__tasklet_hi_schedule(t);
|
__tasklet_hi_schedule(t);
|
}
|
}
|
|
|
|
|
static inline void tasklet_disable_nosync(struct tasklet_struct *t)
|
static inline void tasklet_disable_nosync(struct tasklet_struct *t)
|
{
|
{
|
atomic_inc(&t->count);
|
atomic_inc(&t->count);
|
smp_mb__after_atomic_inc();
|
smp_mb__after_atomic_inc();
|
}
|
}
|
|
|
static inline void tasklet_disable(struct tasklet_struct *t)
|
static inline void tasklet_disable(struct tasklet_struct *t)
|
{
|
{
|
tasklet_disable_nosync(t);
|
tasklet_disable_nosync(t);
|
tasklet_unlock_wait(t);
|
tasklet_unlock_wait(t);
|
smp_mb();
|
smp_mb();
|
}
|
}
|
|
|
static inline void tasklet_enable(struct tasklet_struct *t)
|
static inline void tasklet_enable(struct tasklet_struct *t)
|
{
|
{
|
smp_mb__before_atomic_dec();
|
smp_mb__before_atomic_dec();
|
atomic_dec(&t->count);
|
atomic_dec(&t->count);
|
}
|
}
|
|
|
static inline void tasklet_hi_enable(struct tasklet_struct *t)
|
static inline void tasklet_hi_enable(struct tasklet_struct *t)
|
{
|
{
|
smp_mb__before_atomic_dec();
|
smp_mb__before_atomic_dec();
|
atomic_dec(&t->count);
|
atomic_dec(&t->count);
|
}
|
}
|
|
|
extern void tasklet_kill(struct tasklet_struct *t);
|
extern void tasklet_kill(struct tasklet_struct *t);
|
extern void tasklet_init(struct tasklet_struct *t,
|
extern void tasklet_init(struct tasklet_struct *t,
|
void (*func)(unsigned long), unsigned long data);
|
void (*func)(unsigned long), unsigned long data);
|
|
|
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
|
|
#define SMP_TIMER_NAME(name) name##__thr
|
#define SMP_TIMER_NAME(name) name##__thr
|
|
|
#define SMP_TIMER_DEFINE(name, task) \
|
#define SMP_TIMER_DEFINE(name, task) \
|
DECLARE_TASKLET(task, name##__thr, 0); \
|
DECLARE_TASKLET(task, name##__thr, 0); \
|
static void name (unsigned long dummy) \
|
static void name (unsigned long dummy) \
|
{ \
|
{ \
|
tasklet_schedule(&(task)); \
|
tasklet_schedule(&(task)); \
|
}
|
}
|
|
|
#else /* CONFIG_SMP */
|
#else /* CONFIG_SMP */
|
|
|
#define SMP_TIMER_NAME(name) name
|
#define SMP_TIMER_NAME(name) name
|
#define SMP_TIMER_DEFINE(name, task)
|
#define SMP_TIMER_DEFINE(name, task)
|
|
|
#endif /* CONFIG_SMP */
|
#endif /* CONFIG_SMP */
|
|
|
|
|
/* Old BH definitions */
|
/* Old BH definitions */
|
|
|
extern struct tasklet_struct bh_task_vec[];
|
extern struct tasklet_struct bh_task_vec[];
|
|
|
/* It is exported _ONLY_ for wait_on_irq(). */
|
/* It is exported _ONLY_ for wait_on_irq(). */
|
extern spinlock_t global_bh_lock;
|
extern spinlock_t global_bh_lock;
|
|
|
static inline void mark_bh(int nr)
|
static inline void mark_bh(int nr)
|
{
|
{
|
tasklet_hi_schedule(bh_task_vec+nr);
|
tasklet_hi_schedule(bh_task_vec+nr);
|
}
|
}
|
|
|
extern void init_bh(int nr, void (*routine)(void));
|
extern void init_bh(int nr, void (*routine)(void));
|
extern void remove_bh(int nr);
|
extern void remove_bh(int nr);
|
|
|
|
|
/*
|
/*
|
* Autoprobing for irqs:
|
* Autoprobing for irqs:
|
*
|
*
|
* probe_irq_on() and probe_irq_off() provide robust primitives
|
* probe_irq_on() and probe_irq_off() provide robust primitives
|
* for accurate IRQ probing during kernel initialization. They are
|
* for accurate IRQ probing during kernel initialization. They are
|
* reasonably simple to use, are not "fooled" by spurious interrupts,
|
* reasonably simple to use, are not "fooled" by spurious interrupts,
|
* and, unlike other attempts at IRQ probing, they do not get hung on
|
* and, unlike other attempts at IRQ probing, they do not get hung on
|
* stuck interrupts (such as unused PS2 mouse interfaces on ASUS boards).
|
* stuck interrupts (such as unused PS2 mouse interfaces on ASUS boards).
|
*
|
*
|
* For reasonably foolproof probing, use them as follows:
|
* For reasonably foolproof probing, use them as follows:
|
*
|
*
|
* 1. clear and/or mask the device's internal interrupt.
|
* 1. clear and/or mask the device's internal interrupt.
|
* 2. sti();
|
* 2. sti();
|
* 3. irqs = probe_irq_on(); // "take over" all unassigned idle IRQs
|
* 3. irqs = probe_irq_on(); // "take over" all unassigned idle IRQs
|
* 4. enable the device and cause it to trigger an interrupt.
|
* 4. enable the device and cause it to trigger an interrupt.
|
* 5. wait for the device to interrupt, using non-intrusive polling or a delay.
|
* 5. wait for the device to interrupt, using non-intrusive polling or a delay.
|
* 6. irq = probe_irq_off(irqs); // get IRQ number, 0=none, negative=multiple
|
* 6. irq = probe_irq_off(irqs); // get IRQ number, 0=none, negative=multiple
|
* 7. service the device to clear its pending interrupt.
|
* 7. service the device to clear its pending interrupt.
|
* 8. loop again if paranoia is required.
|
* 8. loop again if paranoia is required.
|
*
|
*
|
* probe_irq_on() returns a mask of allocated irq's.
|
* probe_irq_on() returns a mask of allocated irq's.
|
*
|
*
|
* probe_irq_off() takes the mask as a parameter,
|
* probe_irq_off() takes the mask as a parameter,
|
* and returns the irq number which occurred,
|
* and returns the irq number which occurred,
|
* or zero if none occurred, or a negative irq number
|
* or zero if none occurred, or a negative irq number
|
* if more than one irq occurred.
|
* if more than one irq occurred.
|
*/
|
*/
|
extern unsigned long probe_irq_on(void); /* returns 0 on failure */
|
extern unsigned long probe_irq_on(void); /* returns 0 on failure */
|
extern int probe_irq_off(unsigned long); /* returns 0 or negative on failure */
|
extern int probe_irq_off(unsigned long); /* returns 0 or negative on failure */
|
extern unsigned int probe_irq_mask(unsigned long); /* returns mask of ISA interrupts */
|
extern unsigned int probe_irq_mask(unsigned long); /* returns mask of ISA interrupts */
|
|
|
#endif
|
#endif
|
|
|