22f9d6cd947fa4d802f9259ef4c7cf6e4b50ab0e
[safe/jmp/linux-2.6] / arch / cris / kernel / sys_cris.c
1 /* $Id: sys_cris.c,v 1.6 2004/03/11 11:38:40 starvik Exp $
2  *
3  * linux/arch/cris/kernel/sys_cris.c
4  *
5  * This file contains various random system calls that
6  * have a non-standard calling sequence on some platforms.
7  * Since we don't have to do any backwards compatibility, our
8  * versions are done in the most "normal" way possible.
9  *
10  */
11
12 #include <linux/errno.h>
13 #include <linux/sched.h>
14 #include <linux/syscalls.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/ipc.h>
25
26 #include <asm/uaccess.h>
27 #include <asm/segment.h>
28
29 asmlinkage long
30 sys_mmap2(unsigned long addr, unsigned long len, unsigned long prot,
31           unsigned long flags, unsigned long fd, unsigned long pgoff)
32 {
33         /* bug(?): 8Kb pages here */
34         return sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff);
35 }
36
37 /*
38  * sys_ipc() is the de-multiplexer for the SysV IPC calls..
39  *
40  * This is really horribly ugly. (same as arch/i386)
41  */
42
43 asmlinkage int sys_ipc (uint call, int first, int second,
44                         int third, void __user *ptr, long fifth)
45 {
46         int version, ret;
47
48         version = call >> 16; /* hack for backward compatibility */
49         call &= 0xffff;
50
51         switch (call) {
52         case SEMOP:
53                 return sys_semtimedop (first, (struct sembuf __user *)ptr, second, NULL);
54         case SEMTIMEDOP:
55                 return sys_semtimedop(first, (struct sembuf __user *)ptr, second,
56                                         (const struct timespec __user *)fifth);
57
58         case SEMGET:
59                 return sys_semget (first, second, third);
60         case SEMCTL: {
61                 union semun fourth;
62                 if (!ptr)
63                         return -EINVAL;
64                 if (get_user(fourth.__pad, (void * __user *) ptr))
65                         return -EFAULT;
66                 return sys_semctl (first, second, third, fourth);
67         }
68
69         case MSGSND:
70                 return sys_msgsnd (first, (struct msgbuf __user *) ptr, 
71                                    second, third);
72         case MSGRCV:
73                 switch (version) {
74                 case 0: {
75                         struct ipc_kludge tmp;
76                         if (!ptr)
77                                 return -EINVAL;
78                         
79                         if (copy_from_user(&tmp,
80                                            (struct ipc_kludge __user *) ptr, 
81                                            sizeof (tmp)))
82                                 return -EFAULT;
83                         return sys_msgrcv (first, tmp.msgp, second,
84                                            tmp.msgtyp, third);
85                 }
86                 default:
87                         return sys_msgrcv (first,
88                                            (struct msgbuf __user *) ptr,
89                                            second, fifth, third);
90                 }
91         case MSGGET:
92                 return sys_msgget ((key_t) first, second);
93         case MSGCTL:
94                 return sys_msgctl (first, second, (struct msqid_ds __user *) ptr);
95
96         case SHMAT: {
97                 ulong raddr;
98                 ret = do_shmat (first, (char __user *) ptr, second, &raddr);
99                 if (ret)
100                         return ret;
101                 return put_user (raddr, (ulong __user *) third);
102         }
103         case SHMDT: 
104                 return sys_shmdt ((char __user *)ptr);
105         case SHMGET:
106                 return sys_shmget (first, second, third);
107         case SHMCTL:
108                 return sys_shmctl (first, second,
109                                    (struct shmid_ds __user *) ptr);
110         default:
111                 return -ENOSYS;
112         }
113 }