syscall.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* syscall.h */
  3. #ifndef _ASM_PARISC_SYSCALL_H_
  4. #define _ASM_PARISC_SYSCALL_H_
  5. #include <uapi/linux/audit.h>
  6. #include <linux/compat.h>
  7. #include <linux/err.h>
  8. #include <asm/ptrace.h>
  9. #define NR_syscalls (__NR_Linux_syscalls)
  10. static inline long syscall_get_nr(struct task_struct *tsk,
  11. struct pt_regs *regs)
  12. {
  13. return regs->gr[20];
  14. }
  15. static inline void syscall_set_nr(struct task_struct *tsk,
  16. struct pt_regs *regs,
  17. int nr)
  18. {
  19. regs->gr[20] = nr;
  20. }
  21. static inline void syscall_get_arguments(struct task_struct *tsk,
  22. struct pt_regs *regs,
  23. unsigned long *args)
  24. {
  25. args[5] = regs->gr[21];
  26. args[4] = regs->gr[22];
  27. args[3] = regs->gr[23];
  28. args[2] = regs->gr[24];
  29. args[1] = regs->gr[25];
  30. args[0] = regs->gr[26];
  31. }
  32. static inline void syscall_set_arguments(struct task_struct *tsk,
  33. struct pt_regs *regs,
  34. unsigned long *args)
  35. {
  36. regs->gr[21] = args[5];
  37. regs->gr[22] = args[4];
  38. regs->gr[23] = args[3];
  39. regs->gr[24] = args[2];
  40. regs->gr[25] = args[1];
  41. regs->gr[26] = args[0];
  42. }
  43. static inline long syscall_get_error(struct task_struct *task,
  44. struct pt_regs *regs)
  45. {
  46. unsigned long error = regs->gr[28];
  47. return IS_ERR_VALUE(error) ? error : 0;
  48. }
  49. static inline long syscall_get_return_value(struct task_struct *task,
  50. struct pt_regs *regs)
  51. {
  52. return regs->gr[28];
  53. }
  54. static inline void syscall_set_return_value(struct task_struct *task,
  55. struct pt_regs *regs,
  56. int error, long val)
  57. {
  58. regs->gr[28] = error ? error : val;
  59. }
  60. static inline void syscall_rollback(struct task_struct *task,
  61. struct pt_regs *regs)
  62. {
  63. /* do nothing */
  64. }
  65. static inline int syscall_get_arch(struct task_struct *task)
  66. {
  67. int arch = AUDIT_ARCH_PARISC;
  68. #ifdef CONFIG_64BIT
  69. if (!__is_compat_task(task))
  70. arch = AUDIT_ARCH_PARISC64;
  71. #endif
  72. return arch;
  73. }
  74. #endif /*_ASM_PARISC_SYSCALL_H_*/