header cleaning: don't include smp_lock.h when not used
[usb.git] / arch / frv / kernel / sys_frv.c
blob26b3df32b9a7476a89dd2ee238f642a4bc2e73fa
1 /* sys_frv.c: FRV arch-specific syscall wrappers
3 * Copyright (C) 2003-5 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 * - Derived from arch/m68k/kernel/sys_m68k.c
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
13 #include <linux/errno.h>
14 #include <linux/sched.h>
15 #include <linux/mm.h>
16 #include <linux/smp.h>
17 #include <linux/sem.h>
18 #include <linux/msg.h>
19 #include <linux/shm.h>
20 #include <linux/stat.h>
21 #include <linux/mman.h>
22 #include <linux/file.h>
23 #include <linux/utsname.h>
24 #include <linux/syscalls.h>
26 #include <asm/setup.h>
27 #include <asm/uaccess.h>
28 #include <asm/ipc.h>
31 * sys_pipe() is the normal C calling standard for creating
32 * a pipe. It's not the way unix traditionally does this, though.
34 asmlinkage long sys_pipe(unsigned long __user * fildes)
36 int fd[2];
37 int error;
39 error = do_pipe(fd);
40 if (!error) {
41 if (copy_to_user(fildes, fd, 2*sizeof(int)))
42 error = -EFAULT;
44 return error;
47 asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
48 unsigned long prot, unsigned long flags,
49 unsigned long fd, unsigned long pgoff)
51 int error = -EBADF;
52 struct file * file = NULL;
54 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
55 if (!(flags & MAP_ANONYMOUS)) {
56 file = fget(fd);
57 if (!file)
58 goto out;
61 /* As with sparc32, make sure the shift for mmap2 is constant
62 (12), no matter what PAGE_SIZE we have.... */
64 /* But unlike sparc32, don't just silently break if we're
65 trying to map something we can't */
66 if (pgoff & ((1<<(PAGE_SHIFT-12))-1))
67 return -EINVAL;
69 pgoff >>= (PAGE_SHIFT - 12);
71 down_write(&current->mm->mmap_sem);
72 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
73 up_write(&current->mm->mmap_sem);
75 if (file)
76 fput(file);
77 out:
78 return error;
81 #if 0 /* DAVIDM - do we want this */
82 struct mmap_arg_struct64 {
83 __u32 addr;
84 __u32 len;
85 __u32 prot;
86 __u32 flags;
87 __u64 offset; /* 64 bits */
88 __u32 fd;
91 asmlinkage long sys_mmap64(struct mmap_arg_struct64 *arg)
93 int error = -EFAULT;
94 struct file * file = NULL;
95 struct mmap_arg_struct64 a;
96 unsigned long pgoff;
98 if (copy_from_user(&a, arg, sizeof(a)))
99 return -EFAULT;
101 if ((long)a.offset & ~PAGE_MASK)
102 return -EINVAL;
104 pgoff = a.offset >> PAGE_SHIFT;
105 if ((a.offset >> PAGE_SHIFT) != pgoff)
106 return -EINVAL;
108 if (!(a.flags & MAP_ANONYMOUS)) {
109 error = -EBADF;
110 file = fget(a.fd);
111 if (!file)
112 goto out;
114 a.flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
116 down_write(&current->mm->mmap_sem);
117 error = do_mmap_pgoff(file, a.addr, a.len, a.prot, a.flags, pgoff);
118 up_write(&current->mm->mmap_sem);
119 if (file)
120 fput(file);
121 out:
122 return error;
124 #endif
127 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
129 * This is really horribly ugly.
131 asmlinkage long sys_ipc(unsigned long call,
132 unsigned long first,
133 unsigned long second,
134 unsigned long third,
135 void __user *ptr,
136 unsigned long fifth)
138 int version, ret;
140 version = call >> 16; /* hack for backward compatibility */
141 call &= 0xffff;
143 switch (call) {
144 case SEMOP:
145 return sys_semtimedop(first, (struct sembuf __user *)ptr, second, NULL);
146 case SEMTIMEDOP:
147 return sys_semtimedop(first, (struct sembuf __user *)ptr, second,
148 (const struct timespec __user *)fifth);
150 case SEMGET:
151 return sys_semget (first, second, third);
152 case SEMCTL: {
153 union semun fourth;
154 if (!ptr)
155 return -EINVAL;
156 if (get_user(fourth.__pad, (void * __user *) ptr))
157 return -EFAULT;
158 return sys_semctl (first, second, third, fourth);
161 case MSGSND:
162 return sys_msgsnd (first, (struct msgbuf __user *) ptr,
163 second, third);
164 case MSGRCV:
165 switch (version) {
166 case 0: {
167 struct ipc_kludge tmp;
168 if (!ptr)
169 return -EINVAL;
171 if (copy_from_user(&tmp,
172 (struct ipc_kludge __user *) ptr,
173 sizeof (tmp)))
174 return -EFAULT;
175 return sys_msgrcv (first, tmp.msgp, second,
176 tmp.msgtyp, third);
178 default:
179 return sys_msgrcv (first,
180 (struct msgbuf __user *) ptr,
181 second, fifth, third);
183 case MSGGET:
184 return sys_msgget ((key_t) first, second);
185 case MSGCTL:
186 return sys_msgctl (first, second, (struct msqid_ds __user *) ptr);
188 case SHMAT:
189 switch (version) {
190 default: {
191 ulong raddr;
192 ret = do_shmat (first, (char __user *) ptr, second, &raddr);
193 if (ret)
194 return ret;
195 return put_user (raddr, (ulong __user *) third);
197 case 1: /* iBCS2 emulator entry point */
198 if (!segment_eq(get_fs(), get_ds()))
199 return -EINVAL;
200 /* The "(ulong *) third" is valid _only_ because of the kernel segment thing */
201 return do_shmat (first, (char __user *) ptr, second, (ulong *) third);
203 case SHMDT:
204 return sys_shmdt ((char __user *)ptr);
205 case SHMGET:
206 return sys_shmget (first, second, third);
207 case SHMCTL:
208 return sys_shmctl (first, second,
209 (struct shmid_ds __user *) ptr);
210 default:
211 return -ENOSYS;