When verifying the decoded header before decoding the object identifier
[linux-2.6/mini2440.git] / arch / m68knommu / kernel / sys_m68k.c
blob70028163862981e5ce0f7082a737b97f73f88163
1 /*
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
6 * platform.
7 */
9 #include <linux/errno.h>
10 #include <linux/sched.h>
11 #include <linux/mm.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>
22 #include <linux/fs.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)
37 int error = -EBADF;
38 struct file * file = NULL;
40 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
41 if (!(flags & MAP_ANONYMOUS)) {
42 file = fget(fd);
43 if (!file)
44 goto out;
47 down_write(&current->mm->mmap_sem);
48 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
49 up_write(&current->mm->mmap_sem);
51 if (file)
52 fput(file);
53 out:
54 return error;
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 {
72 unsigned long addr;
73 unsigned long len;
74 unsigned long prot;
75 unsigned long flags;
76 unsigned long fd;
77 unsigned long offset;
80 asmlinkage int old_mmap(struct mmap_arg_struct *arg)
82 struct mmap_arg_struct a;
83 int error = -EFAULT;
85 if (copy_from_user(&a, arg, sizeof(a)))
86 goto out;
88 error = -EINVAL;
89 if (a.offset & ~PAGE_MASK)
90 goto out;
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);
95 out:
96 return error;
99 struct sel_arg_struct {
100 unsigned long n;
101 fd_set *inp, *outp, *exp;
102 struct timeval *tvp;
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)))
110 return -EFAULT;
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)
123 int version, ret;
125 version = call >> 16; /* hack for backward compatibility */
126 call &= 0xffff;
128 if (call <= SEMCTL)
129 switch (call) {
130 case SEMOP:
131 return sys_semop (first, (struct sembuf *)ptr, second);
132 case SEMGET:
133 return sys_semget (first, second, third);
134 case SEMCTL: {
135 union semun fourth;
136 if (!ptr)
137 return -EINVAL;
138 if (get_user(fourth.__pad, (void **) ptr))
139 return -EFAULT;
140 return sys_semctl (first, second, third, fourth);
142 default:
143 return -EINVAL;
145 if (call <= MSGCTL)
146 switch (call) {
147 case MSGSND:
148 return sys_msgsnd (first, (struct msgbuf *) ptr,
149 second, third);
150 case MSGRCV:
151 switch (version) {
152 case 0: {
153 struct ipc_kludge tmp;
154 if (!ptr)
155 return -EINVAL;
156 if (copy_from_user (&tmp,
157 (struct ipc_kludge *)ptr,
158 sizeof (tmp)))
159 return -EFAULT;
160 return sys_msgrcv (first, tmp.msgp, second,
161 tmp.msgtyp, third);
163 default:
164 return sys_msgrcv (first,
165 (struct msgbuf *) ptr,
166 second, fifth, third);
168 case MSGGET:
169 return sys_msgget ((key_t) first, second);
170 case MSGCTL:
171 return sys_msgctl (first, second,
172 (struct msqid_ds *) ptr);
173 default:
174 return -EINVAL;
176 if (call <= SHMCTL)
177 switch (call) {
178 case SHMAT:
179 switch (version) {
180 default: {
181 ulong raddr;
182 ret = do_shmat (first, ptr, second, &raddr);
183 if (ret)
184 return ret;
185 return put_user (raddr, (ulong __user *) third);
188 case SHMDT:
189 return sys_shmdt (ptr);
190 case SHMGET:
191 return sys_shmget (first, second, third);
192 case SHMCTL:
193 return sys_shmctl (first, second, ptr);
194 default:
195 return -ENOSYS;
198 return -EINVAL;
201 /* sys_cacheflush -- flush (part of) the processor cache. */
202 asmlinkage int
203 sys_cacheflush (unsigned long addr, int scope, int cache, unsigned long len)
205 flush_cache_all();
206 return(0);
209 asmlinkage int sys_getpagesize(void)
211 return PAGE_SIZE;
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));
226 return __res;