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 by Ralf Baechle
7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
8 * Copyright (C) 2001 MIPS Technologies, Inc.
10 #include <linux/config.h>
11 #include <linux/init.h>
12 #include <linux/sys.h>
14 #include <asm/addrspace.h>
16 #include <asm/cacheops.h>
17 #include <asm/current.h>
18 #include <asm/errno.h>
19 #include <asm/mipsregs.h>
21 #include <asm/pgtable-bits.h>
22 #include <asm/stackframe.h>
23 #include <asm/processor.h>
24 #include <asm/regdef.h>
25 #include <asm/fpregdef.h>
26 #include <asm/unistd.h>
27 #include <asm/isadep.h>
35 FEXPORT(ret_from_exception)
36 lw t0, PT_STATUS(sp) # returning to kernel mode?
40 FEXPORT(ret_from_sys_call) # here to prevent code duplication
42 mfc0 t0, CP0_STATUS # need_resched and signals atomic test
48 lw v0, TASK_NEED_RESCHED($28)
49 lw v1, TASK_SIGPENDING($28)
51 bnez v1, signal_return
52 restore_all: .set noat
56 /* Put this behind restore_all for the sake of the branch prediction. */
58 .type signal_return, @function
74 * Common spurious interrupt handler.
78 LEAF(spurious_interrupt)
80 * Someone tried to fool us by sending an interrupt but we
81 * couldn't find a cause for it.
83 lui t1,%hi(irq_err_count)
84 lw t0,%lo(irq_err_count)(t1)
86 sw t0,%lo(irq_err_count)(t1)
88 END(spurious_interrupt)
94 NESTED(except_vec1_generic, 0, sp)
95 PANIC("Exception vector 1 called")
96 END(except_vec1_generic)
99 * General exception vector. Used for all CPUs except R4000
100 * and R4400 SC and MC versions.
102 NESTED(except_vec3_generic, 0, sp)
103 #if R5432_CP0_INTERRUPT_WAR
107 la k0, exception_handlers
112 END(except_vec3_generic)
115 /* General exception vector R4000 version. */
116 NESTED(except_vec3_r4000, 0, sp)
124 beq k1, k0, handle_vced
126 beq k1, k0, handle_vcei
127 la k0, exception_handlers
134 * Big shit, we now may have two dirty primary cache lines for
135 * the same physical address. We can savely invalidate the
136 * line pointed to by c0_badvaddr because after return from
137 * this exception handler the load / store will be re-executed.
140 mfc0 k0, CP0_BADVADDR
144 cache Index_Store_Tag_D,(k0)
145 cache Hit_Writeback_Inv_SD,(k0)
146 #ifdef CONFIG_PROC_FS
147 lui k0, %hi(vced_count)
148 lw k1, %lo(vced_count)(k0)
150 sw k1, %lo(vced_count)(k0)
155 mfc0 k0, CP0_BADVADDR
156 cache Hit_Writeback_Inv_SD, (k0) # also cleans pi
157 #ifdef CONFIG_PROC_FS
158 lui k0, %hi(vcei_count)
159 lw k1, %lo(vcei_count)(k0)
161 sw k1, %lo(vcei_count)(k0)
165 END(except_vec3_r4000)
170 * Build a default exception handler for the exceptions that don't need
171 * special handlers. If you didn't know yet - I *like* playing games with
172 * the C preprocessor ...
174 #define __BUILD_clear_none(exception)
175 #define __BUILD_clear_sti(exception) \
177 #define __BUILD_clear_cli(exception) \
179 #define __BUILD_clear_fpe(exception) \
185 #define __BUILD_clear_ade(exception) \
187 MFC0 t0,CP0_BADVADDR; \
189 REG_S t0,PT_BVADDR(sp); \
191 #define __BUILD_silent(exception)
193 #define fmt "Got %s at %08lx.\n"
195 #define __BUILD_verbose(exception) \
198 REG_L a2,PT_EPC(sp); \
200 #define __BUILD_count(exception) \
202 lw t0,exception_count_##exception; \
205 sw t0,exception_count_##exception; \
207 EXPORT(exception_count_##exception); \
210 #define BUILD_HANDLER(exception,handler,clear,verbose) \
212 NESTED(handle_##exception, PT_SIZE, sp); \
215 FEXPORT(handle_##exception##_int); \
216 __BUILD_clear_##clear(exception); \
218 __BUILD_##verbose(exception); \
221 j ret_from_exception; \
223 END(handle_##exception)
225 BUILD_HANDLER(adel,ade,ade,silent) /* #4 */
226 BUILD_HANDLER(ades,ade,ade,silent) /* #5 */
227 BUILD_HANDLER(ibe,be,cli,silent) /* #6 */
228 BUILD_HANDLER(dbe,be,cli,silent) /* #7 */
229 BUILD_HANDLER(bp,bp,sti,silent) /* #9 */
230 BUILD_HANDLER(ri,ri,sti,silent) /* #10 */
231 BUILD_HANDLER(cpu,cpu,sti,silent) /* #11 */
232 BUILD_HANDLER(ov,ov,sti,silent) /* #12 */
233 BUILD_HANDLER(tr,tr,sti,silent) /* #13 */
234 BUILD_HANDLER(fpe,fpe,fpe,silent) /* #15 */
235 BUILD_HANDLER(mdmx,mdmx,sti,silent) /* #22 */
236 BUILD_HANDLER(watch,watch,sti,silent) /* #23 */
237 BUILD_HANDLER(mcheck,mcheck,cli,silent) /* #24 */
238 BUILD_HANDLER(reserved,reserved,sti,silent) /* others */
247 EXPORT(sys_call_table)
248 #define SYS(call, narg) PTR call
250 /* Reserved space for all SVR4 syscalls. */
251 .space (1000)*PTRSIZE
253 #ifdef CONFIG_BINFMT_IRIX
254 /* 32bit IRIX5 system calls. */
255 #include "irix5sys.h"
257 .space (1000)*PTRSIZE /* No IRIX syscalls */
260 /* Reserved space for all the BSD43 and POSIX syscalls. */
261 .space (2000)*PTRSIZE
263 /* Linux flavoured syscalls. */
264 #include "syscalls.h"
267 * Number of arguments of each syscall
269 EXPORT(sys_narg_table)
271 #define SYS(call, narg) .byte narg
273 /* Reserved space for all SVR4 flavoured syscalls. */
276 #ifdef CONFIG_BINFMT_IRIX
277 /* 32bit IRIX5 system calls. */
278 #include "irix5sys.h"
280 .space (1000) /* No IRIX syscalls */
283 /* Reserved space for all the BSD43 and POSIX syscalls. */
286 /* Linux flavoured syscalls. */
287 #include "syscalls.h"