irq.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * arch/sh64/kernel/irq.c
  7. *
  8. * Copyright (C) 2000, 2001 Paolo Alberelli
  9. * Copyright (C) 2003 Paul Mundt
  10. *
  11. */
  12. /*
  13. * IRQs are in fact implemented a bit like signal handlers for the kernel.
  14. * Naturally it's not a 1:1 relation, but there are similarities.
  15. */
  16. #include <linux/errno.h>
  17. #include <linux/kernel_stat.h>
  18. #include <linux/signal.h>
  19. #include <linux/rwsem.h>
  20. #include <linux/sched.h>
  21. #include <linux/ioport.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/timex.h>
  24. #include <linux/slab.h>
  25. #include <linux/random.h>
  26. #include <linux/smp.h>
  27. #include <linux/init.h>
  28. #include <linux/seq_file.h>
  29. #include <linux/bitops.h>
  30. #include <asm/system.h>
  31. #include <asm/io.h>
  32. #include <asm/smp.h>
  33. #include <asm/pgalloc.h>
  34. #include <asm/delay.h>
  35. #include <asm/irq.h>
  36. #include <linux/irq.h>
  37. void ack_bad_irq(unsigned int irq)
  38. {
  39. printk("unexpected IRQ trap at irq %02x\n", irq);
  40. }
  41. #if defined(CONFIG_PROC_FS)
  42. int show_interrupts(struct seq_file *p, void *v)
  43. {
  44. int i = *(loff_t *) v, j;
  45. struct irqaction * action;
  46. unsigned long flags;
  47. if (i == 0) {
  48. seq_puts(p, " ");
  49. for_each_online_cpu(j)
  50. seq_printf(p, "CPU%d ",j);
  51. seq_putc(p, '\n');
  52. }
  53. if (i < NR_IRQS) {
  54. spin_lock_irqsave(&irq_desc[i].lock, flags);
  55. action = irq_desc[i].action;
  56. if (!action)
  57. goto unlock;
  58. seq_printf(p, "%3d: ",i);
  59. seq_printf(p, "%10u ", kstat_irqs(i));
  60. seq_printf(p, " %14s", irq_desc[i].chip->typename);
  61. seq_printf(p, " %s", action->name);
  62. for (action=action->next; action; action = action->next)
  63. seq_printf(p, ", %s", action->name);
  64. seq_putc(p, '\n');
  65. unlock:
  66. spin_unlock_irqrestore(&irq_desc[i].lock, flags);
  67. }
  68. return 0;
  69. }
  70. #endif
  71. /*
  72. * do_NMI handles all Non-Maskable Interrupts.
  73. */
  74. asmlinkage void do_NMI(unsigned long vector_num, struct pt_regs * regs)
  75. {
  76. if (regs->sr & 0x40000000)
  77. printk("unexpected NMI trap in system mode\n");
  78. else
  79. printk("unexpected NMI trap in user mode\n");
  80. /* No statistics */
  81. }
  82. /*
  83. * do_IRQ handles all normal device IRQ's.
  84. */
  85. asmlinkage int do_IRQ(unsigned long vector_num, struct pt_regs * regs)
  86. {
  87. struct pt_regs *old_regs = set_irq_regs(regs);
  88. int irq;
  89. irq_enter();
  90. irq = irq_demux(vector_num);
  91. if (irq >= 0) {
  92. __do_IRQ(irq);
  93. } else {
  94. printk("unexpected IRQ trap at vector %03lx\n", vector_num);
  95. }
  96. irq_exit();
  97. set_irq_regs(old_regs);
  98. return 1;
  99. }