Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * This file is subject to the terms and conditions of the GNU General Public
0003  * License.  See the file "COPYING" in the main directory of this archive
0004  * for more details.
0005  *
0006  * Copyright (C) 1995, 96, 97, 98, 99, 2000, 01, 02 by Ralf Baechle
0007  * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
0008  * Copyright (C) 2001 MIPS Technologies, Inc.
0009  */
0010 #include <linux/errno.h>
0011 #include <asm/asm.h>
0012 #include <asm/asmmacro.h>
0013 #include <asm/irqflags.h>
0014 #include <asm/mipsregs.h>
0015 #include <asm/regdef.h>
0016 #include <asm/stackframe.h>
0017 #include <asm/asm-offsets.h>
0018 #include <asm/sysmips.h>
0019 #include <asm/thread_info.h>
0020 #include <asm/unistd.h>
0021 
0022 #ifndef CONFIG_MIPS32_COMPAT
0023 /* Neither O32 nor N32, so define handle_sys here */
0024 #define handle_sys64 handle_sys
0025 #endif
0026 
0027     .align  5
0028 NESTED(handle_sys64, PT_SIZE, sp)
0029 #if !defined(CONFIG_MIPS32_O32) && !defined(CONFIG_MIPS32_N32)
0030     /*
0031      * When 32-bit compatibility is configured scall_o32.S
0032      * already did this.
0033      */
0034     .set    noat
0035     SAVE_SOME
0036     TRACE_IRQS_ON_RELOAD
0037     STI
0038     .set    at
0039 #endif
0040 
0041 #if !defined(CONFIG_MIPS32_O32) && !defined(CONFIG_MIPS32_N32)
0042     ld  t1, PT_EPC(sp)      # skip syscall on return
0043     daddiu  t1, 4           # skip to next instruction
0044     sd  t1, PT_EPC(sp)
0045 #endif
0046 
0047     sd  a3, PT_R26(sp)      # save a3 for syscall restarting
0048 
0049     li  t1, _TIF_WORK_SYSCALL_ENTRY
0050     LONG_L  t0, TI_FLAGS($28)   # syscall tracing enabled?
0051     and t0, t1, t0
0052     bnez    t0, syscall_trace_entry
0053 
0054 syscall_common:
0055     dsubu   t2, v0, __NR_64_Linux
0056     sltiu   t0, t2, __NR_64_Linux_syscalls
0057     beqz    t0, illegal_syscall
0058 
0059     dsll    t0, t2, 3       # offset into table
0060     dla t2, sys_call_table
0061     daddu   t0, t2, t0
0062     ld  t2, (t0)        # syscall routine
0063     beqz    t2, illegal_syscall
0064 
0065     jalr    t2          # Do The Real Thing (TM)
0066 
0067     li  t0, -EMAXERRNO - 1  # error?
0068     sltu    t0, t0, v0
0069     sd  t0, PT_R7(sp)       # set error flag
0070     beqz    t0, 1f
0071 
0072     ld  t1, PT_R2(sp)       # syscall number
0073     dnegu   v0          # error
0074     sd  t1, PT_R0(sp)       # save it for syscall restarting
0075 1:  sd  v0, PT_R2(sp)       # result
0076 
0077 n64_syscall_exit:
0078     j   syscall_exit_partial
0079 
0080 /* ------------------------------------------------------------------------ */
0081 
0082 syscall_trace_entry:
0083     SAVE_STATIC
0084     move    a0, sp
0085     move    a1, v0
0086     jal syscall_trace_enter
0087 
0088     bltz    v0, 1f          # seccomp failed? Skip syscall
0089 
0090     RESTORE_STATIC
0091     ld  v0, PT_R2(sp)       # Restore syscall (maybe modified)
0092     ld  a0, PT_R4(sp)       # Restore argument registers
0093     ld  a1, PT_R5(sp)
0094     ld  a2, PT_R6(sp)
0095     ld  a3, PT_R7(sp)
0096     ld  a4, PT_R8(sp)
0097     ld  a5, PT_R9(sp)
0098     j   syscall_common
0099 
0100 1:  j   syscall_exit
0101 
0102 illegal_syscall:
0103     /* This also isn't a 64-bit syscall, throw an error.  */
0104     li  v0, ENOSYS          # error
0105     sd  v0, PT_R2(sp)
0106     li  t0, 1               # set error flag
0107     sd  t0, PT_R7(sp)
0108     j   n64_syscall_exit
0109     END(handle_sys64)
0110 
0111 #define __SYSCALL(nr, entry)    PTR_WD entry
0112     .align  3
0113     .type   sys_call_table, @object
0114 EXPORT(sys_call_table)
0115 #include <asm/syscall_table_n64.h>