irq_vectors.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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
  29. * at 0x20:
  30. * hpa said we can start from 0x1f.
  31. * 0x1f is documented as reserved. However, the ability for the APIC
  32. * to generate vectors starting at 0x10 is documented, as is the
  33. * ability for the CPU to receive any vector number as an interrupt.
  34. * 0x1f is used for IRQ_MOVE_CLEANUP_VECTOR since that vector needs
  35. * an entire privilege level (16 vectors) all by itself at a higher
  36. * priority than any actual device vector. Thus, by placing it in the
  37. * otherwise-unusable 0x10 privilege level, we avoid wasting a full
  38. * 16-vector block.
  39. */
  40. #define FIRST_EXTERNAL_VECTOR 0x1f
  41. #define IA32_SYSCALL_VECTOR 0x80
  42. #ifdef CONFIG_X86_32
  43. # define SYSCALL_VECTOR 0x80
  44. #endif
  45. /*
  46. * Reserve the lowest usable priority level 0x10 - 0x1f for triggering
  47. * cleanup after irq migration.
  48. * this overlaps with the reserved range for cpu exceptions so this
  49. * will need to be changed to 0x20 - 0x2f if the last cpu exception is
  50. * ever allocated.
  51. */
  52. #define IRQ_MOVE_CLEANUP_VECTOR FIRST_EXTERNAL_VECTOR
  53. /*
  54. * Vectors 0x20-0x2f are used for ISA interrupts.
  55. * round up to the next 16-vector boundary
  56. */
  57. #define IRQ0_VECTOR ((FIRST_EXTERNAL_VECTOR + 16) & ~15)
  58. #define IRQ1_VECTOR (IRQ0_VECTOR + 1)
  59. #define IRQ2_VECTOR (IRQ0_VECTOR + 2)
  60. #define IRQ3_VECTOR (IRQ0_VECTOR + 3)
  61. #define IRQ4_VECTOR (IRQ0_VECTOR + 4)
  62. #define IRQ5_VECTOR (IRQ0_VECTOR + 5)
  63. #define IRQ6_VECTOR (IRQ0_VECTOR + 6)
  64. #define IRQ7_VECTOR (IRQ0_VECTOR + 7)
  65. #define IRQ8_VECTOR (IRQ0_VECTOR + 8)
  66. #define IRQ9_VECTOR (IRQ0_VECTOR + 9)
  67. #define IRQ10_VECTOR (IRQ0_VECTOR + 10)
  68. #define IRQ11_VECTOR (IRQ0_VECTOR + 11)
  69. #define IRQ12_VECTOR (IRQ0_VECTOR + 12)
  70. #define IRQ13_VECTOR (IRQ0_VECTOR + 13)
  71. #define IRQ14_VECTOR (IRQ0_VECTOR + 14)
  72. #define IRQ15_VECTOR (IRQ0_VECTOR + 15)
  73. /*
  74. * Special IRQ vectors used by the SMP architecture, 0xf0-0xff
  75. *
  76. * some of the following vectors are 'rare', they are merged
  77. * into a single vector (CALL_FUNCTION_VECTOR) to save vector space.
  78. * TLB, reschedule and local APIC vectors are performance-critical.
  79. */
  80. #define SPURIOUS_APIC_VECTOR 0xff
  81. /*
  82. * Sanity check
  83. */
  84. #if ((SPURIOUS_APIC_VECTOR & 0x0F) != 0x0F)
  85. # error SPURIOUS_APIC_VECTOR definition error
  86. #endif
  87. #define ERROR_APIC_VECTOR 0xfe
  88. #define RESCHEDULE_VECTOR 0xfd
  89. #define CALL_FUNCTION_VECTOR 0xfc
  90. #define CALL_FUNCTION_SINGLE_VECTOR 0xfb
  91. #define THERMAL_APIC_VECTOR 0xfa
  92. #define THRESHOLD_APIC_VECTOR 0xf9
  93. #define REBOOT_VECTOR 0xf8
  94. /* f0-f7 used for spreading out TLB flushes: */
  95. #define INVALIDATE_TLB_VECTOR_END 0xf7
  96. #define INVALIDATE_TLB_VECTOR_START 0xf0
  97. #define NUM_INVALIDATE_TLB_VECTORS 8
  98. /*
  99. * Local APIC timer IRQ vector is on a different priority level,
  100. * to work around the 'lost local interrupt if more than 2 IRQ
  101. * sources per level' errata.
  102. */
  103. #define LOCAL_TIMER_VECTOR 0xef
  104. /*
  105. * Generic system vector for platform specific use
  106. */
  107. #define X86_PLATFORM_IPI_VECTOR 0xed
  108. /*
  109. * Performance monitoring pending work vector:
  110. */
  111. #define LOCAL_PENDING_VECTOR 0xec
  112. #define UV_BAU_MESSAGE 0xea
  113. /*
  114. * Self IPI vector for machine checks
  115. */
  116. #define MCE_SELF_VECTOR 0xeb
  117. /*
  118. * First APIC vector available to drivers: (vectors 0x30-0xee) we
  119. * start at 0x31 to spread out vectors evenly between priority
  120. * levels. (0x80 is the syscall vector)
  121. */
  122. #define FIRST_DEVICE_VECTOR (IRQ15_VECTOR + 2)
  123. #define NR_VECTORS 256
  124. #define FPU_IRQ 13
  125. #define FIRST_VM86_IRQ 3
  126. #define LAST_VM86_IRQ 15
  127. #ifndef __ASSEMBLY__
  128. static inline int invalid_vm86_irq(int irq)
  129. {
  130. return irq < FIRST_VM86_IRQ || irq > LAST_VM86_IRQ;
  131. }
  132. #endif
  133. /*
  134. * Size the maximum number of interrupts.
  135. *
  136. * If the irq_desc[] array has a sparse layout, we can size things
  137. * generously - it scales up linearly with the maximum number of CPUs,
  138. * and the maximum number of IO-APICs, whichever is higher.
  139. *
  140. * In other cases we size more conservatively, to not create too large
  141. * static arrays.
  142. */
  143. #define NR_IRQS_LEGACY 16
  144. #define IO_APIC_VECTOR_LIMIT ( 32 * MAX_IO_APICS )
  145. #ifdef CONFIG_X86_IO_APIC
  146. # ifdef CONFIG_SPARSE_IRQ
  147. # define CPU_VECTOR_LIMIT (64 * NR_CPUS)
  148. # define NR_IRQS \
  149. (CPU_VECTOR_LIMIT > IO_APIC_VECTOR_LIMIT ? \
  150. (NR_VECTORS + CPU_VECTOR_LIMIT) : \
  151. (NR_VECTORS + IO_APIC_VECTOR_LIMIT))
  152. # else
  153. # define CPU_VECTOR_LIMIT (32 * NR_CPUS)
  154. # define NR_IRQS \
  155. (CPU_VECTOR_LIMIT < IO_APIC_VECTOR_LIMIT ? \
  156. (NR_VECTORS + CPU_VECTOR_LIMIT) : \
  157. (NR_VECTORS + IO_APIC_VECTOR_LIMIT))
  158. # endif
  159. #else /* !CONFIG_X86_IO_APIC: */
  160. # define NR_IRQS NR_IRQS_LEGACY
  161. #endif
  162. #endif /* _ASM_X86_IRQ_VECTORS_H */