xref: /openbmc/linux/arch/x86/include/asm/hw_irq.h (revision afb46f79)
1 #ifndef _ASM_X86_HW_IRQ_H
2 #define _ASM_X86_HW_IRQ_H
3 
4 /*
5  * (C) 1992, 1993 Linus Torvalds, (C) 1997 Ingo Molnar
6  *
7  * moved some of the old arch/i386/kernel/irq.h to here. VY
8  *
9  * IRQ/IPI changes taken from work by Thomas Radke
10  * <tomsoft@informatik.tu-chemnitz.de>
11  *
12  * hacked by Andi Kleen for x86-64.
13  * unified by tglx
14  */
15 
16 #include <asm/irq_vectors.h>
17 
18 #ifndef __ASSEMBLY__
19 
20 #include <linux/percpu.h>
21 #include <linux/profile.h>
22 #include <linux/smp.h>
23 
24 #include <linux/atomic.h>
25 #include <asm/irq.h>
26 #include <asm/sections.h>
27 
28 /* Interrupt handlers registered during init_IRQ */
29 extern asmlinkage void apic_timer_interrupt(void);
30 extern asmlinkage void x86_platform_ipi(void);
31 extern asmlinkage void kvm_posted_intr_ipi(void);
32 extern asmlinkage void error_interrupt(void);
33 extern asmlinkage void irq_work_interrupt(void);
34 
35 extern asmlinkage void spurious_interrupt(void);
36 extern asmlinkage void thermal_interrupt(void);
37 extern asmlinkage void reschedule_interrupt(void);
38 
39 extern asmlinkage void invalidate_interrupt(void);
40 extern asmlinkage void invalidate_interrupt0(void);
41 extern asmlinkage void invalidate_interrupt1(void);
42 extern asmlinkage void invalidate_interrupt2(void);
43 extern asmlinkage void invalidate_interrupt3(void);
44 extern asmlinkage void invalidate_interrupt4(void);
45 extern asmlinkage void invalidate_interrupt5(void);
46 extern asmlinkage void invalidate_interrupt6(void);
47 extern asmlinkage void invalidate_interrupt7(void);
48 extern asmlinkage void invalidate_interrupt8(void);
49 extern asmlinkage void invalidate_interrupt9(void);
50 extern asmlinkage void invalidate_interrupt10(void);
51 extern asmlinkage void invalidate_interrupt11(void);
52 extern asmlinkage void invalidate_interrupt12(void);
53 extern asmlinkage void invalidate_interrupt13(void);
54 extern asmlinkage void invalidate_interrupt14(void);
55 extern asmlinkage void invalidate_interrupt15(void);
56 extern asmlinkage void invalidate_interrupt16(void);
57 extern asmlinkage void invalidate_interrupt17(void);
58 extern asmlinkage void invalidate_interrupt18(void);
59 extern asmlinkage void invalidate_interrupt19(void);
60 extern asmlinkage void invalidate_interrupt20(void);
61 extern asmlinkage void invalidate_interrupt21(void);
62 extern asmlinkage void invalidate_interrupt22(void);
63 extern asmlinkage void invalidate_interrupt23(void);
64 extern asmlinkage void invalidate_interrupt24(void);
65 extern asmlinkage void invalidate_interrupt25(void);
66 extern asmlinkage void invalidate_interrupt26(void);
67 extern asmlinkage void invalidate_interrupt27(void);
68 extern asmlinkage void invalidate_interrupt28(void);
69 extern asmlinkage void invalidate_interrupt29(void);
70 extern asmlinkage void invalidate_interrupt30(void);
71 extern asmlinkage void invalidate_interrupt31(void);
72 
73 extern asmlinkage void irq_move_cleanup_interrupt(void);
74 extern asmlinkage void reboot_interrupt(void);
75 extern asmlinkage void threshold_interrupt(void);
76 
77 extern asmlinkage void call_function_interrupt(void);
78 extern asmlinkage void call_function_single_interrupt(void);
79 
80 #ifdef CONFIG_TRACING
81 /* Interrupt handlers registered during init_IRQ */
82 extern void trace_apic_timer_interrupt(void);
83 extern void trace_x86_platform_ipi(void);
84 extern void trace_error_interrupt(void);
85 extern void trace_irq_work_interrupt(void);
86 extern void trace_spurious_interrupt(void);
87 extern void trace_thermal_interrupt(void);
88 extern void trace_reschedule_interrupt(void);
89 extern void trace_threshold_interrupt(void);
90 extern void trace_call_function_interrupt(void);
91 extern void trace_call_function_single_interrupt(void);
92 #define trace_irq_move_cleanup_interrupt  irq_move_cleanup_interrupt
93 #define trace_reboot_interrupt  reboot_interrupt
94 #define trace_kvm_posted_intr_ipi kvm_posted_intr_ipi
95 #endif /* CONFIG_TRACING */
96 
97 /* IOAPIC */
98 #define IO_APIC_IRQ(x) (((x) >= NR_IRQS_LEGACY) || ((1<<(x)) & io_apic_irqs))
99 extern unsigned long io_apic_irqs;
100 
101 extern void setup_IO_APIC(void);
102 extern void disable_IO_APIC(void);
103 
104 struct io_apic_irq_attr {
105 	int ioapic;
106 	int ioapic_pin;
107 	int trigger;
108 	int polarity;
109 };
110 
111 static inline void set_io_apic_irq_attr(struct io_apic_irq_attr *irq_attr,
112 					int ioapic, int ioapic_pin,
113 					int trigger, int polarity)
114 {
115 	irq_attr->ioapic	= ioapic;
116 	irq_attr->ioapic_pin	= ioapic_pin;
117 	irq_attr->trigger	= trigger;
118 	irq_attr->polarity	= polarity;
119 }
120 
121 /* Intel specific interrupt remapping information */
122 struct irq_2_iommu {
123 	struct intel_iommu *iommu;
124 	u16 irte_index;
125 	u16 sub_handle;
126 	u8  irte_mask;
127 };
128 
129 /* AMD specific interrupt remapping information */
130 struct irq_2_irte {
131 	u16 devid; /* Device ID for IRTE table */
132 	u16 index; /* Index into IRTE table*/
133 };
134 
135 /*
136  * This is performance-critical, we want to do it O(1)
137  *
138  * Most irqs are mapped 1:1 with pins.
139  */
140 struct irq_cfg {
141 	struct irq_pin_list	*irq_2_pin;
142 	cpumask_var_t		domain;
143 	cpumask_var_t		old_domain;
144 	u8			vector;
145 	u8			move_in_progress : 1;
146 #ifdef CONFIG_IRQ_REMAP
147 	u8			remapped : 1;
148 	union {
149 		struct irq_2_iommu irq_2_iommu;
150 		struct irq_2_irte  irq_2_irte;
151 	};
152 #endif
153 };
154 
155 extern int assign_irq_vector(int, struct irq_cfg *, const struct cpumask *);
156 extern void send_cleanup_vector(struct irq_cfg *);
157 
158 struct irq_data;
159 int __ioapic_set_affinity(struct irq_data *, const struct cpumask *,
160 			  unsigned int *dest_id);
161 extern int IO_APIC_get_PCI_irq_vector(int bus, int devfn, int pin, struct io_apic_irq_attr *irq_attr);
162 extern void setup_ioapic_dest(void);
163 
164 extern void enable_IO_APIC(void);
165 
166 /* Statistics */
167 extern atomic_t irq_err_count;
168 extern atomic_t irq_mis_count;
169 
170 /* EISA */
171 extern void eisa_set_level_irq(unsigned int irq);
172 
173 /* SMP */
174 extern __visible void smp_apic_timer_interrupt(struct pt_regs *);
175 extern __visible void smp_spurious_interrupt(struct pt_regs *);
176 extern __visible void smp_x86_platform_ipi(struct pt_regs *);
177 extern __visible void smp_error_interrupt(struct pt_regs *);
178 #ifdef CONFIG_X86_IO_APIC
179 extern asmlinkage void smp_irq_move_cleanup_interrupt(void);
180 #endif
181 #ifdef CONFIG_SMP
182 extern __visible void smp_reschedule_interrupt(struct pt_regs *);
183 extern __visible void smp_call_function_interrupt(struct pt_regs *);
184 extern __visible void smp_call_function_single_interrupt(struct pt_regs *);
185 extern __visible void smp_invalidate_interrupt(struct pt_regs *);
186 #endif
187 
188 extern void (*__initconst interrupt[NR_VECTORS-FIRST_EXTERNAL_VECTOR])(void);
189 #ifdef CONFIG_TRACING
190 #define trace_interrupt interrupt
191 #endif
192 
193 #define VECTOR_UNDEFINED	-1
194 #define VECTOR_RETRIGGERED	-2
195 
196 typedef int vector_irq_t[NR_VECTORS];
197 DECLARE_PER_CPU(vector_irq_t, vector_irq);
198 extern void setup_vector_irq(int cpu);
199 
200 #ifdef CONFIG_X86_IO_APIC
201 extern void lock_vector_lock(void);
202 extern void unlock_vector_lock(void);
203 extern void __setup_vector_irq(int cpu);
204 #else
205 static inline void lock_vector_lock(void) {}
206 static inline void unlock_vector_lock(void) {}
207 static inline void __setup_vector_irq(int cpu) {}
208 #endif
209 
210 #endif /* !ASSEMBLY_ */
211 
212 #endif /* _ASM_X86_HW_IRQ_H */
213