sys_mn10300.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /* MN10300 Weird system calls
  2. *
  3. * Copyright (C) 2007 Matsushita Electric Industrial Co., Ltd.
  4. * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. #include <linux/errno.h>
  12. #include <linux/sched.h>
  13. #include <linux/syscalls.h>
  14. #include <linux/mm.h>
  15. #include <linux/smp.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>
  22. #include <linux/tty.h>
  23. #include <asm/uaccess.h>
  24. asmlinkage long old_mmap(unsigned long addr, unsigned long len,
  25. unsigned long prot, unsigned long flags,
  26. unsigned long fd, unsigned long offset)
  27. {
  28. if (offset & ~PAGE_MASK)
  29. return -EINVAL;
  30. return sys_mmap_pgoff(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
  31. }
  32. /*
  33. * sys_ipc() is the de-multiplexer for the SysV IPC calls..
  34. *
  35. * This is really horribly ugly.
  36. */
  37. asmlinkage long sys_ipc(uint call, int first, int second,
  38. int third, void __user *ptr, long fifth)
  39. {
  40. int version, ret;
  41. version = call >> 16; /* hack for backward compatibility */
  42. call &= 0xffff;
  43. switch (call) {
  44. case SEMOP:
  45. return sys_semtimedop(first, (struct sembuf __user *)ptr,
  46. second, NULL);
  47. case SEMTIMEDOP:
  48. return sys_semtimedop(first, (struct sembuf __user *)ptr,
  49. second,
  50. (const struct timespec __user *)fifth);
  51. case SEMGET:
  52. return sys_semget(first, second, third);
  53. case SEMCTL: {
  54. union semun fourth;
  55. if (!ptr)
  56. return -EINVAL;
  57. if (get_user(fourth.__pad, (void __user * __user *) ptr))
  58. return -EFAULT;
  59. return sys_semctl(first, second, third, fourth);
  60. }
  61. case MSGSND:
  62. return sys_msgsnd(first, (struct msgbuf __user *) ptr,
  63. second, third);
  64. case MSGRCV:
  65. switch (version) {
  66. case 0: {
  67. struct ipc_kludge tmp;
  68. if (!ptr)
  69. return -EINVAL;
  70. if (copy_from_user(&tmp,
  71. (struct ipc_kludge __user *) ptr,
  72. sizeof(tmp)))
  73. return -EFAULT;
  74. return sys_msgrcv(first, tmp.msgp, second,
  75. tmp.msgtyp, third);
  76. }
  77. default:
  78. return sys_msgrcv(first,
  79. (struct msgbuf __user *) ptr,
  80. second, fifth, third);
  81. }
  82. case MSGGET:
  83. return sys_msgget((key_t) first, second);
  84. case MSGCTL:
  85. return sys_msgctl(first, second,
  86. (struct msqid_ds __user *) ptr);
  87. case SHMAT:
  88. switch (version) {
  89. default: {
  90. ulong raddr;
  91. ret = do_shmat(first, (char __user *) ptr, second,
  92. &raddr);
  93. if (ret)
  94. return ret;
  95. return put_user(raddr, (ulong *) third);
  96. }
  97. case 1: /* iBCS2 emulator entry point */
  98. if (!segment_eq(get_fs(), get_ds()))
  99. return -EINVAL;
  100. return do_shmat(first, (char __user *) ptr, second,
  101. (ulong *) 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 -EINVAL;
  112. }
  113. }