irq.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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/proc_fs.h>
  17. #include <linux/mm.h>
  18. #include <linux/random.h>
  19. #include <linux/sched.h>
  20. #include <linux/seq_file.h>
  21. #include <linux/kallsyms.h>
  22. #include <linux/kgdb.h>
  23. #include <linux/ftrace.h>
  24. #include <linux/atomic.h>
  25. #include <asm/uaccess.h>
  26. /*
  27. * 'what should we do if we get a hw irq event on an illegal vector'.
  28. * each architecture has to answer this themselves.
  29. */
  30. void ack_bad_irq(unsigned int irq)
  31. {
  32. printk("unexpected IRQ # %d\n", irq);
  33. }
  34. atomic_t irq_err_count;
  35. int arch_show_interrupts(struct seq_file *p, int prec)
  36. {
  37. seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
  38. return 0;
  39. }
  40. asmlinkage void spurious_interrupt(void)
  41. {
  42. atomic_inc(&irq_err_count);
  43. }
  44. void __init init_IRQ(void)
  45. {
  46. int i;
  47. for (i = 0; i < NR_IRQS; i++)
  48. irq_set_noprobe(i);
  49. if (cpu_has_veic)
  50. clear_c0_status(ST0_IM);
  51. arch_init_irq();
  52. }
  53. #ifdef CONFIG_DEBUG_STACKOVERFLOW
  54. static inline void check_stack_overflow(void)
  55. {
  56. unsigned long sp;
  57. __asm__ __volatile__("move %0, $sp" : "=r" (sp));
  58. sp &= THREAD_MASK;
  59. /*
  60. * Check for stack overflow: is there less than STACK_WARN free?
  61. * STACK_WARN is defined as 1/8 of THREAD_SIZE by default.
  62. */
  63. if (unlikely(sp < (sizeof(struct thread_info) + STACK_WARN))) {
  64. printk("do_IRQ: stack overflow: %ld\n",
  65. sp - sizeof(struct thread_info));
  66. dump_stack();
  67. }
  68. }
  69. #else
  70. static inline void check_stack_overflow(void) {}
  71. #endif
  72. /*
  73. * do_IRQ handles all normal device IRQ's (the special
  74. * SMP cross-CPU interrupts have their own specific
  75. * handlers).
  76. */
  77. void __irq_entry do_IRQ(unsigned int irq)
  78. {
  79. irq_enter();
  80. check_stack_overflow();
  81. generic_handle_irq(irq);
  82. irq_exit();
  83. }