1/* 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 4 * for more details. 5 * 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. 9 */ 10#include <linux/config.h> 11#include <asm/asm.h> 12#include <linux/errno.h> 13#include <asm/current.h> 14#include <asm/mipsregs.h> 15#include <asm/regdef.h> 16#include <asm/stackframe.h> 17#include <asm/unistd.h> 18#include <asm/offset.h> 19 20#ifndef CONFIG_BINFMT_ELF32 21/* Neither O32 nor N32, so define handle_sys here */ 22#define handle_sys64 handle_sys 23#endif 24 25 .align 5 26NESTED(handle_sys64, PT_SIZE, sp) 27/* When 32-bit compatibility is configured scall_o32.S already did this. */ 28#if !defined(CONFIG_MIPS32_O32) && !defined(CONFIG_MIPS32_N32) 29 .set noat 30 SAVE_SOME 31 STI 32 .set at 33#endif 34 35 subu t0, v0, __NR_64_Linux # check syscall number 36 sltiu t0, t0, __NR_64_Linux_syscalls + 1 37#if !defined(CONFIG_MIPS32_O32) && !defined(CONFIG_MIPS32_N32) 38 ld t1, PT_EPC(sp) # skip syscall on return 39 daddiu t1, 4 # skip to next instruction 40 sd t1, PT_EPC(sp) 41#endif 42 beqz t0, illegal_syscall 43 44 dsll t0, v0, 3 # offset into table 45 ld t2, (sys_call_table - (__NR_64_Linux * 8))(t0) # syscall routine 46 47 sd a3, PT_R26(sp) # save a3 for syscall restarting 48 49 ld t0, TASK_PTRACE($28) # syscall tracing enabled? 50 andi t0, _PT_TRACESYS 51 bnez t0, trace_a_syscall 52 53 jalr t2 # Do The Real Thing (TM) 54 55 li t0, -EMAXERRNO - 1 # error? 56 sltu t0, t0, v0 57 sd t0, PT_R7(sp) # set error flag 58 beqz t0, 1f 59 60 negu v0 # error 61 sd v0, PT_R0(sp) # set flag for syscall restarting 621: sd v0, PT_R2(sp) # result 63 64ret_from_sys_call: 65 mfc0 t0, CP0_STATUS 66 ori t0, t0, 1 67 xori t0, t0, 1 68 mtc0 t0, CP0_STATUS 69 SSNOP; SSNOP; SSNOP 70 71 ld t2, TASK_NEED_RESCHED($28) 72 bnez t2, _64_reschedule 73 lw v0, TASK_SIGPENDING($28) 74 bnez v0, signal_return 75 76restore_all: 77 RESTORE_SOME 78 RESTORE_SP 79 eret 80 81/* Put this behind restore_all for the sake of the branch prediction. */ 82signal_return: 83 .type signal_return, @function 84 85 mfc0 t0, CP0_STATUS 86 ori t0, t0, 1 87 mtc0 t0, CP0_STATUS 88 89 SAVE_STATIC 90 move a0, zero 91 move a1, sp 92 jal do_signal 93 RESTORE_STATIC 94 b restore_all 95 96_64_reschedule: 97 SAVE_STATIC 98 jal schedule 99 b ret_from_sys_call 100 101/* ------------------------------------------------------------------------ */ 102 103trace_a_syscall: 104 SAVE_STATIC 105 sd t2,PT_R1(sp) 106 jal syscall_trace 107 ld t2,PT_R1(sp) 108 109 ld a0, PT_R4(sp) # Restore argument registers 110 ld a1, PT_R5(sp) 111 ld a2, PT_R6(sp) 112 ld a3, PT_R7(sp) 113 jalr t2 114 115 li t0, -EMAXERRNO - 1 # error? 116 sltu t0, t0, v0 117 sd t0, PT_R7(sp) # set error flag 118 beqz t0, 1f 119 120 negu v0 # error 121 sd v0, PT_R0(sp) # set flag for syscall restarting 1221: sd v0, PT_R2(sp) # result 123 124 jal syscall_trace 125 j ret_from_sys_call 126 127illegal_syscall: 128 /* This also isn't a 64-bit syscall, throw an error. */ 129 li v0, ENOSYS # error 130 sd v0, PT_R2(sp) 131 li t0, 1 # set error flag 132 sd t0, PT_R7(sp) 133 j ret_from_sys_call 134 END(handle_sys64) 135 136 .align 3 137sys_call_table: 138 PTR sys_read /* 5000 */ 139 PTR sys_write 140 PTR sys_open 141 PTR sys_close 142 PTR sys_newstat 143 PTR sys_newfstat /* 5005 */ 144 PTR sys_newlstat 145 PTR sys_poll 146 PTR sys_lseek 147 PTR sys_mmap 148 PTR sys_mprotect /* 5010 */ 149 PTR sys_munmap 150 PTR sys_brk 151 PTR sys_rt_sigaction 152 PTR sys_rt_sigprocmask 153 PTR sys_ioctl /* 5015 */ 154 PTR sys_pread 155 PTR sys_pwrite 156 PTR sys_readv 157 PTR sys_writev 158 PTR sys_access /* 5020 */ 159 PTR sys_pipe 160 PTR sys_select 161 PTR sys_sched_yield 162 PTR sys_mremap 163 PTR sys_msync /* 5025 */ 164 PTR sys_mincore 165 PTR sys_madvise 166 PTR sys_shmget 167 PTR sys_shmat 168 PTR sys_shmctl /* 5030 */ 169 PTR sys_dup 170 PTR sys_dup2 171 PTR sys_pause 172 PTR sys_nanosleep 173 PTR sys_getitimer /* 5035 */ 174 PTR sys_setitimer 175 PTR sys_alarm 176 PTR sys_getpid 177 PTR sys_sendfile 178 PTR sys_socket /* 5040 */ 179 PTR sys_connect 180 PTR sys_accept 181 PTR sys_sendto 182 PTR sys_recvfrom 183 PTR sys_sendmsg /* 5045 */ 184 PTR sys_recvmsg 185 PTR sys_shutdown 186 PTR sys_bind 187 PTR sys_listen 188 PTR sys_getsockname /* 5050 */ 189 PTR sys_getpeername 190 PTR sys_socketpair 191 PTR sys_setsockopt 192 PTR sys_getsockopt 193 PTR sys_clone /* 5055 */ 194 PTR sys_fork 195 PTR sys_execve 196 PTR sys_exit 197 PTR sys_wait4 198 PTR sys_kill /* 5060 */ 199 PTR sys_newuname 200 PTR sys_semget 201 PTR sys_semop 202 PTR sys_semctl 203 PTR sys_shmdt /* 5065 */ 204 PTR sys_msgget 205 PTR sys_msgsnd 206 PTR sys_msgrcv 207 PTR sys_msgctl 208 PTR sys_fcntl /* 5070 */ 209 PTR sys_flock 210 PTR sys_fsync 211 PTR sys_fdatasync 212 PTR sys_truncate 213 PTR sys_ftruncate /* 5075 */ 214 PTR sys_getdents 215 PTR sys_getcwd 216 PTR sys_chdir 217 PTR sys_fchdir 218 PTR sys_rename /* 5080 */ 219 PTR sys_mkdir 220 PTR sys_rmdir 221 PTR sys_creat 222 PTR sys_link 223 PTR sys_unlink /* 5085 */ 224 PTR sys_symlink 225 PTR sys_readlink 226 PTR sys_chmod 227 PTR sys_fchmod 228 PTR sys_chown /* 5090 */ 229 PTR sys_fchown 230 PTR sys_lchown 231 PTR sys_umask 232 PTR sys_gettimeofday 233 PTR sys_getrlimit /* 5095 */ 234 PTR sys_getrusage 235 PTR sys_sysinfo 236 PTR sys_times 237 PTR sys_ptrace 238 PTR sys_getuid /* 5100 */ 239 PTR sys_syslog 240 PTR sys_getgid 241 PTR sys_setuid 242 PTR sys_setgid 243 PTR sys_geteuid /* 5105 */ 244 PTR sys_getegid 245 PTR sys_setpgid 246 PTR sys_getppid 247 PTR sys_getpgrp 248 PTR sys_setsid /* 5110 */ 249 PTR sys_setreuid 250 PTR sys_setregid 251 PTR sys_getgroups 252 PTR sys_setgroups 253 PTR sys_setresuid /* 5115 */ 254 PTR sys_getresuid 255 PTR sys_setresgid 256 PTR sys_getresgid 257 PTR sys_getpgid 258 PTR sys_setfsuid /* 5120 */ 259 PTR sys_setfsgid 260 PTR sys_getsid 261 PTR sys_capget 262 PTR sys_capset 263 PTR sys_rt_sigpending /* 5125 */ 264 PTR sys_rt_sigtimedwait 265 PTR sys_rt_sigqueueinfo 266 PTR sys_rt_sigsuspend 267 PTR sys_sigaltstack 268 PTR sys_utime /* 5130 */ 269 PTR sys_mknod 270 PTR sys_personality 271 PTR sys_ustat 272 PTR sys_statfs 273 PTR sys_fstatfs /* 5135 */ 274 PTR sys_sysfs 275 PTR sys_getpriority 276 PTR sys_setpriority 277 PTR sys_sched_setparam 278 PTR sys_sched_getparam /* 5140 */ 279 PTR sys_sched_setscheduler 280 PTR sys_sched_getscheduler 281 PTR sys_sched_get_priority_max 282 PTR sys_sched_get_priority_min 283 PTR sys_sched_rr_get_interval /* 5145 */ 284 PTR sys_mlock 285 PTR sys_munlock 286 PTR sys_mlockall 287 PTR sys_munlockall 288 PTR sys_vhangup /* 5150 */ 289 PTR sys_pivot_root 290 PTR sys_sysctl 291 PTR sys_prctl 292 PTR sys_adjtimex 293 PTR sys_setrlimit /* 5155 */ 294 PTR sys_chroot 295 PTR sys_sync 296 PTR sys_acct 297 PTR sys_settimeofday 298 PTR sys_mount /* 5160 */ 299 PTR sys_umount 300 PTR sys_swapon 301 PTR sys_swapoff 302 PTR sys_reboot 303 PTR sys_sethostname /* 5165 */ 304 PTR sys_setdomainname 305 PTR sys_create_module 306 PTR sys_init_module 307 PTR sys_delete_module 308 PTR sys_get_kernel_syms /* 5170 */ 309 PTR sys_query_module 310 PTR sys_quotactl 311 PTR sys_nfsservctl 312 PTR sys_ni_syscall /* res. for getpmsg */ 313 PTR sys_ni_syscall /* 5175 for putpmsg */ 314 PTR sys_ni_syscall /* res. for afs_syscall */ 315 PTR sys_ni_syscall /* res. for security */ 316 PTR sys_gettid 317 PTR sys_readahead 318 PTR sys_setxattr /* 5180 */ 319 PTR sys_lsetxattr 320 PTR sys_fsetxattr 321 PTR sys_getxattr 322 PTR sys_lgetxattr 323 PTR sys_fgetxattr /* 5185 */ 324 PTR sys_listxattr 325 PTR sys_llistxattr 326 PTR sys_flistxattr 327 PTR sys_removexattr 328 PTR sys_lremovexattr /* 5190 */ 329 PTR sys_fremovexattr 330 PTR sys_tkill 331 PTR sys_ni_syscall 332 PTR sys_ni_syscall /* res. for futex */ 333 PTR sys_ni_syscall /* 5195 rs. sched_setaffinity */ 334 PTR sys_ni_syscall /* res. f. sched_getaffinity */ 335 PTR sys_cacheflush 336 PTR sys_cachectl 337 PTR sys_sysmips 338 PTR sys_ni_syscall /* 5200 */ 339 PTR sys_ni_syscall 340 PTR sys_ni_syscall 341 PTR sys_ni_syscall 342 PTR sys_ni_syscall 343 PTR sys_ni_syscall /* 5205 */ 344 PTR sys_ni_syscall 345 PTR sys_ni_syscall 346 PTR sys_ni_syscall 347 PTR sys_ni_syscall 348 PTR sys_ni_syscall /* 5210 */ 349 PTR sys_rt_sigreturn 350 PTR sys_ni_syscall 351 PTR sys_ni_syscall 352 PTR sys_semtimedop 353