irq_vectors.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. #ifndef _ASM_X86_IRQ_VECTORS_H
  2. #define _ASM_X86_IRQ_VECTORS_H
  3. /*
  4. * Linux IRQ vector layout.
  5. *
  6. * There are 256 IDT entries (per CPU - each entry is 8 bytes) which can
  7. * be defined by Linux. They are used as a jump table by the CPU when a
  8. * given vector is triggered - by a CPU-external, CPU-internal or
  9. * software-triggered event.
  10. *
  11. * Linux sets the kernel code address each entry jumps to early during
  12. * bootup, and never changes them. This is the general layout of the
  13. * IDT entries:
  14. *
  15. * Vectors 0 ... 31 : system traps and exceptions - hardcoded events
  16. * Vectors 32 ... 127 : device interrupts
  17. * Vector 128 : legacy int80 syscall interface
  18. * Vectors 129 ... 237 : device interrupts
  19. * Vectors 238 ... 255 : special interrupts
  20. *
  21. * 64-bit x86 has per CPU IDT tables, 32-bit has one shared IDT table.
  22. *
  23. * This file enumerates the exact layout of them:
  24. */
  25. #define NMI_VECTOR 0x02
  26. #define MCE_VECTOR 0x12
  27. /*
  28. * IDT vectors usable for external interrupt sources start at 0x20.
  29. * (0x80 is the syscall vector, 0x30-0x3f are for ISA)
  30. */
  31. #define FIRST_EXTERNAL_VECTOR 0x20
  32. /*
  33. * We start allocating at 0x21 to spread out vectors evenly between
  34. * priority levels. (0x80 is the syscall vector)
  35. */
  36. #define VECTOR_OFFSET_START 1
  37. /*
  38. * Reserve the lowest usable vector (and hence lowest priority) 0x20 for
  39. * triggering cleanup after irq migration. 0x21-0x2f will still be used
  40. * for device interrupts.
  41. */
  42. #define IRQ_MOVE_CLEANUP_VECTOR FIRST_EXTERNAL_VECTOR
  43. #define IA32_SYSCALL_VECTOR 0x80
  44. #ifdef CONFIG_X86_32
  45. # define SYSCALL_VECTOR 0x80
  46. #endif
  47. /*
  48. * Vectors 0x30-0x3f are used for ISA interrupts.
  49. * round up to the next 16-vector boundary
  50. */
  51. #define IRQ0_VECTOR ((FIRST_EXTERNAL_VECTOR + 16) & ~15)
  52. #define IRQ1_VECTOR (IRQ0_VECTOR + 1)
  53. #define IRQ2_VECTOR (IRQ0_VECTOR + 2)
  54. #define IRQ3_VECTOR (IRQ0_VECTOR + 3)
  55. #define IRQ4_VECTOR (IRQ0_VECTOR + 4)
  56. #define IRQ5_VECTOR (IRQ0_VECTOR + 5)
  57. #define IRQ6_VECTOR (IRQ0_VECTOR + 6)
  58. #define IRQ7_VECTOR (IRQ0_VECTOR + 7)
  59. #define IRQ8_VECTOR (IRQ0_VECTOR + 8)
  60. #define IRQ9_VECTOR (IRQ0_VECTOR + 9)
  61. #define IRQ10_VECTOR (IRQ0_VECTOR + 10)
  62. #define IRQ11_VECTOR (IRQ0_VECTOR + 11)
  63. #define IRQ12_VECTOR (IRQ0_VECTOR + 12)
  64. #define IRQ13_VECTOR (IRQ0_VECTOR + 13)
  65. #define IRQ14_VECTOR (IRQ0_VECTOR + 14)
  66. #define IRQ15_VECTOR (IRQ0_VECTOR + 15)
  67. /*
  68. * Special IRQ vectors used by the SMP architecture, 0xf0-0xff
  69. *
  70. * some of the following vectors are 'rare', they are merged
  71. * into a single vector (CALL_FUNCTION_VECTOR) to save vector space.
  72. * TLB, reschedule and local APIC vectors are performance-critical.
  73. */
  74. #define SPURIOUS_APIC_VECTOR 0xff
  75. /*
  76. * Sanity check
  77. */
  78. #if ((SPURIOUS_APIC_VECTOR & 0x0F) != 0x0F)
  79. # error SPURIOUS_APIC_VECTOR definition error
  80. #endif
  81. #define ERROR_APIC_VECTOR 0xfe
  82. #define RESCHEDULE_VECTOR 0xfd
  83. #define CALL_FUNCTION_VECTOR 0xfc
  84. #define CALL_FUNCTION_SINGLE_VECTOR 0xfb
  85. #define THERMAL_APIC_VECTOR 0xfa
  86. #define THRESHOLD_APIC_VECTOR 0xf9
  87. #define REBOOT_VECTOR 0xf8
  88. /* f0-f7 used for spreading out TLB flushes: */
  89. #define INVALIDATE_TLB_VECTOR_END 0xf7
  90. #define INVALIDATE_TLB_VECTOR_START 0xf0
  91. #define NUM_INVALIDATE_TLB_VECTORS 8
  92. /*
  93. * Local APIC timer IRQ vector is on a different priority level,
  94. * to work around the 'lost local interrupt if more than 2 IRQ
  95. * sources per level' errata.
  96. */
  97. #define LOCAL_TIMER_VECTOR 0xef
  98. /*
  99. * Generic system vector for platform specific use
  100. */
  101. #define X86_PLATFORM_IPI_VECTOR 0xed
  102. /*
  103. * Performance monitoring pending work vector:
  104. */
  105. #define LOCAL_PENDING_VECTOR 0xec
  106. #define UV_BAU_MESSAGE 0xea
  107. /*
  108. * Self IPI vector for machine checks
  109. */
  110. #define MCE_SELF_VECTOR 0xeb
  111. #define NR_VECTORS 256
  112. #define FPU_IRQ 13
  113. #define FIRST_VM86_IRQ 3
  114. #define LAST_VM86_IRQ 15
  115. #ifndef __ASSEMBLY__
  116. static inline int invalid_vm86_irq(int irq)
  117. {
  118. return irq < FIRST_VM86_IRQ || irq > LAST_VM86_IRQ;
  119. }
  120. #endif
  121. /*
  122. * Size the maximum number of interrupts.
  123. *
  124. * If the irq_desc[] array has a sparse layout, we can size things
  125. * generously - it scales up linearly with the maximum number of CPUs,
  126. * and the maximum number of IO-APICs, whichever is higher.
  127. *
  128. * In other cases we size more conservatively, to not create too large
  129. * static arrays.
  130. */
  131. #define NR_IRQS_LEGACY 16
  132. #define IO_APIC_VECTOR_LIMIT ( 32 * MAX_IO_APICS )
  133. #ifdef CONFIG_X86_IO_APIC
  134. # ifdef CONFIG_SPARSE_IRQ
  135. # define CPU_VECTOR_LIMIT (64 * NR_CPUS)
  136. # define NR_IRQS \
  137. (CPU_VECTOR_LIMIT > IO_APIC_VECTOR_LIMIT ? \
  138. (NR_VECTORS + CPU_VECTOR_LIMIT) : \
  139. (NR_VECTORS + IO_APIC_VECTOR_LIMIT))
  140. # else
  141. # define CPU_VECTOR_LIMIT (32 * NR_CPUS)
  142. # define NR_IRQS \
  143. (CPU_VECTOR_LIMIT < IO_APIC_VECTOR_LIMIT ? \
  144. (NR_VECTORS + CPU_VECTOR_LIMIT) : \
  145. (NR_VECTORS + IO_APIC_VECTOR_LIMIT))
  146. # endif
  147. #else /* !CONFIG_X86_IO_APIC: */
  148. # define NR_IRQS NR_IRQS_LEGACY
  149. #endif
  150. #endif /* _ASM_X86_IRQ_VECTORS_H */