1 /* $Id: irq.c,v 1.2 2004/06/09 05:30:27 starvik 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
)
28 etrax_irv
->v
[n
+ 0x20] = (irqvectptr
)addr
;
31 /* the breakpoint vector is obviously not made just like the normal irq handlers
32 * but needs to contain _code_ to jump to addr.
34 * the BREAK n instruction jumps to IBR + n * 8
38 set_break_vector(int n
, irqvectptr addr
)
40 unsigned short *jinstr
= (unsigned short *)&etrax_irv
->v
[n
*2];
41 unsigned long *jaddr
= (unsigned long *)(jinstr
+ 1);
43 /* if you don't know what this does, do not touch it! */
46 *jaddr
= (unsigned long)addr
;
48 /* 00000026 <clrlop+1a> 3f0d82000000 jump 0x82 */
52 * This builds up the IRQ handler stubs using some ugly macros in irq.h
54 * These macros create the low-level assembly IRQ routines that do all
55 * the operations that are needed. They are also written to be fast - and to
56 * disable interrupts as little as humanly possible.
60 /* IRQ0 and 1 are special traps */
61 void hwbreakpoint(void);
62 void IRQ1_interrupt(void);
63 BUILD_TIMER_IRQ(2, 0x04) /* the timer interrupt is somewhat special */
75 void mmu_bus_fault(void); /* IRQ 14 is the bus fault interrupt */
76 void multiple_interrupt(void); /* IRQ 15 is the multiple IRQ interrupt */
77 BUILD_IRQ(16, 0x10000)
78 BUILD_IRQ(17, 0x20000)
79 BUILD_IRQ(18, 0x40000)
80 BUILD_IRQ(19, 0x80000)
81 BUILD_IRQ(20, 0x100000)
82 BUILD_IRQ(21, 0x200000)
83 BUILD_IRQ(22, 0x400000)
84 BUILD_IRQ(23, 0x800000)
85 BUILD_IRQ(24, 0x1000000)
86 BUILD_IRQ(25, 0x2000000)
87 /* IRQ 26-30 are reserved */
88 BUILD_IRQ(31, 0x80000000)
91 * Pointers to the low-level handlers
94 static void (*interrupt
[NR_IRQS
])(void) = {
95 NULL
, NULL
, IRQ2_interrupt
, IRQ3_interrupt
,
96 IRQ4_interrupt
, IRQ5_interrupt
, IRQ6_interrupt
, IRQ7_interrupt
,
97 IRQ8_interrupt
, IRQ9_interrupt
, IRQ10_interrupt
, IRQ11_interrupt
,
98 IRQ12_interrupt
, IRQ13_interrupt
, NULL
, NULL
,
99 IRQ16_interrupt
, IRQ17_interrupt
, IRQ18_interrupt
, IRQ19_interrupt
,
100 IRQ20_interrupt
, IRQ21_interrupt
, IRQ22_interrupt
, IRQ23_interrupt
,
101 IRQ24_interrupt
, IRQ25_interrupt
, NULL
, NULL
, NULL
, NULL
, NULL
,
105 static void (*bad_interrupt
[NR_IRQS
])(void) = {
107 NULL
, bad_IRQ3_interrupt
,
108 bad_IRQ4_interrupt
, bad_IRQ5_interrupt
,
109 bad_IRQ6_interrupt
, bad_IRQ7_interrupt
,
110 bad_IRQ8_interrupt
, bad_IRQ9_interrupt
,
111 bad_IRQ10_interrupt
, bad_IRQ11_interrupt
,
112 bad_IRQ12_interrupt
, bad_IRQ13_interrupt
,
114 bad_IRQ16_interrupt
, bad_IRQ17_interrupt
,
115 bad_IRQ18_interrupt
, bad_IRQ19_interrupt
,
116 bad_IRQ20_interrupt
, bad_IRQ21_interrupt
,
117 bad_IRQ22_interrupt
, bad_IRQ23_interrupt
,
118 bad_IRQ24_interrupt
, bad_IRQ25_interrupt
,
119 NULL
, NULL
, NULL
, NULL
, NULL
,
123 void arch_setup_irq(int irq
)
125 set_int_vector(irq
, interrupt
[irq
]);
128 void arch_free_irq(int irq
)
130 set_int_vector(irq
, bad_interrupt
[irq
]);
133 void weird_irq(void);
134 void system_call(void); /* from entry.S */
135 void do_sigtrap(void); /* from entry.S */
136 void gdb_handle_breakpoint(void); /* from entry.S */
138 /* init_IRQ() is called by start_kernel and is responsible for fixing IRQ masks and
139 setting the irq vector table to point to bad_interrupt ptrs.
147 /* clear all interrupt masks */
149 #ifndef CONFIG_SVINTO_SIM
150 *R_IRQ_MASK0_CLR
= 0xffffffff;
151 *R_IRQ_MASK1_CLR
= 0xffffffff;
152 *R_IRQ_MASK2_CLR
= 0xffffffff;
155 *R_VECT_MASK_CLR
= 0xffffffff;
157 /* clear the shortcut entry points */
159 for(i
= 0; i
< NR_IRQS
; i
++)
160 irq_shortcuts
[i
] = NULL
;
162 for (i
= 0; i
< 256; i
++)
163 etrax_irv
->v
[i
] = weird_irq
;
165 /* the entries in the break vector contain actual code to be
166 executed by the associated break handler, rather than just a jump
167 address. therefore we need to setup a default breakpoint handler
168 for all breakpoints */
170 for (i
= 0; i
< 16; i
++)
171 set_break_vector(i
, do_sigtrap
);
173 /* set all etrax irq's to the bad handlers */
174 for (i
= 2; i
< NR_IRQS
; i
++)
175 set_int_vector(i
, bad_interrupt
[i
]);
177 /* except IRQ 15 which is the multiple-IRQ handler on Etrax100 */
179 set_int_vector(15, multiple_interrupt
);
181 /* 0 and 1 which are special breakpoint/NMI traps */
183 set_int_vector(0, hwbreakpoint
);
184 set_int_vector(1, IRQ1_interrupt
);
186 /* and irq 14 which is the mmu bus fault handler */
188 set_int_vector(14, mmu_bus_fault
);
190 /* setup the system-call trap, which is reached by BREAK 13 */
192 set_break_vector(13, system_call
);
194 /* setup a breakpoint handler for debugging used for both user and
195 kernel mode debugging (which is why it is not inside an ifdef
196 CONFIG_ETRAX_KGDB) */
197 set_break_vector(8, gdb_handle_breakpoint
);
199 #ifdef CONFIG_ETRAX_KGDB
200 /* setup kgdb if its enabled, and break into the debugger */