syscall.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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_set_nr(struct task_struct *task,
  15. struct pt_regs *regs,
  16. int nr)
  17. {
  18. regs->r12 = nr;
  19. }
  20. static inline void syscall_rollback(struct task_struct *task,
  21. struct pt_regs *regs)
  22. {
  23. /* TODO. */
  24. }
  25. static inline long syscall_get_error(struct task_struct *task,
  26. struct pt_regs *regs)
  27. {
  28. return IS_ERR_VALUE(regs->r3) ? regs->r3 : 0;
  29. }
  30. static inline long syscall_get_return_value(struct task_struct *task,
  31. struct pt_regs *regs)
  32. {
  33. return regs->r3;
  34. }
  35. static inline void syscall_set_return_value(struct task_struct *task,
  36. struct pt_regs *regs,
  37. int error, long val)
  38. {
  39. if (error)
  40. regs->r3 = -error;
  41. else
  42. regs->r3 = val;
  43. }
  44. static inline microblaze_reg_t microblaze_get_syscall_arg(struct pt_regs *regs,
  45. unsigned int n)
  46. {
  47. switch (n) {
  48. case 5: return regs->r10;
  49. case 4: return regs->r9;
  50. case 3: return regs->r8;
  51. case 2: return regs->r7;
  52. case 1: return regs->r6;
  53. case 0: return regs->r5;
  54. default:
  55. BUG();
  56. }
  57. return ~0;
  58. }
  59. static inline void syscall_get_arguments(struct task_struct *task,
  60. struct pt_regs *regs,
  61. unsigned long *args)
  62. {
  63. unsigned int i = 0;
  64. unsigned int n = 6;
  65. while (n--)
  66. *args++ = microblaze_get_syscall_arg(regs, i++);
  67. }
  68. asmlinkage unsigned long do_syscall_trace_enter(struct pt_regs *regs);
  69. asmlinkage void do_syscall_trace_leave(struct pt_regs *regs);
  70. static inline int syscall_get_arch(struct task_struct *task)
  71. {
  72. return AUDIT_ARCH_MICROBLAZE;
  73. }
  74. #endif /* __ASM_MICROBLAZE_SYSCALL_H */