sys_frv.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /* sys_frv.c: FRV arch-specific syscall wrappers
  2. *
  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
  6. *
  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.
  11. */
  12. #include <linux/errno.h>
  13. #include <linux/sched.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/syscalls.h>
  24. #include <linux/ipc.h>
  25. #include <asm/setup.h>
  26. #include <asm/uaccess.h>
  27. asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
  28. unsigned long prot, unsigned long flags,
  29. unsigned long fd, unsigned long pgoff)
  30. {
  31. /* As with sparc32, make sure the shift for mmap2 is constant
  32. (12), no matter what PAGE_SIZE we have.... */
  33. /* But unlike sparc32, don't just silently break if we're
  34. trying to map something we can't */
  35. if (pgoff & ((1 << (PAGE_SHIFT - 12)) - 1))
  36. return -EINVAL;
  37. return sys_mmap_pgoff(addr, len, prot, flags, fd,
  38. pgoff >> (PAGE_SHIFT - 12));
  39. }
  40. /*
  41. * sys_ipc() is the de-multiplexer for the SysV IPC calls..
  42. *
  43. * This is really horribly ugly.
  44. */
  45. asmlinkage long sys_ipc(unsigned long call,
  46. unsigned long first,
  47. unsigned long second,
  48. unsigned long third,
  49. void __user *ptr,
  50. unsigned long fifth)
  51. {
  52. int version, ret;
  53. version = call >> 16; /* hack for backward compatibility */
  54. call &= 0xffff;
  55. switch (call) {
  56. case SEMOP:
  57. return sys_semtimedop(first, (struct sembuf __user *)ptr, second, NULL);
  58. case SEMTIMEDOP:
  59. return sys_semtimedop(first, (struct sembuf __user *)ptr, second,
  60. (const struct timespec __user *)fifth);
  61. case SEMGET:
  62. return sys_semget (first, second, third);
  63. case SEMCTL: {
  64. union semun fourth;
  65. if (!ptr)
  66. return -EINVAL;
  67. if (get_user(fourth.__pad, (void * __user *) ptr))
  68. return -EFAULT;
  69. return sys_semctl (first, second, third, fourth);
  70. }
  71. case MSGSND:
  72. return sys_msgsnd (first, (struct msgbuf __user *) ptr,
  73. second, third);
  74. case MSGRCV:
  75. switch (version) {
  76. case 0: {
  77. struct ipc_kludge tmp;
  78. if (!ptr)
  79. return -EINVAL;
  80. if (copy_from_user(&tmp,
  81. (struct ipc_kludge __user *) ptr,
  82. sizeof (tmp)))
  83. return -EFAULT;
  84. return sys_msgrcv (first, tmp.msgp, second,
  85. tmp.msgtyp, third);
  86. }
  87. default:
  88. return sys_msgrcv (first,
  89. (struct msgbuf __user *) ptr,
  90. second, fifth, third);
  91. }
  92. case MSGGET:
  93. return sys_msgget ((key_t) first, second);
  94. case MSGCTL:
  95. return sys_msgctl (first, second, (struct msqid_ds __user *) ptr);
  96. case SHMAT:
  97. switch (version) {
  98. default: {
  99. ulong raddr;
  100. ret = do_shmat (first, (char __user *) ptr, second, &raddr);
  101. if (ret)
  102. return ret;
  103. return put_user (raddr, (ulong __user *) third);
  104. }
  105. case 1: /* iBCS2 emulator entry point */
  106. if (!segment_eq(get_fs(), get_ds()))
  107. return -EINVAL;
  108. /* The "(ulong *) third" is valid _only_ because of the kernel segment thing */
  109. return do_shmat (first, (char __user *) ptr, second, (ulong *) third);
  110. }
  111. case SHMDT:
  112. return sys_shmdt ((char __user *)ptr);
  113. case SHMGET:
  114. return sys_shmget (first, second, third);
  115. case SHMCTL:
  116. return sys_shmctl (first, second,
  117. (struct shmid_ds __user *) ptr);
  118. default:
  119. return -ENOSYS;
  120. }
  121. }