irqinit_32.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. #include <linux/errno.h>
  2. #include <linux/signal.h>
  3. #include <linux/sched.h>
  4. #include <linux/ioport.h>
  5. #include <linux/interrupt.h>
  6. #include <linux/slab.h>
  7. #include <linux/random.h>
  8. #include <linux/init.h>
  9. #include <linux/kernel_stat.h>
  10. #include <linux/sysdev.h>
  11. #include <linux/bitops.h>
  12. #include <asm/atomic.h>
  13. #include <asm/system.h>
  14. #include <asm/io.h>
  15. #include <asm/timer.h>
  16. #include <asm/pgtable.h>
  17. #include <asm/delay.h>
  18. #include <asm/desc.h>
  19. #include <asm/apic.h>
  20. #include <asm/arch_hooks.h>
  21. #include <asm/i8259.h>
  22. /*
  23. * Note that on a 486, we don't want to do a SIGFPE on an irq13
  24. * as the irq is unreliable, and exception 16 works correctly
  25. * (ie as explained in the intel literature). On a 386, you
  26. * can't use exception 16 due to bad IBM design, so we have to
  27. * rely on the less exact irq13.
  28. *
  29. * Careful.. Not only is IRQ13 unreliable, but it is also
  30. * leads to races. IBM designers who came up with it should
  31. * be shot.
  32. */
  33. static irqreturn_t math_error_irq(int cpl, void *dev_id)
  34. {
  35. extern void math_error(void __user *);
  36. outb(0,0xF0);
  37. if (ignore_fpu_irq || !boot_cpu_data.hard_math)
  38. return IRQ_NONE;
  39. math_error((void __user *)get_irq_regs()->ip);
  40. return IRQ_HANDLED;
  41. }
  42. /*
  43. * New motherboards sometimes make IRQ 13 be a PCI interrupt,
  44. * so allow interrupt sharing.
  45. */
  46. static struct irqaction fpu_irq = {
  47. .handler = math_error_irq,
  48. .mask = CPU_MASK_NONE,
  49. .name = "fpu",
  50. };
  51. void __init init_ISA_irqs (void)
  52. {
  53. int i;
  54. #ifdef CONFIG_X86_LOCAL_APIC
  55. init_bsp_APIC();
  56. #endif
  57. init_8259A(0);
  58. /*
  59. * 16 old-style INTA-cycle interrupts:
  60. */
  61. for (i = 0; i < 16; i++) {
  62. set_irq_chip_and_handler_name(i, &i8259A_chip,
  63. handle_level_irq, "XT");
  64. }
  65. }
  66. /*
  67. * IRQ2 is cascade interrupt to second interrupt controller
  68. */
  69. static struct irqaction irq2 = {
  70. .handler = no_action,
  71. .mask = CPU_MASK_NONE,
  72. .name = "cascade",
  73. };
  74. /* Overridden in paravirt.c */
  75. void init_IRQ(void) __attribute__((weak, alias("native_init_IRQ")));
  76. void __init native_init_IRQ(void)
  77. {
  78. int i;
  79. /* all the set up before the call gates are initialised */
  80. pre_intr_init_hook();
  81. /*
  82. * Cover the whole vector space, no vector can escape
  83. * us. (some of these will be overridden and become
  84. * 'special' SMP interrupts)
  85. */
  86. for (i = 0; i < (NR_VECTORS - FIRST_EXTERNAL_VECTOR); i++) {
  87. int vector = FIRST_EXTERNAL_VECTOR + i;
  88. if (i >= NR_IRQS)
  89. break;
  90. /* SYSCALL_VECTOR was reserved in trap_init. */
  91. if (!test_bit(vector, used_vectors))
  92. set_intr_gate(vector, interrupt[i]);
  93. }
  94. #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_SMP)
  95. /*
  96. * IRQ0 must be given a fixed assignment and initialized,
  97. * because it's used before the IO-APIC is set up.
  98. */
  99. set_intr_gate(FIRST_DEVICE_VECTOR, interrupt[0]);
  100. /*
  101. * The reschedule interrupt is a CPU-to-CPU reschedule-helper
  102. * IPI, driven by wakeup.
  103. */
  104. alloc_intr_gate(RESCHEDULE_VECTOR, reschedule_interrupt);
  105. /* IPI for invalidation */
  106. alloc_intr_gate(INVALIDATE_TLB_VECTOR, invalidate_interrupt);
  107. /* IPI for generic function call */
  108. alloc_intr_gate(CALL_FUNCTION_VECTOR, call_function_interrupt);
  109. /* IPI for single call function */
  110. set_intr_gate(CALL_FUNCTION_SINGLE_VECTOR, call_function_single_interrupt);
  111. #endif
  112. #ifdef CONFIG_X86_LOCAL_APIC
  113. /* self generated IPI for local APIC timer */
  114. alloc_intr_gate(LOCAL_TIMER_VECTOR, apic_timer_interrupt);
  115. /* IPI vectors for APIC spurious and error interrupts */
  116. alloc_intr_gate(SPURIOUS_APIC_VECTOR, spurious_interrupt);
  117. alloc_intr_gate(ERROR_APIC_VECTOR, error_interrupt);
  118. #endif
  119. #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_MCE_P4THERMAL)
  120. /* thermal monitor LVT interrupt */
  121. alloc_intr_gate(THERMAL_APIC_VECTOR, thermal_interrupt);
  122. #endif
  123. if (!acpi_ioapic)
  124. setup_irq(2, &irq2);
  125. /* setup after call gates are initialised (usually add in
  126. * the architecture specific gates)
  127. */
  128. intr_init_hook();
  129. /*
  130. * External FPU? Set up irq13 if so, for
  131. * original braindamaged IBM FERR coupling.
  132. */
  133. if (boot_cpu_data.hard_math && !cpu_has_fpu)
  134. setup_irq(FPU_IRQ, &fpu_irq);
  135. irq_ctx_init(smp_processor_id());
  136. }