/arch/sh/include/asm/syscall_32.h

http://github.com/mirrors/linux · C Header · 84 lines · 66 code · 11 blank · 7 comment · 1 complexity · 464658c99a9a6fc06fa5638db8d6b224 MD5 · raw file

  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __ASM_SH_SYSCALL_32_H
  3. #define __ASM_SH_SYSCALL_32_H
  4. #include <uapi/linux/audit.h>
  5. #include <linux/kernel.h>
  6. #include <linux/sched.h>
  7. #include <linux/err.h>
  8. #include <asm/ptrace.h>
  9. /* The system call number is given by the user in R3 */
  10. static inline long syscall_get_nr(struct task_struct *task,
  11. struct pt_regs *regs)
  12. {
  13. return (regs->tra >= 0) ? regs->regs[3] : -1L;
  14. }
  15. static inline void syscall_rollback(struct task_struct *task,
  16. struct pt_regs *regs)
  17. {
  18. /*
  19. * XXX: This needs some thought. On SH we don't
  20. * save away the original r0 value anywhere.
  21. */
  22. }
  23. static inline long syscall_get_error(struct task_struct *task,
  24. struct pt_regs *regs)
  25. {
  26. return IS_ERR_VALUE(regs->regs[0]) ? regs->regs[0] : 0;
  27. }
  28. static inline long syscall_get_return_value(struct task_struct *task,
  29. struct pt_regs *regs)
  30. {
  31. return regs->regs[0];
  32. }
  33. static inline void syscall_set_return_value(struct task_struct *task,
  34. struct pt_regs *regs,
  35. int error, long val)
  36. {
  37. if (error)
  38. regs->regs[0] = -error;
  39. else
  40. regs->regs[0] = val;
  41. }
  42. static inline void syscall_get_arguments(struct task_struct *task,
  43. struct pt_regs *regs,
  44. unsigned long *args)
  45. {
  46. /* Argument pattern is: R4, R5, R6, R7, R0, R1 */
  47. args[5] = regs->regs[1];
  48. args[4] = regs->regs[0];
  49. args[3] = regs->regs[7];
  50. args[2] = regs->regs[6];
  51. args[1] = regs->regs[5];
  52. args[0] = regs->regs[4];
  53. }
  54. static inline void syscall_set_arguments(struct task_struct *task,
  55. struct pt_regs *regs,
  56. const unsigned long *args)
  57. {
  58. regs->regs[1] = args[5];
  59. regs->regs[0] = args[4];
  60. regs->regs[7] = args[3];
  61. regs->regs[6] = args[2];
  62. regs->regs[5] = args[1];
  63. regs->regs[4] = args[0];
  64. }
  65. static inline int syscall_get_arch(struct task_struct *task)
  66. {
  67. int arch = AUDIT_ARCH_SH;
  68. #ifdef CONFIG_CPU_LITTLE_ENDIAN
  69. arch |= __AUDIT_ARCH_LE;
  70. #endif
  71. return arch;
  72. }
  73. #endif /* __ASM_SH_SYSCALL_32_H */