1 /* $Id: irq.c,v 1.1.1.1 2005/04/29 01:40:43 echo Exp $
3 * linux/arch/cris/kernel/irq.c
5 * Copyright (c) 2000-2002 Axis Communications AB
7 * Authors: Bjorn Wesen (bjornw@axis.com)
9 * This file contains the interrupt vectors and some
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/config.h>
19 irqvectptr irq_shortcuts[NR_IRQS]; /* vector of shortcut jumps after the irq prologue */
21 /* don't use set_int_vector, it bypasses the linux interrupt handlers. it is
22 * global just so that the kernel gdb can use it.
26 set_int_vector(int n, irqvectptr addr, irqvectptr saddr)
28 /* remember the shortcut entry point, after the prologue */
30 irq_shortcuts[n] = saddr;
32 etrax_irv->v[n + 0x20] = (irqvectptr)addr;
35 /* the breakpoint vector is obviously not made just like the normal irq handlers
36 * but needs to contain _code_ to jump to addr.
38 * the BREAK n instruction jumps to IBR + n * 8
42 set_break_vector(int n, irqvectptr addr)
44 unsigned short *jinstr = (unsigned short *)&etrax_irv->v[n*2];
45 unsigned long *jaddr = (unsigned long *)(jinstr + 1);
47 /* if you don't know what this does, do not touch it! */
50 *jaddr = (unsigned long)addr;
52 /* 00000026 <clrlop+1a> 3f0d82000000 jump 0x82 */
56 * This builds up the IRQ handler stubs using some ugly macros in irq.h
58 * These macros create the low-level assembly IRQ routines that do all
59 * the operations that are needed. They are also written to be fast - and to
60 * disable interrupts as little as humanly possible.
64 /* IRQ0 and 1 are special traps */
65 void hwbreakpoint(void);
66 void IRQ1_interrupt(void);
67 BUILD_TIMER_IRQ(2, 0x04) /* the timer interrupt is somewhat special */
79 void mmu_bus_fault(void); /* IRQ 14 is the bus fault interrupt */
80 void multiple_interrupt(void); /* IRQ 15 is the multiple IRQ interrupt */
81 BUILD_IRQ(16, 0x10000)
82 BUILD_IRQ(17, 0x20000)
83 BUILD_IRQ(18, 0x40000)
84 BUILD_IRQ(19, 0x80000)
85 BUILD_IRQ(20, 0x100000)
86 BUILD_IRQ(21, 0x200000)
87 BUILD_IRQ(22, 0x400000)
88 BUILD_IRQ(23, 0x800000)
89 BUILD_IRQ(24, 0x1000000)
90 BUILD_IRQ(25, 0x2000000)
91 /* IRQ 26-30 are reserved */
92 BUILD_IRQ(31, 0x80000000)
95 * Pointers to the low-level handlers
98 static void (*interrupt[NR_IRQS])(void) = {
99 NULL, NULL, IRQ2_interrupt, IRQ3_interrupt,
100 IRQ4_interrupt, IRQ5_interrupt, IRQ6_interrupt, IRQ7_interrupt,
101 IRQ8_interrupt, IRQ9_interrupt, IRQ10_interrupt, IRQ11_interrupt,
102 IRQ12_interrupt, IRQ13_interrupt, NULL, NULL,
103 IRQ16_interrupt, IRQ17_interrupt, IRQ18_interrupt, IRQ19_interrupt,
104 IRQ20_interrupt, IRQ21_interrupt, IRQ22_interrupt, IRQ23_interrupt,
105 IRQ24_interrupt, IRQ25_interrupt, NULL, NULL, NULL, NULL, NULL,
109 static void (*sinterrupt[NR_IRQS])(void) = {
110 NULL, NULL, sIRQ2_interrupt, sIRQ3_interrupt,
111 sIRQ4_interrupt, sIRQ5_interrupt, sIRQ6_interrupt, sIRQ7_interrupt,
112 sIRQ8_interrupt, sIRQ9_interrupt, sIRQ10_interrupt, sIRQ11_interrupt,
113 sIRQ12_interrupt, sIRQ13_interrupt, NULL, NULL,
114 sIRQ16_interrupt, sIRQ17_interrupt, sIRQ18_interrupt, sIRQ19_interrupt,
115 sIRQ20_interrupt, sIRQ21_interrupt, sIRQ22_interrupt, sIRQ23_interrupt,
116 sIRQ24_interrupt, sIRQ25_interrupt, NULL, NULL, NULL, NULL, NULL,
120 static void (*bad_interrupt[NR_IRQS])(void) = {
122 NULL, bad_IRQ3_interrupt,
123 bad_IRQ4_interrupt, bad_IRQ5_interrupt,
124 bad_IRQ6_interrupt, bad_IRQ7_interrupt,
125 bad_IRQ8_interrupt, bad_IRQ9_interrupt,
126 bad_IRQ10_interrupt, bad_IRQ11_interrupt,
127 bad_IRQ12_interrupt, bad_IRQ13_interrupt,
129 bad_IRQ16_interrupt, bad_IRQ17_interrupt,
130 bad_IRQ18_interrupt, bad_IRQ19_interrupt,
131 bad_IRQ20_interrupt, bad_IRQ21_interrupt,
132 bad_IRQ22_interrupt, bad_IRQ23_interrupt,
133 bad_IRQ24_interrupt, bad_IRQ25_interrupt,
134 NULL, NULL, NULL, NULL, NULL,
138 void arch_setup_irq(int irq)
140 set_int_vector(irq, interrupt[irq], sinterrupt[irq]);
143 void arch_free_irq(int irq)
145 set_int_vector(irq, bad_interrupt[irq], 0);
148 void weird_irq(void);
149 void system_call(void); /* from entry.S */
150 void do_sigtrap(void); /* from entry.S */
151 void gdb_handle_breakpoint(void); /* from entry.S */
153 /* init_IRQ() is called by start_kernel and is responsible for fixing IRQ masks and
154 setting the irq vector table to point to bad_interrupt ptrs.
162 /* clear all interrupt masks */
164 #ifndef CONFIG_SVINTO_SIM
165 *R_IRQ_MASK0_CLR = 0xffffffff;
166 *R_IRQ_MASK1_CLR = 0xffffffff;
167 *R_IRQ_MASK2_CLR = 0xffffffff;
170 *R_VECT_MASK_CLR = 0xffffffff;
172 /* clear the shortcut entry points */
174 for(i = 0; i < NR_IRQS; i++)
175 irq_shortcuts[i] = NULL;
177 for (i = 0; i < 256; i++)
178 etrax_irv->v[i] = weird_irq;
180 /* the entries in the break vector contain actual code to be
181 executed by the associated break handler, rather than just a jump
182 address. therefore we need to setup a default breakpoint handler
183 for all breakpoints */
185 for (i = 0; i < 16; i++)
186 set_break_vector(i, do_sigtrap);
188 /* set all etrax irq's to the bad handlers */
189 for (i = 2; i < NR_IRQS; i++)
190 set_int_vector(i, bad_interrupt[i], 0);
192 /* except IRQ 15 which is the multiple-IRQ handler on Etrax100 */
194 set_int_vector(15, multiple_interrupt, 0);
196 /* 0 and 1 which are special breakpoint/NMI traps */
198 set_int_vector(0, hwbreakpoint, 0);
199 set_int_vector(1, IRQ1_interrupt, 0);
201 /* and irq 14 which is the mmu bus fault handler */
203 set_int_vector(14, mmu_bus_fault, 0);
205 /* setup the system-call trap, which is reached by BREAK 13 */
207 set_break_vector(13, system_call);
209 /* setup a breakpoint handler for debugging used for both user and
210 kernel mode debugging (which is why it is not inside an ifdef
211 CONFIG_ETRAX_KGDB) */
212 set_break_vector(8, gdb_handle_breakpoint);
214 #ifdef CONFIG_ETRAX_KGDB
215 /* setup kgdb if its enabled, and break into the debugger */