blob: 1f9099627a725fa58b7bfd76c6eb134eddc1aaad [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 *
3 * linux/arch/cris/kernel/irq.c
4 *
5 * Copyright (c) 2000,2001 Axis Communications AB
6 *
7 * Authors: Bjorn Wesen (bjornw@axis.com)
8 *
9 * This file contains the code used by various IRQ handling routines:
10 * asking for different IRQ's should be done through these routines
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 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070015 */
16
17/*
18 * IRQ's are in fact implemented a bit like signal handlers for the kernel.
19 * Naturally it's not a 1:1 relation, but there are similarities.
20 */
21
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#include <linux/module.h>
23#include <linux/ptrace.h>
Mikael Starvik2e0cea1d2005-07-27 11:44:36 -070024#include <linux/irq.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
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>
Mikael Starvik2e0cea1d2005-07-27 11:44:36 -070037#include <linux/spinlock.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39#include <asm/io.h>
40
Mikael Starvik2e0cea1d2005-07-27 11:44:36 -070041void ack_bad_irq(unsigned int irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -070042{
Mikael Starvik2e0cea1d2005-07-27 11:44:36 -070043 printk("unexpected IRQ trap at vector %02x\n", irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070044}
45
Linus Torvalds1da177e2005-04-16 15:20:36 -070046int show_interrupts(struct seq_file *p, void *v)
47{
Mikael Starvik2e0cea1d2005-07-27 11:44:36 -070048 int i = *(loff_t *) v, j;
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 struct irqaction * action;
50 unsigned long flags;
51
Mikael Starvik2e0cea1d2005-07-27 11:44:36 -070052 if (i == 0) {
53 seq_printf(p, " ");
Andrew Morton394e3902006-03-23 03:01:05 -080054 for_each_online_cpu(j)
55 seq_printf(p, "CPU%d ",j);
Mikael Starvik2e0cea1d2005-07-27 11:44:36 -070056 seq_putc(p, '\n');
57 }
58
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 if (i < NR_IRQS) {
Mikael Starvik2e0cea1d2005-07-27 11:44:36 -070060 spin_lock_irqsave(&irq_desc[i].lock, flags);
61 action = irq_desc[i].action;
62 if (!action)
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 goto skip;
Mikael Starvik2e0cea1d2005-07-27 11:44:36 -070064 seq_printf(p, "%3d: ",i);
65#ifndef CONFIG_SMP
66 seq_printf(p, "%10u ", kstat_irqs(i));
67#else
Andrew Morton394e3902006-03-23 03:01:05 -080068 for_each_online_cpu(j)
69 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
Mikael Starvik2e0cea1d2005-07-27 11:44:36 -070070#endif
Ingo Molnard1bef4e2006-06-29 02:24:36 -070071 seq_printf(p, " %14s", irq_desc[i].chip->typename);
Mikael Starvik2e0cea1d2005-07-27 11:44:36 -070072 seq_printf(p, " %s", action->name);
73
74 for (action=action->next; action; action = action->next)
75 seq_printf(p, ", %s", action->name);
76
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 seq_putc(p, '\n');
78skip:
Mikael Starvik2e0cea1d2005-07-27 11:44:36 -070079 spin_unlock_irqrestore(&irq_desc[i].lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 }
81 return 0;
82}
83
Mikael Starvik2e0cea1d2005-07-27 11:44:36 -070084
Linus Torvalds1da177e2005-04-16 15:20:36 -070085/* called by the assembler IRQ entry functions defined in irq.h
86 * to dispatch the interrupts to registred handlers
87 * interrupts are disabled upon entry - depending on if the
88 * interrupt was registred with SA_INTERRUPT or not, interrupts
89 * are re-enabled or not.
90 */
91
92asmlinkage void do_IRQ(int irq, struct pt_regs * regs)
93{
Mikael Starvik2e0cea1d2005-07-27 11:44:36 -070094 unsigned long sp;
95 irq_enter();
96 sp = rdsp();
97 if (unlikely((sp & (PAGE_SIZE - 1)) < (PAGE_SIZE/8))) {
98 printk("do_IRQ: stack overflow: %lX\n", sp);
99 show_stack(NULL, (unsigned long *)sp);
100 }
101 __do_IRQ(irq, regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 irq_exit();
103}
104
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105void weird_irq(void)
106{
107 local_irq_disable();
108 printk("weird irq\n");
109 while(1);
110}
111