syscall.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __ASM_SYSCALL_H
  3. #define __ASM_SYSCALL_H
  4. #include <linux/sched.h>
  5. #include <linux/err.h>
  6. #include <abi/regdef.h>
  7. #include <uapi/linux/audit.h>
  8. extern void *sys_call_table[];
  9. static inline int
  10. syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
  11. {
  12. return regs_syscallid(regs);
  13. }
  14. static inline void
  15. syscall_set_nr(struct task_struct *task, struct pt_regs *regs,
  16. int sysno)
  17. {
  18. regs_syscallid(regs) = sysno;
  19. }
  20. static inline void
  21. syscall_rollback(struct task_struct *task, struct pt_regs *regs)
  22. {
  23. regs->a0 = regs->orig_a0;
  24. }
  25. static inline long
  26. syscall_get_error(struct task_struct *task, struct pt_regs *regs)
  27. {
  28. unsigned long error = regs->a0;
  29. return IS_ERR_VALUE(error) ? error : 0;
  30. }
  31. static inline long
  32. syscall_get_return_value(struct task_struct *task, struct pt_regs *regs)
  33. {
  34. return regs->a0;
  35. }
  36. static inline void
  37. syscall_set_return_value(struct task_struct *task, struct pt_regs *regs,
  38. int error, long val)
  39. {
  40. regs->a0 = (long) error ?: val;
  41. }
  42. static inline void
  43. syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
  44. unsigned long *args)
  45. {
  46. args[0] = regs->orig_a0;
  47. args++;
  48. memcpy(args, &regs->a1, 5 * sizeof(args[0]));
  49. }
  50. static inline void
  51. syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,
  52. const unsigned long *args)
  53. {
  54. memcpy(&regs->a0, args, 6 * sizeof(regs->a0));
  55. /*
  56. * Also copy the first argument into orig_a0
  57. * so that syscall_get_arguments() would return it
  58. * instead of the previous value.
  59. */
  60. regs->orig_a0 = regs->a0;
  61. }
  62. static inline int
  63. syscall_get_arch(struct task_struct *task)
  64. {
  65. return AUDIT_ARCH_CSKY;
  66. }
  67. #endif /* __ASM_SYSCALL_H */