blob: b6117b464bed2338d304170b6ad118697eae7f78 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 *
3 * linux/arch/cris/kernel/irq.c
4 *
Jesper Nilssoneb2746d2007-11-14 17:00:52 -08005 * Copyright (c) 2000,2007 Axis Communications AB
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 *
7 * Authors: Bjorn Wesen (bjornw@axis.com)
8 *
9 * This file contains the code used by various IRQ handling routines:
Simon Arlott49b4ff32007-10-20 01:08:50 +020010 * asking for different IRQs should be done through these routines
Linus Torvalds1da177e2005-04-16 15:20:36 -070011 * 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/*
Simon Arlott49b4ff32007-10-20 01:08:50 +020018 * IRQs are in fact implemented a bit like signal handlers for the kernel.
Linus Torvalds1da177e2005-04-16 15:20:36 -070019 * 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 Starvik2e0cea12005-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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include <linux/random.h>
33#include <linux/init.h>
34#include <linux/seq_file.h>
35#include <linux/errno.h>
Mikael Starvik2e0cea12005-07-27 11:44:36 -070036#include <linux/spinlock.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
38#include <asm/io.h>
39
Linus Torvalds1da177e2005-04-16 15:20:36 -070040int show_interrupts(struct seq_file *p, void *v)
41{
Mikael Starvik2e0cea12005-07-27 11:44:36 -070042 int i = *(loff_t *) v, j;
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 struct irqaction * action;
44 unsigned long flags;
45
Mikael Starvik2e0cea12005-07-27 11:44:36 -070046 if (i == 0) {
47 seq_printf(p, " ");
Andrew Morton394e3902006-03-23 03:01:05 -080048 for_each_online_cpu(j)
49 seq_printf(p, "CPU%d ",j);
Mikael Starvik2e0cea12005-07-27 11:44:36 -070050 seq_putc(p, '\n');
51 }
52
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 if (i < NR_IRQS) {
Thomas Gleixner239007b2009-11-17 16:46:45 +010054 raw_spin_lock_irqsave(&irq_desc[i].lock, flags);
Mikael Starvik2e0cea12005-07-27 11:44:36 -070055 action = irq_desc[i].action;
56 if (!action)
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 goto skip;
Mikael Starvik2e0cea12005-07-27 11:44:36 -070058 seq_printf(p, "%3d: ",i);
59#ifndef CONFIG_SMP
60 seq_printf(p, "%10u ", kstat_irqs(i));
61#else
Andrew Morton394e3902006-03-23 03:01:05 -080062 for_each_online_cpu(j)
Yinghai Lu0b0f0b12009-01-11 13:35:56 -080063 seq_printf(p, "%10u ", kstat_irqs_cpu(i, j));
Mikael Starvik2e0cea12005-07-27 11:44:36 -070064#endif
Thomas Gleixnerd8fe9892009-11-19 13:13:41 +010065 seq_printf(p, " %14s", irq_desc[i].chip->name);
Mikael Starvik2e0cea12005-07-27 11:44:36 -070066 seq_printf(p, " %s", action->name);
67
68 for (action=action->next; action; action = action->next)
69 seq_printf(p, ", %s", action->name);
70
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 seq_putc(p, '\n');
72skip:
Thomas Gleixner239007b2009-11-17 16:46:45 +010073 raw_spin_unlock_irqrestore(&irq_desc[i].lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 }
75 return 0;
76}
77
Mikael Starvik2e0cea12005-07-27 11:44:36 -070078
Linus Torvalds1da177e2005-04-16 15:20:36 -070079/* called by the assembler IRQ entry functions defined in irq.h
Simon Arlott49b4ff32007-10-20 01:08:50 +020080 * to dispatch the interrupts to registered handlers
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 * interrupts are disabled upon entry - depending on if the
Simon Arlott49b4ff32007-10-20 01:08:50 +020082 * interrupt was registered with IRQF_DISABLED or not, interrupts
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 * are re-enabled or not.
84 */
85
86asmlinkage void do_IRQ(int irq, struct pt_regs * regs)
87{
Mikael Starvik2e0cea12005-07-27 11:44:36 -070088 unsigned long sp;
Jesper Nilssoneb2746d2007-11-14 17:00:52 -080089 struct pt_regs *old_regs = set_irq_regs(regs);
Mikael Starvik2e0cea12005-07-27 11:44:36 -070090 irq_enter();
91 sp = rdsp();
92 if (unlikely((sp & (PAGE_SIZE - 1)) < (PAGE_SIZE/8))) {
93 printk("do_IRQ: stack overflow: %lX\n", sp);
94 show_stack(NULL, (unsigned long *)sp);
95 }
Thomas Gleixnerc84077a2011-01-19 13:59:01 +010096 generic_handle_irq(irq);
97 irq_exit();
Jesper Nilssoneb2746d2007-11-14 17:00:52 -080098 set_irq_regs(old_regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -070099}
100
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101void weird_irq(void)
102{
103 local_irq_disable();
104 printk("weird irq\n");
105 while(1);
106}
107