irq.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. /*
  11. * IRQs are in fact implemented a bit like signal handlers for the kernel.
  12. * Naturally it's not a 1:1 relation, but there are similarities.
  13. */
  14. #include <linux/config.h>
  15. #include <linux/module.h>
  16. #include <linux/ptrace.h>
  17. #include <linux/errno.h>
  18. #include <linux/kernel_stat.h>
  19. #include <linux/signal.h>
  20. #include <linux/sched.h>
  21. #include <linux/ioport.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/timex.h>
  24. #include <linux/mm.h>
  25. #include <linux/slab.h>
  26. #include <linux/random.h>
  27. #include <linux/smp.h>
  28. #include <linux/smp_lock.h>
  29. #include <linux/init.h>
  30. #include <linux/seq_file.h>
  31. #include <linux/kallsyms.h>
  32. #include <linux/bitops.h>
  33. #include <asm/system.h>
  34. #include <asm/io.h>
  35. #include <asm/pgalloc.h>
  36. #include <asm/delay.h>
  37. #include <asm/irq.h>
  38. #include <linux/irq.h>
  39. /*
  40. * 'what should we do if we get a hw irq event on an illegal vector'.
  41. * each architecture has to answer this themselves, it doesn't deserve
  42. * a generic callback i think.
  43. */
  44. void ack_bad_irq(unsigned int irq)
  45. {
  46. printk("unexpected IRQ trap at vector %02x\n", irq);
  47. }
  48. #if defined(CONFIG_PROC_FS)
  49. int show_interrupts(struct seq_file *p, void *v)
  50. {
  51. int i = *(loff_t *) v, j;
  52. struct irqaction * action;
  53. unsigned long flags;
  54. if (i == 0) {
  55. seq_puts(p, " ");
  56. for (j=0; j<NR_CPUS; j++)
  57. if (cpu_online(j))
  58. seq_printf(p, "CPU%d ",j);
  59. seq_putc(p, '\n');
  60. }
  61. if (i < ACTUAL_NR_IRQS) {
  62. spin_lock_irqsave(&irq_desc[i].lock, flags);
  63. action = irq_desc[i].action;
  64. if (!action)
  65. goto unlock;
  66. seq_printf(p, "%3d: ",i);
  67. seq_printf(p, "%10u ", kstat_irqs(i));
  68. seq_printf(p, " %14s", irq_desc[i].handler->typename);
  69. seq_printf(p, " %s", action->name);
  70. for (action=action->next; action; action = action->next)
  71. seq_printf(p, ", %s", action->name);
  72. seq_putc(p, '\n');
  73. unlock:
  74. spin_unlock_irqrestore(&irq_desc[i].lock, flags);
  75. }
  76. return 0;
  77. }
  78. #endif
  79. asmlinkage int do_IRQ(unsigned long r4, unsigned long r5,
  80. unsigned long r6, unsigned long r7,
  81. struct pt_regs regs)
  82. {
  83. int irq;
  84. irq_enter();
  85. asm volatile("stc r2_bank, %0\n\t"
  86. "shlr2 %0\n\t"
  87. "shlr2 %0\n\t"
  88. "shlr %0\n\t"
  89. "add #-16, %0\n\t"
  90. :"=z" (irq));
  91. irq = irq_demux(irq);
  92. __do_IRQ(irq, &regs);
  93. irq_exit();
  94. return 1;
  95. }