1 #include <linux/linkage.h>
2 #include <linux/errno.h>
3 #include <linux/signal.h>
4 #include <linux/sched.h>
5 #include <linux/ioport.h>
6 #include <linux/interrupt.h>
7 #include <linux/timex.h>
8 #include <linux/slab.h>
9 #include <linux/random.h>
10 #include <linux/init.h>
11 #include <linux/kernel_stat.h>
12 #include <linux/sysdev.h>
13 #include <linux/bitops.h>
14 #include <linux/acpi.h>
16 #include <linux/delay.h>
18 #include <asm/atomic.h>
19 #include <asm/system.h>
20 #include <asm/timer.h>
21 #include <asm/hw_irq.h>
22 #include <asm/pgtable.h>
25 #include <asm/setup.h>
26 #include <asm/i8259.h>
27 #include <asm/traps.h>
30 * ISA PIC or low IO-APIC triggered (INTA-cycle or APIC) interrupts:
31 * (these are usually mapped to vectors 0x30-0x3f)
35 * The IO-APIC gives us many more interrupt sources. Most of these
36 * are unused but an SMP system is supposed to have enough memory ...
37 * sometimes (mostly wrt. hw bugs) we get corrupted vectors all
38 * across the spectrum, so we really want to be prepared to get all
39 * of these. Plus, more powerful systems might have more than 64
42 * (these are usually mapped into the 0x30-0xff vector range)
47 * Note that on a 486, we don't want to do a SIGFPE on an irq13
48 * as the irq is unreliable, and exception 16 works correctly
49 * (ie as explained in the intel literature). On a 386, you
50 * can't use exception 16 due to bad IBM design, so we have to
51 * rely on the less exact irq13.
53 * Careful.. Not only is IRQ13 unreliable, but it is also
54 * leads to races. IBM designers who came up with it should
58 static irqreturn_t
math_error_irq(int cpl
, void *dev_id
)
61 if (ignore_fpu_irq
|| !boot_cpu_data
.hard_math
)
63 math_error((void __user
*)get_irq_regs()->ip
);
68 * New motherboards sometimes make IRQ 13 be a PCI interrupt,
69 * so allow interrupt sharing.
71 static struct irqaction fpu_irq
= {
72 .handler
= math_error_irq
,
78 * IRQ2 is cascade interrupt to second interrupt controller
80 static struct irqaction irq2
= {
85 DEFINE_PER_CPU(vector_irq_t
, vector_irq
) = {
86 [0 ... IRQ0_VECTOR
- 1] = -1,
103 [IRQ15_VECTOR
+ 1 ... NR_VECTORS
- 1] = -1
106 int vector_used_by_percpu_irq(unsigned int vector
)
110 for_each_online_cpu(cpu
) {
111 if (per_cpu(vector_irq
, cpu
)[vector
] != -1)
118 static void __init
init_ISA_irqs(void)
122 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_LOCAL_APIC)
128 * 16 old-style INTA-cycle interrupts:
130 for (i
= 0; i
< NR_IRQS_LEGACY
; i
++) {
131 struct irq_desc
*desc
= irq_to_desc(i
);
133 desc
->status
= IRQ_DISABLED
;
137 set_irq_chip_and_handler_name(i
, &i8259A_chip
,
138 handle_level_irq
, "XT");
142 /* Overridden in paravirt.c */
143 void init_IRQ(void) __attribute__((weak
, alias("native_init_IRQ")));
145 static void __init
smp_intr_init(void)
148 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_LOCAL_APIC)
150 * The reschedule interrupt is a CPU-to-CPU reschedule-helper
151 * IPI, driven by wakeup.
153 alloc_intr_gate(RESCHEDULE_VECTOR
, reschedule_interrupt
);
155 /* IPIs for invalidation */
156 alloc_intr_gate(INVALIDATE_TLB_VECTOR_START
+0, invalidate_interrupt0
);
157 alloc_intr_gate(INVALIDATE_TLB_VECTOR_START
+1, invalidate_interrupt1
);
158 alloc_intr_gate(INVALIDATE_TLB_VECTOR_START
+2, invalidate_interrupt2
);
159 alloc_intr_gate(INVALIDATE_TLB_VECTOR_START
+3, invalidate_interrupt3
);
160 alloc_intr_gate(INVALIDATE_TLB_VECTOR_START
+4, invalidate_interrupt4
);
161 alloc_intr_gate(INVALIDATE_TLB_VECTOR_START
+5, invalidate_interrupt5
);
162 alloc_intr_gate(INVALIDATE_TLB_VECTOR_START
+6, invalidate_interrupt6
);
163 alloc_intr_gate(INVALIDATE_TLB_VECTOR_START
+7, invalidate_interrupt7
);
165 /* IPI for generic function call */
166 alloc_intr_gate(CALL_FUNCTION_VECTOR
, call_function_interrupt
);
168 /* IPI for generic single function call */
169 alloc_intr_gate(CALL_FUNCTION_SINGLE_VECTOR
,
170 call_function_single_interrupt
);
172 /* Low priority IPI to cleanup after moving an irq */
173 set_intr_gate(IRQ_MOVE_CLEANUP_VECTOR
, irq_move_cleanup_interrupt
);
174 set_bit(IRQ_MOVE_CLEANUP_VECTOR
, used_vectors
);
176 #endif /* CONFIG_SMP */
179 static void __init
apic_intr_init(void)
184 alloc_intr_gate(THERMAL_APIC_VECTOR
, thermal_interrupt
);
185 alloc_intr_gate(THRESHOLD_APIC_VECTOR
, threshold_interrupt
);
188 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_LOCAL_APIC)
189 /* self generated IPI for local APIC timer */
190 alloc_intr_gate(LOCAL_TIMER_VECTOR
, apic_timer_interrupt
);
192 /* generic IPI for platform specific use */
193 alloc_intr_gate(GENERIC_INTERRUPT_VECTOR
, generic_interrupt
);
195 /* IPI vectors for APIC spurious and error interrupts */
196 alloc_intr_gate(SPURIOUS_APIC_VECTOR
, spurious_interrupt
);
197 alloc_intr_gate(ERROR_APIC_VECTOR
, error_interrupt
);
201 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_MCE_P4THERMAL)
202 /* thermal monitor LVT interrupt */
203 alloc_intr_gate(THERMAL_APIC_VECTOR
, thermal_interrupt
);
210 * x86_quirk_pre_intr_init - initialisation prior to setting up interrupt vectors
213 * Perform any necessary interrupt initialisation prior to setting up
214 * the "ordinary" interrupt call gates. For legacy reasons, the ISA
215 * interrupts should be initialised here if the machine emulates a PC
218 static void __init
x86_quirk_pre_intr_init(void)
220 if (x86_quirks
->arch_pre_intr_init
) {
221 if (x86_quirks
->arch_pre_intr_init())
228 void __init
native_init_IRQ(void)
233 /* Execute any quirks before the call gates are initialised: */
234 x86_quirk_pre_intr_init();
240 * Cover the whole vector space, no vector can escape
241 * us. (some of these will be overridden and become
242 * 'special' SMP interrupts)
244 for (i
= FIRST_EXTERNAL_VECTOR
; i
< NR_VECTORS
; i
++) {
245 /* IA32_SYSCALL_VECTOR was reserved in trap_init. */
246 if (i
!= IA32_SYSCALL_VECTOR
)
247 set_intr_gate(i
, interrupt
[i
-FIRST_EXTERNAL_VECTOR
]);
257 * Call quirks after call gates are initialised (usually add in
258 * the architecture specific gates):
260 x86_quirk_intr_init();
263 * External FPU? Set up irq13 if so, for
264 * original braindamaged IBM FERR coupling.
266 if (boot_cpu_data
.hard_math
&& !cpu_has_fpu
)
267 setup_irq(FPU_IRQ
, &fpu_irq
);
269 irq_ctx_init(smp_processor_id());