aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/mips-boards/malta/malta_int.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2006-04-03 12:56:36 -0400
committerRalf Baechle <ralf@linux-mips.org>2006-04-18 22:14:21 -0400
commite4ac58afdfac792c0583af30dbd9eae53e24c78b (patch)
tree7517bef2c515fc630e4d3d238867b91cde96f558 /arch/mips/mips-boards/malta/malta_int.c
parentd35d473c25d43d7db3e5e18b66d558d2a631cca8 (diff)
[MIPS] Rewrite all the assembler interrupt handlers to C.
Saves like 1,600 lines of code, is way easier to debug, compilers frequently do a better job than the cut and paste type of handlers many boards had. And finally having all the stuff done in a single place also means alot of bug potencial for the MT ASE is gone. The only surviving handler in assembler is the DECstation one; I hope Maciej will rewrite it. Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/mips-boards/malta/malta_int.c')
-rw-r--r--arch/mips/mips-boards/malta/malta_int.c91
1 files changed, 87 insertions, 4 deletions
diff --git a/arch/mips/mips-boards/malta/malta_int.c b/arch/mips/mips-boards/malta/malta_int.c
index d06dc5ad6c9e..1da8c18b9c8e 100644
--- a/arch/mips/mips-boards/malta/malta_int.c
+++ b/arch/mips/mips-boards/malta/malta_int.c
@@ -40,7 +40,6 @@
40#include <asm/mips-boards/msc01_pci.h> 40#include <asm/mips-boards/msc01_pci.h>
41#include <asm/msc01_ic.h> 41#include <asm/msc01_ic.h>
42 42
43extern asmlinkage void mipsIRQ(void);
44extern void mips_timer_interrupt(void); 43extern void mips_timer_interrupt(void);
45 44
46static DEFINE_SPINLOCK(mips_irq_lock); 45static DEFINE_SPINLOCK(mips_irq_lock);
@@ -114,7 +113,7 @@ static inline int get_int(void)
114 return irq; 113 return irq;
115} 114}
116 115
117void malta_hw0_irqdispatch(struct pt_regs *regs) 116static void malta_hw0_irqdispatch(struct pt_regs *regs)
118{ 117{
119 int irq; 118 int irq;
120 119
@@ -182,6 +181,92 @@ void corehi_irqdispatch(struct pt_regs *regs)
182 die("CoreHi interrupt", regs); 181 die("CoreHi interrupt", regs);
183} 182}
184 183
184static inline int clz(unsigned long x)
185{
186 __asm__ (
187 " .set push \n"
188 " .set mips32 \n"
189 " clz %0, %1 \n"
190 " .set pop \n"
191 : "=r" (x)
192 : "r" (x));
193
194 return x;
195}
196
197/*
198 * Version of ffs that only looks at bits 12..15.
199 */
200static inline unsigned int irq_ffs(unsigned int pending)
201{
202#if defined(CONFIG_CPU_MIPS32) || defined(CONFIG_CPU_MIPS64)
203 return -clz(pending) + 31 - CAUSEB_IP;
204#else
205 unsigned int a0 = 7;
206 unsigned int t0;
207
208 t0 = s0 & 0xf000;
209 t0 = t0 < 1;
210 t0 = t0 << 2;
211 a0 = a0 - t0;
212 s0 = s0 << t0;
213
214 t0 = s0 & 0xc000;
215 t0 = t0 < 1;
216 t0 = t0 << 1;
217 a0 = a0 - t0;
218 s0 = s0 << t0;
219
220 t0 = s0 & 0x8000;
221 t0 = t0 < 1;
222 //t0 = t0 << 2;
223 a0 = a0 - t0;
224 //s0 = s0 << t0;
225
226 return a0;
227#endif
228}
229
230/*
231 * IRQs on the Malta board look basically (barring software IRQs which we
232 * don't use at all and all external interrupt sources are combined together
233 * on hardware interrupt 0 (MIPS IRQ 2)) like:
234 *
235 * MIPS IRQ Source
236 * -------- ------
237 * 0 Software (ignored)
238 * 1 Software (ignored)
239 * 2 Combined hardware interrupt (hw0)
240 * 3 Hardware (ignored)
241 * 4 Hardware (ignored)
242 * 5 Hardware (ignored)
243 * 6 Hardware (ignored)
244 * 7 R4k timer (what we use)
245 *
246 * We handle the IRQ according to _our_ priority which is:
247 *
248 * Highest ---- R4k Timer
249 * Lowest ---- Combined hardware interrupt
250 *
251 * then we just return, if multiple IRQs are pending then we will just take
252 * another exception, big deal.
253 */
254
255asmlinkage void plat_irq_dispatch(struct pt_regs *regs)
256{
257 unsigned int pending = read_c0_cause() & read_c0_status() & ST0_IM;
258 int irq;
259
260 irq = irq_ffs(pending);
261
262 if (irq == MIPSCPU_INT_I8259A)
263 malta_hw0_irqdispatch(regs);
264 else if (irq > 0)
265 do_IRQ(MIPSCPU_INT_BASE + irq, regs);
266 else
267 spurious_interrupt(regs);
268}
269
185static struct irqaction i8259irq = { 270static struct irqaction i8259irq = {
186 .handler = no_action, 271 .handler = no_action,
187 .name = "XT-PIC cascade" 272 .name = "XT-PIC cascade"
@@ -214,7 +299,6 @@ int __initdata msc_nr_eicirqs = sizeof(msc_eicirqmap)/sizeof(msc_irqmap_t);
214 299
215void __init arch_init_irq(void) 300void __init arch_init_irq(void)
216{ 301{
217 set_except_vector(0, mipsIRQ);
218 init_i8259_irqs(); 302 init_i8259_irqs();
219 303
220 if (!cpu_has_veic) 304 if (!cpu_has_veic)
@@ -245,7 +329,6 @@ void __init arch_init_irq(void)
245 setup_irq (MIPSCPU_INT_BASE+MIPSCPU_INT_COREHI, &corehi_irqaction); 329 setup_irq (MIPSCPU_INT_BASE+MIPSCPU_INT_COREHI, &corehi_irqaction);
246 } 330 }
247 else { 331 else {
248 set_except_vector(0, mipsIRQ);
249 setup_irq (MIPSCPU_INT_BASE+MIPSCPU_INT_I8259A, &i8259irq); 332 setup_irq (MIPSCPU_INT_BASE+MIPSCPU_INT_I8259A, &i8259irq);
250 setup_irq (MIPSCPU_INT_BASE+MIPSCPU_INT_COREHI, &corehi_irqaction); 333 setup_irq (MIPSCPU_INT_BASE+MIPSCPU_INT_COREHI, &corehi_irqaction);
251 } 334 }