irq.c 2.9 KB

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