| 1 | /* interrupt.h */
|
|---|
| 2 | #ifndef _LINUX_INTERRUPT_H
|
|---|
| 3 | #define _LINUX_INTERRUPT_H
|
|---|
| 4 |
|
|---|
| 5 | #include <linux/kernel.h>
|
|---|
| 6 | //#include <asm/bitops.h>
|
|---|
| 7 | #include <asm/atomic.h>
|
|---|
| 8 |
|
|---|
| 9 | /*
|
|---|
| 10 | * For 2.4.x compatibility, 2.4.x can use
|
|---|
| 11 | *
|
|---|
| 12 | * typedef void irqreturn_t;
|
|---|
| 13 | * #define IRQ_NONE
|
|---|
| 14 | * #define IRQ_HANDLED
|
|---|
| 15 | * #define IRQ_RETVAL(x)
|
|---|
| 16 | *
|
|---|
| 17 | * To mix old-style and new-style irq handler returns.
|
|---|
| 18 | *
|
|---|
| 19 | * IRQ_NONE means we didn't handle it.
|
|---|
| 20 | * IRQ_HANDLED means that we did have a valid interrupt and handled it.
|
|---|
| 21 | * IRQ_RETVAL(x) selects on the two depending on x being non-zero (for handled)
|
|---|
| 22 | */
|
|---|
| 23 | typedef int irqreturn_t;
|
|---|
| 24 |
|
|---|
| 25 | #define IRQ_NONE (0)
|
|---|
| 26 | #define IRQ_HANDLED (1)
|
|---|
| 27 | #define IRQ_RETVAL(x) ((x) != 0)
|
|---|
| 28 |
|
|---|
| 29 | #include <linux/signal.h>
|
|---|
| 30 | #define IRQF_SHARED SA_SHIRQ
|
|---|
| 31 | #define IRQF_DISABLED SA_INTERRUPT
|
|---|
| 32 | #define IRQF_SAMPLE_RANDOM SA_SAMPLE_RANDOM
|
|---|
| 33 | #define IRQF_PERCPU SA_PERCPU
|
|---|
| 34 | #ifdef SA_PROBEIRQ
|
|---|
| 35 | #define IRQF_PROBE_SHARED SA_PROBEIRQ
|
|---|
| 36 | #else
|
|---|
| 37 | #define IRQF_PROBE_SHARED 0 /* dummy */
|
|---|
| 38 | #endif
|
|---|
| 39 |
|
|---|
| 40 | struct irqaction {
|
|---|
| 41 | void (*handler)(int, void *, struct pt_regs *);
|
|---|
| 42 | unsigned long flags;
|
|---|
| 43 | unsigned long mask;
|
|---|
| 44 | const char *name;
|
|---|
| 45 | void *dev_id;
|
|---|
| 46 | struct irqaction *next;
|
|---|
| 47 | };
|
|---|
| 48 |
|
|---|
| 49 | extern volatile unsigned char bh_running;
|
|---|
| 50 |
|
|---|
| 51 | extern atomic_t bh_mask_count[32];
|
|---|
| 52 | extern unsigned long bh_active;
|
|---|
| 53 | extern unsigned long bh_mask;
|
|---|
| 54 | extern void (*bh_base[32])(void);
|
|---|
| 55 |
|
|---|
| 56 | void do_bottom_half(void);
|
|---|
| 57 |
|
|---|
| 58 | /* Who gets which entry in bh_base. Things which will occur most often
|
|---|
| 59 | should come first - in which case NET should be up the top with SERIAL/TQUEUE! */
|
|---|
| 60 |
|
|---|
| 61 | enum {
|
|---|
| 62 | TIMER_BH = 0,
|
|---|
| 63 | CONSOLE_BH,
|
|---|
| 64 | TQUEUE_BH,
|
|---|
| 65 | DIGI_BH,
|
|---|
| 66 | SERIAL_BH,
|
|---|
| 67 | RISCOM8_BH,
|
|---|
| 68 | SPECIALIX_BH,
|
|---|
| 69 | AURORA_BH,
|
|---|
| 70 | ESP_BH,
|
|---|
| 71 | NET_BH,
|
|---|
| 72 | SCSI_BH,
|
|---|
| 73 | IMMEDIATE_BH,
|
|---|
| 74 | KEYBOARD_BH,
|
|---|
| 75 | CYCLADES_BH,
|
|---|
| 76 | CM206_BH,
|
|---|
| 77 | JS_BH,
|
|---|
| 78 | MACSERIAL_BH,
|
|---|
| 79 | ISICOM_BH
|
|---|
| 80 | };
|
|---|
| 81 | /* Tasklets --- multithreaded analogue of BHs.
|
|---|
| 82 |
|
|---|
| 83 | Main feature differing them of generic softirqs: tasklet
|
|---|
| 84 | is running only on one CPU simultaneously.
|
|---|
| 85 |
|
|---|
| 86 | Main feature differing them of BHs: different tasklets
|
|---|
| 87 | may be run simultaneously on different CPUs.
|
|---|
| 88 |
|
|---|
| 89 | Properties:
|
|---|
| 90 | * If tasklet_schedule() is called, then tasklet is guaranteed
|
|---|
| 91 | to be executed on some cpu at least once after this.
|
|---|
| 92 | * If the tasklet is already scheduled, but its excecution is still not
|
|---|
| 93 | started, it will be executed only once.
|
|---|
| 94 | * If this tasklet is already running on another CPU (or schedule is called
|
|---|
| 95 | from tasklet itself), it is rescheduled for later.
|
|---|
| 96 | * Tasklet is strictly serialized wrt itself, but not
|
|---|
| 97 | wrt another tasklets. If client needs some intertask synchronization,
|
|---|
| 98 | he makes it with spinlocks.
|
|---|
| 99 | */
|
|---|
| 100 |
|
|---|
| 101 | struct tasklet_struct {
|
|---|
| 102 | struct tasklet_struct *next; /* linked list of active bh's */
|
|---|
| 103 | unsigned long sync; /* must be initialized to zero */
|
|---|
| 104 | void (*func)(void *); /* function to call */
|
|---|
| 105 | void *data; /* argument to function */
|
|---|
| 106 | };
|
|---|
| 107 |
|
|---|
| 108 | extern void tasklet_hi_schedule(struct tasklet_struct *t);
|
|---|
| 109 |
|
|---|
| 110 | #define tasklet_schedule tasklet_hi_schedule
|
|---|
| 111 |
|
|---|
| 112 | extern void tasklet_init(struct tasklet_struct *t,
|
|---|
| 113 | void (*func)(unsigned long), unsigned long data);
|
|---|
| 114 |
|
|---|
| 115 | /*
|
|---|
| 116 | * Autoprobing for irqs:
|
|---|
| 117 | *
|
|---|
| 118 | * probe_irq_on() and probe_irq_off() provide robust primitives
|
|---|
| 119 | * for accurate IRQ probing during kernel initialization. They are
|
|---|
| 120 | * reasonably simple to use, are not "fooled" by spurious interrupts,
|
|---|
| 121 | * and, unlike other attempts at IRQ probing, they do not get hung on
|
|---|
| 122 | * stuck interrupts (such as unused PS2 mouse interfaces on ASUS boards).
|
|---|
| 123 | *
|
|---|
| 124 | * For reasonably foolproof probing, use them as follows:
|
|---|
| 125 | *
|
|---|
| 126 | * 1. clear and/or mask the device's internal interrupt.
|
|---|
| 127 | * 2. sti();
|
|---|
| 128 | * 3. irqs = probe_irq_on(); // "take over" all unassigned idle IRQs
|
|---|
| 129 | * 4. enable the device and cause it to trigger an interrupt.
|
|---|
| 130 | * 5. wait for the device to interrupt, using non-intrusive polling or a delay.
|
|---|
| 131 | * 6. irq = probe_irq_off(irqs); // get IRQ number, 0=none, negative=multiple
|
|---|
| 132 | * 7. service the device to clear its pending interrupt.
|
|---|
| 133 | * 8. loop again if paranoia is required.
|
|---|
| 134 | *
|
|---|
| 135 | * probe_irq_on() returns a mask of allocated irq's.
|
|---|
| 136 | *
|
|---|
| 137 | * probe_irq_off() takes the mask as a parameter,
|
|---|
| 138 | * and returns the irq number which occurred,
|
|---|
| 139 | * or zero if none occurred, or a negative irq number
|
|---|
| 140 | * if more than one irq occurred.
|
|---|
| 141 | */
|
|---|
| 142 | extern unsigned long probe_irq_on(void); /* returns 0 on failure */
|
|---|
| 143 | extern int probe_irq_off(unsigned long); /* returns 0 or negative on failure */
|
|---|
| 144 |
|
|---|
| 145 | typedef irqreturn_t (*snd_irq_handler_t)(int, void *);
|
|---|
| 146 | #define irq_handler_t snd_irq_handler_t
|
|---|
| 147 | #undef irq_handler_t
|
|---|
| 148 | #define irq_handler_t snd_irq_handler_t
|
|---|
| 149 |
|
|---|
| 150 | int request_irq(unsigned int, irq_handler_t handler,
|
|---|
| 151 | unsigned long, const char *, void *);
|
|---|
| 152 |
|
|---|
| 153 | #endif
|
|---|