xref: /openbmc/linux/arch/x86/include/asm/irq_vectors.h (revision 70e4a369)
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
2070e4a369SShaohua Li  *  Vectors 129 ... INVALIDATE_TLB_VECTOR_START-1 : 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
11160f6e65dSShaohua Li 
11260f6e65dSShaohua Li /*
11360f6e65dSShaohua Li  * Self IPI vector for machine checks
11460f6e65dSShaohua Li  */
11560f6e65dSShaohua Li #define MCE_SELF_VECTOR			0xf4
11660f6e65dSShaohua Li 
11760f6e65dSShaohua Li /* Xen vector callback to receive events in a HVM domain */
11860f6e65dSShaohua Li #define XEN_HVM_EVTCHN_CALLBACK		0xf3
1195da690d2SIngo Molnar 
120bb898558SAl Viro /*
121bb898558SAl Viro  * Local APIC timer IRQ vector is on a different priority level,
122bb898558SAl Viro  * to work around the 'lost local interrupt if more than 2 IRQ
123bb898558SAl Viro  * sources per level' errata.
124bb898558SAl Viro  */
125bb898558SAl Viro #define LOCAL_TIMER_VECTOR		0xef
126bb898558SAl Viro 
12770e4a369SShaohua Li /* up to 32 vectors used for spreading out TLB flushes: */
12870e4a369SShaohua Li #if NR_CPUS <= 32
12970e4a369SShaohua Li # define NUM_INVALIDATE_TLB_VECTORS NR_CPUS
13070e4a369SShaohua Li #else
13170e4a369SShaohua Li # define NUM_INVALIDATE_TLB_VECTORS 32
13270e4a369SShaohua Li #endif
13370e4a369SShaohua Li 
13460f6e65dSShaohua Li #define INVALIDATE_TLB_VECTOR_END	0xee
13560f6e65dSShaohua Li #define INVALIDATE_TLB_VECTOR_START	\
13660f6e65dSShaohua Li 	(INVALIDATE_TLB_VECTOR_END - NUM_INVALIDATE_TLB_VECTORS + 1)
13738e20b07SSheng Yang 
138bb898558SAl Viro #define NR_VECTORS			 256
139bb898558SAl Viro 
140bb898558SAl Viro #define FPU_IRQ				  13
141bb898558SAl Viro 
142bb898558SAl Viro #define	FIRST_VM86_IRQ			   3
143bb898558SAl Viro #define LAST_VM86_IRQ			  15
144d8106d2eSIngo Molnar 
145d8106d2eSIngo Molnar #ifndef __ASSEMBLY__
146d8106d2eSIngo Molnar static inline int invalid_vm86_irq(int irq)
147d8106d2eSIngo Molnar {
14857e37293SCyrill Gorcunov 	return irq < FIRST_VM86_IRQ || irq > LAST_VM86_IRQ;
149d8106d2eSIngo Molnar }
150d8106d2eSIngo Molnar #endif
151bb898558SAl Viro 
152009eb3feSIngo Molnar /*
153009eb3feSIngo Molnar  * Size the maximum number of interrupts.
154009eb3feSIngo Molnar  *
155009eb3feSIngo Molnar  * If the irq_desc[] array has a sparse layout, we can size things
156009eb3feSIngo Molnar  * generously - it scales up linearly with the maximum number of CPUs,
157009eb3feSIngo Molnar  * and the maximum number of IO-APICs, whichever is higher.
158009eb3feSIngo Molnar  *
159009eb3feSIngo Molnar  * In other cases we size more conservatively, to not create too large
160009eb3feSIngo Molnar  * static arrays.
161009eb3feSIngo Molnar  */
162009eb3feSIngo Molnar 
16399d093d1SYinghai Lu #define NR_IRQS_LEGACY			  16
16499d093d1SYinghai Lu 
165009eb3feSIngo Molnar #define IO_APIC_VECTOR_LIMIT		( 32 * MAX_IO_APICS )
166009eb3feSIngo Molnar 
1673e92ab3dSIngo Molnar #ifdef CONFIG_X86_IO_APIC
168009eb3feSIngo Molnar # ifdef CONFIG_SPARSE_IRQ
1699959c888SYinghai Lu #  define CPU_VECTOR_LIMIT		(64 * NR_CPUS)
1704a046d17SYinghai Lu #  define NR_IRQS					\
171009eb3feSIngo Molnar 	(CPU_VECTOR_LIMIT > IO_APIC_VECTOR_LIMIT ?	\
172009eb3feSIngo Molnar 		(NR_VECTORS + CPU_VECTOR_LIMIT)  :	\
173009eb3feSIngo Molnar 		(NR_VECTORS + IO_APIC_VECTOR_LIMIT))
174009eb3feSIngo Molnar # else
1759959c888SYinghai Lu #  define CPU_VECTOR_LIMIT		(32 * NR_CPUS)
1769959c888SYinghai Lu #  define NR_IRQS					\
1779959c888SYinghai Lu 	(CPU_VECTOR_LIMIT < IO_APIC_VECTOR_LIMIT ?	\
1789959c888SYinghai Lu 		(NR_VECTORS + CPU_VECTOR_LIMIT)  :	\
1799959c888SYinghai Lu 		(NR_VECTORS + IO_APIC_VECTOR_LIMIT))
1800b8f1efaSYinghai Lu # endif
1813e92ab3dSIngo Molnar #else /* !CONFIG_X86_IO_APIC: */
182009eb3feSIngo Molnar # define NR_IRQS			NR_IRQS_LEGACY
183bb898558SAl Viro #endif
184bb898558SAl Viro 
1851965aae3SH. Peter Anvin #endif /* _ASM_X86_IRQ_VECTORS_H */
186