Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
Jesper Nilsson | 5978e79 | 2007-11-14 17:00:53 -0800 | [diff] [blame] | 16 | #include <linux/fs.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include <linux/smp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
Adrian Bunk | cba4fbb | 2007-10-16 23:29:24 -0700 | [diff] [blame] | 24 | #include <linux/ipc.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
| 26 | #include <asm/uaccess.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #include <asm/segment.h> |
| 28 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | asmlinkage unsigned long old_mmap(unsigned long __user *args) |
| 30 | { |
| 31 | unsigned long buffer[6]; |
| 32 | int err = -EFAULT; |
| 33 | |
| 34 | if (copy_from_user(&buffer, args, sizeof(buffer))) |
| 35 | goto out; |
| 36 | |
| 37 | err = -EINVAL; |
| 38 | if (buffer[5] & ~PAGE_MASK) /* verify that offset is on page boundary */ |
| 39 | goto out; |
| 40 | |
Al Viro | f8b7256 | 2009-11-30 17:37:04 -0500 | [diff] [blame] | 41 | err = sys_mmap_pgoff(buffer[0], buffer[1], buffer[2], buffer[3], |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | buffer[4], buffer[5] >> PAGE_SHIFT); |
| 43 | out: |
| 44 | return err; |
| 45 | } |
| 46 | |
| 47 | asmlinkage long |
| 48 | sys_mmap2(unsigned long addr, unsigned long len, unsigned long prot, |
| 49 | unsigned long flags, unsigned long fd, unsigned long pgoff) |
| 50 | { |
Al Viro | f8b7256 | 2009-11-30 17:37:04 -0500 | [diff] [blame] | 51 | /* bug(?): 8Kb pages here */ |
| 52 | return sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | /* |
| 56 | * sys_ipc() is the de-multiplexer for the SysV IPC calls.. |
| 57 | * |
| 58 | * This is really horribly ugly. (same as arch/i386) |
| 59 | */ |
| 60 | |
| 61 | asmlinkage int sys_ipc (uint call, int first, int second, |
| 62 | int third, void __user *ptr, long fifth) |
| 63 | { |
| 64 | int version, ret; |
| 65 | |
| 66 | version = call >> 16; /* hack for backward compatibility */ |
| 67 | call &= 0xffff; |
| 68 | |
| 69 | switch (call) { |
| 70 | case SEMOP: |
| 71 | return sys_semtimedop (first, (struct sembuf __user *)ptr, second, NULL); |
| 72 | case SEMTIMEDOP: |
| 73 | return sys_semtimedop(first, (struct sembuf __user *)ptr, second, |
| 74 | (const struct timespec __user *)fifth); |
| 75 | |
| 76 | case SEMGET: |
| 77 | return sys_semget (first, second, third); |
| 78 | case SEMCTL: { |
| 79 | union semun fourth; |
| 80 | if (!ptr) |
| 81 | return -EINVAL; |
| 82 | if (get_user(fourth.__pad, (void * __user *) ptr)) |
| 83 | return -EFAULT; |
| 84 | return sys_semctl (first, second, third, fourth); |
| 85 | } |
| 86 | |
| 87 | case MSGSND: |
| 88 | return sys_msgsnd (first, (struct msgbuf __user *) ptr, |
| 89 | second, third); |
| 90 | case MSGRCV: |
| 91 | switch (version) { |
| 92 | case 0: { |
| 93 | struct ipc_kludge tmp; |
| 94 | if (!ptr) |
| 95 | return -EINVAL; |
| 96 | |
| 97 | if (copy_from_user(&tmp, |
| 98 | (struct ipc_kludge __user *) ptr, |
| 99 | sizeof (tmp))) |
| 100 | return -EFAULT; |
| 101 | return sys_msgrcv (first, tmp.msgp, second, |
| 102 | tmp.msgtyp, third); |
| 103 | } |
| 104 | default: |
| 105 | return sys_msgrcv (first, |
| 106 | (struct msgbuf __user *) ptr, |
| 107 | second, fifth, third); |
| 108 | } |
| 109 | case MSGGET: |
| 110 | return sys_msgget ((key_t) first, second); |
| 111 | case MSGCTL: |
| 112 | return sys_msgctl (first, second, (struct msqid_ds __user *) ptr); |
| 113 | |
| 114 | case SHMAT: { |
| 115 | ulong raddr; |
| 116 | ret = do_shmat (first, (char __user *) ptr, second, &raddr); |
| 117 | if (ret) |
| 118 | return ret; |
| 119 | return put_user (raddr, (ulong __user *) third); |
| 120 | } |
| 121 | case SHMDT: |
| 122 | return sys_shmdt ((char __user *)ptr); |
| 123 | case SHMGET: |
| 124 | return sys_shmget (first, second, third); |
| 125 | case SHMCTL: |
| 126 | return sys_shmctl (first, second, |
| 127 | (struct shmid_ds __user *) ptr); |
| 128 | default: |
| 129 | return -ENOSYS; |
| 130 | } |
| 131 | } |