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 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/thread_info.h>
0018 #include <asm/unistd.h>
0019 
0020 #ifndef CONFIG_MIPS32_O32
0021 /* No O32, so define handle_sys here */
0022 #define handle_sysn32 handle_sys
0023 #endif
0024 
0025     .align  5
0026 NESTED(handle_sysn32, PT_SIZE, sp)
0027 #ifndef CONFIG_MIPS32_O32
0028     .set    noat
0029     SAVE_SOME
0030     TRACE_IRQS_ON_RELOAD
0031     STI
0032     .set    at
0033 #endif
0034 
0035     dsubu   t0, v0, __NR_N32_Linux  # check syscall number
0036     sltiu   t0, t0, __NR_N32_Linux_syscalls
0037 
0038 #ifndef CONFIG_MIPS32_O32
0039     ld  t1, PT_EPC(sp)      # skip syscall on return
0040     daddiu  t1, 4           # skip to next instruction
0041     sd  t1, PT_EPC(sp)
0042 #endif
0043     beqz    t0, not_n32_scall
0044 
0045     sd  a3, PT_R26(sp)      # save a3 for syscall restarting
0046 
0047     li  t1, _TIF_WORK_SYSCALL_ENTRY
0048     LONG_L  t0, TI_FLAGS($28)   # syscall tracing enabled?
0049     and t0, t1, t0
0050     bnez    t0, n32_syscall_trace_entry
0051 
0052 syscall_common:
0053     dsll    t0, v0, 3       # offset into table
0054     ld  t2, (sysn32_call_table - (__NR_N32_Linux * 8))(t0)
0055 
0056     jalr    t2          # Do The Real Thing (TM)
0057 
0058     li  t0, -EMAXERRNO - 1  # error?
0059     sltu    t0, t0, v0
0060     sd  t0, PT_R7(sp)       # set error flag
0061     beqz    t0, 1f
0062 
0063     ld  t1, PT_R2(sp)       # syscall number
0064     dnegu   v0          # error
0065     sd  t1, PT_R0(sp)       # save it for syscall restarting
0066 1:  sd  v0, PT_R2(sp)       # result
0067 
0068     j   syscall_exit_partial
0069 
0070 /* ------------------------------------------------------------------------ */
0071 
0072 n32_syscall_trace_entry:
0073     SAVE_STATIC
0074     move    a0, sp
0075     move    a1, v0
0076     jal syscall_trace_enter
0077 
0078     bltz    v0, 1f          # seccomp failed? Skip syscall
0079 
0080     RESTORE_STATIC
0081     ld  v0, PT_R2(sp)       # Restore syscall (maybe modified)
0082     ld  a0, PT_R4(sp)       # Restore argument registers
0083     ld  a1, PT_R5(sp)
0084     ld  a2, PT_R6(sp)
0085     ld  a3, PT_R7(sp)
0086     ld  a4, PT_R8(sp)
0087     ld  a5, PT_R9(sp)
0088 
0089     dsubu   t2, v0, __NR_N32_Linux  # check (new) syscall number
0090     sltiu   t0, t2, __NR_N32_Linux_syscalls
0091     beqz    t0, not_n32_scall
0092 
0093     j   syscall_common
0094 
0095 1:  j   syscall_exit
0096 
0097 not_n32_scall:
0098     /* This is not an n32 compatibility syscall, pass it on to
0099        the n64 syscall handlers.  */
0100     j   handle_sys64
0101 
0102     END(handle_sysn32)
0103 
0104 #define __SYSCALL(nr, entry)    PTR_WD entry
0105     .type   sysn32_call_table, @object
0106 EXPORT(sysn32_call_table)
0107 #include <asm/syscall_table_n32.h>