syscall_64.h 1.8 KB

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