blob: 5c9dcd5eed59e7cf3459381990e873346d329d5a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 */
34void ack_bad_irq(unsigned int irq)
35{
36 printk("unexpected IRQ # %d\n", irq);
37}
38
39atomic_t irq_err_count;
40
Ralf Baechle41c594a2006-04-05 09:45:45 +010041#ifdef CONFIG_MIPS_MT_SMTC
42/*
43 * SMTC Kernel needs to manipulate low-level CPU interrupt mask
44 * in do_IRQ. These are passed in setup_irq_smtc() and stored
45 * in this table.
46 */
47unsigned long irq_hwmask[NR_IRQS];
48#endif /* CONFIG_MIPS_MT_SMTC */
49
Linus Torvalds1da177e2005-04-16 15:20:36 -070050#undef do_IRQ
51
52/*
53 * do_IRQ handles all normal device IRQ's (the special
54 * SMP cross-CPU interrupts have their own specific
55 * handlers).
56 */
57asmlinkage unsigned int do_IRQ(unsigned int irq, struct pt_regs *regs)
58{
59 irq_enter();
60
Ralf Baechle41c594a2006-04-05 09:45:45 +010061 __DO_IRQ_SMTC_HOOK();
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 __do_IRQ(irq, regs);
63
64 irq_exit();
65
66 return 1;
67}
68
69/*
70 * Generic, controller-independent functions:
71 */
72
73int show_interrupts(struct seq_file *p, void *v)
74{
75 int i = *(loff_t *) v, j;
76 struct irqaction * action;
77 unsigned long flags;
78
79 if (i == 0) {
80 seq_printf(p, " ");
Andrew Morton394e3902006-03-23 03:01:05 -080081 for_each_online_cpu(j)
82 seq_printf(p, "CPU%d ",j);
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 seq_putc(p, '\n');
84 }
85
86 if (i < NR_IRQS) {
87 spin_lock_irqsave(&irq_desc[i].lock, flags);
88 action = irq_desc[i].action;
Ralf Baechle42a3b4f2005-09-03 15:56:17 -070089 if (!action)
Linus Torvalds1da177e2005-04-16 15:20:36 -070090 goto skip;
91 seq_printf(p, "%3d: ",i);
92#ifndef CONFIG_SMP
93 seq_printf(p, "%10u ", kstat_irqs(i));
94#else
Andrew Morton394e3902006-03-23 03:01:05 -080095 for_each_online_cpu(j)
96 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -070097#endif
Ingo Molnard1bef4e2006-06-29 02:24:36 -070098 seq_printf(p, " %14s", irq_desc[i].chip->typename);
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 seq_printf(p, " %s", action->name);
100
101 for (action=action->next; action; action = action->next)
102 seq_printf(p, ", %s", action->name);
103
104 seq_putc(p, '\n');
105skip:
106 spin_unlock_irqrestore(&irq_desc[i].lock, flags);
107 } else if (i == NR_IRQS) {
108 seq_putc(p, '\n');
109 seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count));
110 }
111 return 0;
112}
113
Ralf Baechle93373ed2006-04-01 21:17:45 +0100114asmlinkage void spurious_interrupt(struct pt_regs *regs)
115{
116 atomic_inc(&irq_err_count);
117}
118
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119#ifdef CONFIG_KGDB
120extern void breakpoint(void);
121extern void set_debug_traps(void);
122
123static int kgdb_flag = 1;
124static int __init nokgdb(char *str)
125{
126 kgdb_flag = 0;
127 return 1;
128}
129__setup("nokgdb", nokgdb);
130#endif
131
132void __init init_IRQ(void)
133{
134 int i;
135
136 for (i = 0; i < NR_IRQS; i++) {
137 irq_desc[i].status = IRQ_DISABLED;
138 irq_desc[i].action = NULL;
139 irq_desc[i].depth = 1;
Ingo Molnard1bef4e2006-06-29 02:24:36 -0700140 irq_desc[i].chip = &no_irq_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 spin_lock_init(&irq_desc[i].lock);
Ralf Baechle41c594a2006-04-05 09:45:45 +0100142#ifdef CONFIG_MIPS_MT_SMTC
143 irq_hwmask[i] = 0;
144#endif /* CONFIG_MIPS_MT_SMTC */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145 }
146
147 arch_init_irq();
148
149#ifdef CONFIG_KGDB
150 if (kgdb_flag) {
151 printk("Wait for gdb client connection ...\n");
152 set_debug_traps();
153 breakpoint();
154 }
155#endif
156}