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 - 2000, 2001 by Ralf Baechle
7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
8 * Copyright (C) 2001 MIPS Technologies, Inc.
10 * Hairy, the userspace application uses a different argument passing
11 * convention than the kernel, so we have to translate things from o32
12 * to ABI64 calling convention. 64-bit syscalls are also processed
15 #include <linux/config.h>
16 #include <linux/errno.h>
18 #include <asm/asmmacro.h>
19 #include <asm/mipsregs.h>
20 #include <asm/regdef.h>
21 #include <asm/stackframe.h>
22 #include <asm/thread_info.h>
23 #include <asm/unistd.h>
24 #include <asm/sysmips.h>
27 NESTED(handle_sys, PT_SIZE, sp)
32 ld t1, PT_EPC(sp) # skip syscall on return
34 subu t0, v0, __NR_O32_Linux # check syscall number
35 sltiu t0, t0, __NR_O32_Linux_syscalls + 1
36 daddiu t1, 4 # skip to next instruction
37 beqz t0, not_o32_scall
51 /* XXX Put both in one cacheline, should save a bit. */
52 dsll t0, v0, 3 # offset into table
53 ld t2, (sys_call_table - (__NR_O32_Linux * 8))(t0)
54 lbu t3, (sys_narg_table - __NR_O32_Linux)(v0)
56 subu t0, t3, 5 # 5 or more arguments?
57 sd a3, PT_R26(sp) # save a3 for syscall restarting
61 LONG_L t0, TI_FLAGS($28)
62 # syscall tracing enabled?
63 bnez t0, trace_a_syscall
65 jalr t2 # Do The Real Thing (TM)
67 li t0, -EMAXERRNO - 1 # error?
69 sd t0, PT_R7(sp) # set error flag
73 sd v0, PT_R0(sp) # flag for syscall restarting
74 1: sd v0, PT_R2(sp) # result
76 FEXPORT(o32_syscall_exit)
77 local_irq_disable # make need_resched and
78 # signals dont change between
80 LONG_L a2, TI_FLAGS($28)
81 li t0, _TIF_ALLWORK_MASK
83 bnez t0, o32_syscall_exit_work
87 o32_syscall_exit_work:
88 j syscall_exit_work_partial
90 /* ------------------------------------------------------------------------ */
103 ld a0, PT_R4(sp) # Restore argument registers
112 li t0, -EMAXERRNO - 1 # error?
114 sd t0, PT_R7(sp) # set error flag
118 sd v0, PT_R0(sp) # set flag for syscall restarting
119 1: sd v0, PT_R2(sp) # result
123 /* ------------------------------------------------------------------------ */
126 * More than four arguments. Try to deal with it by copying the
127 * stack arguments from the user stack to the kernel stack.
131 ld t0, PT_R29(sp) # get old user stack pointer
133 sll t1, t3, 2 # stack valid?
135 addu t1, t0 # end address
137 bltz t0, bad_stack # -> sp is bad
139 ld t0, PT_R29(sp) # get old user stack pointer
140 PTR_LA t1, 3f # copy 1 to 2 arguments
145 /* Ok, copy the args from the luser stack to the kernel stack */
149 1: lw a5, 20(t0) # argument #6 from usp
150 2: lw a4, 16(t0) # argument #5 from usp
153 j stack_done # go back
155 .section __ex_table,"a"
161 * The stackpointer for a call with more than 4 arguments is bad.
167 li t0, 1 # set error flag
173 * This is not an o32 compatibility syscall, pass it on
174 * to the 64-bit syscall handlers.
176 #ifdef CONFIG_MIPS32_N32
183 /* This also isn't a 64-bit syscall, throw an error. */
184 li v0, ENOSYS # error
186 li t0, 1 # set error flag
192 ld t0, PT_R29(sp) # user sp
194 sltu v0, a0, __NR_O32_Linux + __NR_O32_Linux_syscalls + 1
198 dla v1, sys32_syscall
199 ld t2, (sys_call_table - (__NR_O32_Linux * 8))(v0)
200 lbu t3, (sys_narg_table - __NR_O32_Linux)(a0)
203 beq t2, v1, out # do not recurse
205 beqz t2, enosys # null function pointer?
207 andi v0, t0, 0x3 # unaligned stack pointer?
210 daddiu v0, t0, 16 # v0 = usp + 16
211 daddu t1, v0, 12 # 3 32-bit arguments
212 ld v1, TI_ADDR_LIMIT($28)
217 move a0, a1 # shift argument registers
225 .section __ex_table,"a"
231 sw t3, 16(sp) # put into new stackframe
234 bnez t1, 1f # zero arguments?
235 daddu a0, sp, 32 # then pass sp in a0
243 enosys: li v0, -ENOSYS
252 efault: li v0, -EFAULT
258 sys sys32_syscall 0 /* 4000 */
263 sys sys_open 3 /* 4005 */
268 sys sys_unlink 1 /* 4010 */
273 sys sys_chmod 2 /* 4015 */
276 sys sys_ni_syscall 0 /* was sys_stat */
278 sys sys_getpid 0 /* 4020 */
283 sys sys_stime 1 /* 4025 */
286 sys sys_ni_syscall 0 /* was sys_fstat */
288 sys compat_sys_utime 2 /* 4030 */
293 sys sys_ni_syscall 0 /* 4035 */
298 sys sys_rmdir 1 /* 4040 */
301 sys compat_sys_times 1
303 sys sys_brk 1 /* 4045 */
306 sys sys_ni_syscall 0 /* was signal 2 */
308 sys sys_getegid 0 /* 4050 */
312 sys compat_sys_ioctl 3
313 sys compat_sys_fcntl 3 /* 4055 */
316 sys sys_ni_syscall, 0
318 sys sys_umask 1 /* 4060 */
323 sys sys_getpgrp 0 /* 4065 */
325 sys sys32_sigaction 3
328 sys sys_setreuid 2 /* 4070 */
330 sys sys32_sigsuspend 0
331 sys compat_sys_sigpending 1
332 sys sys_sethostname 2
333 sys compat_sys_setrlimit 2 /* 4075 */
334 sys compat_sys_getrlimit 2
335 sys compat_sys_getrusage 2
336 sys sys32_gettimeofday 2
337 sys sys32_settimeofday 2
338 sys sys_getgroups 2 /* 4080 */
340 sys sys_ni_syscall 0 /* old_select */
342 sys sys_ni_syscall 0 /* was sys_lstat */
343 sys sys_readlink 3 /* 4085 */
348 sys old_mmap 6 /* 4090 */
353 sys sys_fchown 3 /* 4095 */
354 sys sys_getpriority 2
355 sys sys_setpriority 3
357 sys compat_sys_statfs 2
358 sys compat_sys_fstatfs 2 /* 4100 */
359 sys sys_ni_syscall 0 /* sys_ioperm */
360 sys sys32_socketcall 2
362 sys compat_sys_setitimer 3
363 sys compat_sys_getitimer 2 /* 4105 */
364 sys compat_sys_newstat 2
365 sys compat_sys_newlstat 2
366 sys compat_sys_newfstat 2
368 sys sys_ni_syscall 0 /* sys_ioperm *//* 4110 */
370 sys sys_ni_syscall 0 /* was sys_idle */
371 sys sys_ni_syscall 0 /* sys_vm86 */
373 sys sys_swapoff 1 /* 4115 */
377 sys sys32_sigreturn 0
378 sys sys_clone 0 /* 4120 */
379 sys sys_setdomainname 2
381 sys sys_ni_syscall 0 /* sys_modify_ldt */
383 sys sys_mprotect 3 /* 4125 */
384 sys compat_sys_sigprocmask 3
385 sys sys_ni_syscall 0 /* was creat_module */
386 sys sys_init_module 5
387 sys sys_delete_module 1
388 sys sys_ni_syscall 0 /* 4130, get_kernel_syms */
393 sys sys_sysfs 3 /* 4135 */
394 sys sys32_personality 1
395 sys sys_ni_syscall 0 /* for afs_syscall */
398 sys sys32_llseek 5 /* 4140 */
403 sys sys32_readv 3 /* 4145 */
408 sys sys_ni_syscall 0 /* 4150 */
413 sys sys_munlock 2 /* 4155 */
416 sys sys_sched_setparam 2
417 sys sys_sched_getparam 2
418 sys sys_sched_setscheduler 3 /* 4160 */
419 sys sys_sched_getscheduler 1
420 sys sys_sched_yield 0
421 sys sys_sched_get_priority_max 1
422 sys sys_sched_get_priority_min 1
423 sys sys32_sched_rr_get_interval 2 /* 4165 */
424 sys compat_sys_nanosleep 2
428 sys sys_connect 3 /* 4170 */
429 sys sys_getpeername 3
430 sys sys_getsockname 3
433 sys sys_recv 4 /* 4175 */
435 sys compat_sys_recvmsg 3
437 sys compat_sys_sendmsg 3
438 sys sys_sendto 6 /* 4180 */
439 sys compat_sys_setsockopt 5
443 sys sys_setresuid 3 /* 4185 */
445 sys sys_ni_syscall 0 /* was query_module */
448 sys sys_setresgid 3 /* 4190 */
451 sys sys32_rt_sigreturn 0
452 sys sys32_rt_sigaction 4
453 sys sys32_rt_sigprocmask 4 /* 4195 */
454 sys sys32_rt_sigpending 2
455 sys sys32_rt_sigtimedwait 4
456 sys sys32_rt_sigqueueinfo 3
457 sys sys32_rt_sigsuspend 0
458 sys sys32_pread 6 /* 4200 */
463 sys sys_capset 2 /* 4205 */
464 sys sys32_sigaltstack 0
468 sys sys32_mmap2 6 /* 4210 */
469 sys sys32_truncate64 4
470 sys sys32_ftruncate64 4
473 sys sys_newfstat 2 /* 4215 */
478 sys compat_sys_fcntl64 3 /* 4220 */
481 sys sys32_readahead 5
483 sys sys_lsetxattr 5 /* 4225 */
488 sys sys_listxattr 3 /* 4230 */
491 sys sys_removexattr 2
492 sys sys_lremovexattr 2
493 sys sys_fremovexattr 2 /* 4235 */
496 sys compat_sys_futex 5
497 sys compat_sys_sched_setaffinity 3
498 sys compat_sys_sched_getaffinity 3 /* 4240 */
501 sys sys_io_getevents 5
503 sys sys_io_cancel 3 /* 4245 */
505 sys sys_lookup_dcookie 3
506 sys sys_epoll_create 1
508 sys sys_epoll_wait 3 /* 4250 */
509 sys sys_remap_file_pages 5
510 sys sys_set_tid_address 1
511 sys sys_restart_syscall 0
512 sys sys_fadvise64_64 7
513 sys sys_statfs64 3 /* 4255 */
515 sys sys_timer_create 3
516 sys sys_timer_settime 4
517 sys sys_timer_gettime 2
518 sys sys_timer_getoverrun 1 /* 4260 */
519 sys sys_timer_delete 1
520 sys sys_clock_settime 2
521 sys sys_clock_gettime 2
522 sys sys_clock_getres 2
523 sys sys_clock_nanosleep 4 /* 4265 */
525 sys compat_sys_utimes 2
529 .macro sys function, nargs
537 .macro sys function, nargs