sys_m68k.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /*
  2. * linux/arch/m68knommu/kernel/sys_m68k.c
  3. *
  4. * This file contains various random system calls that
  5. * have a non-standard calling sequence on the Linux/m68k
  6. * platform.
  7. */
  8. #include <linux/errno.h>
  9. #include <linux/sched.h>
  10. #include <linux/mm.h>
  11. #include <linux/smp.h>
  12. #include <linux/sem.h>
  13. #include <linux/msg.h>
  14. #include <linux/shm.h>
  15. #include <linux/stat.h>
  16. #include <linux/syscalls.h>
  17. #include <linux/mman.h>
  18. #include <linux/file.h>
  19. #include <linux/ipc.h>
  20. #include <linux/fs.h>
  21. #include <asm/setup.h>
  22. #include <asm/uaccess.h>
  23. #include <asm/cachectl.h>
  24. #include <asm/traps.h>
  25. #include <asm/cacheflush.h>
  26. #include <asm/unistd.h>
  27. /*
  28. * Perform the select(nd, in, out, ex, tv) and mmap() system
  29. * calls. Linux/m68k cloned Linux/i386, which didn't use to be able to
  30. * handle more than 4 system call parameters, so these system calls
  31. * used a memory block for parameter passing..
  32. */
  33. struct mmap_arg_struct {
  34. unsigned long addr;
  35. unsigned long len;
  36. unsigned long prot;
  37. unsigned long flags;
  38. unsigned long fd;
  39. unsigned long offset;
  40. };
  41. asmlinkage int old_mmap(struct mmap_arg_struct *arg)
  42. {
  43. struct mmap_arg_struct a;
  44. int error = -EFAULT;
  45. if (copy_from_user(&a, arg, sizeof(a)))
  46. goto out;
  47. error = -EINVAL;
  48. if (a.offset & ~PAGE_MASK)
  49. goto out;
  50. error = sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd,
  51. a.offset >> PAGE_SHIFT);
  52. out:
  53. return error;
  54. }
  55. struct sel_arg_struct {
  56. unsigned long n;
  57. fd_set *inp, *outp, *exp;
  58. struct timeval *tvp;
  59. };
  60. asmlinkage int old_select(struct sel_arg_struct *arg)
  61. {
  62. struct sel_arg_struct a;
  63. if (copy_from_user(&a, arg, sizeof(a)))
  64. return -EFAULT;
  65. /* sys_select() does the appropriate kernel locking */
  66. return sys_select(a.n, a.inp, a.outp, a.exp, a.tvp);
  67. }
  68. /*
  69. * sys_ipc() is the de-multiplexer for the SysV IPC calls..
  70. *
  71. * This is really horribly ugly.
  72. */
  73. asmlinkage int sys_ipc (uint call, int first, int second,
  74. int third, void *ptr, long fifth)
  75. {
  76. int version, ret;
  77. version = call >> 16; /* hack for backward compatibility */
  78. call &= 0xffff;
  79. if (call <= SEMCTL)
  80. switch (call) {
  81. case SEMOP:
  82. return sys_semop (first, (struct sembuf *)ptr, second);
  83. case SEMGET:
  84. return sys_semget (first, second, third);
  85. case SEMCTL: {
  86. union semun fourth;
  87. if (!ptr)
  88. return -EINVAL;
  89. if (get_user(fourth.__pad, (void **) ptr))
  90. return -EFAULT;
  91. return sys_semctl (first, second, third, fourth);
  92. }
  93. default:
  94. return -EINVAL;
  95. }
  96. if (call <= MSGCTL)
  97. switch (call) {
  98. case MSGSND:
  99. return sys_msgsnd (first, (struct msgbuf *) ptr,
  100. second, third);
  101. case MSGRCV:
  102. switch (version) {
  103. case 0: {
  104. struct ipc_kludge tmp;
  105. if (!ptr)
  106. return -EINVAL;
  107. if (copy_from_user (&tmp,
  108. (struct ipc_kludge *)ptr,
  109. sizeof (tmp)))
  110. return -EFAULT;
  111. return sys_msgrcv (first, tmp.msgp, second,
  112. tmp.msgtyp, third);
  113. }
  114. default:
  115. return sys_msgrcv (first,
  116. (struct msgbuf *) ptr,
  117. second, fifth, third);
  118. }
  119. case MSGGET:
  120. return sys_msgget ((key_t) first, second);
  121. case MSGCTL:
  122. return sys_msgctl (first, second,
  123. (struct msqid_ds *) ptr);
  124. default:
  125. return -EINVAL;
  126. }
  127. if (call <= SHMCTL)
  128. switch (call) {
  129. case SHMAT:
  130. switch (version) {
  131. default: {
  132. ulong raddr;
  133. ret = do_shmat (first, ptr, second, &raddr);
  134. if (ret)
  135. return ret;
  136. return put_user (raddr, (ulong __user *) third);
  137. }
  138. }
  139. case SHMDT:
  140. return sys_shmdt (ptr);
  141. case SHMGET:
  142. return sys_shmget (first, second, third);
  143. case SHMCTL:
  144. return sys_shmctl (first, second, ptr);
  145. default:
  146. return -ENOSYS;
  147. }
  148. return -EINVAL;
  149. }
  150. /* sys_cacheflush -- flush (part of) the processor cache. */
  151. asmlinkage int
  152. sys_cacheflush (unsigned long addr, int scope, int cache, unsigned long len)
  153. {
  154. flush_cache_all();
  155. return(0);
  156. }
  157. asmlinkage int sys_getpagesize(void)
  158. {
  159. return PAGE_SIZE;
  160. }
  161. /*
  162. * Do a system call from kernel instead of calling sys_execve so we
  163. * end up with proper pt_regs.
  164. */
  165. int kernel_execve(const char *filename, char *const argv[], char *const envp[])
  166. {
  167. register long __res asm ("%d0") = __NR_execve;
  168. register long __a asm ("%d1") = (long)(filename);
  169. register long __b asm ("%d2") = (long)(argv);
  170. register long __c asm ("%d3") = (long)(envp);
  171. asm volatile ("trap #0" : "+d" (__res)
  172. : "d" (__a), "d" (__b), "d" (__c));
  173. return __res;
  174. }