syscall.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __ASM_MICROBLAZE_SYSCALL_H
  3. #define __ASM_MICROBLAZE_SYSCALL_H
  4. #include <uapi/linux/audit.h>
  5. #include <linux/kernel.h>
  6. #include <linux/sched.h>
  7. #include <asm/ptrace.h>
  8. /* The system call number is given by the user in R12 */
  9. static inline long syscall_get_nr(struct task_struct *task,
  10. struct pt_regs *regs)
  11. {
  12. return regs->r12;
  13. }
  14. static inline void syscall_rollback(struct task_struct *task,
  15. struct pt_regs *regs)
  16. {
  17. /* TODO. */
  18. }
  19. static inline long syscall_get_error(struct task_struct *task,
  20. struct pt_regs *regs)
  21. {
  22. return IS_ERR_VALUE(regs->r3) ? regs->r3 : 0;
  23. }
  24. static inline long syscall_get_return_value(struct task_struct *task,
  25. struct pt_regs *regs)
  26. {
  27. return regs->r3;
  28. }
  29. static inline void syscall_set_return_value(struct task_struct *task,
  30. struct pt_regs *regs,
  31. int error, long val)
  32. {
  33. if (error)
  34. regs->r3 = -error;
  35. else
  36. regs->r3 = val;
  37. }
  38. static inline microblaze_reg_t microblaze_get_syscall_arg(struct pt_regs *regs,
  39. unsigned int n)
  40. {
  41. switch (n) {
  42. case 5: return regs->r10;
  43. case 4: return regs->r9;
  44. case 3: return regs->r8;
  45. case 2: return regs->r7;
  46. case 1: return regs->r6;
  47. case 0: return regs->r5;
  48. default:
  49. BUG();
  50. }
  51. return ~0;
  52. }
  53. static inline void syscall_get_arguments(struct task_struct *task,
  54. struct pt_regs *regs,
  55. unsigned long *args)
  56. {
  57. unsigned int i = 0;
  58. unsigned int n = 6;
  59. while (n--)
  60. *args++ = microblaze_get_syscall_arg(regs, i++);
  61. }
  62. asmlinkage unsigned long do_syscall_trace_enter(struct pt_regs *regs);
  63. asmlinkage void do_syscall_trace_leave(struct pt_regs *regs);
  64. static inline int syscall_get_arch(struct task_struct *task)
  65. {
  66. return AUDIT_ARCH_MICROBLAZE;
  67. }
  68. #endif /* __ASM_MICROBLAZE_SYSCALL_H */