Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* $Id: irq.c,v 1.20 2004/01/13 05:52:11 kkojima Exp $ |
| 2 | * |
| 3 | * linux/arch/sh/kernel/irq.c |
| 4 | * |
| 5 | * Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar |
| 6 | * |
| 7 | * |
| 8 | * SuperH version: Copyright (C) 1999 Niibe Yutaka |
| 9 | */ |
| 10 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/irq.h> |
Paul Mundt | bf3a00f | 2006-01-16 22:14:14 -0800 | [diff] [blame] | 12 | #include <linux/interrupt.h> |
| 13 | #include <linux/kernel_stat.h> |
| 14 | #include <linux/seq_file.h> |
| 15 | #include <asm/irq.h> |
| 16 | #include <asm/processor.h> |
| 17 | #include <asm/cpu/mmu_context.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | |
| 19 | /* |
| 20 | * 'what should we do if we get a hw irq event on an illegal vector'. |
| 21 | * each architecture has to answer this themselves, it doesn't deserve |
| 22 | * a generic callback i think. |
| 23 | */ |
| 24 | void ack_bad_irq(unsigned int irq) |
| 25 | { |
| 26 | printk("unexpected IRQ trap at vector %02x\n", irq); |
| 27 | } |
| 28 | |
| 29 | #if defined(CONFIG_PROC_FS) |
| 30 | int show_interrupts(struct seq_file *p, void *v) |
| 31 | { |
| 32 | int i = *(loff_t *) v, j; |
| 33 | struct irqaction * action; |
| 34 | unsigned long flags; |
| 35 | |
| 36 | if (i == 0) { |
| 37 | seq_puts(p, " "); |
Andrew Morton | 394e390 | 2006-03-23 03:01:05 -0800 | [diff] [blame] | 38 | for_each_online_cpu(j) |
| 39 | seq_printf(p, "CPU%d ",j); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | seq_putc(p, '\n'); |
| 41 | } |
| 42 | |
Paul Mundt | bf3a00f | 2006-01-16 22:14:14 -0800 | [diff] [blame] | 43 | if (i < NR_IRQS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | spin_lock_irqsave(&irq_desc[i].lock, flags); |
| 45 | action = irq_desc[i].action; |
| 46 | if (!action) |
| 47 | goto unlock; |
| 48 | seq_printf(p, "%3d: ",i); |
| 49 | seq_printf(p, "%10u ", kstat_irqs(i)); |
Ingo Molnar | d1bef4e | 2006-06-29 02:24:36 -0700 | [diff] [blame] | 50 | seq_printf(p, " %14s", irq_desc[i].chip->typename); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | seq_printf(p, " %s", action->name); |
| 52 | |
| 53 | for (action=action->next; action; action = action->next) |
| 54 | seq_printf(p, ", %s", action->name); |
| 55 | seq_putc(p, '\n'); |
| 56 | unlock: |
| 57 | spin_unlock_irqrestore(&irq_desc[i].lock, flags); |
| 58 | } |
| 59 | return 0; |
| 60 | } |
| 61 | #endif |
| 62 | |
| 63 | asmlinkage int do_IRQ(unsigned long r4, unsigned long r5, |
| 64 | unsigned long r6, unsigned long r7, |
| 65 | struct pt_regs regs) |
Paul Mundt | bf3a00f | 2006-01-16 22:14:14 -0800 | [diff] [blame] | 66 | { |
| 67 | int irq = r4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | |
| 69 | irq_enter(); |
Paul Mundt | bf3a00f | 2006-01-16 22:14:14 -0800 | [diff] [blame] | 70 | |
Paul Mundt | d153ea8 | 2006-09-27 18:20:16 +0900 | [diff] [blame] | 71 | #ifdef CONFIG_DEBUG_STACKOVERFLOW |
| 72 | /* Debugging check for stack overflow: is there less than 1KB free? */ |
| 73 | { |
| 74 | long sp; |
| 75 | |
| 76 | __asm__ __volatile__ ("and r15, %0" : |
| 77 | "=r" (sp) : "0" (THREAD_SIZE - 1)); |
| 78 | |
| 79 | if (unlikely(sp < (sizeof(struct thread_info) + STACK_WARN))) { |
| 80 | printk("do_IRQ: stack overflow: %ld\n", |
| 81 | sp - sizeof(struct thread_info)); |
| 82 | dump_stack(); |
| 83 | } |
| 84 | } |
| 85 | #endif |
| 86 | |
Paul Mundt | bf3a00f | 2006-01-16 22:14:14 -0800 | [diff] [blame] | 87 | #ifdef CONFIG_CPU_HAS_INTEVT |
| 88 | __asm__ __volatile__ ( |
| 89 | #ifdef CONFIG_CPU_HAS_SR_RB |
| 90 | "stc r2_bank, %0\n\t" |
| 91 | #else |
| 92 | "mov.l @%1, %0\n\t" |
| 93 | #endif |
| 94 | "shlr2 %0\n\t" |
| 95 | "shlr2 %0\n\t" |
| 96 | "shlr %0\n\t" |
| 97 | "add #-16, %0\n\t" |
| 98 | : "=z" (irq), "=r" (r4) |
| 99 | : "1" (INTEVT) |
| 100 | : "memory" |
| 101 | ); |
| 102 | #endif |
| 103 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | irq = irq_demux(irq); |
| 105 | __do_IRQ(irq, ®s); |
| 106 | irq_exit(); |
| 107 | return 1; |
| 108 | } |