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>
21 #include <linux/ipc.h>
24 #include <asm/setup.h>
25 #include <asm/uaccess.h>
26 #include <asm/cachectl.h>
27 #include <asm/traps.h>
28 #include <asm/cacheflush.h>
29 #include <asm/unistd.h>
31 /* common code for old and new mmaps */
32 static inline long do_mmap2(
33 unsigned long addr
, unsigned long len
,
34 unsigned long prot
, unsigned long flags
,
35 unsigned long fd
, unsigned long pgoff
)
38 struct file
* file
= NULL
;
40 flags
&= ~(MAP_EXECUTABLE
| MAP_DENYWRITE
);
41 if (!(flags
& MAP_ANONYMOUS
)) {
47 down_write(¤t
->mm
->mmap_sem
);
48 error
= do_mmap_pgoff(file
, addr
, len
, prot
, flags
, pgoff
);
49 up_write(¤t
->mm
->mmap_sem
);
57 asmlinkage
long sys_mmap2(unsigned long addr
, unsigned long len
,
58 unsigned long prot
, unsigned long flags
,
59 unsigned long fd
, unsigned long pgoff
)
61 return do_mmap2(addr
, len
, prot
, flags
, fd
, pgoff
);
65 * Perform the select(nd, in, out, ex, tv) and mmap() system
66 * calls. Linux/m68k cloned Linux/i386, which didn't use to be able to
67 * handle more than 4 system call parameters, so these system calls
68 * used a memory block for parameter passing..
71 struct mmap_arg_struct
{
80 asmlinkage
int old_mmap(struct mmap_arg_struct
*arg
)
82 struct mmap_arg_struct a
;
85 if (copy_from_user(&a
, arg
, sizeof(a
)))
89 if (a
.offset
& ~PAGE_MASK
)
92 a
.flags
&= ~(MAP_EXECUTABLE
| MAP_DENYWRITE
);
94 error
= do_mmap2(a
.addr
, a
.len
, a
.prot
, a
.flags
, a
.fd
, a
.offset
>> PAGE_SHIFT
);
99 struct sel_arg_struct
{
101 fd_set
*inp
, *outp
, *exp
;
105 asmlinkage
int old_select(struct sel_arg_struct
*arg
)
107 struct sel_arg_struct a
;
109 if (copy_from_user(&a
, arg
, sizeof(a
)))
111 /* sys_select() does the appropriate kernel locking */
112 return sys_select(a
.n
, a
.inp
, a
.outp
, a
.exp
, a
.tvp
);
116 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
118 * This is really horribly ugly.
120 asmlinkage
int sys_ipc (uint call
, int first
, int second
,
121 int third
, void *ptr
, long fifth
)
125 version
= call
>> 16; /* hack for backward compatibility */
131 return sys_semop (first
, (struct sembuf
*)ptr
, second
);
133 return sys_semget (first
, second
, third
);
138 if (get_user(fourth
.__pad
, (void **) ptr
))
140 return sys_semctl (first
, second
, third
, fourth
);
148 return sys_msgsnd (first
, (struct msgbuf
*) ptr
,
153 struct ipc_kludge tmp
;
156 if (copy_from_user (&tmp
,
157 (struct ipc_kludge
*)ptr
,
160 return sys_msgrcv (first
, tmp
.msgp
, second
,
164 return sys_msgrcv (first
,
165 (struct msgbuf
*) ptr
,
166 second
, fifth
, third
);
169 return sys_msgget ((key_t
) first
, second
);
171 return sys_msgctl (first
, second
,
172 (struct msqid_ds
*) ptr
);
182 ret
= do_shmat (first
, ptr
, second
, &raddr
);
185 return put_user (raddr
, (ulong __user
*) third
);
189 return sys_shmdt (ptr
);
191 return sys_shmget (first
, second
, third
);
193 return sys_shmctl (first
, second
, ptr
);
201 /* sys_cacheflush -- flush (part of) the processor cache. */
203 sys_cacheflush (unsigned long addr
, int scope
, int cache
, unsigned long len
)
209 asmlinkage
int sys_getpagesize(void)
215 * Do a system call from kernel instead of calling sys_execve so we
216 * end up with proper pt_regs.
218 int kernel_execve(const char *filename
, char *const argv
[], char *const envp
[])
220 register long __res
asm ("%d0") = __NR_execve
;
221 register long __a
asm ("%d1") = (long)(filename
);
222 register long __b
asm ("%d2") = (long)(argv
);
223 register long __c
asm ("%d3") = (long)(envp
);
224 asm volatile ("trap #0" : "+d" (__res
)
225 : "d" (__a
), "d" (__b
), "d" (__c
));