Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | */ |
| 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 | |
| 22 | #include <linux/config.h> |
| 23 | #include <linux/module.h> |
| 24 | #include <linux/ptrace.h> |
Mikael Starvik | 2e0cea1 | 2005-07-27 11:44:36 -0700 | [diff] [blame] | 25 | #include <linux/irq.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | |
| 27 | #include <linux/kernel_stat.h> |
| 28 | #include <linux/signal.h> |
| 29 | #include <linux/sched.h> |
| 30 | #include <linux/ioport.h> |
| 31 | #include <linux/interrupt.h> |
| 32 | #include <linux/timex.h> |
| 33 | #include <linux/slab.h> |
| 34 | #include <linux/random.h> |
| 35 | #include <linux/init.h> |
| 36 | #include <linux/seq_file.h> |
| 37 | #include <linux/errno.h> |
Mikael Starvik | 2e0cea1 | 2005-07-27 11:44:36 -0700 | [diff] [blame] | 38 | #include <linux/spinlock.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | |
| 40 | #include <asm/io.h> |
| 41 | |
Mikael Starvik | 2e0cea1 | 2005-07-27 11:44:36 -0700 | [diff] [blame] | 42 | void ack_bad_irq(unsigned int irq) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | { |
Mikael Starvik | 2e0cea1 | 2005-07-27 11:44:36 -0700 | [diff] [blame] | 44 | printk("unexpected IRQ trap at vector %02x\n", irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | } |
| 46 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | int show_interrupts(struct seq_file *p, void *v) |
| 48 | { |
Mikael Starvik | 2e0cea1 | 2005-07-27 11:44:36 -0700 | [diff] [blame] | 49 | int i = *(loff_t *) v, j; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | struct irqaction * action; |
| 51 | unsigned long flags; |
| 52 | |
Mikael Starvik | 2e0cea1 | 2005-07-27 11:44:36 -0700 | [diff] [blame] | 53 | if (i == 0) { |
| 54 | seq_printf(p, " "); |
Andrew Morton | 394e390 | 2006-03-23 03:01:05 -0800 | [diff] [blame] | 55 | for_each_online_cpu(j) |
| 56 | seq_printf(p, "CPU%d ",j); |
Mikael Starvik | 2e0cea1 | 2005-07-27 11:44:36 -0700 | [diff] [blame] | 57 | seq_putc(p, '\n'); |
| 58 | } |
| 59 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | if (i < NR_IRQS) { |
Mikael Starvik | 2e0cea1 | 2005-07-27 11:44:36 -0700 | [diff] [blame] | 61 | spin_lock_irqsave(&irq_desc[i].lock, flags); |
| 62 | action = irq_desc[i].action; |
| 63 | if (!action) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | goto skip; |
Mikael Starvik | 2e0cea1 | 2005-07-27 11:44:36 -0700 | [diff] [blame] | 65 | seq_printf(p, "%3d: ",i); |
| 66 | #ifndef CONFIG_SMP |
| 67 | seq_printf(p, "%10u ", kstat_irqs(i)); |
| 68 | #else |
Andrew Morton | 394e390 | 2006-03-23 03:01:05 -0800 | [diff] [blame] | 69 | for_each_online_cpu(j) |
| 70 | seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]); |
Mikael Starvik | 2e0cea1 | 2005-07-27 11:44:36 -0700 | [diff] [blame] | 71 | #endif |
Ingo Molnar | d1bef4e | 2006-06-29 02:24:36 -0700 | [diff] [blame^] | 72 | seq_printf(p, " %14s", irq_desc[i].chip->typename); |
Mikael Starvik | 2e0cea1 | 2005-07-27 11:44:36 -0700 | [diff] [blame] | 73 | seq_printf(p, " %s", action->name); |
| 74 | |
| 75 | for (action=action->next; action; action = action->next) |
| 76 | seq_printf(p, ", %s", action->name); |
| 77 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | seq_putc(p, '\n'); |
| 79 | skip: |
Mikael Starvik | 2e0cea1 | 2005-07-27 11:44:36 -0700 | [diff] [blame] | 80 | spin_unlock_irqrestore(&irq_desc[i].lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | } |
| 82 | return 0; |
| 83 | } |
| 84 | |
Mikael Starvik | 2e0cea1 | 2005-07-27 11:44:36 -0700 | [diff] [blame] | 85 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | /* called by the assembler IRQ entry functions defined in irq.h |
| 87 | * to dispatch the interrupts to registred handlers |
| 88 | * interrupts are disabled upon entry - depending on if the |
| 89 | * interrupt was registred with SA_INTERRUPT or not, interrupts |
| 90 | * are re-enabled or not. |
| 91 | */ |
| 92 | |
| 93 | asmlinkage void do_IRQ(int irq, struct pt_regs * regs) |
| 94 | { |
Mikael Starvik | 2e0cea1 | 2005-07-27 11:44:36 -0700 | [diff] [blame] | 95 | unsigned long sp; |
| 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); |
| 101 | } |
| 102 | __do_IRQ(irq, regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | irq_exit(); |
| 104 | } |
| 105 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | void weird_irq(void) |
| 107 | { |
| 108 | local_irq_disable(); |
| 109 | printk("weird irq\n"); |
| 110 | while(1); |
| 111 | } |
| 112 | |