2 * linux/arch/cris/kernel/sys_cris.c
4 * This file contains various random system calls that
5 * have a non-standard calling sequence on some platforms.
6 * Since we don't have to do any backwards compatibility, our
7 * versions are done in the most "normal" way possible.
11 #include <linux/errno.h>
12 #include <linux/sched.h>
14 #include <linux/smp.h>
15 #include <linux/smp_lock.h>
16 #include <linux/sem.h>
17 #include <linux/msg.h>
18 #include <linux/shm.h>
19 #include <linux/stat.h>
20 #include <linux/mman.h>
21 #include <linux/file.h>
23 #include <asm/uaccess.h>
25 #include <asm/segment.h>
28 * sys_pipe() is the normal C calling standard for creating
29 * a pipe. It's not the way Unix traditionally does this, though.
31 asmlinkage int sys_pipe(unsigned long * fildes)
40 if (copy_to_user(fildes, fd, 2*sizeof(int)))
46 /* common code for old and new mmaps */
48 do_mmap2(unsigned long addr, unsigned long len, unsigned long prot,
49 unsigned long flags, unsigned long fd, unsigned long pgoff)
52 struct file * file = NULL;
54 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
55 if (!(flags & MAP_ANONYMOUS)) {
61 down_write(¤t->mm->mmap_sem);
62 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
63 up_write(¤t->mm->mmap_sem);
71 asmlinkage unsigned long old_mmap(unsigned long *args)
73 unsigned long buffer[6];
76 if (copy_from_user(&buffer, args, sizeof(buffer)))
80 if (buffer[5] & ~PAGE_MASK) /* verify that offset is on page boundary */
83 err = do_mmap2(buffer[0], buffer[1], buffer[2], buffer[3],
84 buffer[4], buffer[5] >> PAGE_SHIFT);
90 sys_mmap2(unsigned long addr, unsigned long len, unsigned long prot,
91 unsigned long flags, unsigned long fd, unsigned long pgoff)
93 return do_mmap2(addr, len, prot, flags, fd, pgoff);
97 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
99 * This is really horribly ugly. (same as arch/i386)
102 asmlinkage int sys_ipc (uint call, int first, int second,
103 int third, void *ptr, long fifth)
107 version = call >> 16; /* hack for backward compatibility */
112 return sys_semtimedop (first, (struct sembuf *)ptr, second, NULL);
114 return sys_semtimedop (first, (struct sembuf *)ptr, second,
115 (const struct timespec *)fifth);
117 return sys_semget (first, second, third);
122 if (get_user(fourth.__pad, (void **) ptr))
124 return sys_semctl (first, second, third, fourth);
128 return sys_msgsnd (first, (struct msgbuf *) ptr,
133 struct ipc_kludge tmp;
137 if (copy_from_user(&tmp,
138 (struct ipc_kludge *) ptr,
141 return sys_msgrcv (first, tmp.msgp, second,
145 return sys_msgrcv (first,
146 (struct msgbuf *) ptr,
147 second, fifth, third);
150 return sys_msgget ((key_t) first, second);
152 return sys_msgctl (first, second, (struct msqid_ds *) ptr);
156 ret = sys_shmat (first, (char *) ptr, second, &raddr);
159 return put_user (raddr, (ulong *) third);
162 return sys_shmdt ((char *)ptr);
164 return sys_shmget (first, second, third);
166 return sys_shmctl (first, second,
167 (struct shmid_ds *) ptr);
173 /* apparently this is legacy - if we don't need this in Linux/CRIS we can remove it. */
175 asmlinkage int sys_pause(void)
177 current->state = TASK_INTERRUPTIBLE;
179 return -ERESTARTNOHAND;