include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[linux-2.6-block.git] / arch / arm / kernel / sys_arm.c
CommitLineData
1da177e4
LT
1/*
2 * linux/arch/arm/kernel/sys_arm.c
3 *
4 * Copyright (C) People who wrote linux/arch/i386/kernel/sys_i386.c
5 * Copyright (C) 1995, 1996 Russell King.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * This file contains various random system calls that
12 * have a non-standard calling sequence on the Linux/arm
13 * platform.
14 */
15#include <linux/module.h>
16#include <linux/errno.h>
17#include <linux/sched.h>
1da177e4
LT
18#include <linux/mm.h>
19#include <linux/sem.h>
20#include <linux/msg.h>
21#include <linux/shm.h>
22#include <linux/stat.h>
23#include <linux/syscalls.h>
24#include <linux/mman.h>
25#include <linux/fs.h>
26#include <linux/file.h>
cba4fbbf 27#include <linux/ipc.h>
33fa9b13 28#include <linux/uaccess.h>
5a0e3ad6 29#include <linux/slab.h>
1da177e4 30
1da177e4
LT
31/* Fork a new task - this creates a new program thread.
32 * This is called indirectly via a small wrapper
33 */
34asmlinkage int sys_fork(struct pt_regs *regs)
35{
f24284ad 36#ifdef CONFIG_MMU
1da177e4 37 return do_fork(SIGCHLD, regs->ARM_sp, regs, 0, NULL, NULL);
f24284ad
HC
38#else
39 /* can not support in nommu mode */
40 return(-EINVAL);
41#endif
1da177e4
LT
42}
43
44/* Clone a task - this clones the calling program thread.
45 * This is called indirectly via a small wrapper
46 */
47asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp,
48 int __user *parent_tidptr, int tls_val,
49 int __user *child_tidptr, struct pt_regs *regs)
50{
51 if (!newsp)
52 newsp = regs->ARM_sp;
53
54 return do_fork(clone_flags, newsp, regs, 0, parent_tidptr, child_tidptr);
55}
56
57asmlinkage int sys_vfork(struct pt_regs *regs)
58{
59 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->ARM_sp, regs, 0, NULL, NULL);
60}
61
62/* sys_execve() executes a new program.
63 * This is called indirectly via a small wrapper
64 */
65asmlinkage int sys_execve(char __user *filenamei, char __user * __user *argv,
66 char __user * __user *envp, struct pt_regs *regs)
67{
68 int error;
69 char * filename;
70
71 filename = getname(filenamei);
72 error = PTR_ERR(filename);
73 if (IS_ERR(filename))
74 goto out;
75 error = do_execve(filename, argv, envp, regs);
76 putname(filename);
77out:
78 return error;
79}
80
3db03b4a 81int kernel_execve(const char *filename, char *const argv[], char *const envp[])
1da177e4
LT
82{
83 struct pt_regs regs;
84 int ret;
85
86 memset(&regs, 0, sizeof(struct pt_regs));
87 ret = do_execve((char *)filename, (char __user * __user *)argv,
88 (char __user * __user *)envp, &regs);
89 if (ret < 0)
90 goto out;
91
92 /*
93 * Save argc to the register structure for userspace.
94 */
95 regs.ARM_r0 = ret;
96
97 /*
98 * We were successful. We won't be returning to our caller, but
99 * instead to user space by manipulating the kernel stack.
100 */
101 asm( "add r0, %0, %1\n\t"
102 "mov r1, %2\n\t"
103 "mov r2, %3\n\t"
104 "bl memmove\n\t" /* copy regs to top of stack */
105 "mov r8, #0\n\t" /* not a syscall */
106 "mov r9, %0\n\t" /* thread structure */
107 "mov sp, r0\n\t" /* reposition stack pointer */
108 "b ret_to_user"
109 :
110 : "r" (current_thread_info()),
4f7a1812 111 "Ir" (THREAD_START_SP - sizeof(regs)),
1da177e4
LT
112 "r" (&regs),
113 "Ir" (sizeof(regs))
c2f48086 114 : "r0", "r1", "r2", "r3", "ip", "lr", "memory");
1da177e4
LT
115
116 out:
117 return ret;
118}
3db03b4a 119EXPORT_SYMBOL(kernel_execve);
68d9102f
NP
120
121/*
6cbdc8c5 122 * Since loff_t is a 64 bit type we avoid a lot of ABI hassle
68d9102f
NP
123 * with a different argument ordering.
124 */
125asmlinkage long sys_arm_fadvise64_64(int fd, int advice,
126 loff_t offset, loff_t len)
127{
128 return sys_fadvise64_64(fd, offset, len, advice);
129}