irq_vectors.h 4.8 KB

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