Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * linux/arch/i386/kernel/irq.c | |
3 | * | |
4 | * Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar | |
5 | * | |
6 | * This file contains the lowest level x86-specific interrupt | |
7 | * entry, irq-stacks and irq statistics code. All the remaining | |
8 | * irq logic is done by the generic kernel/irq/ code and | |
9 | * by the x86-specific irq controller code. (e.g. i8259.c and | |
10 | * io_apic.c.) | |
11 | */ | |
12 | ||
13 | #include <asm/uaccess.h> | |
14 | #include <linux/module.h> | |
15 | #include <linux/seq_file.h> | |
16 | #include <linux/interrupt.h> | |
17 | #include <linux/kernel_stat.h> | |
f3705136 ZM |
18 | #include <linux/notifier.h> |
19 | #include <linux/cpu.h> | |
20 | #include <linux/delay.h> | |
1da177e4 | 21 | |
22fc6ecc | 22 | DEFINE_PER_CPU(irq_cpustat_t, irq_stat) ____cacheline_internodealigned_in_smp; |
1da177e4 LT |
23 | EXPORT_PER_CPU_SYMBOL(irq_stat); |
24 | ||
25 | #ifndef CONFIG_X86_LOCAL_APIC | |
26 | /* | |
27 | * 'what should we do if we get a hw irq event on an illegal vector'. | |
28 | * each architecture has to answer this themselves. | |
29 | */ | |
30 | void ack_bad_irq(unsigned int irq) | |
31 | { | |
32 | printk("unexpected IRQ trap at vector %02x\n", irq); | |
33 | } | |
34 | #endif | |
35 | ||
36 | #ifdef CONFIG_4KSTACKS | |
37 | /* | |
38 | * per-CPU IRQ handling contexts (thread information and stack) | |
39 | */ | |
40 | union irq_ctx { | |
41 | struct thread_info tinfo; | |
42 | u32 stack[THREAD_SIZE/sizeof(u32)]; | |
43 | }; | |
44 | ||
22722051 AM |
45 | static union irq_ctx *hardirq_ctx[NR_CPUS] __read_mostly; |
46 | static union irq_ctx *softirq_ctx[NR_CPUS] __read_mostly; | |
1da177e4 LT |
47 | #endif |
48 | ||
49 | /* | |
50 | * do_IRQ handles all normal device IRQ's (the special | |
51 | * SMP cross-CPU interrupts have their own specific | |
52 | * handlers). | |
53 | */ | |
54 | fastcall unsigned int do_IRQ(struct pt_regs *regs) | |
55 | { | |
19eadf98 RR |
56 | /* high bit used in ret_from_ code */ |
57 | int irq = ~regs->orig_eax; | |
1da177e4 LT |
58 | #ifdef CONFIG_4KSTACKS |
59 | union irq_ctx *curctx, *irqctx; | |
60 | u32 *isp; | |
61 | #endif | |
62 | ||
a052b68b AM |
63 | if (unlikely((unsigned)irq >= NR_IRQS)) { |
64 | printk(KERN_EMERG "%s: cannot handle IRQ %d\n", | |
65 | __FUNCTION__, irq); | |
66 | BUG(); | |
67 | } | |
68 | ||
1da177e4 LT |
69 | irq_enter(); |
70 | #ifdef CONFIG_DEBUG_STACKOVERFLOW | |
71 | /* Debugging check for stack overflow: is there less than 1KB free? */ | |
72 | { | |
73 | long esp; | |
74 | ||
75 | __asm__ __volatile__("andl %%esp,%0" : | |
76 | "=r" (esp) : "0" (THREAD_SIZE - 1)); | |
77 | if (unlikely(esp < (sizeof(struct thread_info) + STACK_WARN))) { | |
78 | printk("do_IRQ: stack overflow: %ld\n", | |
79 | esp - sizeof(struct thread_info)); | |
80 | dump_stack(); | |
81 | } | |
82 | } | |
83 | #endif | |
84 | ||
85 | #ifdef CONFIG_4KSTACKS | |
86 | ||
87 | curctx = (union irq_ctx *) current_thread_info(); | |
88 | irqctx = hardirq_ctx[smp_processor_id()]; | |
89 | ||
90 | /* | |
91 | * this is where we switch to the IRQ stack. However, if we are | |
92 | * already using the IRQ stack (because we interrupted a hardirq | |
93 | * handler) we can't do that and just have to keep using the | |
94 | * current stack (which is the irq stack already after all) | |
95 | */ | |
96 | if (curctx != irqctx) { | |
97 | int arg1, arg2, ebx; | |
98 | ||
99 | /* build the stack frame on the IRQ stack */ | |
100 | isp = (u32*) ((char*)irqctx + sizeof(*irqctx)); | |
101 | irqctx->tinfo.task = curctx->tinfo.task; | |
102 | irqctx->tinfo.previous_esp = current_stack_pointer; | |
103 |