| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * This file is subject to the terms and conditions of the GNU General Public | 
|  | 3 | * License.  See the file "COPYING" in the main directory of this archive | 
|  | 4 | * for more details. | 
|  | 5 | * | 
|  | 6 | * Code to handle x86 style IRQs plus some generic interrupt stuff. | 
|  | 7 | * | 
|  | 8 | * Copyright (C) 1992 Linus Torvalds | 
|  | 9 | * Copyright (C) 1994 - 2000 Ralf Baechle | 
|  | 10 | */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/kernel.h> | 
|  | 12 | #include <linux/delay.h> | 
|  | 13 | #include <linux/init.h> | 
|  | 14 | #include <linux/interrupt.h> | 
|  | 15 | #include <linux/kernel_stat.h> | 
|  | 16 | #include <linux/module.h> | 
|  | 17 | #include <linux/proc_fs.h> | 
|  | 18 | #include <linux/slab.h> | 
|  | 19 | #include <linux/mm.h> | 
|  | 20 | #include <linux/random.h> | 
|  | 21 | #include <linux/sched.h> | 
|  | 22 | #include <linux/seq_file.h> | 
|  | 23 | #include <linux/kallsyms.h> | 
|  | 24 |  | 
|  | 25 | #include <asm/atomic.h> | 
|  | 26 | #include <asm/system.h> | 
|  | 27 | #include <asm/uaccess.h> | 
|  | 28 |  | 
|  | 29 | /* | 
|  | 30 | * 'what should we do if we get a hw irq event on an illegal vector'. | 
|  | 31 | * each architecture has to answer this themselves. | 
|  | 32 | */ | 
|  | 33 | void ack_bad_irq(unsigned int irq) | 
|  | 34 | { | 
|  | 35 | printk("unexpected IRQ # %d\n", irq); | 
|  | 36 | } | 
|  | 37 |  | 
|  | 38 | atomic_t irq_err_count; | 
|  | 39 |  | 
| Ralf Baechle | 41c594a | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 40 | #ifdef CONFIG_MIPS_MT_SMTC | 
|  | 41 | /* | 
|  | 42 | * SMTC Kernel needs to manipulate low-level CPU interrupt mask | 
|  | 43 | * in do_IRQ. These are passed in setup_irq_smtc() and stored | 
|  | 44 | * in this table. | 
|  | 45 | */ | 
|  | 46 | unsigned long irq_hwmask[NR_IRQS]; | 
|  | 47 | #endif /* CONFIG_MIPS_MT_SMTC */ | 
|  | 48 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | #undef do_IRQ | 
|  | 50 |  | 
|  | 51 | /* | 
|  | 52 | * do_IRQ handles all normal device IRQ's (the special | 
|  | 53 | * SMP cross-CPU interrupts have their own specific | 
|  | 54 | * handlers). | 
|  | 55 | */ | 
|  | 56 | asmlinkage unsigned int do_IRQ(unsigned int irq, struct pt_regs *regs) | 
|  | 57 | { | 
|  | 58 | irq_enter(); | 
|  | 59 |  | 
| Ralf Baechle | 41c594a | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 60 | __DO_IRQ_SMTC_HOOK(); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | __do_IRQ(irq, regs); | 
|  | 62 |  | 
|  | 63 | irq_exit(); | 
|  | 64 |  | 
|  | 65 | return 1; | 
|  | 66 | } | 
|  | 67 |  | 
|  | 68 | /* | 
|  | 69 | * Generic, controller-independent functions: | 
|  | 70 | */ | 
|  | 71 |  | 
|  | 72 | int show_interrupts(struct seq_file *p, void *v) | 
|  | 73 | { | 
|  | 74 | int i = *(loff_t *) v, j; | 
|  | 75 | struct irqaction * action; | 
|  | 76 | unsigned long flags; | 
|  | 77 |  | 
|  | 78 | if (i == 0) { | 
|  | 79 | seq_printf(p, "           "); | 
| Andrew Morton | 394e390 | 2006-03-23 03:01:05 -0800 | [diff] [blame] | 80 | for_each_online_cpu(j) | 
|  | 81 | seq_printf(p, "CPU%d       ",j); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | seq_putc(p, '\n'); | 
|  | 83 | } | 
|  | 84 |  | 
|  | 85 | if (i < NR_IRQS) { | 
|  | 86 | spin_lock_irqsave(&irq_desc[i].lock, flags); | 
|  | 87 | action = irq_desc[i].action; | 
| Ralf Baechle | 42a3b4f | 2005-09-03 15:56:17 -0700 | [diff] [blame] | 88 | if (!action) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | goto skip; | 
|  | 90 | seq_printf(p, "%3d: ",i); | 
|  | 91 | #ifndef CONFIG_SMP | 
|  | 92 | seq_printf(p, "%10u ", kstat_irqs(i)); | 
|  | 93 | #else | 
| Andrew Morton | 394e390 | 2006-03-23 03:01:05 -0800 | [diff] [blame] | 94 | for_each_online_cpu(j) | 
|  | 95 | seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | #endif | 
| Ingo Molnar | d1bef4e | 2006-06-29 02:24:36 -0700 | [diff] [blame] | 97 | seq_printf(p, " %14s", irq_desc[i].chip->typename); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | seq_printf(p, "  %s", action->name); | 
|  | 99 |  | 
|  | 100 | for (action=action->next; action; action = action->next) | 
|  | 101 | seq_printf(p, ", %s", action->name); | 
|  | 102 |  | 
|  | 103 | seq_putc(p, '\n'); | 
|  | 104 | skip: | 
|  | 105 | spin_unlock_irqrestore(&irq_desc[i].lock, flags); | 
|  | 106 | } else if (i == NR_IRQS) { | 
|  | 107 | seq_putc(p, '\n'); | 
|  | 108 | seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count)); | 
|  | 109 | } | 
|  | 110 | return 0; | 
|  | 111 | } | 
|  | 112 |  | 
| Ralf Baechle | 93373ed | 2006-04-01 21:17:45 +0100 | [diff] [blame] | 113 | asmlinkage void spurious_interrupt(struct pt_regs *regs) | 
|  | 114 | { | 
|  | 115 | atomic_inc(&irq_err_count); | 
|  | 116 | } | 
|  | 117 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | #ifdef CONFIG_KGDB | 
|  | 119 | extern void breakpoint(void); | 
|  | 120 | extern void set_debug_traps(void); | 
|  | 121 |  | 
|  | 122 | static int kgdb_flag = 1; | 
|  | 123 | static int __init nokgdb(char *str) | 
|  | 124 | { | 
|  | 125 | kgdb_flag = 0; | 
|  | 126 | return 1; | 
|  | 127 | } | 
|  | 128 | __setup("nokgdb", nokgdb); | 
|  | 129 | #endif | 
|  | 130 |  | 
|  | 131 | void __init init_IRQ(void) | 
|  | 132 | { | 
|  | 133 | int i; | 
|  | 134 |  | 
|  | 135 | for (i = 0; i < NR_IRQS; i++) { | 
|  | 136 | irq_desc[i].status  = IRQ_DISABLED; | 
|  | 137 | irq_desc[i].action  = NULL; | 
|  | 138 | irq_desc[i].depth   = 1; | 
| Ralf Baechle | 94dee17 | 2006-07-02 14:41:42 +0100 | [diff] [blame] | 139 | irq_desc[i].chip = &no_irq_chip; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | spin_lock_init(&irq_desc[i].lock); | 
| Ralf Baechle | 41c594a | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 141 | #ifdef CONFIG_MIPS_MT_SMTC | 
|  | 142 | irq_hwmask[i] = 0; | 
|  | 143 | #endif /* CONFIG_MIPS_MT_SMTC */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | } | 
|  | 145 |  | 
|  | 146 | arch_init_irq(); | 
|  | 147 |  | 
|  | 148 | #ifdef CONFIG_KGDB | 
|  | 149 | if (kgdb_flag) { | 
|  | 150 | printk("Wait for gdb client connection ...\n"); | 
|  | 151 | set_debug_traps(); | 
|  | 152 | breakpoint(); | 
|  | 153 | } | 
|  | 154 | #endif | 
|  | 155 | } |