2 * Linux/m68k general interrupt handling code from arch/m68k/kernel/ints.c
3 * Needed to drive the m68k emulating IRQ hardware on the PowerUp boards.
6 #include <linux/types.h>
7 #include <linux/sched.h>
8 #include <linux/kernel_stat.h>
9 #include <linux/errno.h>
10 #include <linux/init.h>
11 #include <linux/seq_file.h>
13 #include <asm/setup.h>
14 #include <asm/system.h>
16 #include <asm/traps.h>
18 #include <asm/machdep.h>
20 /* table for system interrupt handlers */
21 static irq_handler_t irq_list[SYS_IRQS];
23 static const char *default_names[SYS_IRQS] = {
24 "spurious int", "int1 handler", "int2 handler", "int3 handler",
25 "int4 handler", "int5 handler", "int6 handler", "int7 handler"
28 /* The number of spurious interrupts */
29 volatile unsigned int num_spurious;
31 #define NUM_IRQ_NODES 100
32 static irq_node_t nodes[NUM_IRQ_NODES];
42 * This function should be called during kernel startup to initialize
43 * the IRQ handling routines.
47 void m68k_init_IRQ(void)
51 for (i = 0; i < SYS_IRQS; i++) {
52 if (mach_default_handler)
53 irq_list[i].handler = (*mach_default_handler)[i];
54 irq_list[i].flags = 0;
55 irq_list[i].dev_id = NULL;
56 irq_list[i].devname = default_names[i];
59 for (i = 0; i < NUM_IRQ_NODES; i++)
60 nodes[i].handler = NULL;
65 irq_node_t *new_irq_node(void)
70 for (node = nodes, i = NUM_IRQ_NODES-1; i >= 0; node++, i--)
74 printk ("new_irq_node: out of nodes\n");
78 int sys_request_irq(unsigned int irq,
79 void (*handler)(int, void *, struct pt_regs *),
80 unsigned long flags, const char *devname, void *dev_id)
82 if (irq < IRQ1 || irq > IRQ7) {
83 printk("%s: Incorrect IRQ %d from %s\n",
84 __FUNCTION__, irq, devname);
89 if (!(irq_list[irq].flags & IRQ_FLG_STD)) {
90 if (irq_list[irq].flags & IRQ_FLG_LOCK) {
91 printk("%s: IRQ %d from %s is not replaceable\n",
92 __FUNCTION__, irq, irq_list[irq].devname);
95 if (!(flags & IRQ_FLG_REPLACE)) {
96 printk("%s: %s can't replace IRQ %d from %s\n",
97 __FUNCTION__, devname, irq, irq_list[irq].devname);
103 irq_list[irq].handler = handler;
104 irq_list[irq].flags = flags;
105 irq_list[irq].dev_id = dev_id;
106 irq_list[irq].devname = devname;
110 void sys_free_irq(unsigned int irq, void *dev_id)
112 if (irq < IRQ1 || irq > IRQ7) {
113 printk("%s: Incorrect IRQ %d\n", __FUNCTION__, irq);
117 if (irq_list[irq].dev_id != dev_id)
118 printk("%s: Removing probably wrong IRQ %d from %s\n",
119 __FUNCTION__, irq, irq_list[irq].devname);
121 irq_list[irq].handler = (*mach_default_handler)[irq];
122 irq_list[irq].flags = 0;
123 irq_list[irq].dev_id = NULL;
124 irq_list[irq].devname = default_names[irq];
127 asmlinkage void process_int(unsigned long vec, struct pt_regs *fp)
129 if (vec >= VEC_INT1 && vec <= VEC_INT7 && !MACH_IS_BVME6000) {
131 kstat_cpu(0).irqs[vec]++;
132 irq_list[vec].handler(vec, irq_list[vec].dev_id, fp);
134 if (mach_process_int)
135 mach_process_int(vec, fp);
137 panic("Can't process interrupt vector %ld\n", vec);
142 int m68k_get_irq_list(struct seq_file *p, void *v)
146 /* autovector interrupts */
147 if (mach_default_handler) {
148 for (i = 0; i < SYS_IRQS; i++) {
149 seq_printf(p, "auto %2d: %10u ", i,
150 i ? kstat_cpu(0).irqs[i] : num_spurious);
152 seq_printf(p, "%s\n", irq_list[i].devname);
156 mach_get_irq_list(p, v);