syscall.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 int
  51. syscall_get_arch(struct task_struct *task)
  52. {
  53. return AUDIT_ARCH_CSKY;
  54. }
  55. #endif /* __ASM_SYSCALL_H */