sys_sh32.c 2.2 KB

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