[PATCH] m68k: adjust to changed HARDIRQ_MASK
[linux-2.6/linux-2.6-openrd.git] / arch / m68k / kernel / ints.c
blob4b85514792e7868917436d2f192760a2ddba1ced
1 /*
2 * linux/arch/m68k/kernel/ints.c -- Linux/m68k general interrupt handling code
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file COPYING in the main directory of this archive
6 * for more details.
8 * 07/03/96: Timer initialization, and thus mach_sched_init(),
9 * removed from request_irq() and moved to init_time().
10 * We should therefore consider renaming our add_isr() and
11 * remove_isr() to request_irq() and free_irq()
12 * respectively, so they are compliant with the other
13 * architectures. /Jes
14 * 11/07/96: Changed all add_/remove_isr() to request_/free_irq() calls.
15 * Removed irq list support, if any machine needs an irq server
16 * it must implement this itself (as it's already done), instead
17 * only default handler are used with mach_default_handler.
18 * request_irq got some flags different from other architectures:
19 * - IRQ_FLG_REPLACE : Replace an existing handler (the default one
20 * can be replaced without this flag)
21 * - IRQ_FLG_LOCK : handler can't be replaced
22 * There are other machine depending flags, see there
23 * If you want to replace a default handler you should know what
24 * you're doing, since it might handle different other irq sources
25 * which must be served /Roman Zippel
28 #include <linux/config.h>
29 #include <linux/module.h>
30 #include <linux/types.h>
31 #include <linux/sched.h>
32 #include <linux/kernel_stat.h>
33 #include <linux/errno.h>
34 #include <linux/init.h>
36 #include <asm/setup.h>
37 #include <asm/system.h>
38 #include <asm/irq.h>
39 #include <asm/traps.h>
40 #include <asm/page.h>
41 #include <asm/machdep.h>
43 #ifdef CONFIG_Q40
44 #include <asm/q40ints.h>
45 #endif
47 /* table for system interrupt handlers */
48 static irq_handler_t irq_list[SYS_IRQS];
50 static const char *default_names[SYS_IRQS] = {
51 [0] = "spurious int",
52 [1] = "int1 handler",
53 [2] = "int2 handler",
54 [3] = "int3 handler",
55 [4] = "int4 handler",
56 [5] = "int5 handler",
57 [6] = "int6 handler",
58 [7] = "int7 handler"
61 /* The number of spurious interrupts */
62 volatile unsigned int num_spurious;
64 #define NUM_IRQ_NODES 100
65 static irq_node_t nodes[NUM_IRQ_NODES];
67 static void dummy_enable_irq(unsigned int irq);
68 static void dummy_disable_irq(unsigned int irq);
69 static int dummy_request_irq(unsigned int irq,
70 irqreturn_t (*handler) (int, void *, struct pt_regs *),
71 unsigned long flags, const char *devname, void *dev_id);
72 static void dummy_free_irq(unsigned int irq, void *dev_id);
74 void (*enable_irq) (unsigned int) = dummy_enable_irq;
75 void (*disable_irq) (unsigned int) = dummy_disable_irq;
77 int (*mach_request_irq) (unsigned int, irqreturn_t (*)(int, void *, struct pt_regs *),
78 unsigned long, const char *, void *) = dummy_request_irq;
79 void (*mach_free_irq) (unsigned int, void *) = dummy_free_irq;
81 void init_irq_proc(void);
84 * void init_IRQ(void)
86 * Parameters: None
88 * Returns: Nothing
90 * This function should be called during kernel startup to initialize
91 * the IRQ handling routines.
94 void __init init_IRQ(void)
96 int i;
98 /* assembly irq entry code relies on this... */
99 if (HARDIRQ_MASK != 0x00ff0000) {
100 extern void hardirq_mask_is_broken(void);
101 hardirq_mask_is_broken();
104 for (i = 0; i < SYS_IRQS; i++) {
105 if (mach_default_handler)
106 irq_list[i].handler = (*mach_default_handler)[i];
107 irq_list[i].flags = 0;
108 irq_list[i].dev_id = NULL;
109 irq_list[i].devname = default_names[i];
112 for (i = 0; i < NUM_IRQ_NODES; i++)
113 nodes[i].handler = NULL;
115 mach_init_IRQ ();
118 irq_node_t *new_irq_node(void)
120 irq_node_t *node;
121 short i;
123 for (node = nodes, i = NUM_IRQ_NODES-1; i >= 0; node++, i--)
124 if (!node->handler)
125 return node;
127 printk ("new_irq_node: out of nodes\n");
128 return NULL;
132 * We will keep these functions until I have convinced Linus to move
133 * the declaration of them from include/linux/sched.h to
134 * include/asm/irq.h.
136 int request_irq(unsigned int irq,
137 irqreturn_t (*handler) (int, void *, struct pt_regs *),
138 unsigned long flags, const char *devname, void *dev_id)
140 return mach_request_irq(irq, handler, flags, devname, dev_id);
143 EXPORT_SYMBOL(request_irq);
145 void free_irq(unsigned int irq, void *dev_id)
147 mach_free_irq(irq, dev_id);
150 EXPORT_SYMBOL(free_irq);
152 int cpu_request_irq(unsigned int irq,
153 irqreturn_t (*handler)(int, void *, struct pt_regs *),
154 unsigned long flags, const char *devname, void *dev_id)
156 if (irq < IRQ1 || irq > IRQ7) {
157 printk("%s: Incorrect IRQ %d from %s\n",
158 __FUNCTION__, irq, devname);
159 return -ENXIO;
162 #if 0
163 if (!(irq_list[irq].flags & IRQ_FLG_STD)) {
164 if (irq_list[irq].flags & IRQ_FLG_LOCK) {
165 printk("%s: IRQ %d from %s is not replaceable\n",
166 __FUNCTION__, irq, irq_list[irq].devname);
167 return -EBUSY;
169 if (!(flags & IRQ_FLG_REPLACE)) {
170 printk("%s: %s can't replace IRQ %d from %s\n",
171 __FUNCTION__, devname, irq, irq_list[irq].devname);
172 return -EBUSY;
175 #endif
177 irq_list[irq].handler = handler;
178 irq_list[irq].flags = flags;
179 irq_list[irq].dev_id = dev_id;
180 irq_list[irq].devname = devname;
181 return 0;
184 void cpu_free_irq(unsigned int irq, void *dev_id)
186 if (irq < IRQ1 || irq > IRQ7) {
187 printk("%s: Incorrect IRQ %d\n", __FUNCTION__, irq);
188 return;
191 if (irq_list[irq].dev_id != dev_id)
192 printk("%s: Removing probably wrong IRQ %d from %s\n",
193 __FUNCTION__, irq, irq_list[irq].devname);
195 irq_list[irq].handler = (*mach_default_handler)[irq];
196 irq_list[irq].flags = 0;
197 irq_list[irq].dev_id = NULL;
198 irq_list[irq].devname = default_names[irq];
202 * Do we need these probe functions on the m68k?
204 * ... may be useful with ISA devices
206 unsigned long probe_irq_on (void)
208 #ifdef CONFIG_Q40
209 if (MACH_IS_Q40)
210 return q40_probe_irq_on();
211 #endif
212 return 0;
215 EXPORT_SYMBOL(probe_irq_on);
217 int probe_irq_off (unsigned long irqs)
219 #ifdef CONFIG_Q40
220 if (MACH_IS_Q40)
221 return q40_probe_irq_off(irqs);
222 #endif
223 return 0;
226 EXPORT_SYMBOL(probe_irq_off);
228 static void dummy_enable_irq(unsigned int irq)
230 printk("calling uninitialized enable_irq()\n");
233 static void dummy_disable_irq(unsigned int irq)
235 printk("calling uninitialized disable_irq()\n");
238 static int dummy_request_irq(unsigned int irq,
239 irqreturn_t (*handler) (int, void *, struct pt_regs *),
240 unsigned long flags, const char *devname, void *dev_id)
242 printk("calling uninitialized request_irq()\n");
243 return 0;
246 static void dummy_free_irq(unsigned int irq, void *dev_id)
248 printk("calling uninitialized disable_irq()\n");
251 asmlinkage void process_int(unsigned long vec, struct pt_regs *fp)
253 if (vec >= VEC_INT1 && vec <= VEC_INT7 && !MACH_IS_BVME6000) {
254 vec -= VEC_SPUR;
255 kstat_cpu(0).irqs[vec]++;
256 irq_list[vec].handler(vec, irq_list[vec].dev_id, fp);
257 } else {
258 if (mach_process_int)
259 mach_process_int(vec, fp);
260 else
261 panic("Can't process interrupt vector %ld\n", vec);
262 return;
266 int show_interrupts(struct seq_file *p, void *v)
268 int i = *(loff_t *) v;
270 /* autovector interrupts */
271 if (i < SYS_IRQS) {
272 if (mach_default_handler) {
273 seq_printf(p, "auto %2d: %10u ", i,
274 i ? kstat_cpu(0).irqs[i] : num_spurious);
275 seq_puts(p, " ");
276 seq_printf(p, "%s\n", irq_list[i].devname);
278 } else if (i == SYS_IRQS)
279 mach_get_irq_list(p, v);
280 return 0;
283 void init_irq_proc(void)
285 /* Insert /proc/irq driver here */