irq.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. * Code to handle x86 style IRQs plus some generic interrupt stuff.
  7. *
  8. * Copyright (C) 1992 Linus Torvalds
  9. * Copyright (C) 1994 - 2000 Ralf Baechle
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/delay.h>
  13. #include <linux/init.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/kernel_stat.h>
  16. #include <linux/module.h>
  17. #include <linux/proc_fs.h>
  18. #include <linux/slab.h>
  19. #include <linux/mm.h>
  20. #include <linux/random.h>
  21. #include <linux/sched.h>
  22. #include <linux/seq_file.h>
  23. #include <linux/kallsyms.h>
  24. #include <asm/atomic.h>
  25. #include <asm/system.h>
  26. #include <asm/uaccess.h>
  27. /*
  28. * 'what should we do if we get a hw irq event on an illegal vector'.
  29. * each architecture has to answer this themselves.
  30. */
  31. void ack_bad_irq(unsigned int irq)
  32. {
  33. printk("unexpected IRQ # %d\n", irq);
  34. }
  35. atomic_t irq_err_count;
  36. #ifdef CONFIG_MIPS_MT_SMTC
  37. /*
  38. * SMTC Kernel needs to manipulate low-level CPU interrupt mask
  39. * in do_IRQ. These are passed in setup_irq_smtc() and stored
  40. * in this table.
  41. */
  42. unsigned long irq_hwmask[NR_IRQS];
  43. #endif /* CONFIG_MIPS_MT_SMTC */
  44. #undef do_IRQ
  45. /*
  46. * do_IRQ handles all normal device IRQ's (the special
  47. * SMP cross-CPU interrupts have their own specific
  48. * handlers).
  49. */
  50. asmlinkage unsigned int do_IRQ(unsigned int irq, struct pt_regs *regs)
  51. {
  52. struct pt_regs *old_regs = set_irq_regs(regs);
  53. irq_enter();
  54. __DO_IRQ_SMTC_HOOK();
  55. __do_IRQ(irq);
  56. irq_exit();
  57. set_irq_regs(old_regs);
  58. return 1;
  59. }
  60. /*
  61. * Generic, controller-independent functions:
  62. */
  63. int show_interrupts(struct seq_file *p, void *v)
  64. {
  65. int i = *(loff_t *) v, j;
  66. struct irqaction * action;
  67. unsigned long flags;
  68. if (i == 0) {
  69. seq_printf(p, " ");
  70. for_each_online_cpu(j)
  71. seq_printf(p, "CPU%d ",j);
  72. seq_putc(p, '\n');
  73. }
  74. if (i < NR_IRQS) {
  75. spin_lock_irqsave(&irq_desc[i].lock, flags);
  76. action = irq_desc[i].action;
  77. if (!action)
  78. goto skip;
  79. seq_printf(p, "%3d: ",i);
  80. #ifndef CONFIG_SMP
  81. seq_printf(p, "%10u ", kstat_irqs(i));
  82. #else
  83. for_each_online_cpu(j)
  84. seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
  85. #endif
  86. seq_printf(p, " %14s", irq_desc[i].chip->typename);
  87. seq_printf(p, " %s", action->name);
  88. for (action=action->next; action; action = action->next)
  89. seq_printf(p, ", %s", action->name);
  90. seq_putc(p, '\n');
  91. skip:
  92. spin_unlock_irqrestore(&irq_desc[i].lock, flags);
  93. } else if (i == NR_IRQS) {
  94. seq_putc(p, '\n');
  95. seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count));
  96. }
  97. return 0;
  98. }
  99. asmlinkage void spurious_interrupt(struct pt_regs *regs)
  100. {
  101. atomic_inc(&irq_err_count);
  102. }
  103. #ifdef CONFIG_KGDB
  104. extern void breakpoint(void);
  105. extern void set_debug_traps(void);
  106. static int kgdb_flag = 1;
  107. static int __init nokgdb(char *str)
  108. {
  109. kgdb_flag = 0;
  110. return 1;
  111. }
  112. __setup("nokgdb", nokgdb);
  113. #endif
  114. void __init init_IRQ(void)
  115. {
  116. int i;
  117. for (i = 0; i < NR_IRQS; i++) {
  118. irq_desc[i].status = IRQ_DISABLED;
  119. irq_desc[i].action = NULL;
  120. irq_desc[i].depth = 1;
  121. irq_desc[i].chip = &no_irq_chip;
  122. spin_lock_init(&irq_desc[i].lock);
  123. #ifdef CONFIG_MIPS_MT_SMTC
  124. irq_hwmask[i] = 0;
  125. #endif /* CONFIG_MIPS_MT_SMTC */
  126. }
  127. arch_init_irq();
  128. #ifdef CONFIG_KGDB
  129. if (kgdb_flag) {
  130. printk("Wait for gdb client connection ...\n");
  131. set_debug_traps();
  132. breakpoint();
  133. }
  134. #endif
  135. }