sys_sh32.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #include <linux/errno.h>
  2. #include <linux/sched.h>
  3. #include <linux/mm.h>
  4. #include <linux/smp.h>
  5. #include <linux/sem.h>
  6. #include <linux/msg.h>
  7. #include <linux/shm.h>
  8. #include <linux/stat.h>
  9. #include <linux/syscalls.h>
  10. #include <linux/mman.h>
  11. #include <linux/file.h>
  12. #include <linux/utsname.h>
  13. #include <linux/module.h>
  14. #include <linux/fs.h>
  15. #include <linux/ipc.h>
  16. #include <asm/cacheflush.h>
  17. #include <asm/uaccess.h>
  18. #include <asm/unistd.h>
  19. #include <asm/syscalls.h>
  20. /*
  21. * sys_pipe() is the normal C calling standard for creating
  22. * a pipe. It's not the way Unix traditionally does this, though.
  23. */
  24. asmlinkage int sys_sh_pipe(unsigned long r4, unsigned long r5,
  25. unsigned long r6, unsigned long r7,
  26. struct pt_regs __regs)
  27. {
  28. struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
  29. int fd[2];
  30. int error;
  31. error = do_pipe_flags(fd, 0);
  32. if (!error) {
  33. regs->regs[1] = fd[1];
  34. return fd[0];
  35. }
  36. return error;
  37. }
  38. asmlinkage ssize_t sys_pread_wrapper(unsigned int fd, char __user *buf,
  39. size_t count, long dummy, loff_t pos)
  40. {
  41. return sys_pread64(fd, buf, count, pos);
  42. }
  43. asmlinkage ssize_t sys_pwrite_wrapper(unsigned int fd, const char __user *buf,
  44. size_t count, long dummy, loff_t pos)
  45. {
  46. return sys_pwrite64(fd, buf, count, pos);
  47. }
  48. asmlinkage int sys_fadvise64_64_wrapper(int fd, u32 offset0, u32 offset1,
  49. u32 len0, u32 len1, int advice)
  50. {
  51. #ifdef __LITTLE_ENDIAN__
  52. return sys_fadvise64_64(fd, (u64)offset1 << 32 | offset0,
  53. (u64)len1 << 32 | len0, advice);
  54. #else
  55. return sys_fadvise64_64(fd, (u64)offset0 << 32 | offset1,
  56. (u64)len0 << 32 | len1, advice);
  57. #endif
  58. }
  59. #if defined(CONFIG_CPU_SH2) || defined(CONFIG_CPU_SH2A)
  60. #define SYSCALL_ARG3 "trapa #0x23"
  61. #else
  62. #define SYSCALL_ARG3 "trapa #0x13"
  63. #endif
  64. /*
  65. * Do a system call from kernel instead of calling sys_execve so we
  66. * end up with proper pt_regs.
  67. */
  68. int kernel_execve(const char *filename, char *const argv[], char *const envp[])
  69. {
  70. register long __sc0 __asm__ ("r3") = __NR_execve;
  71. register long __sc4 __asm__ ("r4") = (long) filename;
  72. register long __sc5 __asm__ ("r5") = (long) argv;
  73. register long __sc6 __asm__ ("r6") = (long) envp;
  74. __asm__ __volatile__ (SYSCALL_ARG3 : "=z" (__sc0)
  75. : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6)
  76. : "memory");
  77. return __sc0;
  78. }