syscall.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 microblaze_set_syscall_arg(struct pt_regs *regs,
  54. unsigned int n,
  55. unsigned long val)
  56. {
  57. switch (n) {
  58. case 5:
  59. regs->r10 = val;
  60. case 4:
  61. regs->r9 = val;
  62. case 3:
  63. regs->r8 = val;
  64. case 2:
  65. regs->r7 = val;
  66. case 1:
  67. regs->r6 = val;
  68. case 0:
  69. regs->r5 = val;
  70. default:
  71. BUG();
  72. }
  73. }
  74. static inline void syscall_get_arguments(struct task_struct *task,
  75. struct pt_regs *regs,
  76. unsigned int i, unsigned int n,
  77. unsigned long *args)
  78. {
  79. while (n--)
  80. *args++ = microblaze_get_syscall_arg(regs, i++);
  81. }
  82. static inline void syscall_set_arguments(struct task_struct *task,
  83. struct pt_regs *regs,
  84. unsigned int i, unsigned int n,
  85. const unsigned long *args)
  86. {
  87. while (n--)
  88. microblaze_set_syscall_arg(regs, i++, *args++);
  89. }
  90. asmlinkage unsigned long do_syscall_trace_enter(struct pt_regs *regs);
  91. asmlinkage void do_syscall_trace_leave(struct pt_regs *regs);
  92. static inline int syscall_get_arch(void)
  93. {
  94. return AUDIT_ARCH_MICROBLAZE;
  95. }
  96. #endif /* __ASM_MICROBLAZE_SYSCALL_H */