xref: /openbmc/linux/arch/x86/include/asm/irq_vectors.h (revision 5c0d728e)
11965aae3SH. Peter Anvin #ifndef _ASM_X86_IRQ_VECTORS_H
21965aae3SH. Peter Anvin #define _ASM_X86_IRQ_VECTORS_H
3bb898558SAl Viro 
460f6e65dSShaohua Li #include <linux/threads.h>
59fc2e79dSIngo Molnar /*
69fc2e79dSIngo Molnar  * Linux IRQ vector layout.
79fc2e79dSIngo Molnar  *
89fc2e79dSIngo Molnar  * There are 256 IDT entries (per CPU - each entry is 8 bytes) which can
99fc2e79dSIngo Molnar  * be defined by Linux. They are used as a jump table by the CPU when a
109fc2e79dSIngo Molnar  * given vector is triggered - by a CPU-external, CPU-internal or
119fc2e79dSIngo Molnar  * software-triggered event.
129fc2e79dSIngo Molnar  *
139fc2e79dSIngo Molnar  * Linux sets the kernel code address each entry jumps to early during
149fc2e79dSIngo Molnar  * bootup, and never changes them. This is the general layout of the
159fc2e79dSIngo Molnar  * IDT entries:
169fc2e79dSIngo Molnar  *
179fc2e79dSIngo Molnar  *  Vectors   0 ...  31 : system traps and exceptions - hardcoded events
189fc2e79dSIngo Molnar  *  Vectors  32 ... 127 : device interrupts
199fc2e79dSIngo Molnar  *  Vector  128         : legacy int80 syscall interface
205cec93c2SAndy Lutomirski  *  Vectors 129 ... INVALIDATE_TLB_VECTOR_START-1 except 204 : device interrupts
2170e4a369SShaohua Li  *  Vectors INVALIDATE_TLB_VECTOR_START ... 255 : special interrupts
229fc2e79dSIngo Molnar  *
239fc2e79dSIngo Molnar  * 64-bit x86 has per CPU IDT tables, 32-bit has one shared IDT table.
249fc2e79dSIngo Molnar  *
259fc2e79dSIngo Molnar  * This file enumerates the exact layout of them:
269fc2e79dSIngo Molnar  */
279fc2e79dSIngo Molnar 
28bb898558SAl Viro #define NMI_VECTOR			0x02
298fa8dd9eSAndi Kleen #define MCE_VECTOR			0x12
30bb898558SAl Viro 
31bb898558SAl Viro /*
326579b474SSuresh Siddha  * IDT vectors usable for external interrupt sources start at 0x20.
336579b474SSuresh Siddha  * (0x80 is the syscall vector, 0x30-0x3f are for ISA)
34bb898558SAl Viro  */
356579b474SSuresh Siddha #define FIRST_EXTERNAL_VECTOR		0x20
366579b474SSuresh Siddha /*
376579b474SSuresh Siddha  * We start allocating at 0x21 to spread out vectors evenly between
386579b474SSuresh Siddha  * priority levels. (0x80 is the syscall vector)
396579b474SSuresh Siddha  */
406579b474SSuresh Siddha #define VECTOR_OFFSET_START		1
416579b474SSuresh Siddha 
426579b474SSuresh Siddha /*
436579b474SSuresh Siddha  * Reserve the lowest usable vector (and hence lowest priority)  0x20 for
446579b474SSuresh Siddha  * triggering cleanup after irq migration. 0x21-0x2f will still be used
456579b474SSuresh Siddha  * for device interrupts.
466579b474SSuresh Siddha  */
476579b474SSuresh Siddha #define IRQ_MOVE_CLEANUP_VECTOR		FIRST_EXTERNAL_VECTOR
48bb898558SAl Viro 
4999d113b1SH. Peter Anvin #define IA32_SYSCALL_VECTOR		0x80
50bb898558SAl Viro #ifdef CONFIG_X86_32
51bb898558SAl Viro # define SYSCALL_VECTOR			0x80
52bb898558SAl Viro #endif
53bb898558SAl Viro 
54bb898558SAl Viro /*
556579b474SSuresh Siddha  * Vectors 0x30-0x3f are used for ISA interrupts.
5699d113b1SH. Peter Anvin  *   round up to the next 16-vector boundary
57bb898558SAl Viro  */
5899d113b1SH. Peter Anvin #define IRQ0_VECTOR			((FIRST_EXTERNAL_VECTOR + 16) & ~15)
599fc2e79dSIngo Molnar 
60bb898558SAl Viro #define IRQ1_VECTOR			(IRQ0_VECTOR +  1)
61bb898558SAl Viro #define IRQ2_VECTOR			(IRQ0_VECTOR +  2)
62bb898558SAl Viro #define IRQ3_VECTOR			(IRQ0_VECTOR +  3)
63bb898558SAl Viro #define IRQ4_VECTOR			(IRQ0_VECTOR +  4)
64bb898558SAl Viro #define IRQ5_VECTOR			(IRQ0_VECTOR +  5)
65bb898558SAl Viro #define IRQ6_VECTOR			(IRQ0_VECTOR +  6)
66bb898558SAl Viro #define IRQ7_VECTOR			(IRQ0_VECTOR +  7)
67bb898558SAl Viro #define IRQ8_VECTOR			(IRQ0_VECTOR +  8)
68bb898558SAl Viro #define IRQ9_VECTOR			(IRQ0_VECTOR +  9)
69bb898558SAl Viro #define IRQ10_VECTOR			(IRQ0_VECTOR + 10)
70bb898558SAl Viro #define IRQ11_VECTOR			(IRQ0_VECTOR + 11)
71bb898558SAl Viro #define IRQ12_VECTOR			(IRQ0_VECTOR + 12)
72bb898558SAl Viro #define IRQ13_VECTOR			(IRQ0_VECTOR + 13)
73bb898558SAl Viro #define IRQ14_VECTOR			(IRQ0_VECTOR + 14)
74bb898558SAl Viro #define IRQ15_VECTOR			(IRQ0_VECTOR + 15)
75bb898558SAl Viro 
76bb898558SAl Viro /*
77bb898558SAl Viro  * Special IRQ vectors used by the SMP architecture, 0xf0-0xff
78bb898558SAl Viro  *
79bb898558SAl Viro  *  some of the following vectors are 'rare', they are merged
80bb898558SAl Viro  *  into a single vector (CALL_FUNCTION_VECTOR) to save vector space.
81bb898558SAl Viro  *  TLB, reschedule and local APIC vectors are performance-critical.
82bb898558SAl Viro  */
835da690d2SIngo Molnar 
845da690d2SIngo Molnar #define SPURIOUS_APIC_VECTOR		0xff
85647ad94fSIngo Molnar /*
86647ad94fSIngo Molnar  * Sanity check
87647ad94fSIngo Molnar  */
88647ad94fSIngo Molnar #if ((SPURIOUS_APIC_VECTOR & 0x0F) != 0x0F)
89647ad94fSIngo Molnar # error SPURIOUS_APIC_VECTOR definition error
90647ad94fSIngo Molnar #endif
91647ad94fSIngo Molnar 
925da690d2SIngo Molnar #define ERROR_APIC_VECTOR		0xfe
935da690d2SIngo Molnar #define RESCHEDULE_VECTOR		0xfd
945da690d2SIngo Molnar #define CALL_FUNCTION_VECTOR		0xfc
955da690d2SIngo Molnar #define CALL_FUNCTION_SINGLE_VECTOR	0xfb
965da690d2SIngo Molnar #define THERMAL_APIC_VECTOR		0xfa
97bb898558SAl Viro #define THRESHOLD_APIC_VECTOR		0xf9
984ef702c1SAndi Kleen #define REBOOT_VECTOR			0xf8
99bb898558SAl Viro 
10060f6e65dSShaohua Li /*
10160f6e65dSShaohua Li  * Generic system vector for platform specific use
10260f6e65dSShaohua Li  */
10360f6e65dSShaohua Li #define X86_PLATFORM_IPI_VECTOR		0xf7
10460f6e65dSShaohua Li 
10560f6e65dSShaohua Li /*
10660f6e65dSShaohua Li  * IRQ work vector:
10760f6e65dSShaohua Li  */
10860f6e65dSShaohua Li #define IRQ_WORK_VECTOR			0xf6
10960f6e65dSShaohua Li 
11060f6e65dSShaohua Li #define UV_BAU_MESSAGE			0xf5
11124fd78a8SAravind Gopalakrishnan #define DEFERRED_ERROR_VECTOR		0xf4
11260f6e65dSShaohua Li 
113bc2b0331SK. Y. Srinivasan /* Vector on which hypervisor callbacks will be delivered */
114bc2b0331SK. Y. Srinivasan #define HYPERVISOR_CALLBACK_VECTOR	0xf3
1155da690d2SIngo Molnar 
1165c0d728eSAravind Gopalakrishnan /* Vector for KVM to deliver posted interrupt IPI */
1175c0d728eSAravind Gopalakrishnan #ifdef CONFIG_HAVE_KVM
1185c0d728eSAravind Gopalakrishnan #define POSTED_INTR_VECTOR		0xf2
1195c0d728eSAravind Gopalakrishnan #endif
1205c0d728eSAravind Gopalakrishnan 
121bb898558SAl Viro /*
122bb898558SAl Viro  * Local APIC timer IRQ vector is on a different priority level,
123bb898558SAl Viro  * to work around the 'lost local interrupt if more than 2 IRQ
124bb898558SAl Viro  * sources per level' errata.
125bb898558SAl Viro  */
126bb898558SAl Viro #define LOCAL_TIMER_VECTOR		0xef
127bb898558SAl Viro 
128bb898558SAl Viro #define NR_VECTORS			 256
129bb898558SAl Viro 
1302414e021SJan Beulich #ifdef CONFIG_X86_LOCAL_APIC
1312414e021SJan Beulich #define FIRST_SYSTEM_VECTOR		LOCAL_TIMER_VECTOR
1322414e021SJan Beulich #else
1332414e021SJan Beulich #define FIRST_SYSTEM_VECTOR		NR_VECTORS
1342414e021SJan Beulich #endif
1352414e021SJan Beulich 
136bb898558SAl Viro #define FPU_IRQ				  13
137bb898558SAl Viro 
138bb898558SAl Viro #define	FIRST_VM86_IRQ			   3
139bb898558SAl Viro #define LAST_VM86_IRQ			  15
140d8106d2eSIngo Molnar 
141d8106d2eSIngo Molnar #ifndef __ASSEMBLY__
142d8106d2eSIngo Molnar static inline int invalid_vm86_irq(int irq)
143d8106d2eSIngo Molnar {
14457e37293SCyrill Gorcunov 	return irq < FIRST_VM86_IRQ || irq > LAST_VM86_IRQ;
145d8106d2eSIngo Molnar }
146d8106d2eSIngo Molnar #endif
147bb898558SAl Viro 
148009eb3feSIngo Molnar /*
149009eb3feSIngo Molnar  * Size the maximum number of interrupts.
150009eb3feSIngo Molnar  *
151009eb3feSIngo Molnar  * If the irq_desc[] array has a sparse layout, we can size things
152009eb3feSIngo Molnar  * generously - it scales up linearly with the maximum number of CPUs,
153009eb3feSIngo Molnar  * and the maximum number of IO-APICs, whichever is higher.
154009eb3feSIngo Molnar  *
155009eb3feSIngo Molnar  * In other cases we size more conservatively, to not create too large
156009eb3feSIngo Molnar  * static arrays.
157009eb3feSIngo Molnar  */
158009eb3feSIngo Molnar 
15999d093d1SYinghai Lu #define NR_IRQS_LEGACY			  16
16099d093d1SYinghai Lu 
161009eb3feSIngo Molnar #define IO_APIC_VECTOR_LIMIT		( 32 * MAX_IO_APICS )
162009eb3feSIngo Molnar 
1633e92ab3dSIngo Molnar #ifdef CONFIG_X86_IO_APIC
1649959c888SYinghai Lu # define CPU_VECTOR_LIMIT		(64 * NR_CPUS)
1654a046d17SYinghai Lu # define NR_IRQS					\
166009eb3feSIngo Molnar 	(CPU_VECTOR_LIMIT > IO_APIC_VECTOR_LIMIT ?	\
167009eb3feSIngo Molnar 		(NR_VECTORS + CPU_VECTOR_LIMIT)  :	\
168009eb3feSIngo Molnar 		(NR_VECTORS + IO_APIC_VECTOR_LIMIT))
1693e92ab3dSIngo Molnar #else /* !CONFIG_X86_IO_APIC: */
170009eb3feSIngo Molnar # define NR_IRQS			NR_IRQS_LEGACY
171bb898558SAl Viro #endif
172bb898558SAl Viro 
1731965aae3SH. Peter Anvin #endif /* _ASM_X86_IRQ_VECTORS_H */
174