OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [LINUX_2_4_26_OR32/] [linux/] [linux-2.4/] [include/] [linux/] [interrupt.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.