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/hw_irq.h>
21 #include <asm/pgtable.h>
24 #include <asm/i8259.h>
27 * ISA PIC or low IO-APIC triggered (INTA-cycle or APIC) interrupts:
28 * (these are usually mapped to vectors 0x30-0x3f)
32 * The IO-APIC gives us many more interrupt sources. Most of these
33 * are unused but an SMP system is supposed to have enough memory ...
34 * sometimes (mostly wrt. hw bugs) we get corrupted vectors all
35 * across the spectrum, so we really want to be prepared to get all
36 * of these. Plus, more powerful systems might have more than 64
39 * (these are usually mapped into the 0x30-0xff vector range)
44 * Note that on a 486, we don't want to do a SIGFPE on an irq13
45 * as the irq is unreliable, and exception 16 works correctly
46 * (ie as explained in the intel literature). On a 386, you
47 * can't use exception 16 due to bad IBM design, so we have to
48 * rely on the less exact irq13.
50 * Careful.. Not only is IRQ13 unreliable, but it is also
51 * leads to races. IBM designers who came up with it should
55 static irqreturn_t
math_error_irq(int cpl
, void *dev_id
)
58 if (ignore_fpu_irq
|| !boot_cpu_data
.hard_math
)
60 math_error((void __user
*)get_irq_regs()->ip
);
65 * New motherboards sometimes make IRQ 13 be a PCI interrupt,
66 * so allow interrupt sharing.
68 static struct irqaction fpu_irq
= {
69 .handler
= math_error_irq
,
75 * IRQ2 is cascade interrupt to second interrupt controller
77 static struct irqaction irq2
= {
82 DEFINE_PER_CPU(vector_irq_t
, vector_irq
) = {
83 [0 ... IRQ0_VECTOR
- 1] = -1,
100 [IRQ15_VECTOR
+ 1 ... NR_VECTORS
- 1] = -1
103 int vector_used_by_percpu_irq(unsigned int vector
)
107 for_each_online_cpu(cpu
) {
108 if (per_cpu(vector_irq
, cpu
)[vector
] != -1)
115 static void __init
init_ISA_irqs(void)
119 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_LOCAL_APIC)
125 * 16 old-style INTA-cycle interrupts:
127 for (i
= 0; i
< NR_IRQS_LEGACY
; i
++) {
128 struct irq_desc
*desc
= irq_to_desc(i
);
130 desc
->status
= IRQ_DISABLED
;
134 set_irq_chip_and_handler_name(i
, &i8259A_chip
,
135 handle_level_irq
, "XT");
139 void init_IRQ(void) __attribute__((weak
, alias("native_init_IRQ")));
141 static void __init
smp_intr_init(void)
144 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_LOCAL_APIC)
146 * The reschedule interrupt is a CPU-to-CPU reschedule-helper
147 * IPI, driven by wakeup.
149 alloc_intr_gate(RESCHEDULE_VECTOR
, reschedule_interrupt
);
151 /* IPIs for invalidation */
152 alloc_intr_gate(INVALIDATE_TLB_VECTOR_START
+0, invalidate_interrupt0
);
153 alloc_intr_gate(INVALIDATE_TLB_VECTOR_START
+1, invalidate_interrupt1
);
154 alloc_intr_gate(INVALIDATE_TLB_VECTOR_START
+2, invalidate_interrupt2
);
155 alloc_intr_gate(INVALIDATE_TLB_VECTOR_START
+3, invalidate_interrupt3
);
156 alloc_intr_gate(INVALIDATE_TLB_VECTOR_START
+4, invalidate_interrupt4
);
157 alloc_intr_gate(INVALIDATE_TLB_VECTOR_START
+5, invalidate_interrupt5
);
158 alloc_intr_gate(INVALIDATE_TLB_VECTOR_START
+6, invalidate_interrupt6
);
159 alloc_intr_gate(INVALIDATE_TLB_VECTOR_START
+7, invalidate_interrupt7
);
161 /* IPI for generic function call */
162 alloc_intr_gate(CALL_FUNCTION_VECTOR
, call_function_interrupt
);
164 /* IPI for generic single function call */
165 alloc_intr_gate(CALL_FUNCTION_SINGLE_VECTOR
,
166 call_function_single_interrupt
);
168 /* Low priority IPI to cleanup after moving an irq */
169 set_intr_gate(IRQ_MOVE_CLEANUP_VECTOR
, irq_move_cleanup_interrupt
);
170 set_bit(IRQ_MOVE_CLEANUP_VECTOR
, used_vectors
);
172 #endif /* CONFIG_SMP */
175 static void __init
apic_intr_init(void)
179 alloc_intr_gate(THERMAL_APIC_VECTOR
, thermal_interrupt
);
180 alloc_intr_gate(THRESHOLD_APIC_VECTOR
, threshold_interrupt
);
182 /* self generated IPI for local APIC timer */
183 alloc_intr_gate(LOCAL_TIMER_VECTOR
, apic_timer_interrupt
);
185 /* generic IPI for platform specific use */
186 alloc_intr_gate(GENERIC_INTERRUPT_VECTOR
, generic_interrupt
);
188 /* IPI vectors for APIC spurious and error interrupts */
189 alloc_intr_gate(SPURIOUS_APIC_VECTOR
, spurious_interrupt
);
190 alloc_intr_gate(ERROR_APIC_VECTOR
, error_interrupt
);
195 * x86_quirk_pre_intr_init - initialisation prior to setting up interrupt vectors
198 * Perform any necessary interrupt initialisation prior to setting up
199 * the "ordinary" interrupt call gates. For legacy reasons, the ISA
200 * interrupts should be initialised here if the machine emulates a PC
203 static void __init
x86_quirk_pre_intr_init(void)
205 if (x86_quirks
->arch_pre_intr_init
) {
206 if (x86_quirks
->arch_pre_intr_init())
213 void __init
native_init_IRQ(void)
218 /* Execute any quirks before the call gates are initialised: */
219 x86_quirk_pre_intr_init();
225 * Cover the whole vector space, no vector can escape
226 * us. (some of these will be overridden and become
227 * 'special' SMP interrupts)
229 for (i
= FIRST_EXTERNAL_VECTOR
; i
< NR_VECTORS
; i
++) {
231 /* SYSCALL_VECTOR was reserved in trap_init. */
232 if (i
!= SYSCALL_VECTOR
)
233 set_intr_gate(i
, interrupt
[i
-FIRST_EXTERNAL_VECTOR
]);
235 /* IA32_SYSCALL_VECTOR was reserved in trap_init. */
236 if (i
!= IA32_SYSCALL_VECTOR
)
237 set_intr_gate(i
, interrupt
[i
-FIRST_EXTERNAL_VECTOR
]);
248 * Call quirks after call gates are initialised (usually add in
249 * the architecture specific gates):
251 x86_quirk_intr_init();
254 * External FPU? Set up irq13 if so, for
255 * original braindamaged IBM FERR coupling.
257 if (boot_cpu_data
.hard_math
&& !cpu_has_fpu
)
258 setup_irq(FPU_IRQ
, &fpu_irq
);
260 irq_ctx_init(smp_processor_id());