blob: 8670b3ce626e7ee6bf0d379c610959a699d79aef [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#include <linux/linkage.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#include <linux/init.h>
11#include <linux/kernel_stat.h>
12#include <linux/sysdev.h>
13#include <linux/bitops.h>
14
15#include <asm/acpi.h>
16#include <asm/atomic.h>
17#include <asm/system.h>
18#include <asm/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <asm/hw_irq.h>
20#include <asm/pgtable.h>
21#include <asm/delay.h>
22#include <asm/desc.h>
23#include <asm/apic.h>
Paul Jimenez2b8e05b2008-01-30 13:30:29 +010024#include <asm/i8259.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
Linus Torvalds1da177e2005-04-16 15:20:36 -070026/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070027 * ISA PIC or low IO-APIC triggered (INTA-cycle or APIC) interrupts:
Yinghai Luc97beb42007-03-28 23:10:29 -060028 * (these are usually mapped to vectors 0x30-0x3f)
Linus Torvalds1da177e2005-04-16 15:20:36 -070029 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
Linus Torvalds1da177e2005-04-16 15:20:36 -070031/*
Paul Jimenez2b8e05b2008-01-30 13:30:29 +010032 * The IO-APIC gives us many more interrupt sources. Most of these
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 * 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
37 * IO-APIC registers.
38 *
39 * (these are usually mapped into the 0x30-0xff vector range)
40 */
Paul Jimenez2b8e05b2008-01-30 13:30:29 +010041
Linus Torvalds1da177e2005-04-16 15:20:36 -070042/*
43 * IRQ2 is cascade interrupt to second interrupt controller
44 */
45
Thomas Gleixnerdf5ddf62007-10-17 18:04:36 +020046static struct irqaction irq2 = {
47 .handler = no_action,
48 .mask = CPU_MASK_NONE,
49 .name = "cascade",
50};
Eric W. Biederman550f2292006-10-04 02:16:51 -070051DEFINE_PER_CPU(vector_irq_t, vector_irq) = {
Eric W. Biedermanbc5e81a2007-02-23 04:38:26 -070052 [0 ... IRQ0_VECTOR - 1] = -1,
53 [IRQ0_VECTOR] = 0,
54 [IRQ1_VECTOR] = 1,
55 [IRQ2_VECTOR] = 2,
56 [IRQ3_VECTOR] = 3,
57 [IRQ4_VECTOR] = 4,
58 [IRQ5_VECTOR] = 5,
59 [IRQ6_VECTOR] = 6,
60 [IRQ7_VECTOR] = 7,
61 [IRQ8_VECTOR] = 8,
62 [IRQ9_VECTOR] = 9,
63 [IRQ10_VECTOR] = 10,
64 [IRQ11_VECTOR] = 11,
65 [IRQ12_VECTOR] = 12,
66 [IRQ13_VECTOR] = 13,
67 [IRQ14_VECTOR] = 14,
68 [IRQ15_VECTOR] = 15,
69 [IRQ15_VECTOR + 1 ... NR_VECTORS - 1] = -1
Eric W. Biedermane500f572006-10-04 02:16:50 -070070};
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
Glauber Costa780209a2008-07-11 15:12:39 -030072void __init init_ISA_irqs(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070073{
74 int i;
75
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 init_bsp_APIC();
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 init_8259A(0);
78
Yinghai Lu2c6927a2008-08-19 20:50:11 -070079 for (i = 0; i < 16; i++) {
Yinghai Lucb5bc832008-08-19 20:50:17 -070080 /* first time call this irq_desc */
Thomas Gleixneree32c972008-10-15 14:34:09 +020081 struct irq_desc *desc = irq_to_desc(i);
Yinghai Lu08678b02008-08-19 20:50:05 -070082
83 desc->status = IRQ_DISABLED;
84 desc->action = NULL;
85 desc->depth = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070086
Yinghai Lu2c6927a2008-08-19 20:50:11 -070087 /*
88 * 16 old-style INTA-cycle interrupts:
89 */
90 set_irq_chip_and_handler_name(i, &i8259A_chip,
Ingo Molnara460e742006-10-17 00:10:03 -070091 handle_level_irq, "XT");
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 }
93}
94
Glauber de Oliveira Costab0387832008-01-30 13:33:19 +010095void init_IRQ(void) __attribute__((weak, alias("native_init_IRQ")));
96
Yinghai Lu9b658f62008-09-25 22:22:12 -070097static void __init smp_intr_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070098{
Linus Torvalds1da177e2005-04-16 15:20:36 -070099#ifdef CONFIG_SMP
100 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101 * The reschedule interrupt is a CPU-to-CPU reschedule-helper
102 * IPI, driven by wakeup.
103 */
Alan Mayer305b92a2008-04-15 15:36:56 -0500104 alloc_intr_gate(RESCHEDULE_VECTOR, reschedule_interrupt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105
Andi Kleene5bc8b62005-09-12 18:49:24 +0200106 /* IPIs for invalidation */
Alan Mayer305b92a2008-04-15 15:36:56 -0500107 alloc_intr_gate(INVALIDATE_TLB_VECTOR_START+0, invalidate_interrupt0);
108 alloc_intr_gate(INVALIDATE_TLB_VECTOR_START+1, invalidate_interrupt1);
109 alloc_intr_gate(INVALIDATE_TLB_VECTOR_START+2, invalidate_interrupt2);
110 alloc_intr_gate(INVALIDATE_TLB_VECTOR_START+3, invalidate_interrupt3);
111 alloc_intr_gate(INVALIDATE_TLB_VECTOR_START+4, invalidate_interrupt4);
112 alloc_intr_gate(INVALIDATE_TLB_VECTOR_START+5, invalidate_interrupt5);
113 alloc_intr_gate(INVALIDATE_TLB_VECTOR_START+6, invalidate_interrupt6);
114 alloc_intr_gate(INVALIDATE_TLB_VECTOR_START+7, invalidate_interrupt7);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115
116 /* IPI for generic function call */
Alan Mayer305b92a2008-04-15 15:36:56 -0500117 alloc_intr_gate(CALL_FUNCTION_VECTOR, call_function_interrupt);
Eric W. Biederman61014292007-02-23 04:40:58 -0700118
Ingo Molnar1a781a72008-07-15 21:55:59 +0200119 /* IPI for generic single function call */
120 alloc_intr_gate(CALL_FUNCTION_SINGLE_VECTOR,
121 call_function_single_interrupt);
122
Eric W. Biederman61014292007-02-23 04:40:58 -0700123 /* Low priority IPI to cleanup after moving an irq */
124 set_intr_gate(IRQ_MOVE_CLEANUP_VECTOR, irq_move_cleanup_interrupt);
125#endif
Glauber Costa2f974352008-07-11 15:08:39 -0300126}
127
Yinghai Lu9b658f62008-09-25 22:22:12 -0700128static void __init apic_intr_init(void)
Glauber Costa2f974352008-07-11 15:08:39 -0300129{
Glauber Costa2f974352008-07-11 15:08:39 -0300130 smp_intr_init();
Glauber Costa2f974352008-07-11 15:08:39 -0300131
Alan Mayer305b92a2008-04-15 15:36:56 -0500132 alloc_intr_gate(THERMAL_APIC_VECTOR, thermal_interrupt);
133 alloc_intr_gate(THRESHOLD_APIC_VECTOR, threshold_interrupt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 /* self generated IPI for local APIC timer */
Alan Mayer305b92a2008-04-15 15:36:56 -0500136 alloc_intr_gate(LOCAL_TIMER_VECTOR, apic_timer_interrupt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137
138 /* IPI vectors for APIC spurious and error interrupts */
Alan Mayer305b92a2008-04-15 15:36:56 -0500139 alloc_intr_gate(SPURIOUS_APIC_VECTOR, spurious_interrupt);
140 alloc_intr_gate(ERROR_APIC_VECTOR, error_interrupt);
Glauber Costa2f974352008-07-11 15:08:39 -0300141}
142
143void __init native_init_IRQ(void)
144{
145 int i;
146
147 init_ISA_irqs();
148 /*
149 * Cover the whole vector space, no vector can escape
150 * us. (some of these will be overridden and become
151 * 'special' SMP interrupts)
152 */
153 for (i = 0; i < (NR_VECTORS - FIRST_EXTERNAL_VECTOR); i++) {
154 int vector = FIRST_EXTERNAL_VECTOR + i;
155 if (vector != IA32_SYSCALL_VECTOR)
156 set_intr_gate(vector, interrupt[i]);
157 }
158
159 apic_intr_init();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 if (!acpi_ioapic)
162 setup_irq(2, &irq2);
163}