Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | /* * linux/arch/m68k/kernel/ints.c -- Linux/m68k general interrupt handling code * * This file is subject to the terms and conditions of the GNU General Public * License. See the file COPYING in the main directory of this archive * for more details. * * 07/03/96: Timer initialization, and thus mach_sched_init(), * removed from request_irq() and moved to init_time(). * We should therefore consider renaming our add_isr() and * remove_isr() to request_irq() and free_irq() * respectively, so they are compliant with the other * architectures. /Jes * 11/07/96: Changed all add_/remove_isr() to request_/free_irq() calls. * Removed irq list support, if any machine needs an irq server * it must implement this itself (as it's already done), instead * only default handler are used with mach_default_handler. * request_irq got some flags different from other architectures: * - IRQ_FLG_REPLACE : Replace an existing handler (the default one * can be replaced without this flag) * - IRQ_FLG_LOCK : handler can't be replaced * There are other machine depending flags, see there * If you want to replace a default handler you should know what * you're doing, since it might handle different other irq sources * which must be served /Roman Zippel */ #include <linux/types.h> #include <linux/sched.h> #include <linux/kernel_stat.h> #include <linux/errno.h> #include <linux/init.h> #include <asm/system.h> #include <asm/irq.h> #include <asm/traps.h> #include <asm/page.h> #include <asm/machdep.h> /* table for system interrupt handlers */ static irq_handler_t irq_list[SYS_IRQS]; static const char *default_names[SYS_IRQS] = { "spurious int", "int1 handler", "int2 handler", "int3 handler", "int4 handler", "int5 handler", "int6 handler", "int7 handler" }; /* The number of spurious interrupts */ volatile unsigned int num_spurious; #define NUM_IRQ_NODES 100 static irq_node_t nodes[NUM_IRQ_NODES]; unsigned int local_irq_count[NR_CPUS]; int __m68k_bh_counter; static void dummy_enable_irq(unsigned int irq); static void dummy_disable_irq(unsigned int irq); static int dummy_request_irq(unsigned int irq, void (*handler) (int, void *, struct pt_regs *), unsigned long flags, const char *devname, void *dev_id); static void dummy_free_irq(unsigned int irq, void *dev_id); void (*enable_irq) (unsigned int) = dummy_enable_irq; void (*disable_irq) (unsigned int) = dummy_disable_irq; int (*mach_request_irq) (unsigned int, void (*)(int, void *, struct pt_regs *), unsigned long, const char *, void *) = dummy_request_irq; void (*mach_free_irq) (unsigned int, void *) = dummy_free_irq; /* * void init_IRQ(void) * * Parameters: None * * Returns: Nothing * * This function should be called during kernel startup to initialize * the IRQ handling routines. */ __initfunc(void init_IRQ(void)) { int i; for (i = 0; i < SYS_IRQS; i++) { if (mach_default_handler) irq_list[i].handler = (*mach_default_handler)[i]; irq_list[i].flags = IRQ_FLG_STD; irq_list[i].dev_id = NULL; irq_list[i].devname = default_names[i]; } for (i = 0; i < NUM_IRQ_NODES; i++) nodes[i].handler = NULL; mach_init_IRQ (); } irq_node_t *new_irq_node(void) { irq_node_t *node; short i; for (node = nodes, i = NUM_IRQ_NODES-1; i >= 0; node++, i--) if (!node->handler) return node; printk ("new_irq_node: out of nodes\n"); return NULL; } /* * We will keep these functions until I have convinced Linus to move * the declaration of them from include/linux/sched.h to * include/asm/irq.h. */ int request_irq(unsigned int irq, void (*handler) (int, void *, struct pt_regs *), unsigned long flags, const char *devname, void *dev_id) { return mach_request_irq(irq, handler, flags, devname, dev_id); } void free_irq(unsigned int irq, void *dev_id) { mach_free_irq(irq, dev_id); } int sys_request_irq(unsigned int irq, void (*handler)(int, void *, struct pt_regs *), unsigned long flags, const char *devname, void *dev_id) { if (irq < IRQ1 || irq > IRQ7) { printk("%s: Incorrect IRQ %d from %s\n", __FUNCTION__, irq, devname); return -ENXIO; } if (!(irq_list[irq].flags & IRQ_FLG_STD)) { if (irq_list[irq].flags & IRQ_FLG_LOCK) { printk("%s: IRQ %d from %s is not replaceable\n", __FUNCTION__, irq, irq_list[irq].devname); return -EBUSY; } if (!(flags & IRQ_FLG_REPLACE)) { printk("%s: %s can't replace IRQ %d from %s\n", __FUNCTION__, devname, irq, irq_list[irq].devname); return -EBUSY; } } irq_list[irq].handler = handler; irq_list[irq].flags = flags; irq_list[irq].dev_id = dev_id; irq_list[irq].devname = devname; return 0; } void sys_free_irq(unsigned int irq, void *dev_id) { if (irq < IRQ1 || irq > IRQ7) { printk("%s: Incorrect IRQ %d\n", __FUNCTION__, irq); return; } if (irq_list[irq].dev_id != dev_id) printk("%s: Removing probably wrong IRQ %d from %s\n", __FUNCTION__, irq, irq_list[irq].devname); irq_list[irq].handler = (*mach_default_handler)[irq]; irq_list[irq].flags = IRQ_FLG_STD; irq_list[irq].dev_id = NULL; irq_list[irq].devname = default_names[irq]; } /* * Do we need these probe functions on the m68k? */ unsigned long probe_irq_on (void) { return 0; } int probe_irq_off (unsigned long irqs) { return 0; } static void dummy_enable_irq(unsigned int irq) { printk("calling uninitialized enable_irq()\n"); } static void dummy_disable_irq(unsigned int irq) { printk("calling uninitialized disable_irq()\n"); } static int dummy_request_irq(unsigned int irq, void (*handler) (int, void *, struct pt_regs *), unsigned long flags, const char *devname, void *dev_id) { printk("calling uninitialized request_irq()\n"); return 0; } static void dummy_free_irq(unsigned int irq, void *dev_id) { printk("calling uninitialized disable_irq()\n"); } asmlinkage void process_int(unsigned long vec, struct pt_regs *fp) { if (vec >= VEC_INT1 && vec <= VEC_INT7) { vec -= VEC_SPUR; kstat.interrupts[vec]++; irq_list[vec].handler(vec, irq_list[vec].dev_id, fp); } else { if (mach_process_int) mach_process_int(vec, fp); else panic("Can't process interrupt vector %ld\n", vec); return; } } int get_irq_list(char *buf) { int i, len = 0; /* autovector interrupts */ if (mach_default_handler) { for (i = 0; i < SYS_IRQS; i++) { len += sprintf(buf+len, "auto %2d: %10u ", i, i ? kstat.interrupts[i] : num_spurious); if (irq_list[i].flags & IRQ_FLG_LOCK) len += sprintf(buf+len, "L "); else len += sprintf(buf+len, " "); len += sprintf(buf+len, "%s\n", irq_list[i].devname); } } len += mach_get_irq_list(buf+len); return len; } |