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 file contains various random system calls that
8 * have a non-standard calling sequence on the Linux/arm
12 #include <linux/errno.h>
13 #include <linux/sched.h>
14 #include <linux/malloc.h>
16 #include <linux/sem.h>
17 #include <linux/msg.h>
18 #include <linux/shm.h>
19 #include <linux/stat.h>
20 #include <linux/mman.h>
22 #include <linux/file.h>
23 #include <linux/utsname.h>
25 #include <asm/uaccess.h>
29 * Constant strings used in inlined functions in header files
33 * sys_pipe() is the normal C calling standard for creating
34 * a pipe. It's not the way unix traditionally does this, though.
36 asmlinkage
int sys_pipe(unsigned long * fildes
)
43 if (copy_to_user(fildes
, fd
, 2*sizeof(int)))
49 /* common code for old and new mmaps */
51 unsigned long addr
, unsigned long len
,
52 unsigned long prot
, unsigned long flags
,
53 unsigned long fd
, unsigned long pgoff
)
56 struct file
* file
= NULL
;
58 flags
&= ~(MAP_EXECUTABLE
| MAP_DENYWRITE
);
59 if (!(flags
& MAP_ANONYMOUS
)) {
65 down(¤t
->mm
->mmap_sem
);
66 error
= do_mmap_pgoff(file
, addr
, len
, prot
, flags
, pgoff
);
67 up(¤t
->mm
->mmap_sem
);
75 struct mmap_arg_struct
{
84 asmlinkage
int old_mmap(struct mmap_arg_struct
*arg
)
87 struct mmap_arg_struct a
;
89 if (copy_from_user(&a
, arg
, sizeof(a
)))
93 if (a
.offset
& ~PAGE_MASK
)
96 error
= do_mmap2(a
.addr
, a
.len
, a
.prot
, a
.flags
, a
.fd
, a
.offset
>> PAGE_SHIFT
);
102 * Perform the select(nd, in, out, ex, tv) and mmap() system
105 extern asmlinkage
int sys_select(int, fd_set
*, fd_set
*, fd_set
*, struct timeval
*);
107 struct sel_arg_struct
{
109 fd_set
*inp
, *outp
, *exp
;
113 asmlinkage
int old_select(struct sel_arg_struct
*arg
)
115 struct sel_arg_struct a
;
117 if (copy_from_user(&a
, arg
, sizeof(a
)))
119 /* sys_select() does the appropriate kernel locking */
120 return sys_select(a
.n
, a
.inp
, a
.outp
, a
.exp
, a
.tvp
);
124 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
126 * This is really horribly ugly.
128 asmlinkage
int sys_ipc (uint call
, int first
, int second
, int third
, void *ptr
, long fifth
)
132 version
= call
>> 16; /* hack for backward compatibility */
137 return sys_semop (first
, (struct sembuf
*)ptr
, second
);
139 return sys_semget (first
, second
, third
);
144 if (get_user(fourth
.__pad
, (void **) ptr
))
146 return sys_semctl (first
, second
, third
, fourth
);
150 return sys_msgsnd (first
, (struct msgbuf
*) ptr
,
155 struct ipc_kludge tmp
;
158 if (copy_from_user(&tmp
,(struct ipc_kludge
*) ptr
,
161 return sys_msgrcv (first
, tmp
.msgp
, second
,
165 return sys_msgrcv (first
,
166 (struct msgbuf
*) ptr
,
167 second
, fifth
, third
);
170 return sys_msgget ((key_t
) first
, second
);
172 return sys_msgctl (first
, second
, (struct msqid_ds
*) ptr
);
178 ret
= sys_shmat (first
, (char *) ptr
, second
, &raddr
);
181 return put_user (raddr
, (ulong
*) third
);
183 case 1: /* iBCS2 emulator entry point */
184 if (!segment_eq(get_fs(), get_ds()))
186 return sys_shmat (first
, (char *) ptr
,
187 second
, (ulong
*) third
);
190 return sys_shmdt ((char *)ptr
);
192 return sys_shmget (first
, second
, third
);
194 return sys_shmctl (first
, second
,
195 (struct shmid_ds
*) ptr
);
201 /* Fork a new task - this creates a new program thread.
202 * This is called indirectly via a small wrapper
204 asmlinkage
int sys_fork(struct pt_regs
*regs
)
206 return do_fork(SIGCHLD
, regs
->ARM_sp
, regs
, 0);
209 /* Clone a task - this clones the calling program thread.
210 * This is called indirectly via a small wrapper
212 asmlinkage
int sys_clone(unsigned long clone_flags
, unsigned long newsp
, struct pt_regs
*regs
)
215 newsp
= regs
->ARM_sp
;
216 return do_fork(clone_flags
, newsp
, regs
, 0);
219 asmlinkage
int sys_vfork(struct pt_regs
*regs
)
221 return do_fork(CLONE_VFORK
| CLONE_VM
| SIGCHLD
, regs
->ARM_sp
, regs
, 0);
224 /* sys_execve() executes a new program.
225 * This is called indirectly via a small wrapper
227 asmlinkage
int sys_execve(char *filenamei
, char **argv
, char **envp
, struct pt_regs
*regs
)
232 filename
= getname(filenamei
);
233 error
= PTR_ERR(filename
);
234 if (IS_ERR(filename
))
236 error
= do_execve(filename
, argv
, envp
, regs
);
242 asmlinkage
int sys_pause(void)
244 current
->state
= TASK_INTERRUPTIBLE
;
246 return -ERESTARTNOHAND
;