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 | */ |
| 11 | #include <linux/config.h> |
| 12 | #include <linux/kernel.h> |
| 13 | #include <linux/delay.h> |
| 14 | #include <linux/init.h> |
| 15 | #include <linux/interrupt.h> |
| 16 | #include <linux/kernel_stat.h> |
| 17 | #include <linux/module.h> |
| 18 | #include <linux/proc_fs.h> |
| 19 | #include <linux/slab.h> |
| 20 | #include <linux/mm.h> |
| 21 | #include <linux/random.h> |
| 22 | #include <linux/sched.h> |
| 23 | #include <linux/seq_file.h> |
| 24 | #include <linux/kallsyms.h> |
| 25 | |
| 26 | #include <asm/atomic.h> |
| 27 | #include <asm/system.h> |
| 28 | #include <asm/uaccess.h> |
| 29 | |
| 30 | /* |
| 31 | * 'what should we do if we get a hw irq event on an illegal vector'. |
| 32 | * each architecture has to answer this themselves. |
| 33 | */ |
| 34 | void ack_bad_irq(unsigned int irq) |
| 35 | { |
| 36 | printk("unexpected IRQ # %d\n", irq); |
| 37 | } |
| 38 | |
| 39 | atomic_t irq_err_count; |
| 40 | |
| 41 | #undef do_IRQ |
| 42 | |
| 43 | /* |
| 44 | * do_IRQ handles all normal device IRQ's (the special |
| 45 | * SMP cross-CPU interrupts have their own specific |
| 46 | * handlers). |
| 47 | */ |
| 48 | asmlinkage unsigned int do_IRQ(unsigned int irq, struct pt_regs *regs) |
| 49 | { |
| 50 | irq_enter(); |
| 51 | |
| 52 | __do_IRQ(irq, regs); |
| 53 | |
| 54 | irq_exit(); |
| 55 | |
| 56 | return 1; |
| 57 | } |
| 58 | |
| 59 | /* |
| 60 | * Generic, controller-independent functions: |
| 61 | */ |
| 62 | |
| 63 | int show_interrupts(struct seq_file *p, void *v) |
| 64 | { |
| 65 | int i = *(loff_t *) v, j; |
| 66 | struct irqaction * action; |
| 67 | unsigned long flags; |
| 68 | |
| 69 | if (i == 0) { |
| 70 | seq_printf(p, " "); |
| 71 | for (j=0; j<NR_CPUS; j++) |
| 72 | if (cpu_online(j)) |
| 73 | seq_printf(p, "CPU%d ",j); |
| 74 | seq_putc(p, '\n'); |
| 75 | } |
| 76 | |
| 77 | if (i < NR_IRQS) { |
| 78 | spin_lock_irqsave(&irq_desc[i].lock, flags); |
| 79 | action = irq_desc[i].action; |
Ralf Baechle | 42a3b4f | 2005-09-03 15:56:17 -0700 | [diff] [blame] | 80 | if (!action) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | goto skip; |
| 82 | seq_printf(p, "%3d: ",i); |
| 83 | #ifndef CONFIG_SMP |
| 84 | seq_printf(p, "%10u ", kstat_irqs(i)); |
| 85 | #else |
| 86 | for (j = 0; j < NR_CPUS; j++) |
| 87 | if (cpu_online(j)) |
| 88 | seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]); |
| 89 | #endif |
| 90 | seq_printf(p, " %14s", irq_desc[i].handler->typename); |
| 91 | seq_printf(p, " %s", action->name); |
| 92 | |
| 93 | for (action=action->next; action; action = action->next) |
| 94 | seq_printf(p, ", %s", action->name); |
| 95 | |
| 96 | seq_putc(p, '\n'); |
| 97 | skip: |
| 98 | spin_unlock_irqrestore(&irq_desc[i].lock, flags); |
| 99 | } else if (i == NR_IRQS) { |
| 100 | seq_putc(p, '\n'); |
| 101 | seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count)); |
| 102 | } |
| 103 | return 0; |
| 104 | } |
| 105 | |
| 106 | #ifdef CONFIG_KGDB |
| 107 | extern void breakpoint(void); |
| 108 | extern void set_debug_traps(void); |
| 109 | |
| 110 | static int kgdb_flag = 1; |
| 111 | static int __init nokgdb(char *str) |
| 112 | { |
| 113 | kgdb_flag = 0; |
| 114 | return 1; |
| 115 | } |
| 116 | __setup("nokgdb", nokgdb); |
| 117 | #endif |
| 118 | |
| 119 | void __init init_IRQ(void) |
| 120 | { |
| 121 | int i; |
| 122 | |
| 123 | for (i = 0; i < NR_IRQS; i++) { |
| 124 | irq_desc[i].status = IRQ_DISABLED; |
| 125 | irq_desc[i].action = NULL; |
| 126 | irq_desc[i].depth = 1; |
| 127 | irq_desc[i].handler = &no_irq_type; |
| 128 | spin_lock_init(&irq_desc[i].lock); |
| 129 | } |
| 130 | |
| 131 | arch_init_irq(); |
| 132 | |
| 133 | #ifdef CONFIG_KGDB |
| 134 | if (kgdb_flag) { |
| 135 | printk("Wait for gdb client connection ...\n"); |
| 136 | set_debug_traps(); |
| 137 | breakpoint(); |
| 138 | } |
| 139 | #endif |
| 140 | } |