syscall_32.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. regs->regs[0] = (long) error ?: val;
  38. }
  39. static inline void syscall_get_arguments(struct task_struct *task,
  40. struct pt_regs *regs,
  41. unsigned long *args)
  42. {
  43. /* Argument pattern is: R4, R5, R6, R7, R0, R1 */
  44. args[5] = regs->regs[1];
  45. args[4] = regs->regs[0];
  46. args[3] = regs->regs[7];
  47. args[2] = regs->regs[6];
  48. args[1] = regs->regs[5];
  49. args[0] = regs->regs[4];
  50. }
  51. static inline int syscall_get_arch(struct task_struct *task)
  52. {
  53. int arch = AUDIT_ARCH_SH;
  54. #ifdef CONFIG_CPU_LITTLE_ENDIAN
  55. arch |= __AUDIT_ARCH_LE;
  56. #endif
  57. return arch;
  58. }
  59. #endif /* __ASM_SH_SYSCALL_32_H */