]> bbs.cooldavid.org Git - net-next-2.6.git/blame - arch/mips/kernel/irq.c
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
[net-next-2.6.git] / arch / mips / kernel / irq.c
CommitLineData
1da177e4
LT
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 */
1da177e4
LT
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 */
33void ack_bad_irq(unsigned int irq)
34{
35 printk("unexpected IRQ # %d\n", irq);
36}
37
38atomic_t irq_err_count;
39
41c594ab
RB
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 */
46unsigned long irq_hwmask[NR_IRQS];
47#endif /* CONFIG_MIPS_MT_SMTC */
48
1da177e4
LT
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 */
56asmlinkage unsigned int do_IRQ(unsigned int irq, struct pt_regs *regs)
57{
7d12e780 58 struct pt_regs *old_regs = set_irq_regs(regs);
1da177e4
LT
59 irq_enter();
60
41c594ab 61 __DO_IRQ_SMTC_HOOK();
7d12e780 62 __do_IRQ(irq);
1da177e4
LT
63
64 irq_exit();
65
7d12e780 66 set_irq_regs(old_regs);
1da177e4
LT
67 return 1;
68}
69
70/*
71 * Generic, controller-independent functions:
72 */
73
74int show_interrupts(struct seq_file *p, void *v)
75{
76 int i = *(loff_t *) v, j;
77 struct irqaction * action;
78 unsigned long flags;
79
80 if (i == 0) {
81 seq_printf(p, " ");
394e3902
AM
82 for_each_online_cpu(j)
83 seq_printf(p, "CPU%d ",j);
1da177e4
LT
84 seq_putc(p, '\n');
85 }
86
87 if (i < NR_IRQS) {
88 spin_lock_irqsave(&irq_desc[i].lock, flags);
89 action = irq_desc[i].action;
42a3b4f2 90 if (!action)
1da177e4
LT
91 goto skip;
92 seq_printf(p, "%3d: ",i);
93#ifndef CONFIG_SMP
94 seq_printf(p, "%10u ", kstat_irqs(i));
95#else
394e3902
AM
96 for_each_online_cpu(j)
97 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
1da177e4 98#endif
d1bef4ed 99 seq_printf(p, " %14s", irq_desc[i].chip->typename);
1da177e4
LT
100 seq_printf(p, " %s", action->name);
101
102 for (action=action->next; action; action = action->next)
103 seq_printf(p, ", %s", action->name);
104
105 seq_putc(p, '\n');
106skip:
107 spin_unlock_irqrestore(&irq_desc[i].lock, flags);
108 } else if (i == NR_IRQS) {
109 seq_putc(p, '\n');
110 seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count));
111 }
112 return 0;
113}
114
93373ed4
RB
115asmlinkage void spurious_interrupt(struct pt_regs *regs)
116{
117 atomic_inc(&irq_err_count);
118}
119
1da177e4
LT
120#ifdef CONFIG_KGDB
121extern void breakpoint(void);
122extern void set_debug_traps(void);
123
124static int kgdb_flag = 1;
125static int __init nokgdb(char *str)
126{
127 kgdb_flag = 0;
128 return 1;
129}
130__setup("nokgdb", nokgdb);
131#endif
132
133void __init init_IRQ(void)
134{
135 int i;
136
137 for (i = 0; i < NR_IRQS; i++) {
138 irq_desc[i].status = IRQ_DISABLED;
139 irq_desc[i].action = NULL;
140 irq_desc[i].depth = 1;
94dee171 141 irq_desc[i].chip = &no_irq_chip;
1da177e4 142 spin_lock_init(&irq_desc[i].lock);
41c594ab
RB
143#ifdef CONFIG_MIPS_MT_SMTC
144 irq_hwmask[i] = 0;
145#endif /* CONFIG_MIPS_MT_SMTC */
1da177e4
LT
146 }
147
148 arch_init_irq();
149
150#ifdef CONFIG_KGDB
151 if (kgdb_flag) {
152 printk("Wait for gdb client connection ...\n");
153 set_debug_traps();
154 breakpoint();
155 }
156#endif
157}