Merge branches 'release', 'bugzilla-6217', 'bugzilla-6629', 'bugzilla-6933', 'bugzill...
[sfrench/cifs-2.6.git] / arch / sh / kernel / sys_sh64.c
1 /*
2  * arch/sh/kernel/sys_sh64.c
3  *
4  * Copyright (C) 2000, 2001  Paolo Alberelli
5  *
6  * This file contains various random system calls that
7  * have a non-standard calling sequence on the Linux/SH5
8  * platform.
9  *
10  * This file is subject to the terms and conditions of the GNU General Public
11  * License.  See the file "COPYING" in the main directory of this archive
12  * for more details.
13  */
14 #include <linux/errno.h>
15 #include <linux/rwsem.h>
16 #include <linux/sched.h>
17 #include <linux/mm.h>
18 #include <linux/fs.h>
19 #include <linux/smp.h>
20 #include <linux/sem.h>
21 #include <linux/msg.h>
22 #include <linux/shm.h>
23 #include <linux/stat.h>
24 #include <linux/mman.h>
25 #include <linux/file.h>
26 #include <linux/utsname.h>
27 #include <linux/syscalls.h>
28 #include <linux/ipc.h>
29 #include <asm/uaccess.h>
30 #include <asm/ptrace.h>
31 #include <asm/unistd.h>
32
33 /*
34  * sys_pipe() is the normal C calling standard for creating
35  * a pipe. It's not the way Unix traditionally does this, though.
36  */
37 asmlinkage int sys_pipe(unsigned long * fildes)
38 {
39         int fd[2];
40         int error;
41
42         error = do_pipe(fd);
43         if (!error) {
44                 if (copy_to_user(fildes, fd, 2*sizeof(int)))
45                         error = -EFAULT;
46         }
47         return error;
48 }
49
50 /*
51  * Do a system call from kernel instead of calling sys_execve so we
52  * end up with proper pt_regs.
53  */
54 int kernel_execve(const char *filename, char *const argv[], char *const envp[])
55 {
56         register unsigned long __sc0 __asm__ ("r9") = ((0x13 << 16) | __NR_execve);
57         register unsigned long __sc2 __asm__ ("r2") = (unsigned long) filename;
58         register unsigned long __sc3 __asm__ ("r3") = (unsigned long) argv;
59         register unsigned long __sc4 __asm__ ("r4") = (unsigned long) envp;
60         __asm__ __volatile__ ("trapa    %1 !\t\t\t execve(%2,%3,%4)"
61         : "=r" (__sc0)
62         : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4) );
63         __asm__ __volatile__ ("!dummy   %0 %1 %2 %3"
64         : : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4) : "memory");
65         return __sc0;
66 }