xref: /openbmc/linux/arch/mips/kernel/scall64-n32.S (revision 79f08d9e)
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/errno.h>
11#include <asm/asm.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>
19
20#ifndef CONFIG_MIPS32_O32
21/* No O32, so define handle_sys here */
22#define handle_sysn32 handle_sys
23#endif
24
25	.align	5
26NESTED(handle_sysn32, PT_SIZE, sp)
27#ifndef CONFIG_MIPS32_O32
28	.set	noat
29	SAVE_SOME
30	TRACE_IRQS_ON_RELOAD
31	STI
32	.set	at
33#endif
34
35	dsubu	t0, v0, __NR_N32_Linux	# check syscall number
36	sltiu	t0, t0, __NR_N32_Linux_syscalls + 1
37
38#ifndef CONFIG_MIPS32_O32
39	ld	t1, PT_EPC(sp)		# skip syscall on return
40	daddiu	t1, 4			# skip to next instruction
41	sd	t1, PT_EPC(sp)
42#endif
43	beqz	t0, not_n32_scall
44
45	dsll	t0, v0, 3		# offset into table
46	ld	t2, (sysn32_call_table - (__NR_N32_Linux * 8))(t0)
47
48	sd	a3, PT_R26(sp)		# save a3 for syscall restarting
49
50	li	t1, _TIF_WORK_SYSCALL_ENTRY
51	LONG_L	t0, TI_FLAGS($28)	# syscall tracing enabled?
52	and	t0, t1, t0
53	bnez	t0, n32_syscall_trace_entry
54
55	jalr	t2			# Do The Real Thing (TM)
56
57	li	t0, -EMAXERRNO - 1	# error?
58	sltu	t0, t0, v0
59	sd	t0, PT_R7(sp)		# set error flag
60	beqz	t0, 1f
61
62	ld	t1, PT_R2(sp)		# syscall number
63	dnegu	v0			# error
64	sd	t1, PT_R0(sp)		# save it for syscall restarting
651:	sd	v0, PT_R2(sp)		# result
66
67	j	syscall_exit_partial
68
69/* ------------------------------------------------------------------------ */
70
71n32_syscall_trace_entry:
72	SAVE_STATIC
73	move	s0, t2
74	move	a0, sp
75	jal	syscall_trace_enter
76
77	move	t0, s0
78	RESTORE_STATIC
79	ld	a0, PT_R4(sp)		# Restore argument registers
80	ld	a1, PT_R5(sp)
81	ld	a2, PT_R6(sp)
82	ld	a3, PT_R7(sp)
83	ld	a4, PT_R8(sp)
84	ld	a5, PT_R9(sp)
85	jalr	t0
86
87	li	t0, -EMAXERRNO - 1	# error?
88	sltu	t0, t0, v0
89	sd	t0, PT_R7(sp)		# set error flag
90	beqz	t0, 1f
91
92	ld	t1, PT_R2(sp)		# syscall number
93	dnegu	v0			# error
94	sd	t1, PT_R0(sp)		# save it for syscall restarting
951:	sd	v0, PT_R2(sp)		# result
96
97	j	syscall_exit
98
99not_n32_scall:
100	/* This is not an n32 compatibility syscall, pass it on to
101	   the n64 syscall handlers.  */
102	j	handle_sys64
103
104	END(handle_sysn32)
105
106	.type	sysn32_call_table, @object
107EXPORT(sysn32_call_table)
108	PTR	sys_read			/* 6000 */
109	PTR	sys_write
110	PTR	sys_open
111	PTR	sys_close
112	PTR	sys_newstat
113	PTR	sys_newfstat			/* 6005 */
114	PTR	sys_newlstat
115	PTR	sys_poll
116	PTR	sys_lseek
117	PTR	sys_mips_mmap
118	PTR	sys_mprotect			/* 6010 */
119	PTR	sys_munmap
120	PTR	sys_brk
121	PTR	compat_sys_rt_sigaction
122	PTR	compat_sys_rt_sigprocmask
123	PTR	compat_sys_ioctl		/* 6015 */
124	PTR	sys_pread64
125	PTR	sys_pwrite64
126	PTR	compat_sys_readv
127	PTR	compat_sys_writev
128	PTR	sys_access			/* 6020 */
129	PTR	sysm_pipe
130	PTR	compat_sys_select
131	PTR	sys_sched_yield
132	PTR	sys_mremap
133	PTR	sys_msync			/* 6025 */
134	PTR	sys_mincore
135	PTR	sys_madvise
136	PTR	sys_shmget
137	PTR	sys_shmat
138	PTR	compat_sys_shmctl			/* 6030 */
139	PTR	sys_dup
140	PTR	sys_dup2
141	PTR	sys_pause
142	PTR	compat_sys_nanosleep
143	PTR	compat_sys_getitimer		/* 6035 */
144	PTR	compat_sys_setitimer
145	PTR	sys_alarm
146	PTR	sys_getpid
147	PTR	compat_sys_sendfile
148	PTR	sys_socket			/* 6040 */
149	PTR	sys_connect
150	PTR	sys_accept
151	PTR	sys_sendto
152	PTR	compat_sys_recvfrom
153	PTR	compat_sys_sendmsg		/* 6045 */
154	PTR	compat_sys_recvmsg
155	PTR	sys_shutdown
156	PTR	sys_bind
157	PTR	sys_listen
158	PTR	sys_getsockname			/* 6050 */
159	PTR	sys_getpeername
160	PTR	sys_socketpair
161	PTR	compat_sys_setsockopt
162	PTR	sys_getsockopt
163	PTR	__sys_clone			/* 6055 */
164	PTR	__sys_fork
165	PTR	compat_sys_execve
166	PTR	sys_exit
167	PTR	compat_sys_wait4
168	PTR	sys_kill			/* 6060 */
169	PTR	sys_newuname
170	PTR	sys_semget
171	PTR	sys_semop
172	PTR	compat_sys_semctl
173	PTR	sys_shmdt			/* 6065 */
174	PTR	sys_msgget
175	PTR	compat_sys_msgsnd
176	PTR	compat_sys_msgrcv
177	PTR	compat_sys_msgctl
178	PTR	compat_sys_fcntl		/* 6070 */
179	PTR	sys_flock
180	PTR	sys_fsync
181	PTR	sys_fdatasync
182	PTR	sys_truncate
183	PTR	sys_ftruncate			/* 6075 */
184	PTR	compat_sys_getdents
185	PTR	sys_getcwd
186	PTR	sys_chdir
187	PTR	sys_fchdir
188	PTR	sys_rename			/* 6080 */
189	PTR	sys_mkdir
190	PTR	sys_rmdir
191	PTR	sys_creat
192	PTR	sys_link
193	PTR	sys_unlink			/* 6085 */
194	PTR	sys_symlink
195	PTR	sys_readlink
196	PTR	sys_chmod
197	PTR	sys_fchmod
198	PTR	sys_chown			/* 6090 */
199	PTR	sys_fchown
200	PTR	sys_lchown
201	PTR	sys_umask
202	PTR	compat_sys_gettimeofday
203	PTR	compat_sys_getrlimit		/* 6095 */
204	PTR	compat_sys_getrusage
205	PTR	compat_sys_sysinfo
206	PTR	compat_sys_times
207	PTR	compat_sys_ptrace
208	PTR	sys_getuid			/* 6100 */
209	PTR	sys_syslog
210	PTR	sys_getgid
211	PTR	sys_setuid
212	PTR	sys_setgid
213	PTR	sys_geteuid			/* 6105 */
214	PTR	sys_getegid
215	PTR	sys_setpgid
216	PTR	sys_getppid
217	PTR	sys_getpgrp
218	PTR	sys_setsid			/* 6110 */
219	PTR	sys_setreuid
220	PTR	sys_setregid
221	PTR	sys_getgroups
222	PTR	sys_setgroups
223	PTR	sys_setresuid			/* 6115 */
224	PTR	sys_getresuid
225	PTR	sys_setresgid
226	PTR	sys_getresgid
227	PTR	sys_getpgid
228	PTR	sys_setfsuid			/* 6120 */
229	PTR	sys_setfsgid
230	PTR	sys_getsid
231	PTR	sys_capget
232	PTR	sys_capset
233	PTR	compat_sys_rt_sigpending	/* 6125 */
234	PTR	compat_sys_rt_sigtimedwait
235	PTR	compat_sys_rt_sigqueueinfo
236	PTR	compat_sys_rt_sigsuspend
237	PTR	compat_sys_sigaltstack
238	PTR	compat_sys_utime		/* 6130 */
239	PTR	sys_mknod
240	PTR	sys_32_personality
241	PTR	compat_sys_ustat
242	PTR	compat_sys_statfs
243	PTR	compat_sys_fstatfs		/* 6135 */
244	PTR	sys_sysfs
245	PTR	sys_getpriority
246	PTR	sys_setpriority
247	PTR	sys_sched_setparam
248	PTR	sys_sched_getparam		/* 6140 */
249	PTR	sys_sched_setscheduler
250	PTR	sys_sched_getscheduler
251	PTR	sys_sched_get_priority_max
252	PTR	sys_sched_get_priority_min
253	PTR	compat_sys_sched_rr_get_interval	/* 6145 */
254	PTR	sys_mlock
255	PTR	sys_munlock
256	PTR	sys_mlockall
257	PTR	sys_munlockall
258	PTR	sys_vhangup			/* 6150 */
259	PTR	sys_pivot_root
260	PTR	compat_sys_sysctl
261	PTR	sys_prctl
262	PTR	compat_sys_adjtimex
263	PTR	compat_sys_setrlimit		/* 6155 */
264	PTR	sys_chroot
265	PTR	sys_sync
266	PTR	sys_acct
267	PTR	compat_sys_settimeofday
268	PTR	compat_sys_mount		/* 6160 */
269	PTR	sys_umount
270	PTR	sys_swapon
271	PTR	sys_swapoff
272	PTR	sys_reboot
273	PTR	sys_sethostname			/* 6165 */
274	PTR	sys_setdomainname
275	PTR	sys_ni_syscall			/* was create_module */
276	PTR	sys_init_module
277	PTR	sys_delete_module
278	PTR	sys_ni_syscall			/* 6170, was get_kernel_syms */
279	PTR	sys_ni_syscall			/* was query_module */
280	PTR	sys_quotactl
281	PTR	sys_ni_syscall			/* was nfsservctl */
282	PTR	sys_ni_syscall			/* res. for getpmsg */
283	PTR	sys_ni_syscall			/* 6175	 for putpmsg */
284	PTR	sys_ni_syscall			/* res. for afs_syscall */
285	PTR	sys_ni_syscall			/* res. for security */
286	PTR	sys_gettid
287	PTR	sys_readahead
288	PTR	sys_setxattr			/* 6180 */
289	PTR	sys_lsetxattr
290	PTR	sys_fsetxattr
291	PTR	sys_getxattr
292	PTR	sys_lgetxattr
293	PTR	sys_fgetxattr			/* 6185 */
294	PTR	sys_listxattr
295	PTR	sys_llistxattr
296	PTR	sys_flistxattr
297	PTR	sys_removexattr
298	PTR	sys_lremovexattr		/* 6190 */
299	PTR	sys_fremovexattr
300	PTR	sys_tkill
301	PTR	sys_ni_syscall
302	PTR	compat_sys_futex
303	PTR	compat_sys_sched_setaffinity	/* 6195 */
304	PTR	compat_sys_sched_getaffinity
305	PTR	sys_cacheflush
306	PTR	sys_cachectl
307	PTR	sys_sysmips
308	PTR	compat_sys_io_setup			/* 6200 */
309	PTR	sys_io_destroy
310	PTR	compat_sys_io_getevents
311	PTR	compat_sys_io_submit
312	PTR	sys_io_cancel
313	PTR	sys_exit_group			/* 6205 */
314	PTR	sys_lookup_dcookie
315	PTR	sys_epoll_create
316	PTR	sys_epoll_ctl
317	PTR	sys_epoll_wait
318	PTR	sys_remap_file_pages		/* 6210 */
319	PTR	sysn32_rt_sigreturn
320	PTR	compat_sys_fcntl64
321	PTR	sys_set_tid_address
322	PTR	sys_restart_syscall
323	PTR	compat_sys_semtimedop			/* 6215 */
324	PTR	sys_fadvise64_64
325	PTR	compat_sys_statfs64
326	PTR	compat_sys_fstatfs64
327	PTR	sys_sendfile64
328	PTR	compat_sys_timer_create		/* 6220 */
329	PTR	compat_sys_timer_settime
330	PTR	compat_sys_timer_gettime
331	PTR	sys_timer_getoverrun
332	PTR	sys_timer_delete
333	PTR	compat_sys_clock_settime		/* 6225 */
334	PTR	compat_sys_clock_gettime
335	PTR	compat_sys_clock_getres
336	PTR	compat_sys_clock_nanosleep
337	PTR	sys_tgkill
338	PTR	compat_sys_utimes		/* 6230 */
339	PTR	sys_ni_syscall			/* sys_mbind */
340	PTR	sys_ni_syscall			/* sys_get_mempolicy */
341	PTR	sys_ni_syscall			/* sys_set_mempolicy */
342	PTR	compat_sys_mq_open
343	PTR	sys_mq_unlink			/* 6235 */
344	PTR	compat_sys_mq_timedsend
345	PTR	compat_sys_mq_timedreceive
346	PTR	compat_sys_mq_notify
347	PTR	compat_sys_mq_getsetattr
348	PTR	sys_ni_syscall			/* 6240, sys_vserver */
349	PTR	compat_sys_waitid
350	PTR	sys_ni_syscall			/* available, was setaltroot */
351	PTR	sys_add_key
352	PTR	sys_request_key
353	PTR	sys_keyctl			/* 6245 */
354	PTR	sys_set_thread_area
355	PTR	sys_inotify_init
356	PTR	sys_inotify_add_watch
357	PTR	sys_inotify_rm_watch
358	PTR	sys_migrate_pages		/* 6250 */
359	PTR	sys_openat
360	PTR	sys_mkdirat
361	PTR	sys_mknodat
362	PTR	sys_fchownat
363	PTR	compat_sys_futimesat		/* 6255 */
364	PTR	sys_newfstatat
365	PTR	sys_unlinkat
366	PTR	sys_renameat
367	PTR	sys_linkat
368	PTR	sys_symlinkat			/* 6260 */
369	PTR	sys_readlinkat
370	PTR	sys_fchmodat
371	PTR	sys_faccessat
372	PTR	compat_sys_pselect6
373	PTR	compat_sys_ppoll		/* 6265 */
374	PTR	sys_unshare
375	PTR	sys_splice
376	PTR	sys_sync_file_range
377	PTR	sys_tee
378	PTR	compat_sys_vmsplice		/* 6270 */
379	PTR	sys_move_pages
380	PTR	compat_sys_set_robust_list
381	PTR	compat_sys_get_robust_list
382	PTR	compat_sys_kexec_load
383	PTR	sys_getcpu			/* 6275 */
384	PTR	compat_sys_epoll_pwait
385	PTR	sys_ioprio_set
386	PTR	sys_ioprio_get
387	PTR	compat_sys_utimensat
388	PTR	compat_sys_signalfd		/* 6280 */
389	PTR	sys_ni_syscall			/* was timerfd */
390	PTR	sys_eventfd
391	PTR	sys_fallocate
392	PTR	sys_timerfd_create
393	PTR	compat_sys_timerfd_gettime	/* 6285 */
394	PTR	compat_sys_timerfd_settime
395	PTR	compat_sys_signalfd4
396	PTR	sys_eventfd2
397	PTR	sys_epoll_create1
398	PTR	sys_dup3			/* 6290 */
399	PTR	sys_pipe2
400	PTR	sys_inotify_init1
401	PTR	compat_sys_preadv
402	PTR	compat_sys_pwritev
403	PTR	compat_sys_rt_tgsigqueueinfo	/* 6295 */
404	PTR	sys_perf_event_open
405	PTR	sys_accept4
406	PTR	compat_sys_recvmmsg
407	PTR	sys_getdents64
408	PTR	sys_fanotify_init		/* 6300 */
409	PTR	sys_fanotify_mark
410	PTR	sys_prlimit64
411	PTR	sys_name_to_handle_at
412	PTR	sys_open_by_handle_at
413	PTR	compat_sys_clock_adjtime	/* 6305 */
414	PTR	sys_syncfs
415	PTR	compat_sys_sendmmsg
416	PTR	sys_setns
417	PTR	compat_sys_process_vm_readv
418	PTR	compat_sys_process_vm_writev	/* 6310 */
419	PTR	sys_kcmp
420	PTR	sys_finit_module
421	.size	sysn32_call_table,.-sysn32_call_table
422