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/config.h>
12 #include <linux/init.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)
126 * Special interrupt vector for MIPS64 ISA & embedded MIPS processors.
127 * This is a dedicated interrupt exception vector which reduces the
128 * interrupt processing overhead. The jump instruction will be replaced
129 * at the initialization time.
131 * Be careful when changing this, it has to be at most 128 bytes
132 * to fit into space reserved for the exception handler.
134 NESTED(except_vec4, 0, sp)
135 1: j 1b /* Dummy, will be replaced */
139 * EJTAG debug exception handler.
140 * The EJTAG debug exception entry point is 0xbfc00480, which
141 * normally is in the boot PROM, so the boot PROM must do a
142 * unconditional jump to this vector.
144 NESTED(except_vec_ejtag_debug, 0, sp)
145 j ejtag_debug_handler
146 END(except_vec_ejtag_debug)
151 * Vectored interrupt handler.
152 * This prototype is copied to ebase + n*IntCtl.VS and patched
153 * to invoke the handler
155 NESTED(except_vec_vi, 0, sp)
160 EXPORT(except_vec_vi_lui)
161 lui v0, 0 /* Patched */
162 j except_vec_vi_handler
163 EXPORT(except_vec_vi_ori)
164 ori v0, 0 /* Patched */
167 EXPORT(except_vec_vi_end)
170 * Common Vectored Interrupt code
171 * Complete the register saves and invoke the handler which is passed in $v0
173 NESTED(except_vec_vi_handler, 0, sp)
180 END(except_vec_vi_handler)
183 * EJTAG debug exception handler.
185 NESTED(ejtag_debug_handler, PT_SIZE, sp)
191 sll k0, k0, 30 # Check for SDBBP.
192 bgez k0, ejtag_return
194 PTR_LA k0, ejtag_debug_buffer
198 jal ejtag_exception_handler
200 PTR_LA k0, ejtag_debug_buffer
208 END(ejtag_debug_handler)
211 * This buffer is reserved for the use of the EJTAG debug
215 EXPORT(ejtag_debug_buffer)
222 * NMI debug exception handler for MIPS reference boards.
223 * The NMI debug exception entry point is 0xbfc00000, which
224 * normally is in the boot PROM, so the boot PROM must do a
225 * unconditional jump to this vector.
227 NESTED(except_vec_nmi, 0, sp)
233 NESTED(nmi_handler, PT_SIZE, sp)
238 jal nmi_exception_handler
245 .macro __build_clear_none
248 .macro __build_clear_sti
252 .macro __build_clear_cli
256 .macro __build_clear_fpe
264 .macro __build_clear_ade
265 MFC0 t0, CP0_BADVADDR
266 PTR_S t0, PT_BVADDR(sp)
270 .macro __BUILD_silent exception
273 /* Gas tries to parse the PRINT argument as a string containing
274 string escapes and emits bogus warnings if it believes to
275 recognize an unknown escape code. So make the arguments
276 start with an n and gas will believe \n is ok ... */
277 .macro __BUILD_verbose nexception
278 LONG_L a1, PT_EPC(sp)
280 PRINT("Got \nexception at %08lx\012")
283 PRINT("Got \nexception at %016lx\012")
287 .macro __BUILD_count exception
288 LONG_L t0,exception_count_\exception
290 LONG_S t0,exception_count_\exception
291 .comm exception_count\exception, 8, 8
294 .macro __BUILD_HANDLER exception handler clear verbose ext
296 NESTED(handle_\exception, PT_SIZE, sp)
299 FEXPORT(handle_\exception\ext)
302 __BUILD_\verbose \exception
306 END(handle_\exception)
309 .macro BUILD_HANDLER exception handler clear verbose
310 __BUILD_HANDLER \exception \handler \clear \verbose _int
313 BUILD_HANDLER adel ade ade silent /* #4 */
314 BUILD_HANDLER ades ade ade silent /* #5 */
315 BUILD_HANDLER ibe be cli silent /* #6 */
316 BUILD_HANDLER dbe be cli silent /* #7 */
317 BUILD_HANDLER bp bp sti silent /* #9 */
318 BUILD_HANDLER ri ri sti silent /* #10 */
319 BUILD_HANDLER cpu cpu sti silent /* #11 */
320 BUILD_HANDLER ov ov sti silent /* #12 */
321 BUILD_HANDLER tr tr sti silent /* #13 */
322 BUILD_HANDLER fpe fpe fpe silent /* #15 */
323 BUILD_HANDLER mdmx mdmx sti silent /* #22 */
324 BUILD_HANDLER watch watch sti verbose /* #23 */
325 BUILD_HANDLER mcheck mcheck cli verbose /* #24 */
326 BUILD_HANDLER mt mt sti verbose /* #25 */
327 BUILD_HANDLER dsp dsp sti silent /* #26 */
328 BUILD_HANDLER reserved reserved sti verbose /* others */
331 /* A temporary overflow handler used by check_daddi(). */
335 BUILD_HANDLER daddi_ov daddi_ov none silent /* #12 */