sys_m68k.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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/smp_lock.h>
  13. #include <linux/sem.h>
  14. #include <linux/msg.h>
  15. #include <linux/shm.h>
  16. #include <linux/stat.h>
  17. #include <linux/syscalls.h>
  18. #include <linux/mman.h>
  19. #include <linux/file.h>
  20. #include <linux/utsname.h>
  21. #include <asm/setup.h>
  22. #include <asm/uaccess.h>
  23. #include <asm/cachectl.h>
  24. #include <asm/traps.h>
  25. #include <asm/ipc.h>
  26. #include <asm/cacheflush.h>
  27. /*
  28. * sys_pipe() is the normal C calling standard for creating
  29. * a pipe. It's not the way unix traditionally does this, though.
  30. */
  31. asmlinkage int sys_pipe(unsigned long * fildes)
  32. {
  33. int fd[2];
  34. int error;
  35. error = do_pipe(fd);
  36. if (!error) {
  37. if (copy_to_user(fildes, fd, 2*sizeof(int)))
  38. error = -EFAULT;
  39. }
  40. return error;
  41. }
  42. /* common code for old and new mmaps */
  43. static inline long do_mmap2(
  44. unsigned long addr, unsigned long len,
  45. unsigned long prot, unsigned long flags,
  46. unsigned long fd, unsigned long pgoff)
  47. {
  48. int error = -EBADF;
  49. struct file * file = NULL;
  50. flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
  51. if (!(flags & MAP_ANONYMOUS)) {
  52. file = fget(fd);
  53. if (!file)
  54. goto out;
  55. }
  56. down_write(&current->mm->mmap_sem);
  57. error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
  58. up_write(&current->mm->mmap_sem);
  59. if (file)
  60. fput(file);
  61. out:
  62. return error;
  63. }
  64. asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
  65. unsigned long prot, unsigned long flags,
  66. unsigned long fd, unsigned long pgoff)
  67. {
  68. return do_mmap2(addr, len, prot, flags, fd, pgoff);
  69. }
  70. /*
  71. * Perform the select(nd, in, out, ex, tv) and mmap() system
  72. * calls. Linux/m68k cloned Linux/i386, which didn't use to be able to
  73. * handle more than 4 system call parameters, so these system calls
  74. * used a memory block for parameter passing..
  75. */
  76. struct mmap_arg_struct {
  77. unsigned long addr;
  78. unsigned long len;
  79. unsigned long prot;
  80. unsigned long flags;
  81. unsigned long fd;
  82. unsigned long offset;
  83. };
  84. asmlinkage int old_mmap(struct mmap_arg_struct *arg)
  85. {
  86. struct mmap_arg_struct a;
  87. int error = -EFAULT;
  88. if (copy_from_user(&a, arg, sizeof(a)))
  89. goto out;
  90. error = -EINVAL;
  91. if (a.offset & ~PAGE_MASK)
  92. goto out;
  93. a.flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
  94. error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT);
  95. out:
  96. return error;
  97. }
  98. struct sel_arg_struct {
  99. unsigned long n;
  100. fd_set *inp, *outp, *exp;
  101. struct timeval *tvp;
  102. };
  103. asmlinkage int old_select(struct sel_arg_struct *arg)
  104. {
  105. struct sel_arg_struct a;
  106. if (copy_from_user(&a, arg, sizeof(a)))
  107. return -EFAULT;
  108. /* sys_select() does the appropriate kernel locking */
  109. return sys_select(a.n, a.inp, a.outp, a.exp, a.tvp);
  110. }
  111. /*
  112. * sys_ipc() is the de-multiplexer for the SysV IPC calls..
  113. *
  114. * This is really horribly ugly.
  115. */
  116. asmlinkage int sys_ipc (uint call, int first, int second,
  117. int third, void *ptr, long fifth)
  118. {
  119. int version;
  120. version = call >> 16; /* hack for backward compatibility */
  121. call &= 0xffff;
  122. if (call <= SEMCTL)
  123. switch (call) {
  124. case SEMOP:
  125. return sys_semop (first, (struct sembuf *)ptr, second);
  126. case SEMGET:
  127. return sys_semget (first, second, third);
  128. case SEMCTL: {
  129. union semun fourth;
  130. if (!ptr)
  131. return -EINVAL;
  132. if (get_user(fourth.__pad, (void **) ptr))
  133. return -EFAULT;
  134. return sys_semctl (first, second, third, fourth);
  135. }
  136. default:
  137. return -EINVAL;
  138. }
  139. if (call <= MSGCTL)
  140. switch (call) {
  141. case MSGSND:
  142. return sys_msgsnd (first, (struct msgbuf *) ptr,
  143. second, third);
  144. case MSGRCV:
  145. switch (version) {
  146. case 0: {
  147. struct ipc_kludge tmp;
  148. if (!ptr)
  149. return -EINVAL;
  150. if (copy_from_user (&tmp,
  151. (struct ipc_kludge *)ptr,
  152. sizeof (tmp)))
  153. return -EFAULT;
  154. return sys_msgrcv (first, tmp.msgp, second,
  155. tmp.msgtyp, third);
  156. }
  157. default:
  158. return sys_msgrcv (first,
  159. (struct msgbuf *) ptr,
  160. second, fifth, third);
  161. }
  162. case MSGGET:
  163. return sys_msgget ((key_t) first, second);
  164. case MSGCTL:
  165. return sys_msgctl (first, second,
  166. (struct msqid_ds *) ptr);
  167. default:
  168. return -EINVAL;
  169. }
  170. return -EINVAL;
  171. }
  172. /* sys_cacheflush -- flush (part of) the processor cache. */
  173. asmlinkage int
  174. sys_cacheflush (unsigned long addr, int scope, int cache, unsigned long len)
  175. {
  176. flush_cache_all();
  177. return(0);
  178. }
  179. asmlinkage int sys_getpagesize(void)
  180. {
  181. return PAGE_SIZE;
  182. }