2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 1994 - 2000, 2001, 2003 Ralf Baechle
7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
8 * Copyright (C) 2001 MIPS Technologies, Inc.
9 * Copyright (C) 2002 Maciej W. Rozycki
11 #include <linux/init.h>
14 #include <asm/asmmacro.h>
15 #include <asm/cacheops.h>
16 #include <asm/regdef.h>
17 #include <asm/fpregdef.h>
18 #include <asm/mipsregs.h>
19 #include <asm/stackframe.h>
22 #define PANIC_PIC(msg) \
35 NESTED(except_vec0_generic, 0, sp)
36 PANIC_PIC("Exception vector 0 called")
37 END(except_vec0_generic)
39 NESTED(except_vec1_generic, 0, sp)
40 PANIC_PIC("Exception vector 1 called")
41 END(except_vec1_generic)
44 * General exception vector for all other CPUs.
46 * Be careful when changing this, it has to be at most 128 bytes
47 * to fit into space reserved for the exception handler.
49 NESTED(except_vec3_generic, 0, sp)
52 #if R5432_CP0_INTERRUPT_WAR
60 PTR_L k0, exception_handlers(k1)
63 END(except_vec3_generic)
66 * General exception handler for CPUs with virtual coherency exception.
68 * Be careful when changing this, it has to be at most 256 (as a special
69 * exception) bytes to fit into space reserved for the exception handler.
71 NESTED(except_vec3_r4000, 0, sp)
81 beq k1, k0, handle_vced
83 beq k1, k0, handle_vcei
88 PTR_L k0, exception_handlers(k1)
92 * Big shit, we now may have two dirty primary cache lines for the same
93 * physical address. We can safely invalidate the line pointed to by
94 * c0_badvaddr because after return from this exception handler the
95 * load / store will be re-executed.
99 li k1, -4 # Is this ...
100 and k0, k1 # ... really needed?
102 cache Index_Store_Tag_D, (k0)
103 cache Hit_Writeback_Inv_SD, (k0)
104 #ifdef CONFIG_PROC_FS
105 PTR_LA k0, vced_count
113 MFC0 k0, CP0_BADVADDR
114 cache Hit_Writeback_Inv_SD, (k0) # also cleans pi
115 #ifdef CONFIG_PROC_FS
116 PTR_LA k0, vcei_count
123 END(except_vec3_r4000)
128 NESTED(handle_int, PT_SIZE, sp)
132 PTR_LA ra, ret_from_irq
140 * Special interrupt vector for MIPS64 ISA & embedded MIPS processors.
141 * This is a dedicated interrupt exception vector which reduces the
142 * interrupt processing overhead. The jump instruction will be replaced
143 * at the initialization time.
145 * Be careful when changing this, it has to be at most 128 bytes
146 * to fit into space reserved for the exception handler.
148 NESTED(except_vec4, 0, sp)
149 1: j 1b /* Dummy, will be replaced */
153 * EJTAG debug exception handler.
154 * The EJTAG debug exception entry point is 0xbfc00480, which
155 * normally is in the boot PROM, so the boot PROM must do a
156 * unconditional jump to this vector.
158 NESTED(except_vec_ejtag_debug, 0, sp)
159 j ejtag_debug_handler
160 END(except_vec_ejtag_debug)
165 * Vectored interrupt handler.
166 * This prototype is copied to ebase + n*IntCtl.VS and patched
167 * to invoke the handler
169 NESTED(except_vec_vi, 0, sp)
174 #ifdef CONFIG_MIPS_MT_SMTC
176 * To keep from blindly blocking *all* interrupts
177 * during service by SMTC kernel, we also want to
178 * pass the IM value to be cleared.
180 EXPORT(except_vec_vi_mori)
182 #endif /* CONFIG_MIPS_MT_SMTC */
183 EXPORT(except_vec_vi_lui)
184 lui v0, 0 /* Patched */
185 j except_vec_vi_handler
186 EXPORT(except_vec_vi_ori)
187 ori v0, 0 /* Patched */
190 EXPORT(except_vec_vi_end)
193 * Common Vectored Interrupt code
194 * Complete the register saves and invoke the handler which is passed in $v0
196 NESTED(except_vec_vi_handler, 0, sp)
199 #ifdef CONFIG_MIPS_MT_SMTC
201 * SMTC has an interesting problem that interrupts are level-triggered,
202 * and the CLI macro will clear EXL, potentially causing a duplicate
203 * interrupt service invocation. So we need to clear the associated
204 * IM bit of Status prior to doing CLI, and restore it after the
205 * service routine has been invoked - we must assume that the
206 * service routine will have cleared the state, and any active
207 * level represents a new or otherwised unserviced event...
211 mfc0 t2, CP0_TCCONTEXT
213 mtc0 t0, CP0_TCCONTEXT
217 #endif /* CONFIG_MIPS_MT_SMTC */
222 END(except_vec_vi_handler)
225 * EJTAG debug exception handler.
227 NESTED(ejtag_debug_handler, PT_SIZE, sp)
233 sll k0, k0, 30 # Check for SDBBP.
234 bgez k0, ejtag_return
236 PTR_LA k0, ejtag_debug_buffer
240 jal ejtag_exception_handler
242 PTR_LA k0, ejtag_debug_buffer
250 END(ejtag_debug_handler)
253 * This buffer is reserved for the use of the EJTAG debug
257 EXPORT(ejtag_debug_buffer)
264 * NMI debug exception handler for MIPS reference boards.
265 * The NMI debug exception entry point is 0xbfc00000, which
266 * normally is in the boot PROM, so the boot PROM must do a
267 * unconditional jump to this vector.
269 NESTED(except_vec_nmi, 0, sp)
275 NESTED(nmi_handler, PT_SIZE, sp)
280 jal nmi_exception_handler
287 .macro __build_clear_none
290 .macro __build_clear_sti
294 .macro __build_clear_cli
298 .macro __build_clear_fpe
306 .macro __build_clear_ade
307 MFC0 t0, CP0_BADVADDR
308 PTR_S t0, PT_BVADDR(sp)
312 .macro __BUILD_silent exception
315 /* Gas tries to parse the PRINT argument as a string containing
316 string escapes and emits bogus warnings if it believes to
317 recognize an unknown escape code. So make the arguments
318 start with an n and gas will believe \n is ok ... */
319 .macro __BUILD_verbose nexception
320 LONG_L a1, PT_EPC(sp)
322 PRINT("Got \nexception at %08lx\012")
325 PRINT("Got \nexception at %016lx\012")
329 .macro __BUILD_count exception
330 LONG_L t0,exception_count_\exception
332 LONG_S t0,exception_count_\exception
333 .comm exception_count\exception, 8, 8
336 .macro __BUILD_HANDLER exception handler clear verbose ext
338 NESTED(handle_\exception, PT_SIZE, sp)
341 FEXPORT(handle_\exception\ext)
344 __BUILD_\verbose \exception
348 END(handle_\exception)
351 .macro BUILD_HANDLER exception handler clear verbose
352 __BUILD_HANDLER \exception \handler \clear \verbose _int
355 BUILD_HANDLER adel ade ade silent /* #4 */
356 BUILD_HANDLER ades ade ade silent /* #5 */
357 BUILD_HANDLER ibe be cli silent /* #6 */
358 BUILD_HANDLER dbe be cli silent /* #7 */
359 BUILD_HANDLER bp bp sti silent /* #9 */
360 BUILD_HANDLER ri ri sti silent /* #10 */
361 BUILD_HANDLER cpu cpu sti silent /* #11 */
362 BUILD_HANDLER ov ov sti silent /* #12 */
363 BUILD_HANDLER tr tr sti silent /* #13 */
364 BUILD_HANDLER fpe fpe fpe silent /* #15 */
365 BUILD_HANDLER mdmx mdmx sti silent /* #22 */
366 BUILD_HANDLER watch watch sti verbose /* #23 */
367 BUILD_HANDLER mcheck mcheck cli verbose /* #24 */
368 BUILD_HANDLER mt mt sti verbose /* #25 */
369 BUILD_HANDLER dsp dsp sti silent /* #26 */
370 BUILD_HANDLER reserved reserved sti verbose /* others */
373 /* A temporary overflow handler used by check_daddi(). */
377 BUILD_HANDLER daddi_ov daddi_ov none silent /* #12 */