syscall.h 2.2 KB

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