Merge branches 'irq/genirq', 'irq/sparseirq' and 'irq/urgent' into irq/core
[linux-2.6-block.git] / arch / cris / kernel / irq.c
CommitLineData
1da177e4
LT
1/*
2 *
3 * linux/arch/cris/kernel/irq.c
4 *
eb2746dd 5 * Copyright (c) 2000,2007 Axis Communications AB
1da177e4
LT
6 *
7 * Authors: Bjorn Wesen (bjornw@axis.com)
8 *
9 * This file contains the code used by various IRQ handling routines:
49b4ff33 10 * asking for different IRQs should be done through these routines
1da177e4
LT
11 * instead of just grabbing them. Thus setups with different IRQ numbers
12 * shouldn't result in any weird surprises, and installing new handlers
13 * should be easier.
14 *
1da177e4
LT
15 */
16
17/*
49b4ff33 18 * IRQs are in fact implemented a bit like signal handlers for the kernel.
1da177e4
LT
19 * Naturally it's not a 1:1 relation, but there are similarities.
20 */
21
1da177e4
LT
22#include <linux/module.h>
23#include <linux/ptrace.h>
2e0cea1d 24#include <linux/irq.h>
1da177e4
LT
25
26#include <linux/kernel_stat.h>
27#include <linux/signal.h>
28#include <linux/sched.h>
29#include <linux/ioport.h>
30#include <linux/interrupt.h>
31#include <linux/timex.h>
32#include <linux/slab.h>
33#include <linux/random.h>
34#include <linux/init.h>
35#include <linux/seq_file.h>
36#include <linux/errno.h>
2e0cea1d 37#include <linux/spinlock.h>
1da177e4
LT
38
39#include <asm/io.h>
40
2e0cea1d 41void ack_bad_irq(unsigned int irq)
1da177e4 42{
2e0cea1d 43 printk("unexpected IRQ trap at vector %02x\n", irq);
1da177e4
LT
44}
45
1da177e4
LT
46int show_interrupts(struct seq_file *p, void *v)
47{
2e0cea1d 48 int i = *(loff_t *) v, j;
1da177e4
LT
49 struct irqaction * action;
50 unsigned long flags;
51
2e0cea1d
MS
52 if (i == 0) {
53 seq_printf(p, " ");
394e3902
AM
54 for_each_online_cpu(j)
55 seq_printf(p, "CPU%d ",j);
2e0cea1d
MS
56 seq_putc(p, '\n');
57 }
58
1da177e4 59 if (i < NR_IRQS) {
2e0cea1d
MS
60 spin_lock_irqsave(&irq_desc[i].lock, flags);
61 action = irq_desc[i].action;
62 if (!action)
1da177e4 63 goto skip;
2e0cea1d
MS
64 seq_printf(p, "%3d: ",i);
65#ifndef CONFIG_SMP
66 seq_printf(p, "%10u ", kstat_irqs(i));
67#else
394e3902 68 for_each_online_cpu(j)
0b0f0b1c 69 seq_printf(p, "%10u ", kstat_irqs_cpu(i, j));
2e0cea1d 70#endif
d1bef4ed 71 seq_printf(p, " %14s", irq_desc[i].chip->typename);
2e0cea1d
MS
72 seq_printf(p, " %s", action->name);
73
74 for (action=action->next; action; action = action->next)
75 seq_printf(p, ", %s", action->name);
76
1da177e4
LT
77 seq_putc(p, '\n');
78skip:
2e0cea1d 79 spin_unlock_irqrestore(&irq_desc[i].lock, flags);
1da177e4
LT
80 }
81 return 0;
82}
83
2e0cea1d 84
1da177e4 85/* called by the assembler IRQ entry functions defined in irq.h
49b4ff33 86 * to dispatch the interrupts to registered handlers
1da177e4 87 * interrupts are disabled upon entry - depending on if the
49b4ff33 88 * interrupt was registered with IRQF_DISABLED or not, interrupts
1da177e4
LT
89 * are re-enabled or not.
90 */
91
92asmlinkage void do_IRQ(int irq, struct pt_regs * regs)
93{
2e0cea1d 94 unsigned long sp;
eb2746dd 95 struct pt_regs *old_regs = set_irq_regs(regs);
2e0cea1d
MS
96 irq_enter();
97 sp = rdsp();
98 if (unlikely((sp & (PAGE_SIZE - 1)) < (PAGE_SIZE/8))) {
99 printk("do_IRQ: stack overflow: %lX\n", sp);
100 show_stack(NULL, (unsigned long *)sp);
1da177e4 101 }
eb2746dd 102 __do_IRQ(irq);
2e0cea1d 103 irq_exit();
eb2746dd 104 set_irq_regs(old_regs);
1da177e4
LT
105}
106
1da177e4
LT
107void weird_irq(void)
108{
109 local_irq_disable();
110 printk("weird irq\n");
111 while(1);
112}
113