added 2.6.29.6 aldebaran kernel
[nao-ulib.git] / kernel / 2.6.29.6-aldebaran-rt / arch / frv / kernel / sys_frv.c
blobbaadc97f86278ff2060f64932d60977c80d04abc
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/fs.h>
17 #include <linux/smp.h>
18 #include <linux/sem.h>
19 #include <linux/msg.h>
20 #include <linux/shm.h>
21 #include <linux/stat.h>
22 #include <linux/mman.h>
23 #include <linux/file.h>
24 #include <linux/utsname.h>
25 #include <linux/syscalls.h>
26 #include <linux/ipc.h>
28 #include <asm/setup.h>
29 #include <asm/uaccess.h>
31 asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
32 unsigned long prot, unsigned long flags,
33 unsigned long fd, unsigned long pgoff)
35 int error = -EBADF;
36 struct file * file = NULL;
38 /* As with sparc32, make sure the shift for mmap2 is constant
39 (12), no matter what PAGE_SIZE we have.... */
41 /* But unlike sparc32, don't just silently break if we're
42 trying to map something we can't */
43 if (pgoff & ((1 << (PAGE_SHIFT - 12)) - 1))
44 return -EINVAL;
45 pgoff >>= PAGE_SHIFT - 12;
47 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
48 if (!(flags & MAP_ANONYMOUS)) {
49 file = fget(fd);
50 if (!file)
51 goto out;
54 down_write(&current->mm->mmap_sem);
55 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
56 up_write(&current->mm->mmap_sem);
58 if (file)
59 fput(file);
60 out:
61 return error;
64 #if 0 /* DAVIDM - do we want this */
65 struct mmap_arg_struct64 {
66 __u32 addr;
67 __u32 len;
68 __u32 prot;
69 __u32 flags;
70 __u64 offset; /* 64 bits */
71 __u32 fd;
74 asmlinkage long sys_mmap64(struct mmap_arg_struct64 *arg)
76 int error = -EFAULT;
77 struct file * file = NULL;
78 struct mmap_arg_struct64 a;
79 unsigned long pgoff;
81 if (copy_from_user(&a, arg, sizeof(a)))
82 return -EFAULT;
84 if ((long)a.offset & ~PAGE_MASK)
85 return -EINVAL;
87 pgoff = a.offset >> PAGE_SHIFT;
88 if ((a.offset >> PAGE_SHIFT) != pgoff)
89 return -EINVAL;
91 if (!(a.flags & MAP_ANONYMOUS)) {
92 error = -EBADF;
93 file = fget(a.fd);
94 if (!file)
95 goto out;
97 a.flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
99 down_write(&current->mm->mmap_sem);
100 error = do_mmap_pgoff(file, a.addr, a.len, a.prot, a.flags, pgoff);
101 up_write(&current->mm->mmap_sem);
102 if (file)
103 fput(file);
104 out:
105 return error;
107 #endif
110 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
112 * This is really horribly ugly.
114 asmlinkage long sys_ipc(unsigned long call,
115 unsigned long first,
116 unsigned long second,
117 unsigned long third,
118 void __user *ptr,
119 unsigned long fifth)
121 int version, ret;
123 version = call >> 16; /* hack for backward compatibility */
124 call &= 0xffff;
126 switch (call) {
127 case SEMOP:
128 return sys_semtimedop(first, (struct sembuf __user *)ptr, second, NULL);
129 case SEMTIMEDOP:
130 return sys_semtimedop(first, (struct sembuf __user *)ptr, second,
131 (const struct timespec __user *)fifth);
133 case SEMGET:
134 return sys_semget (first, second, third);
135 case SEMCTL: {
136 union semun fourth;
137 if (!ptr)
138 return -EINVAL;
139 if (get_user(fourth.__pad, (void * __user *) ptr))
140 return -EFAULT;
141 return sys_semctl (first, second, third, fourth);
144 case MSGSND:
145 return sys_msgsnd (first, (struct msgbuf __user *) ptr,
146 second, third);
147 case MSGRCV:
148 switch (version) {
149 case 0: {
150 struct ipc_kludge tmp;
151 if (!ptr)
152 return -EINVAL;
154 if (copy_from_user(&tmp,
155 (struct ipc_kludge __user *) ptr,
156 sizeof (tmp)))
157 return -EFAULT;
158 return sys_msgrcv (first, tmp.msgp, second,
159 tmp.msgtyp, third);
161 default:
162 return sys_msgrcv (first,
163 (struct msgbuf __user *) ptr,
164 second, fifth, third);
166 case MSGGET:
167 return sys_msgget ((key_t) first, second);
168 case MSGCTL:
169 return sys_msgctl (first, second, (struct msqid_ds __user *) ptr);
171 case SHMAT:
172 switch (version) {
173 default: {
174 ulong raddr;
175 ret = do_shmat (first, (char __user *) ptr, second, &raddr);
176 if (ret)
177 return ret;
178 return put_user (raddr, (ulong __user *) third);
180 case 1: /* iBCS2 emulator entry point */
181 if (!segment_eq(get_fs(), get_ds()))
182 return -EINVAL;
183 /* The "(ulong *) third" is valid _only_ because of the kernel segment thing */
184 return do_shmat (first, (char __user *) ptr, second, (ulong *) third);
186 case SHMDT:
187 return sys_shmdt ((char __user *)ptr);
188 case SHMGET:
189 return sys_shmget (first, second, third);
190 case SHMCTL:
191 return sys_shmctl (first, second,
192 (struct shmid_ds __user *) ptr);
193 default:
194 return -ENOSYS;