2 * linux/arch/arm/kernel/sys_arm.c
4 * Copyright (C) People who wrote linux/arch/i386/kernel/sys_i386.c
5 * Copyright (C) 1995, 1996 Russell King.
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.
11 * This file contains various random system calls that
12 * have a non-standard calling sequence on the Linux/arm
15 #include <linux/errno.h>
16 #include <linux/sched.h>
17 #include <linux/slab.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>
26 #include <linux/file.h>
27 #include <linux/utsname.h>
29 #include <asm/uaccess.h>
32 extern unsigned long do_mremap(unsigned long addr, unsigned long old_len,
33 unsigned long new_len, unsigned long flags,
34 unsigned long new_addr);
37 * sys_pipe() is the normal C calling standard for creating
38 * a pipe. It's not the way unix traditionally does this, though.
40 asmlinkage int sys_pipe(unsigned long __user *fildes)
47 if (copy_to_user(fildes, fd, 2*sizeof(int)))
53 /* common code for old and new mmaps */
55 unsigned long addr, unsigned long len,
56 unsigned long prot, unsigned long flags,
57 unsigned long fd, unsigned long pgoff)
60 struct file * file = NULL;
62 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
65 * If we are doing a fixed mapping, and address < PAGE_SIZE,
68 if (flags & MAP_FIXED && addr < PAGE_SIZE && vectors_base() == 0)
72 if (!(flags & MAP_ANONYMOUS)) {
78 down_write(¤t->mm->mmap_sem);
79 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
80 up_write(¤t->mm->mmap_sem);
88 struct mmap_arg_struct {
97 asmlinkage int old_mmap(struct mmap_arg_struct __user *arg)
100 struct mmap_arg_struct a;
102 if (copy_from_user(&a, arg, sizeof(a)))
106 if (a.offset & ~PAGE_MASK)
109 error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT);
114 asmlinkage unsigned long
115 sys_arm_mremap(unsigned long addr, unsigned long old_len,
116 unsigned long new_len, unsigned long flags,
117 unsigned long new_addr)
119 unsigned long ret = -EINVAL;
122 * If we are doing a fixed mapping, and address < PAGE_SIZE,
125 if (flags & MREMAP_FIXED && new_addr < PAGE_SIZE &&
129 down_write(¤t->mm->mmap_sem);
130 ret = do_mremap(addr, old_len, new_len, flags, new_addr);
131 up_write(¤t->mm->mmap_sem);
138 * Perform the select(nd, in, out, ex, tv) and mmap() system
142 struct sel_arg_struct {
144 fd_set __user *inp, *outp, *exp;
145 struct timeval __user *tvp;
148 asmlinkage int old_select(struct sel_arg_struct __user *arg)
150 struct sel_arg_struct a;
152 if (copy_from_user(&a, arg, sizeof(a)))
154 /* sys_select() does the appropriate kernel locking */
155 return sys_select(a.n, a.inp, a.outp, a.exp, a.tvp);
159 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
161 * This is really horribly ugly.
163 asmlinkage int sys_ipc(uint call, int first, int second, int third,
164 void __user *ptr, long fifth)
168 version = call >> 16; /* hack for backward compatibility */
173 return sys_semop(first, (struct sembuf __user *)ptr, second);
175 return sys_semget (first, second, third);
180 if (get_user(fourth.__pad, (void __user **) ptr))
182 return sys_semctl (first, second, third, fourth);
186 return sys_msgsnd(first, (struct msgbuf __user *) ptr,
191 struct ipc_kludge tmp;
194 if (copy_from_user(&tmp,(struct ipc_kludge __user *)ptr,
197 return sys_msgrcv (first, tmp.msgp, second,
201 return sys_msgrcv (first,
202 (struct msgbuf __user *) ptr,
203 second, fifth, third);
206 return sys_msgget ((key_t) first, second);
208 return sys_msgctl(first, second, (struct msqid_ds __user *)ptr);
214 ret = do_shmat(first, (char __user *)ptr, second, &raddr);
217 return put_user(raddr, (ulong __user *)third);
219 case 1: /* iBCS2 emulator entry point */
220 if (!segment_eq(get_fs(), get_ds()))
222 return do_shmat(first, (char __user *) ptr,
223 second, (ulong __user *) third);
226 return sys_shmdt ((char __user *)ptr);
228 return sys_shmget (first, second, third);
230 return sys_shmctl (first, second,
231 (struct shmid_ds __user *) ptr);
237 /* Fork a new task - this creates a new program thread.
238 * This is called indirectly via a small wrapper
240 asmlinkage int sys_fork(struct pt_regs *regs)
242 return do_fork(SIGCHLD, regs->ARM_sp, regs, 0, NULL, NULL);
245 /* Clone a task - this clones the calling program thread.
246 * This is called indirectly via a small wrapper
248 asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp, struct pt_regs *regs)
251 * We don't support SETTID / CLEARTID
253 if (clone_flags & (CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID))
257 newsp = regs->ARM_sp;
259 return do_fork(clone_flags & ~CLONE_IDLETASK, newsp, regs, 0, NULL, NULL);
262 asmlinkage int sys_vfork(struct pt_regs *regs)
264 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->ARM_sp, regs, 0, NULL, NULL);
267 /* sys_execve() executes a new program.
268 * This is called indirectly via a small wrapper
270 asmlinkage int sys_execve(char __user *filenamei, char __user * __user *argv,
271 char __user * __user *envp, struct pt_regs *regs)
276 filename = getname(filenamei);
277 error = PTR_ERR(filename);
278 if (IS_ERR(filename))
280 error = do_execve(filename, argv, envp, regs);