IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
[linux-2.6-block.git] / arch / i386 / kernel / irq.c
CommitLineData
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 22DEFINE_PER_CPU(irq_cpustat_t, irq_stat) ____cacheline_internodealigned_in_smp;
1da177e4
LT
23EXPORT_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 */
30void 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 */
40union irq_ctx {
41 struct thread_info tinfo;
42 u32 stack[THREAD_SIZE/sizeof(u32)];
43};
44
22722051
AM
45static union irq_ctx *hardirq_ctx[NR_CPUS] __read_mostly;
46static 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 */
54fastcall unsigned int do_IRQ(struct pt_regs *regs)
55{
7d12e780 56 struct pt_regs *old_regs;
19eadf98
RR
57 /* high bit used in ret_from_ code */
58 int irq = ~regs->orig_eax;
f5b9ed7a 59 struct irq_desc *desc = irq_desc + irq;
1da177e4
LT
60#ifdef CONFIG_4KSTACKS
61 union irq_ctx *curctx, *irqctx;
62 u32 *isp;
63#endif
64
a052b68b
AM
65 if (unlikely((unsigned)irq >= NR_IRQS)) {
66 printk(KERN_EMERG "%s: cannot handle IRQ %d\n",
67 __FUNCTION__, irq);
68 BUG();
69 }
70
7d12e780 71 old_regs = set_irq_regs(regs);
1da177e4
LT
72 irq_enter();
73#ifdef CONFIG_DEBUG_STACKOVERFLOW
74 /* Debugging check for stack overflow: is there less than 1KB free? */
75 {
76 long esp;
77
78 __asm__ __volatile__("andl %%esp,%0" :
79 "=r" (esp) : "0" (THREAD_SIZE - 1));
80 if (unlikely(esp < (sizeof(struct thread_info) + STACK_WARN))) {
81 printk("do_IRQ: stack overflow: %ld\n",
82 esp - sizeof(struct thread_info));
83 dump_stack();
84 }
85 }
86#endif
87
88#ifdef CONFIG_4KSTACKS
89
90 curctx = (union irq_ctx *) current_thread_info();
91 irqctx = hardirq_ctx[smp_processor_id()];
92
93 /*
94 * this is where we switch to the IRQ stack. However, if we are
95 * already using the IRQ stack (because we interrupted a hardirq
96 * handler) we can't do that and just have to keep using the
97 * current stack (which is the irq stack already after all)
98 */
99 if (curctx != irqctx) {
7d12e780 100 int arg1, arg2, ebx;
1da177e4
LT
101
102 /* build the stack frame on the IRQ stack */
103 isp = (u32*) ((char*)irqctx + sizeof(*irqctx));
104 irqctx->tinfo.task = curctx->tinfo.task;
105 irqctx->tinfo.previous_esp = current_stack_pointer;
106