2 * linux/arch/m68knommu/kernel/sys_m68k.c
4 * This file contains various random system calls that
5 * have a non-standard calling sequence on the Linux/m68k
9 #include <linux/errno.h>
10 #include <linux/sched.h>
12 #include <linux/smp.h>
13 #include <linux/sem.h>
14 #include <linux/msg.h>
15 #include <linux/shm.h>
16 #include <linux/stat.h>
17 #include <linux/syscalls.h>
18 #include <linux/mman.h>
19 #include <linux/file.h>
20 #include <linux/utsname.h>
23 #include <asm/setup.h>
24 #include <asm/uaccess.h>
25 #include <asm/cachectl.h>
26 #include <asm/traps.h>
28 #include <asm/cacheflush.h>
29 #include <asm/unistd.h>
32 * sys_pipe() is the normal C calling standard for creating
33 * a pipe. It's not the way unix traditionally does this, though.
35 asmlinkage
int sys_pipe(unsigned long * fildes
)
42 if (copy_to_user(fildes
, fd
, 2*sizeof(int)))
48 /* common code for old and new mmaps */
49 static inline long do_mmap2(
50 unsigned long addr
, unsigned long len
,
51 unsigned long prot
, unsigned long flags
,
52 unsigned long fd
, unsigned long pgoff
)
55 struct file
* file
= NULL
;
57 flags
&= ~(MAP_EXECUTABLE
| MAP_DENYWRITE
);
58 if (!(flags
& MAP_ANONYMOUS
)) {
64 down_write(¤t
->mm
->mmap_sem
);
65 error
= do_mmap_pgoff(file
, addr
, len
, prot
, flags
, pgoff
);
66 up_write(¤t
->mm
->mmap_sem
);
74 asmlinkage
long sys_mmap2(unsigned long addr
, unsigned long len
,
75 unsigned long prot
, unsigned long flags
,
76 unsigned long fd
, unsigned long pgoff
)
78 return do_mmap2(addr
, len
, prot
, flags
, fd
, pgoff
);
82 * Perform the select(nd, in, out, ex, tv) and mmap() system
83 * calls. Linux/m68k cloned Linux/i386, which didn't use to be able to
84 * handle more than 4 system call parameters, so these system calls
85 * used a memory block for parameter passing..
88 struct mmap_arg_struct
{
97 asmlinkage
int old_mmap(struct mmap_arg_struct
*arg
)
99 struct mmap_arg_struct a
;
102 if (copy_from_user(&a
, arg
, sizeof(a
)))
106 if (a
.offset
& ~PAGE_MASK
)
109 a
.flags
&= ~(MAP_EXECUTABLE
| MAP_DENYWRITE
);
111 error
= do_mmap2(a
.addr
, a
.len
, a
.prot
, a
.flags
, a
.fd
, a
.offset
>> PAGE_SHIFT
);
116 struct sel_arg_struct
{
118 fd_set
*inp
, *outp
, *exp
;
122 asmlinkage
int old_select(struct sel_arg_struct
*arg
)
124 struct sel_arg_struct a
;
126 if (copy_from_user(&a
, arg
, sizeof(a
)))
128 /* sys_select() does the appropriate kernel locking */
129 return sys_select(a
.n
, a
.inp
, a
.outp
, a
.exp
, a
.tvp
);
133 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
135 * This is really horribly ugly.
137 asmlinkage
int sys_ipc (uint call
, int first
, int second
,
138 int third
, void *ptr
, long fifth
)
142 version
= call
>> 16; /* hack for backward compatibility */
148 return sys_semop (first
, (struct sembuf
*)ptr
, second
);
150 return sys_semget (first
, second
, third
);
155 if (get_user(fourth
.__pad
, (void **) ptr
))
157 return sys_semctl (first
, second
, third
, fourth
);
165 return sys_msgsnd (first
, (struct msgbuf
*) ptr
,
170 struct ipc_kludge tmp
;
173 if (copy_from_user (&tmp
,
174 (struct ipc_kludge
*)ptr
,
177 return sys_msgrcv (first
, tmp
.msgp
, second
,
181 return sys_msgrcv (first
,
182 (struct msgbuf
*) ptr
,
183 second
, fifth
, third
);
186 return sys_msgget ((key_t
) first
, second
);
188 return sys_msgctl (first
, second
,
189 (struct msqid_ds
*) ptr
);
199 ret
= do_shmat (first
, ptr
, second
, &raddr
);
202 return put_user (raddr
, (ulong __user
*) third
);
206 return sys_shmdt (ptr
);
208 return sys_shmget (first
, second
, third
);
210 return sys_shmctl (first
, second
, ptr
);
218 /* sys_cacheflush -- flush (part of) the processor cache. */
220 sys_cacheflush (unsigned long addr
, int scope
, int cache
, unsigned long len
)
226 asmlinkage
int sys_getpagesize(void)
232 * Do a system call from kernel instead of calling sys_execve so we
233 * end up with proper pt_regs.
235 int kernel_execve(const char *filename
, char *const argv
[], char *const envp
[])
237 register long __res
asm ("%d0") = __NR_execve
;
238 register long __a
asm ("%d1") = (long)(filename
);
239 register long __b
asm ("%d2") = (long)(argv
);
240 register long __c
asm ("%d3") = (long)(envp
);
241 asm volatile ("trap #0" : "+d" (__res
)
242 : "d" (__a
), "d" (__b
), "d" (__c
));