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) 1995, 96, 97, 98, 99, 2000, 01 by Ralf Baechle
7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
8 * Copyright (C) 2001 MIPS Technologies, Inc.
10 #include <linux/errno.h>
12 #include <asm/asmmacro.h>
13 #include <asm/irqflags.h>
14 #include <asm/mipsregs.h>
15 #include <asm/regdef.h>
16 #include <asm/stackframe.h>
17 #include <asm/thread_info.h>
18 #include <asm/unistd.h>
20 #ifndef CONFIG_MIPS32_O32
21 /* No O32, so define handle_sys here */
22 #define handle_sysn32 handle_sys
26 NESTED(handle_sysn32, PT_SIZE, sp)
27 #ifndef CONFIG_MIPS32_O32
35 dsubu t0, v0, __NR_N32_Linux # check syscall number
36 sltiu t0, t0, __NR_N32_Linux_syscalls
38 #ifndef CONFIG_MIPS32_O32
39 ld t1, PT_EPC(sp) # skip syscall on return
40 daddiu t1, 4 # skip to next instruction
43 beqz t0, not_n32_scall
45 sd a3, PT_R26(sp) # save a3 for syscall restarting
47 LONG_S v0, TI_SYSCALL($28) # Store syscall number
49 li t1, _TIF_WORK_SYSCALL_ENTRY
50 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
52 bnez t0, n32_syscall_trace_entry
55 dsll t0, v0, 3 # offset into table
56 ld t2, (sysn32_call_table - (__NR_N32_Linux * 8))(t0)
58 jalr t2 # Do The Real Thing (TM)
60 li t0, -EMAXERRNO - 1 # error?
62 sd t0, PT_R7(sp) # set error flag
65 ld t1, PT_R2(sp) # syscall number
67 sd t1, PT_R0(sp) # save it for syscall restarting
68 1: sd v0, PT_R2(sp) # result
70 j syscall_exit_partial
72 /* ------------------------------------------------------------------------ */
74 n32_syscall_trace_entry:
77 jal syscall_trace_enter
79 bltz v0, 1f # seccomp failed? Skip syscall
82 ld v0, PT_R2(sp) # Restore syscall (maybe modified)
83 ld a0, PT_R4(sp) # Restore argument registers
90 dsubu t2, v0, __NR_N32_Linux # check (new) syscall number
91 sltiu t0, t2, __NR_N32_Linux_syscalls
92 beqz t0, not_n32_scall
99 /* This is not an n32 compatibility syscall, pass it on to
100 the n64 syscall handlers. */
105 #define __SYSCALL(nr, entry) PTR_WD entry
106 .type sysn32_call_table, @object
107 EXPORT(sysn32_call_table)
108 #include <asm/syscall_table_n32.h>