| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
 | 2 |  * | 
 | 3 |  *	linux/arch/cris/kernel/irq.c | 
 | 4 |  * | 
| Jesper Nilsson | eb2746d | 2007-11-14 17:00:52 -0800 | [diff] [blame] | 5 |  *      Copyright (c) 2000,2007 Axis Communications AB | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 |  * | 
 | 7 |  *      Authors: Bjorn Wesen (bjornw@axis.com) | 
 | 8 |  * | 
 | 9 |  * This file contains the code used by various IRQ handling routines: | 
| Simon Arlott | 49b4ff3 | 2007-10-20 01:08:50 +0200 | [diff] [blame] | 10 |  * asking for different IRQs should be done through these routines | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 |  */ | 
 | 16 |  | 
 | 17 | /* | 
| Simon Arlott | 49b4ff3 | 2007-10-20 01:08:50 +0200 | [diff] [blame] | 18 |  * IRQs are in fact implemented a bit like signal handlers for the kernel. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 |  * Naturally it's not a 1:1 relation, but there are similarities. | 
 | 20 |  */ | 
 | 21 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | #include <linux/module.h> | 
 | 23 | #include <linux/ptrace.h> | 
| Mikael Starvik | 2e0cea1 | 2005-07-27 11:44:36 -0700 | [diff] [blame] | 24 | #include <linux/irq.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include <linux/random.h> | 
 | 33 | #include <linux/init.h> | 
 | 34 | #include <linux/seq_file.h> | 
 | 35 | #include <linux/errno.h> | 
| Mikael Starvik | 2e0cea1 | 2005-07-27 11:44:36 -0700 | [diff] [blame] | 36 | #include <linux/spinlock.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 |  | 
 | 38 | #include <asm/io.h> | 
 | 39 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | int show_interrupts(struct seq_file *p, void *v) | 
 | 41 | { | 
| Mikael Starvik | 2e0cea1 | 2005-07-27 11:44:36 -0700 | [diff] [blame] | 42 | 	int i = *(loff_t *) v, j; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | 	struct irqaction * action; | 
 | 44 | 	unsigned long flags; | 
 | 45 |  | 
| Mikael Starvik | 2e0cea1 | 2005-07-27 11:44:36 -0700 | [diff] [blame] | 46 | 	if (i == 0) { | 
 | 47 | 		seq_printf(p, "           "); | 
| Andrew Morton | 394e390 | 2006-03-23 03:01:05 -0800 | [diff] [blame] | 48 | 		for_each_online_cpu(j) | 
 | 49 | 			seq_printf(p, "CPU%d       ",j); | 
| Mikael Starvik | 2e0cea1 | 2005-07-27 11:44:36 -0700 | [diff] [blame] | 50 | 		seq_putc(p, '\n'); | 
 | 51 | 	} | 
 | 52 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | 	if (i < NR_IRQS) { | 
| Thomas Gleixner | 239007b | 2009-11-17 16:46:45 +0100 | [diff] [blame] | 54 | 		raw_spin_lock_irqsave(&irq_desc[i].lock, flags); | 
| Mikael Starvik | 2e0cea1 | 2005-07-27 11:44:36 -0700 | [diff] [blame] | 55 | 		action = irq_desc[i].action; | 
 | 56 | 		if (!action) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | 			goto skip; | 
| Mikael Starvik | 2e0cea1 | 2005-07-27 11:44:36 -0700 | [diff] [blame] | 58 | 		seq_printf(p, "%3d: ",i); | 
 | 59 | #ifndef CONFIG_SMP | 
 | 60 | 		seq_printf(p, "%10u ", kstat_irqs(i)); | 
 | 61 | #else | 
| Andrew Morton | 394e390 | 2006-03-23 03:01:05 -0800 | [diff] [blame] | 62 | 		for_each_online_cpu(j) | 
| Yinghai Lu | 0b0f0b1 | 2009-01-11 13:35:56 -0800 | [diff] [blame] | 63 | 			seq_printf(p, "%10u ", kstat_irqs_cpu(i, j)); | 
| Mikael Starvik | 2e0cea1 | 2005-07-27 11:44:36 -0700 | [diff] [blame] | 64 | #endif | 
| Thomas Gleixner | d8fe989 | 2009-11-19 13:13:41 +0100 | [diff] [blame] | 65 | 		seq_printf(p, " %14s", irq_desc[i].chip->name); | 
| Mikael Starvik | 2e0cea1 | 2005-07-27 11:44:36 -0700 | [diff] [blame] | 66 | 		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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | 		seq_putc(p, '\n'); | 
 | 72 | skip: | 
| Thomas Gleixner | 239007b | 2009-11-17 16:46:45 +0100 | [diff] [blame] | 73 | 		raw_spin_unlock_irqrestore(&irq_desc[i].lock, flags); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | 	} | 
 | 75 | 	return 0; | 
 | 76 | } | 
 | 77 |  | 
| Mikael Starvik | 2e0cea1 | 2005-07-27 11:44:36 -0700 | [diff] [blame] | 78 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | /* called by the assembler IRQ entry functions defined in irq.h | 
| Simon Arlott | 49b4ff3 | 2007-10-20 01:08:50 +0200 | [diff] [blame] | 80 |  * to dispatch the interrupts to registered handlers | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 |  * interrupts are disabled upon entry - depending on if the | 
| Simon Arlott | 49b4ff3 | 2007-10-20 01:08:50 +0200 | [diff] [blame] | 82 |  * interrupt was registered with IRQF_DISABLED or not, interrupts | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 |  * are re-enabled or not. | 
 | 84 |  */ | 
 | 85 |  | 
 | 86 | asmlinkage void do_IRQ(int irq, struct pt_regs * regs) | 
 | 87 | { | 
| Mikael Starvik | 2e0cea1 | 2005-07-27 11:44:36 -0700 | [diff] [blame] | 88 | 	unsigned long sp; | 
| Jesper Nilsson | eb2746d | 2007-11-14 17:00:52 -0800 | [diff] [blame] | 89 | 	struct pt_regs *old_regs = set_irq_regs(regs); | 
| Mikael Starvik | 2e0cea1 | 2005-07-27 11:44:36 -0700 | [diff] [blame] | 90 | 	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 | 	} | 
| Jesper Nilsson | eb2746d | 2007-11-14 17:00:52 -0800 | [diff] [blame] | 96 | 	__do_IRQ(irq); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 |         irq_exit(); | 
| Jesper Nilsson | eb2746d | 2007-11-14 17:00:52 -0800 | [diff] [blame] | 98 | 	set_irq_regs(old_regs); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | } | 
 | 100 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | void weird_irq(void) | 
 | 102 | { | 
 | 103 | 	local_irq_disable(); | 
 | 104 | 	printk("weird irq\n"); | 
 | 105 | 	while(1); | 
 | 106 | } | 
 | 107 |  |