syscall.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * OpenRISC Linux
  4. *
  5. * Linux architectural port borrowing liberally from similar works of
  6. * others. All original copyrights apply as per the original source
  7. * declaration.
  8. *
  9. * OpenRISC implementation:
  10. * Copyright (C) 2003 Matjaz Breskvar <[email protected]>
  11. * Copyright (C) 2010-2011 Jonas Bonn <[email protected]>
  12. * et al.
  13. */
  14. #ifndef __ASM_OPENRISC_SYSCALL_H__
  15. #define __ASM_OPENRISC_SYSCALL_H__
  16. #include <uapi/linux/audit.h>
  17. #include <linux/err.h>
  18. #include <linux/sched.h>
  19. static inline int
  20. syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
  21. {
  22. return regs->orig_gpr11;
  23. }
  24. static inline void
  25. syscall_rollback(struct task_struct *task, struct pt_regs *regs)
  26. {
  27. regs->gpr[11] = regs->orig_gpr11;
  28. }
  29. static inline long
  30. syscall_get_error(struct task_struct *task, struct pt_regs *regs)
  31. {
  32. return IS_ERR_VALUE(regs->gpr[11]) ? regs->gpr[11] : 0;
  33. }
  34. static inline long
  35. syscall_get_return_value(struct task_struct *task, struct pt_regs *regs)
  36. {
  37. return regs->gpr[11];
  38. }
  39. static inline void
  40. syscall_set_return_value(struct task_struct *task, struct pt_regs *regs,
  41. int error, long val)
  42. {
  43. regs->gpr[11] = (long) error ?: val;
  44. }
  45. static inline void
  46. syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
  47. unsigned long *args)
  48. {
  49. memcpy(args, &regs->gpr[3], 6 * sizeof(args[0]));
  50. }
  51. static inline int syscall_get_arch(struct task_struct *task)
  52. {
  53. return AUDIT_ARCH_OPENRISC;
  54. }
  55. #endif