irqinit_32.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. /* Overridden in paravirt.c */
  67. void init_IRQ(void) __attribute__((weak, alias("native_init_IRQ")));
  68. void __init native_init_IRQ(void)
  69. {
  70. int i;
  71. /* all the set up before the call gates are initialised */
  72. pre_intr_init_hook();
  73. /*
  74. * Cover the whole vector space, no vector can escape
  75. * us. (some of these will be overridden and become
  76. * 'special' SMP interrupts)
  77. */
  78. for (i = 0; i < (NR_VECTORS - FIRST_EXTERNAL_VECTOR); i++) {
  79. int vector = FIRST_EXTERNAL_VECTOR + i;
  80. if (i >= NR_IRQS)
  81. break;
  82. /* SYSCALL_VECTOR was reserved in trap_init. */
  83. if (!test_bit(vector, used_vectors))
  84. set_intr_gate(vector, interrupt[i]);
  85. }
  86. /* setup after call gates are initialised (usually add in
  87. * the architecture specific gates)
  88. */
  89. intr_init_hook();
  90. /*
  91. * External FPU? Set up irq13 if so, for
  92. * original braindamaged IBM FERR coupling.
  93. */
  94. if (boot_cpu_data.hard_math && !cpu_has_fpu)
  95. setup_irq(FPU_IRQ, &fpu_irq);
  96. irq_ctx_init(smp_processor_id());
  97. }