11965aae3SH. Peter Anvin #ifndef _ASM_X86_IRQ_VECTORS_H 21965aae3SH. Peter Anvin #define _ASM_X86_IRQ_VECTORS_H 3bb898558SAl Viro 49fc2e79dSIngo Molnar /* 59fc2e79dSIngo Molnar * Linux IRQ vector layout. 69fc2e79dSIngo Molnar * 79fc2e79dSIngo Molnar * There are 256 IDT entries (per CPU - each entry is 8 bytes) which can 89fc2e79dSIngo Molnar * be defined by Linux. They are used as a jump table by the CPU when a 99fc2e79dSIngo Molnar * given vector is triggered - by a CPU-external, CPU-internal or 109fc2e79dSIngo Molnar * software-triggered event. 119fc2e79dSIngo Molnar * 129fc2e79dSIngo Molnar * Linux sets the kernel code address each entry jumps to early during 139fc2e79dSIngo Molnar * bootup, and never changes them. This is the general layout of the 149fc2e79dSIngo Molnar * IDT entries: 159fc2e79dSIngo Molnar * 169fc2e79dSIngo Molnar * Vectors 0 ... 31 : system traps and exceptions - hardcoded events 179fc2e79dSIngo Molnar * Vectors 32 ... 127 : device interrupts 189fc2e79dSIngo Molnar * Vector 128 : legacy int80 syscall interface 199fc2e79dSIngo Molnar * Vectors 129 ... 237 : device interrupts 209fc2e79dSIngo Molnar * Vectors 238 ... 255 : special interrupts 219fc2e79dSIngo Molnar * 229fc2e79dSIngo Molnar * 64-bit x86 has per CPU IDT tables, 32-bit has one shared IDT table. 239fc2e79dSIngo Molnar * 249fc2e79dSIngo Molnar * This file enumerates the exact layout of them: 259fc2e79dSIngo Molnar */ 269fc2e79dSIngo Molnar 27bb898558SAl Viro #define NMI_VECTOR 0x02 28bb898558SAl Viro 29bb898558SAl Viro /* 30bb898558SAl Viro * IDT vectors usable for external interrupt sources start 31bb898558SAl Viro * at 0x20: 32bb898558SAl Viro */ 33bb898558SAl Viro #define FIRST_EXTERNAL_VECTOR 0x20 34bb898558SAl Viro 35bb898558SAl Viro #ifdef CONFIG_X86_32 36bb898558SAl Viro # define SYSCALL_VECTOR 0x80 37bb898558SAl Viro #else 38bb898558SAl Viro # define IA32_SYSCALL_VECTOR 0x80 39bb898558SAl Viro #endif 40bb898558SAl Viro 41bb898558SAl Viro /* 42bb898558SAl Viro * Reserve the lowest usable priority level 0x20 - 0x2f for triggering 43bb898558SAl Viro * cleanup after irq migration. 44bb898558SAl Viro */ 45bb898558SAl Viro #define IRQ_MOVE_CLEANUP_VECTOR FIRST_EXTERNAL_VECTOR 46bb898558SAl Viro 47bb898558SAl Viro /* 48bb898558SAl Viro * Vectors 0x30-0x3f are used for ISA interrupts. 49bb898558SAl Viro */ 50bb898558SAl Viro #define IRQ0_VECTOR (FIRST_EXTERNAL_VECTOR + 0x10) 519fc2e79dSIngo Molnar 52bb898558SAl Viro #define IRQ1_VECTOR (IRQ0_VECTOR + 1) 53bb898558SAl Viro #define IRQ2_VECTOR (IRQ0_VECTOR + 2) 54bb898558SAl Viro #define IRQ3_VECTOR (IRQ0_VECTOR + 3) 55bb898558SAl Viro #define IRQ4_VECTOR (IRQ0_VECTOR + 4) 56bb898558SAl Viro #define IRQ5_VECTOR (IRQ0_VECTOR + 5) 57bb898558SAl Viro #define IRQ6_VECTOR (IRQ0_VECTOR + 6) 58bb898558SAl Viro #define IRQ7_VECTOR (IRQ0_VECTOR + 7) 59bb898558SAl Viro #define IRQ8_VECTOR (IRQ0_VECTOR + 8) 60bb898558SAl Viro #define IRQ9_VECTOR (IRQ0_VECTOR + 9) 61bb898558SAl Viro #define IRQ10_VECTOR (IRQ0_VECTOR + 10) 62bb898558SAl Viro #define IRQ11_VECTOR (IRQ0_VECTOR + 11) 63bb898558SAl Viro #define IRQ12_VECTOR (IRQ0_VECTOR + 12) 64bb898558SAl Viro #define IRQ13_VECTOR (IRQ0_VECTOR + 13) 65bb898558SAl Viro #define IRQ14_VECTOR (IRQ0_VECTOR + 14) 66bb898558SAl Viro #define IRQ15_VECTOR (IRQ0_VECTOR + 15) 67bb898558SAl Viro 68bb898558SAl Viro /* 69bb898558SAl Viro * Special IRQ vectors used by the SMP architecture, 0xf0-0xff 70bb898558SAl Viro * 71bb898558SAl Viro * some of the following vectors are 'rare', they are merged 72bb898558SAl Viro * into a single vector (CALL_FUNCTION_VECTOR) to save vector space. 73bb898558SAl Viro * TLB, reschedule and local APIC vectors are performance-critical. 74bb898558SAl Viro */ 755da690d2SIngo Molnar 765da690d2SIngo Molnar #define SPURIOUS_APIC_VECTOR 0xff 77647ad94fSIngo Molnar /* 78647ad94fSIngo Molnar * Sanity check 79647ad94fSIngo Molnar */ 80647ad94fSIngo Molnar #if ((SPURIOUS_APIC_VECTOR & 0x0F) != 0x0F) 81647ad94fSIngo Molnar # error SPURIOUS_APIC_VECTOR definition error 82647ad94fSIngo Molnar #endif 83647ad94fSIngo Molnar 845da690d2SIngo Molnar #define ERROR_APIC_VECTOR 0xfe 855da690d2SIngo Molnar #define RESCHEDULE_VECTOR 0xfd 865da690d2SIngo Molnar #define CALL_FUNCTION_VECTOR 0xfc 875da690d2SIngo Molnar #define CALL_FUNCTION_SINGLE_VECTOR 0xfb 885da690d2SIngo Molnar #define THERMAL_APIC_VECTOR 0xfa 895da690d2SIngo Molnar 90bb898558SAl Viro #ifdef CONFIG_X86_32 9102cf94c3STejun Heo /* 0xf8 - 0xf9 : free */ 92bb898558SAl Viro #else 93bb898558SAl Viro # define THRESHOLD_APIC_VECTOR 0xf9 94bb898558SAl Viro # define UV_BAU_MESSAGE 0xf8 95bb898558SAl Viro #endif 96bb898558SAl Viro 975da690d2SIngo Molnar /* f0-f7 used for spreading out TLB flushes: */ 985da690d2SIngo Molnar #define INVALIDATE_TLB_VECTOR_END 0xf7 995da690d2SIngo Molnar #define INVALIDATE_TLB_VECTOR_START 0xf0 1005da690d2SIngo Molnar #define NUM_INVALIDATE_TLB_VECTORS 8 1015da690d2SIngo Molnar 102bb898558SAl Viro /* 103bb898558SAl Viro * Local APIC timer IRQ vector is on a different priority level, 104bb898558SAl Viro * to work around the 'lost local interrupt if more than 2 IRQ 105bb898558SAl Viro * sources per level' errata. 106bb898558SAl Viro */ 107bb898558SAl Viro #define LOCAL_TIMER_VECTOR 0xef 108bb898558SAl Viro 109bb898558SAl Viro /* 110193c81b9SIngo Molnar * Performance monitoring interrupt vector: 111193c81b9SIngo Molnar */ 112193c81b9SIngo Molnar #define LOCAL_PERF_VECTOR 0xee 113193c81b9SIngo Molnar 114193c81b9SIngo Molnar /* 115bb898558SAl Viro * First APIC vector available to drivers: (vectors 0x30-0xee) we 116bb898558SAl Viro * start at 0x31(0x41) to spread out vectors evenly between priority 117bb898558SAl Viro * levels. (0x80 is the syscall vector) 118bb898558SAl Viro */ 119bb898558SAl Viro #define FIRST_DEVICE_VECTOR (IRQ15_VECTOR + 2) 120bb898558SAl Viro 121bb898558SAl Viro #define NR_VECTORS 256 122bb898558SAl Viro 123bb898558SAl Viro #define FPU_IRQ 13 124bb898558SAl Viro 125bb898558SAl Viro #define FIRST_VM86_IRQ 3 126bb898558SAl Viro #define LAST_VM86_IRQ 15 127d8106d2eSIngo Molnar 128d8106d2eSIngo Molnar #ifndef __ASSEMBLY__ 129d8106d2eSIngo Molnar static inline int invalid_vm86_irq(int irq) 130d8106d2eSIngo Molnar { 13157e37293SCyrill Gorcunov return irq < FIRST_VM86_IRQ || irq > LAST_VM86_IRQ; 132d8106d2eSIngo Molnar } 133d8106d2eSIngo Molnar #endif 134bb898558SAl Viro 135009eb3feSIngo Molnar /* 136009eb3feSIngo Molnar * Size the maximum number of interrupts. 137009eb3feSIngo Molnar * 138009eb3feSIngo Molnar * If the irq_desc[] array has a sparse layout, we can size things 139009eb3feSIngo Molnar * generously - it scales up linearly with the maximum number of CPUs, 140009eb3feSIngo Molnar * and the maximum number of IO-APICs, whichever is higher. 141009eb3feSIngo Molnar * 142009eb3feSIngo Molnar * In other cases we size more conservatively, to not create too large 143009eb3feSIngo Molnar * static arrays. 144009eb3feSIngo Molnar */ 145009eb3feSIngo Molnar 14699d093d1SYinghai Lu #define NR_IRQS_LEGACY 16 14799d093d1SYinghai Lu 148009eb3feSIngo Molnar #define CPU_VECTOR_LIMIT ( 8 * NR_CPUS ) 149009eb3feSIngo Molnar #define IO_APIC_VECTOR_LIMIT ( 32 * MAX_IO_APICS ) 150009eb3feSIngo Molnar 1513e92ab3dSIngo Molnar #ifdef CONFIG_X86_IO_APIC 152009eb3feSIngo Molnar # ifdef CONFIG_SPARSE_IRQ 1534a046d17SYinghai Lu # define NR_IRQS \ 154009eb3feSIngo Molnar (CPU_VECTOR_LIMIT > IO_APIC_VECTOR_LIMIT ? \ 155009eb3feSIngo Molnar (NR_VECTORS + CPU_VECTOR_LIMIT) : \ 156009eb3feSIngo Molnar (NR_VECTORS + IO_APIC_VECTOR_LIMIT)) 157009eb3feSIngo Molnar # else 158009eb3feSIngo Molnar # if NR_CPUS < MAX_IO_APICS 159009eb3feSIngo Molnar # define NR_IRQS (NR_VECTORS + 4*CPU_VECTOR_LIMIT) 160009eb3feSIngo Molnar # else 161009eb3feSIngo Molnar # define NR_IRQS (NR_VECTORS + IO_APIC_VECTOR_LIMIT) 162009eb3feSIngo Molnar # endif 1630b8f1efaSYinghai Lu # endif 1643e92ab3dSIngo Molnar #else /* !CONFIG_X86_IO_APIC: */ 165009eb3feSIngo Molnar # define NR_IRQS NR_IRQS_LEGACY 166bb898558SAl Viro #endif 167bb898558SAl Viro 1681965aae3SH. Peter Anvin #endif /* _ASM_X86_IRQ_VECTORS_H */ 169