syscall.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Author: Hanlu Li <[email protected]>
  4. * Huacai Chen <[email protected]>
  5. *
  6. * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
  7. */
  8. #ifndef __ASM_LOONGARCH_SYSCALL_H
  9. #define __ASM_LOONGARCH_SYSCALL_H
  10. #include <linux/compiler.h>
  11. #include <uapi/linux/audit.h>
  12. #include <linux/elf-em.h>
  13. #include <linux/kernel.h>
  14. #include <linux/sched.h>
  15. #include <linux/uaccess.h>
  16. #include <asm/ptrace.h>
  17. #include <asm/unistd.h>
  18. extern void *sys_call_table[];
  19. static inline long syscall_get_nr(struct task_struct *task,
  20. struct pt_regs *regs)
  21. {
  22. return regs->regs[11];
  23. }
  24. static inline void syscall_rollback(struct task_struct *task,
  25. struct pt_regs *regs)
  26. {
  27. regs->regs[4] = regs->orig_a0;
  28. }
  29. static inline long syscall_get_error(struct task_struct *task,
  30. struct pt_regs *regs)
  31. {
  32. unsigned long error = regs->regs[4];
  33. return IS_ERR_VALUE(error) ? error : 0;
  34. }
  35. static inline long syscall_get_return_value(struct task_struct *task,
  36. struct pt_regs *regs)
  37. {
  38. return regs->regs[4];
  39. }
  40. static inline void syscall_set_return_value(struct task_struct *task,
  41. struct pt_regs *regs,
  42. int error, long val)
  43. {
  44. regs->regs[4] = (long) error ? error : val;
  45. }
  46. static inline void syscall_get_arguments(struct task_struct *task,
  47. struct pt_regs *regs,
  48. unsigned long *args)
  49. {
  50. args[0] = regs->orig_a0;
  51. memcpy(&args[1], &regs->regs[5], 5 * sizeof(long));
  52. }
  53. static inline int syscall_get_arch(struct task_struct *task)
  54. {
  55. return AUDIT_ARCH_LOONGARCH64;
  56. }
  57. static inline bool arch_syscall_is_vdso_sigreturn(struct pt_regs *regs)
  58. {
  59. return false;
  60. }
  61. #endif /* __ASM_LOONGARCH_SYSCALL_H */