Add missing syscalls.
[linux-2.6/linux-mips.git] / arch / mips64 / kernel / scall_64.S
blobe1a8ad2bba290134ec7d942d993ccce356b838ee
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, 02 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/mipsregs.h>
14 #include <asm/regdef.h>
15 #include <asm/stackframe.h>
16 #include <asm/offset.h>
17 #include <asm/unistd.h>
18 #include <asm/thread_info.h>
20 #ifndef CONFIG_BINFMT_ELF32
21 /* Neither O32 nor N32, so define handle_sys here */
22 #define handle_sys64 handle_sys
23 #endif
25         .align  5
26 NESTED(handle_sys64, PT_SIZE, sp)
27 #if !defined(CONFIG_MIPS32_O32) && !defined(CONFIG_MIPS32_N32)
28                 /*
29                  * When 32-bit compatibility is configured scall_o32.S
30                  * already did this.
31                  */
32                 .set    noat
33                 SAVE_SOME
34                 STI
35                 .set    at
36 #endif
37                 ld      t1, PT_EPC(sp)          # skip syscall on return
39                 subu    t0, v0, __NR_Linux      # check syscall number
40                 sltiu   t0, t0, __NR_Linux_syscalls + 1
41                 daddiu  t1, 4                   # skip to next instruction
42                 beqz    t0, illegal_syscall
43                 sd      t1, PT_EPC(sp)
45                 dsll    t0, v0, 3               # offset into table
46                 ld      t2, (sys_call_table - (__NR_Linux * 8))(t0)
47                                                 # syscall routine
49                 sd      a3, PT_R26(sp)          # save a3 for syscall restarting
51                 LONG_L  t0, TI_FLAGS($28)
52                 bltz    t0, syscall_trace_entry # syscall tracing enabled?
54                 jalr    t2                      # Do The Real Thing (TM)
56                 li      t0, -EMAXERRNO - 1      # error?
57                 sltu    t0, t0, v0
58                 sd      t0, PT_R7(sp)           # set error flag
59                 beqz    t0, 1f
61                 negu    v0                      # error
62                 sd      v0, PT_R0(sp)           # set flag for syscall
63                                                 # restarting
64 1:              sd      v0, PT_R2(sp)           # result
66 syscall_exit:
67                 mfc0    t0, CP0_STATUS          # make sure need_resched and
68                 ori     t0, t0, 1               # signals dont change between
69                 xori    t0, t0, 1               # sampling and return
70                 mtc0    t0, CP0_STATUS
71                 SSNOP; SSNOP; SSNOP
73                 LONG_L  a2, TI_FLAGS($28)       # current->work
74                 bnez    a2, syscall_exit_work
76 FEXPORT(restore_all)
77                 RESTORE_SOME
78                 RESTORE_SP
79                 eret
81 EXPORT(work_pending)
82                 andi    t0, a2, _TIF_NEED_RESCHED
83                 bltz    t0, work_notifysig
84 work_resched:
85                 jal     schedule
87                 mfc0    t0, CP0_STATUS          # make sure need_resched and
88                 ori     t0, t0, 1               # signals dont change between
89                 xori    t0, t0, 1               # sampling and return
90                 mtc0    t0, CP0_STATUS
91                 SSNOP; SSNOP; SSNOP
93                 LONG_L  a2, TI_FLAGS($28)
94                 andi    a2, _TIF_WORK_MASK      # is there any work to be done
95                                                 # other than syscall tracing
96                 beqz    a2, restore_all
97                 andi    t0, a2, _TIF_NEED_RESCHED
98                 bnez    t0, work_resched
100 work_notifysig:                                 # deal with pending signals and
101                                                 # notify-resume requests
102                 SAVE_STATIC
103                 move    a0, sp
104                 li      a1, 0
105                 jal     do_notify_resume        # a2 already loaded
106                 RESTORE_STATIC
107                 j       restore_all
109 syscall_exit_work:
110                 LONG_L  t0, TI_FLAGS($28)       # current->work.syscall_trace
111                 bgez    t0, work_pending
113                 mfc0    t0, CP0_STATUS          # sti
114                 ori     t0, t0, 1
115                 mtc0    t0, CP0_STATUS
116                 jal     do_syscall_trace
117                 j       resume_userspace
119 /* ------------------------------------------------------------------------ */
121 syscall_trace_entry:
122         SAVE_STATIC
123         sd      t2,PT_R1(sp)
124         jal     do_syscall_trace
125         ld      t2,PT_R1(sp)
127         ld      a0, PT_R4(sp)           # Restore argument registers
128         ld      a1, PT_R5(sp)
129         ld      a2, PT_R6(sp)
130         ld      a3, PT_R7(sp)
131         jalr    t2
133         li      t0, -EMAXERRNO - 1      # error?
134         sltu    t0, t0, v0
135         sd      t0, PT_R7(sp)           # set error flag
136         beqz    t0, 1f
138         negu    v0                      # error
139         sd      v0, PT_R0(sp)           # set flag for syscall restarting
140 1:      sd      v0, PT_R2(sp)           # result
142         j       syscall_exit
144 illegal_syscall:
145         /* This also isn't a 64-bit syscall, throw an error.  */
146         li      v0, ENOSYS                      # error
147         sd      v0, PT_R2(sp)
148         li      t0, 1                           # set error flag
149         sd      t0, PT_R7(sp)
150         j       syscall_exit
151         END(handle_sys64)
153         .align  3
154 sys_call_table:
155         PTR     sys_read                        /* 5000 */
156         PTR     sys_write
157         PTR     sys_open
158         PTR     sys_close
159         PTR     sys_newstat
160         PTR     sys_newfstat                    /* 5005 */
161         PTR     sys_newlstat
162         PTR     sys_poll
163         PTR     sys_lseek
164         PTR     sys_mmap
165         PTR     sys_mprotect                    /* 5010 */
166         PTR     sys_munmap
167         PTR     sys_brk
168         PTR     sys_rt_sigaction
169         PTR     sys_rt_sigprocmask
170         PTR     sys_ioctl                       /* 5015 */
171         PTR     sys_pread64
172         PTR     sys_pwrite64
173         PTR     sys_readv
174         PTR     sys_writev
175         PTR     sys_access                      /* 5020 */
176         PTR     sys_pipe
177         PTR     sys_select
178         PTR     sys_sched_yield
179         PTR     sys_mremap
180         PTR     sys_msync                       /* 5025 */
181         PTR     sys_mincore
182         PTR     sys_madvise
183         PTR     sys_shmget
184         PTR     sys_shmat
185         PTR     sys_shmctl                      /* 5030 */
186         PTR     sys_dup
187         PTR     sys_dup2
188         PTR     sys_pause
189         PTR     sys_nanosleep
190         PTR     sys_getitimer                   /* 5035 */
191         PTR     sys_setitimer
192         PTR     sys_alarm
193         PTR     sys_getpid
194         PTR     sys_sendfile
195         PTR     sys_socket                      /* 5040 */
196         PTR     sys_connect
197         PTR     sys_accept
198         PTR     sys_sendto
199         PTR     sys_recvfrom
200         PTR     sys_sendmsg                     /* 5045 */
201         PTR     sys_recvmsg
202         PTR     sys_shutdown
203         PTR     sys_bind
204         PTR     sys_listen
205         PTR     sys_getsockname                 /* 5050 */
206         PTR     sys_getpeername
207         PTR     sys_socketpair
208         PTR     sys_setsockopt
209         PTR     sys_getsockopt
210         PTR     sys_clone                       /* 5055 */
211         PTR     sys_fork
212         PTR     sys_execve
213         PTR     sys_exit
214         PTR     sys_wait4
215         PTR     sys_kill                        /* 5060 */
216         PTR     sys_newuname
217         PTR     sys_semget
218         PTR     sys_semop
219         PTR     sys_semctl
220         PTR     sys_shmdt                       /* 5065 */
221         PTR     sys_msgget
222         PTR     sys_msgsnd
223         PTR     sys_msgrcv
224         PTR     sys_msgctl
225         PTR     sys_fcntl                       /* 5070 */
226         PTR     sys_flock
227         PTR     sys_fsync
228         PTR     sys_fdatasync
229         PTR     sys_truncate
230         PTR     sys_ftruncate                   /* 5075 */
231         PTR     sys_getdents
232         PTR     sys_getcwd
233         PTR     sys_chdir
234         PTR     sys_fchdir
235         PTR     sys_rename                      /* 5080 */
236         PTR     sys_mkdir
237         PTR     sys_rmdir
238         PTR     sys_creat
239         PTR     sys_link
240         PTR     sys_unlink                      /* 5085 */
241         PTR     sys_symlink
242         PTR     sys_readlink
243         PTR     sys_chmod
244         PTR     sys_fchmod
245         PTR     sys_chown                       /* 5090 */
246         PTR     sys_fchown
247         PTR     sys_lchown
248         PTR     sys_umask
249         PTR     sys_gettimeofday
250         PTR     sys_getrlimit                   /* 5095 */
251         PTR     sys_getrusage
252         PTR     sys_sysinfo
253         PTR     sys_times
254         PTR     sys_ptrace
255         PTR     sys_getuid                      /* 5100 */
256         PTR     sys_syslog
257         PTR     sys_getgid
258         PTR     sys_setuid
259         PTR     sys_setgid
260         PTR     sys_geteuid                     /* 5105 */
261         PTR     sys_getegid
262         PTR     sys_setpgid
263         PTR     sys_getppid
264         PTR     sys_getpgrp
265         PTR     sys_setsid                      /* 5110 */
266         PTR     sys_setreuid
267         PTR     sys_setregid
268         PTR     sys_getgroups
269         PTR     sys_setgroups
270         PTR     sys_setresuid                   /* 5115 */
271         PTR     sys_getresuid
272         PTR     sys_setresgid
273         PTR     sys_getresgid
274         PTR     sys_getpgid
275         PTR     sys_setfsuid                    /* 5120 */
276         PTR     sys_setfsgid
277         PTR     sys_getsid
278         PTR     sys_capget
279         PTR     sys_capset
280         PTR     sys_rt_sigpending               /* 5125 */
281         PTR     sys_rt_sigtimedwait
282         PTR     sys_rt_sigqueueinfo
283         PTR     sys_rt_sigsuspend
284         PTR     sys_sigaltstack
285         PTR     sys_utime                       /* 5130 */
286         PTR     sys_mknod
287         PTR     sys_personality
288         PTR     sys_ustat
289         PTR     sys_statfs
290         PTR     sys_fstatfs                     /* 5135 */
291         PTR     sys_sysfs
292         PTR     sys_getpriority
293         PTR     sys_setpriority
294         PTR     sys_sched_setparam
295         PTR     sys_sched_getparam              /* 5140 */
296         PTR     sys_sched_setscheduler
297         PTR     sys_sched_getscheduler
298         PTR     sys_sched_get_priority_max
299         PTR     sys_sched_get_priority_min
300         PTR     sys_sched_rr_get_interval       /* 5145 */
301         PTR     sys_mlock
302         PTR     sys_munlock
303         PTR     sys_mlockall
304         PTR     sys_munlockall
305         PTR     sys_vhangup                     /* 5150 */
306         PTR     sys_pivot_root
307         PTR     sys_sysctl
308         PTR     sys_prctl
309         PTR     sys_adjtimex
310         PTR     sys_setrlimit                   /* 5155 */
311         PTR     sys_chroot
312         PTR     sys_sync
313         PTR     sys_acct
314         PTR     sys_settimeofday
315         PTR     sys_mount                       /* 5160 */
316         PTR     sys_umount
317         PTR     sys_swapon
318         PTR     sys_swapoff
319         PTR     sys_reboot
320         PTR     sys_sethostname                 /* 5165 */
321         PTR     sys_setdomainname
322         PTR     sys_ni_syscall                  /* was create_module */
323         PTR     sys_init_module
324         PTR     sys_delete_module
325         PTR     sys_ni_syscall                  /* 5170, was get_kernel_syms */
326         PTR     sys_ni_syscall                  /* was query_module */
327         PTR     sys_quotactl
328         PTR     sys_nfsservctl
329         PTR     sys_ni_syscall                  /* res. for getpmsg */
330         PTR     sys_ni_syscall                  /* 5175  for putpmsg */
331         PTR     sys_ni_syscall                  /* res. for afs_syscall */
332         PTR     sys_ni_syscall                  /* res. for security */
333         PTR     sys_gettid
334         PTR     sys_readahead
335         PTR     sys_setxattr                    /* 5180 */
336         PTR     sys_lsetxattr
337         PTR     sys_fsetxattr
338         PTR     sys_getxattr
339         PTR     sys_lgetxattr
340         PTR     sys_fgetxattr                   /* 5185 */
341         PTR     sys_listxattr
342         PTR     sys_llistxattr
343         PTR     sys_flistxattr
344         PTR     sys_removexattr
345         PTR     sys_lremovexattr                /* 5190 */
346         PTR     sys_fremovexattr
347         PTR     sys_tkill
348         PTR     sys_time
349         PTR     sys_futex
350         PTR     sys_sched_setaffinity           /* 5195 */
351         PTR     sys_sched_getaffinity
352         PTR     sys_cacheflush
353         PTR     sys_cachectl
354         PTR     sys_sysmips
355         PTR     sys_io_setup                    /* 5200 */
356         PTR     sys_io_destroy
357         PTR     sys_io_getevents
358         PTR     sys_io_submit
359         PTR     sys_io_cancel
360         PTR     sys_exit_group                  /* 5205 */
361         PTR     sys_lookup_dcookie
362         PTR     sys_epoll_create
363         PTR     sys_epoll_ctl
364         PTR     sys_epoll_wait
365         PTR     sys_remap_file_pages            /* 5210 */
366         PTR     sys_rt_sigreturn
367         PTR     sys_set_tid_address
368         PTR     sys_restart_syscall
369         PTR     sys_semtimedop
370         PTR     sys_fadvise64                   /* 5215 */
371         sys     sys_timer_create
372         sys     sys_timer_settime
373         sys     sys_timer_gettime
374         sys     sys_timer_getoverrun
375         sys     sys_timer_delete                /* 5220 */
376         sys     sys_clock_settime
377         sys     sys_clock_gettime
378         sys     sys_clock_getres
379         sys     sys_clock_nanosleep