irqinit_64.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. #include <linux/linkage.h>
  2. #include <linux/errno.h>
  3. #include <linux/signal.h>
  4. #include <linux/sched.h>
  5. #include <linux/ioport.h>
  6. #include <linux/interrupt.h>
  7. #include <linux/timex.h>
  8. #include <linux/slab.h>
  9. #include <linux/random.h>
  10. #include <linux/init.h>
  11. #include <linux/kernel_stat.h>
  12. #include <linux/sysdev.h>
  13. #include <linux/bitops.h>
  14. #include <asm/acpi.h>
  15. #include <asm/atomic.h>
  16. #include <asm/system.h>
  17. #include <asm/io.h>
  18. #include <asm/hw_irq.h>
  19. #include <asm/pgtable.h>
  20. #include <asm/delay.h>
  21. #include <asm/desc.h>
  22. #include <asm/apic.h>
  23. #include <asm/i8259.h>
  24. /*
  25. * Common place to define all x86 IRQ vectors
  26. *
  27. * This builds up the IRQ handler stubs using some ugly macros in irq.h
  28. *
  29. * These macros create the low-level assembly IRQ routines that save
  30. * register context and call do_IRQ(). do_IRQ() then does all the
  31. * operations that are needed to keep the AT (or SMP IOAPIC)
  32. * interrupt-controller happy.
  33. */
  34. #define BI(x,y) \
  35. BUILD_IRQ(x##y)
  36. #define BUILD_16_IRQS(x) \
  37. BI(x,0) BI(x,1) BI(x,2) BI(x,3) \
  38. BI(x,4) BI(x,5) BI(x,6) BI(x,7) \
  39. BI(x,8) BI(x,9) BI(x,a) BI(x,b) \
  40. BI(x,c) BI(x,d) BI(x,e) BI(x,f)
  41. /*
  42. * ISA PIC or low IO-APIC triggered (INTA-cycle or APIC) interrupts:
  43. * (these are usually mapped to vectors 0x30-0x3f)
  44. */
  45. /*
  46. * The IO-APIC gives us many more interrupt sources. Most of these
  47. * are unused but an SMP system is supposed to have enough memory ...
  48. * sometimes (mostly wrt. hw bugs) we get corrupted vectors all
  49. * across the spectrum, so we really want to be prepared to get all
  50. * of these. Plus, more powerful systems might have more than 64
  51. * IO-APIC registers.
  52. *
  53. * (these are usually mapped into the 0x30-0xff vector range)
  54. */
  55. BUILD_16_IRQS(0x2) BUILD_16_IRQS(0x3)
  56. BUILD_16_IRQS(0x4) BUILD_16_IRQS(0x5) BUILD_16_IRQS(0x6) BUILD_16_IRQS(0x7)
  57. BUILD_16_IRQS(0x8) BUILD_16_IRQS(0x9) BUILD_16_IRQS(0xa) BUILD_16_IRQS(0xb)
  58. BUILD_16_IRQS(0xc) BUILD_16_IRQS(0xd) BUILD_16_IRQS(0xe) BUILD_16_IRQS(0xf)
  59. #undef BUILD_16_IRQS
  60. #undef BI
  61. #define IRQ(x,y) \
  62. IRQ##x##y##_interrupt
  63. #define IRQLIST_16(x) \
  64. IRQ(x,0), IRQ(x,1), IRQ(x,2), IRQ(x,3), \
  65. IRQ(x,4), IRQ(x,5), IRQ(x,6), IRQ(x,7), \
  66. IRQ(x,8), IRQ(x,9), IRQ(x,a), IRQ(x,b), \
  67. IRQ(x,c), IRQ(x,d), IRQ(x,e), IRQ(x,f)
  68. /* for the irq vectors */
  69. static void (*__initdata interrupt[NR_VECTORS - FIRST_EXTERNAL_VECTOR])(void) = {
  70. IRQLIST_16(0x2), IRQLIST_16(0x3),
  71. IRQLIST_16(0x4), IRQLIST_16(0x5), IRQLIST_16(0x6), IRQLIST_16(0x7),
  72. IRQLIST_16(0x8), IRQLIST_16(0x9), IRQLIST_16(0xa), IRQLIST_16(0xb),
  73. IRQLIST_16(0xc), IRQLIST_16(0xd), IRQLIST_16(0xe), IRQLIST_16(0xf)
  74. };
  75. #undef IRQ
  76. #undef IRQLIST_16
  77. /*
  78. * IRQ2 is cascade interrupt to second interrupt controller
  79. */
  80. static struct irqaction irq2 = {
  81. .handler = no_action,
  82. .mask = CPU_MASK_NONE,
  83. .name = "cascade",
  84. };
  85. DEFINE_PER_CPU(vector_irq_t, vector_irq) = {
  86. [0 ... IRQ0_VECTOR - 1] = -1,
  87. [IRQ0_VECTOR] = 0,
  88. [IRQ1_VECTOR] = 1,
  89. [IRQ2_VECTOR] = 2,
  90. [IRQ3_VECTOR] = 3,
  91. [IRQ4_VECTOR] = 4,
  92. [IRQ5_VECTOR] = 5,
  93. [IRQ6_VECTOR] = 6,
  94. [IRQ7_VECTOR] = 7,
  95. [IRQ8_VECTOR] = 8,
  96. [IRQ9_VECTOR] = 9,
  97. [IRQ10_VECTOR] = 10,
  98. [IRQ11_VECTOR] = 11,
  99. [IRQ12_VECTOR] = 12,
  100. [IRQ13_VECTOR] = 13,
  101. [IRQ14_VECTOR] = 14,
  102. [IRQ15_VECTOR] = 15,
  103. [IRQ15_VECTOR + 1 ... NR_VECTORS - 1] = -1
  104. };
  105. static void __init init_ISA_irqs (void)
  106. {
  107. int i;
  108. init_bsp_APIC();
  109. init_8259A(0);
  110. for (i = 0; i < NR_IRQS; i++) {
  111. irq_desc[i].status = IRQ_DISABLED;
  112. irq_desc[i].action = NULL;
  113. irq_desc[i].depth = 1;
  114. if (i < 16) {
  115. /*
  116. * 16 old-style INTA-cycle interrupts:
  117. */
  118. set_irq_chip_and_handler_name(i, &i8259A_chip,
  119. handle_level_irq, "XT");
  120. } else {
  121. /*
  122. * 'high' PCI IRQs filled in on demand
  123. */
  124. irq_desc[i].chip = &no_irq_chip;
  125. }
  126. }
  127. }
  128. void init_IRQ(void) __attribute__((weak, alias("native_init_IRQ")));
  129. void __init native_init_IRQ(void)
  130. {
  131. int i;
  132. init_ISA_irqs();
  133. /*
  134. * Cover the whole vector space, no vector can escape
  135. * us. (some of these will be overridden and become
  136. * 'special' SMP interrupts)
  137. */
  138. for (i = 0; i < (NR_VECTORS - FIRST_EXTERNAL_VECTOR); i++) {
  139. int vector = FIRST_EXTERNAL_VECTOR + i;
  140. if (vector != IA32_SYSCALL_VECTOR)
  141. set_intr_gate(vector, interrupt[i]);
  142. }
  143. #ifdef CONFIG_SMP
  144. /*
  145. * The reschedule interrupt is a CPU-to-CPU reschedule-helper
  146. * IPI, driven by wakeup.
  147. */
  148. set_intr_gate(RESCHEDULE_VECTOR, reschedule_interrupt);
  149. /* IPIs for invalidation */
  150. set_intr_gate(INVALIDATE_TLB_VECTOR_START+0, invalidate_interrupt0);
  151. set_intr_gate(INVALIDATE_TLB_VECTOR_START+1, invalidate_interrupt1);
  152. set_intr_gate(INVALIDATE_TLB_VECTOR_START+2, invalidate_interrupt2);
  153. set_intr_gate(INVALIDATE_TLB_VECTOR_START+3, invalidate_interrupt3);
  154. set_intr_gate(INVALIDATE_TLB_VECTOR_START+4, invalidate_interrupt4);
  155. set_intr_gate(INVALIDATE_TLB_VECTOR_START+5, invalidate_interrupt5);
  156. set_intr_gate(INVALIDATE_TLB_VECTOR_START+6, invalidate_interrupt6);
  157. set_intr_gate(INVALIDATE_TLB_VECTOR_START+7, invalidate_interrupt7);
  158. /* IPI for generic function call */
  159. set_intr_gate(CALL_FUNCTION_VECTOR, call_function_interrupt);
  160. /* Low priority IPI to cleanup after moving an irq */
  161. set_intr_gate(IRQ_MOVE_CLEANUP_VECTOR, irq_move_cleanup_interrupt);
  162. #endif
  163. set_intr_gate(THERMAL_APIC_VECTOR, thermal_interrupt);
  164. set_intr_gate(THRESHOLD_APIC_VECTOR, threshold_interrupt);
  165. /* self generated IPI for local APIC timer */
  166. set_intr_gate(LOCAL_TIMER_VECTOR, apic_timer_interrupt);
  167. /* IPI vectors for APIC spurious and error interrupts */
  168. set_intr_gate(SPURIOUS_APIC_VECTOR, spurious_interrupt);
  169. set_intr_gate(ERROR_APIC_VECTOR, error_interrupt);
  170. if (!acpi_ioapic)
  171. setup_irq(2, &irq2);
  172. }