sys_cris.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. #include <linux/errno.h>
  12. #include <linux/sched.h>
  13. #include <linux/syscalls.h>
  14. #include <linux/mm.h>
  15. #include <linux/fs.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/ipc.h>
  24. #include <asm/uaccess.h>
  25. #include <asm/segment.h>
  26. asmlinkage long
  27. sys_mmap2(unsigned long addr, unsigned long len, unsigned long prot,
  28. unsigned long flags, unsigned long fd, unsigned long pgoff)
  29. {
  30. /* bug(?): 8Kb pages here */
  31. return sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff);
  32. }
  33. /*
  34. * sys_ipc() is the de-multiplexer for the SysV IPC calls..
  35. *
  36. * This is really horribly ugly. (same as arch/i386)
  37. */
  38. asmlinkage int sys_ipc (uint call, int first, int second,
  39. int third, void __user *ptr, long fifth)
  40. {
  41. int version, ret;
  42. version = call >> 16; /* hack for backward compatibility */
  43. call &= 0xffff;
  44. switch (call) {
  45. case SEMOP:
  46. return sys_semtimedop (first, (struct sembuf __user *)ptr, second, NULL);
  47. case SEMTIMEDOP:
  48. return sys_semtimedop(first, (struct sembuf __user *)ptr, second,
  49. (const struct timespec __user *)fifth);
  50. case SEMGET:
  51. return sys_semget (first, second, third);
  52. case SEMCTL: {
  53. union semun fourth;
  54. if (!ptr)
  55. return -EINVAL;
  56. if (get_user(fourth.__pad, (void * __user *) ptr))
  57. return -EFAULT;
  58. return sys_semctl (first, second, third, fourth);
  59. }
  60. case MSGSND:
  61. return sys_msgsnd (first, (struct msgbuf __user *) ptr,
  62. second, third);
  63. case MSGRCV:
  64. switch (version) {
  65. case 0: {
  66. struct ipc_kludge tmp;
  67. if (!ptr)
  68. return -EINVAL;
  69. if (copy_from_user(&tmp,
  70. (struct ipc_kludge __user *) ptr,
  71. sizeof (tmp)))
  72. return -EFAULT;
  73. return sys_msgrcv (first, tmp.msgp, second,
  74. tmp.msgtyp, third);
  75. }
  76. default:
  77. return sys_msgrcv (first,
  78. (struct msgbuf __user *) ptr,
  79. second, fifth, third);
  80. }
  81. case MSGGET:
  82. return sys_msgget ((key_t) first, second);
  83. case MSGCTL:
  84. return sys_msgctl (first, second, (struct msqid_ds __user *) ptr);
  85. case SHMAT: {
  86. ulong raddr;
  87. ret = do_shmat (first, (char __user *) ptr, second, &raddr);
  88. if (ret)
  89. return ret;
  90. return put_user (raddr, (ulong __user *) third);
  91. }
  92. case SHMDT:
  93. return sys_shmdt ((char __user *)ptr);
  94. case SHMGET:
  95. return sys_shmget (first, second, third);
  96. case SHMCTL:
  97. return sys_shmctl (first, second,
  98. (struct shmid_ds __user *) ptr);
  99. default:
  100. return -ENOSYS;
  101. }
  102. }