2 * arch/ppc/amiga/ints.c
4 * Linux/m68k general interrupt handling code from arch/m68k/kernel/ints.c
5 * Needed to drive the m68k emulating IRQ hardware on the PowerUp boards.
8 #include <linux/types.h>
9 #include <linux/sched.h>
10 #include <linux/kernel_stat.h>
11 #include <linux/errno.h>
12 #include <linux/init.h>
13 #include <linux/seq_file.h>
15 #include <asm/setup.h>
16 #include <asm/system.h>
18 #include <asm/traps.h>
20 #include <asm/machdep.h>
22 /* table for system interrupt handlers */
23 static irq_handler_t irq_list[SYS_IRQS];
25 static const char *default_names[SYS_IRQS] = {
26 "spurious int", "int1 handler", "int2 handler", "int3 handler",
27 "int4 handler", "int5 handler", "int6 handler", "int7 handler"
30 /* The number of spurious interrupts */
31 volatile unsigned int num_spurious;
33 #define NUM_IRQ_NODES 100
34 static irq_node_t nodes[NUM_IRQ_NODES];
44 * This function should be called during kernel startup to initialize
45 * the IRQ handling routines.
49 void m68k_init_IRQ(void)
53 for (i = 0; i < SYS_IRQS; i++) {
54 if (mach_default_handler)
55 irq_list[i].handler = (*mach_default_handler)[i];
56 irq_list[i].flags = 0;
57 irq_list[i].dev_id = NULL;
58 irq_list[i].devname = default_names[i];
61 for (i = 0; i < NUM_IRQ_NODES; i++)
62 nodes[i].handler = NULL;
67 irq_node_t *new_irq_node(void)
72 for (node = nodes, i = NUM_IRQ_NODES-1; i >= 0; node++, i--)
76 printk ("new_irq_node: out of nodes\n");
80 int sys_request_irq(unsigned int irq,
81 void (*handler)(int, void *, struct pt_regs *),
82 unsigned long flags, const char *devname, void *dev_id)
84 if (irq < IRQ1 || irq > IRQ7) {
85 printk("%s: Incorrect IRQ %d from %s\n",
86 __FUNCTION__, irq, devname);
91 if (!(irq_list[irq].flags & IRQ_FLG_STD)) {
92 if (irq_list[irq].flags & IRQ_FLG_LOCK) {
93 printk("%s: IRQ %d from %s is not replaceable\n",
94 __FUNCTION__, irq, irq_list[irq].devname);
97 if (!(flags & IRQ_FLG_REPLACE)) {
98 printk("%s: %s can't replace IRQ %d from %s\n",
99 __FUNCTION__, devname, irq, irq_list[irq].devname);
105 irq_list[irq].handler = handler;
106 irq_list[irq].flags = flags;
107 irq_list[irq].dev_id = dev_id;
108 irq_list[irq].devname = devname;
112 void sys_free_irq(unsigned int irq, void *dev_id)
114 if (irq < IRQ1 || irq > IRQ7) {
115 printk("%s: Incorrect IRQ %d\n", __FUNCTION__, irq);
119 if (irq_list[irq].dev_id != dev_id)
120 printk("%s: Removing probably wrong IRQ %d from %s\n",
121 __FUNCTION__, irq, irq_list[irq].devname);
123 irq_list[irq].handler = (*mach_default_handler)[irq];
124 irq_list[irq].flags = 0;
125 irq_list[irq].dev_id = NULL;
126 irq_list[irq].devname = default_names[irq];
129 asmlinkage void process_int(unsigned long vec, struct pt_regs *fp)
131 if (vec >= VEC_INT1 && vec <= VEC_INT7 && !MACH_IS_BVME6000) {
133 kstat_cpu(0).irqs[vec]++;
134 irq_list[vec].handler(vec, irq_list[vec].dev_id, fp);
136 if (mach_process_int)
137 mach_process_int(vec, fp);
139 panic("Can't process interrupt vector %ld\n", vec);
144 int m68k_get_irq_list(struct seq_file *p, void *v)
148 /* autovector interrupts */
149 if (mach_default_handler) {
150 for (i = 0; i < SYS_IRQS; i++) {
151 seq_printf(p, "auto %2d: %10u ", i,
152 i ? kstat_cpu(0).irqs[i] : num_spurious);
154 seq_printf(p, "%s\n", irq_list[i].devname);
158 mach_get_irq_list(p, v);