syscall.h 2.0 KB

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