1#ifndef _ASM_HW_IRQ_H
2#define _ASM_HW_IRQ_H
3
4
5
6
7
8
9
10
11
12
13
14
15#include <linux/config.h>
16#include <asm/atomic.h>
17#include <asm/irq.h>
18
19
20
21
22
23#define FIRST_EXTERNAL_VECTOR 0x20
24
25#define SYSCALL_VECTOR 0x80
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40#define SPURIOUS_APIC_VECTOR 0xff
41#define ERROR_APIC_VECTOR 0xfe
42#define INVALIDATE_TLB_VECTOR 0xfd
43#define RESCHEDULE_VECTOR 0xfc
44#define CALL_FUNCTION_VECTOR 0xfb
45
46
47
48
49
50
51#define LOCAL_TIMER_VECTOR 0xef
52
53
54
55
56
57
58#define FIRST_DEVICE_VECTOR 0x31
59#define FIRST_SYSTEM_VECTOR 0xef
60
61extern int irq_vector[NR_IRQS];
62#define IO_APIC_VECTOR(irq) irq_vector[irq]
63
64
65
66
67
68
69
70
71extern void mask_irq(unsigned int irq);
72extern void unmask_irq(unsigned int irq);
73extern void disable_8259A_irq(unsigned int irq);
74extern void enable_8259A_irq(unsigned int irq);
75extern int i8259A_irq_pending(unsigned int irq);
76extern void make_8259A_irq(unsigned int irq);
77extern void init_8259A(int aeoi);
78extern void FASTCALL(send_IPI_self(int vector));
79extern void init_VISWS_APIC_irqs(void);
80extern void setup_IO_APIC(void);
81extern void disable_IO_APIC(void);
82extern void print_IO_APIC(void);
83extern int IO_APIC_get_PCI_irq_vector(int bus, int slot, int fn);
84extern void send_IPI(int dest, int vector);
85
86extern unsigned long io_apic_irqs;
87
88extern atomic_t irq_err_count;
89extern atomic_t irq_mis_count;
90
91extern char _stext, _etext;
92
93#define IO_APIC_IRQ(x) (((x) >= 16) || ((1<<(x)) & io_apic_irqs))
94
95#define __STR(x) #x
96#define STR(x) __STR(x)
97
98#define SAVE_ALL \
99 "cld\n\t" \
100 "pushl %es\n\t" \
101 "pushl %ds\n\t" \
102 "pushl %eax\n\t" \
103 "pushl %ebp\n\t" \
104 "pushl %edi\n\t" \
105 "pushl %esi\n\t" \
106 "pushl %edx\n\t" \
107 "pushl %ecx\n\t" \
108 "pushl %ebx\n\t" \
109 "movl $" STR(__KERNEL_DS) ",%edx\n\t" \
110 "movl %edx,%ds\n\t" \
111 "movl %edx,%es\n\t"
112
113#define IRQ_NAME2(nr) nr##_interrupt(void)
114#define IRQ_NAME(nr) IRQ_NAME2(IRQ##nr)
115
116#define GET_CURRENT \
117 "movl %esp, %ebx\n\t" \
118 "andl $-8192, %ebx\n\t"
119
120
121
122
123
124
125
126#define BUILD_SMP_INTERRUPT(x,v) XBUILD_SMP_INTERRUPT(x,v)
127#define XBUILD_SMP_INTERRUPT(x,v)\
128asmlinkage void x(void); \
129asmlinkage void call_##x(void); \
130__asm__( \
131"\n"__ALIGN_STR"\n" \
132SYMBOL_NAME_STR(x) ":\n\t" \
133 "pushl $"#v"-256\n\t" \
134 SAVE_ALL \
135 SYMBOL_NAME_STR(call_##x)":\n\t" \
136 "call "SYMBOL_NAME_STR(smp_##x)"\n\t" \
137 "jmp ret_from_intr\n");
138
139#define BUILD_SMP_TIMER_INTERRUPT(x,v) XBUILD_SMP_TIMER_INTERRUPT(x,v)
140#define XBUILD_SMP_TIMER_INTERRUPT(x,v) \
141asmlinkage void x(struct pt_regs * regs); \
142asmlinkage void call_##x(void); \
143__asm__( \
144"\n"__ALIGN_STR"\n" \
145SYMBOL_NAME_STR(x) ":\n\t" \
146 "pushl $"#v"-256\n\t" \
147 SAVE_ALL \
148 "movl %esp,%eax\n\t" \
149 "pushl %eax\n\t" \
150 SYMBOL_NAME_STR(call_##x)":\n\t" \
151 "call "SYMBOL_NAME_STR(smp_##x)"\n\t" \
152 "addl $4,%esp\n\t" \
153 "jmp ret_from_intr\n");
154
155#define BUILD_COMMON_IRQ() \
156asmlinkage void call_do_IRQ(void); \
157__asm__( \
158 "\n" __ALIGN_STR"\n" \
159 "common_interrupt:\n\t" \
160 SAVE_ALL \
161 SYMBOL_NAME_STR(call_do_IRQ)":\n\t" \
162 "call " SYMBOL_NAME_STR(do_IRQ) "\n\t" \
163 "jmp ret_from_intr\n");
164
165
166
167
168
169
170
171
172
173
174
175#define BUILD_IRQ(nr) \
176asmlinkage void IRQ_NAME(nr); \
177__asm__( \
178"\n"__ALIGN_STR"\n" \
179SYMBOL_NAME_STR(IRQ) #nr "_interrupt:\n\t" \
180 "pushl $"#nr"-256\n\t" \
181 "jmp common_interrupt");
182
183extern unsigned long prof_cpu_mask;
184extern unsigned int * prof_buffer;
185extern unsigned long prof_len;
186extern unsigned long prof_shift;
187
188
189
190
191
192static inline void x86_do_profile (unsigned long eip)
193{
194 if (!prof_buffer)
195 return;
196
197
198
199
200
201 if (!((1<<smp_processor_id()) & prof_cpu_mask))
202 return;
203
204 eip -= (unsigned long) &_stext;
205 eip >>= prof_shift;
206
207
208
209
210
211 if (eip > prof_len-1)
212 eip = prof_len-1;
213 atomic_inc((atomic_t *)&prof_buffer[eip]);
214}
215
216#ifdef CONFIG_SMP
217static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) {
218 if (IO_APIC_IRQ(i))
219 send_IPI_self(IO_APIC_VECTOR(i));
220}
221#else
222static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) {}
223#endif
224
225#endif
226