syscall.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Author: Hanlu Li <lihanlu@loongson.cn>
  4. * Huacai Chen <chenhuacai@loongson.cn>
  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_set_nr(struct task_struct *task,
  25. struct pt_regs *regs,
  26. int nr)
  27. {
  28. regs->regs[11] = nr;
  29. }
  30. static inline void syscall_rollback(struct task_struct *task,
  31. struct pt_regs *regs)
  32. {
  33. regs->regs[4] = regs->orig_a0;
  34. }
  35. static inline long syscall_get_error(struct task_struct *task,
  36. struct pt_regs *regs)
  37. {
  38. unsigned long error = regs->regs[4];
  39. return IS_ERR_VALUE(error) ? error : 0;
  40. }
  41. static inline long syscall_get_return_value(struct task_struct *task,
  42. struct pt_regs *regs)
  43. {
  44. return regs->regs[4];
  45. }
  46. static inline void syscall_set_return_value(struct task_struct *task,
  47. struct pt_regs *regs,
  48. int error, long val)
  49. {
  50. regs->regs[4] = (long) error ? error : val;
  51. }
  52. static inline void syscall_get_arguments(struct task_struct *task,
  53. struct pt_regs *regs,
  54. unsigned long *args)
  55. {
  56. args[0] = regs->orig_a0;
  57. memcpy(&args[1], &regs->regs[5], 5 * sizeof(long));
  58. }
  59. static inline void syscall_set_arguments(struct task_struct *task,
  60. struct pt_regs *regs,
  61. unsigned long *args)
  62. {
  63. regs->orig_a0 = args[0];
  64. memcpy(&regs->regs[5], &args[1], 5 * sizeof(long));
  65. }
  66. static inline int syscall_get_arch(struct task_struct *task)
  67. {
  68. return AUDIT_ARCH_LOONGARCH64;
  69. }
  70. static inline bool arch_syscall_is_vdso_sigreturn(struct pt_regs *regs)
  71. {
  72. return false;
  73. }
  74. #endif /* __ASM_LOONGARCH_SYSCALL_H */