syscall_64.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #ifndef __ASM_SH_SYSCALL_64_H
  2. #define __ASM_SH_SYSCALL_64_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 R9 */
  7. static inline long syscall_get_nr(struct task_struct *task,
  8. struct pt_regs *regs)
  9. {
  10. return (regs->syscall_nr >= 0) ? regs->regs[9] : -1L;
  11. }
  12. static inline void syscall_rollback(struct task_struct *task,
  13. struct pt_regs *regs)
  14. {
  15. /*
  16. * XXX: This needs some thought. On SH we don't
  17. * save away the original R9 value anywhere.
  18. */
  19. }
  20. static inline bool syscall_has_error(struct pt_regs *regs)
  21. {
  22. return (regs->sr & 0x1) ? true : false;
  23. }
  24. static inline void syscall_set_error(struct pt_regs *regs)
  25. {
  26. regs->sr |= 0x1;
  27. }
  28. static inline void syscall_clear_error(struct pt_regs *regs)
  29. {
  30. regs->sr &= ~0x1;
  31. }
  32. static inline long syscall_get_error(struct task_struct *task,
  33. struct pt_regs *regs)
  34. {
  35. return syscall_has_error(regs) ? regs->regs[9] : 0;
  36. }
  37. static inline long syscall_get_return_value(struct task_struct *task,
  38. struct pt_regs *regs)
  39. {
  40. return regs->regs[9];
  41. }
  42. static inline void syscall_set_return_value(struct task_struct *task,
  43. struct pt_regs *regs,
  44. int error, long val)
  45. {
  46. if (error) {
  47. syscall_set_error(regs);
  48. regs->regs[9] = -error;
  49. } else {
  50. syscall_clear_error(regs);
  51. regs->regs[9] = val;
  52. }
  53. }
  54. static inline void syscall_get_arguments(struct task_struct *task,
  55. struct pt_regs *regs,
  56. unsigned int i, unsigned int n,
  57. unsigned long *args)
  58. {
  59. BUG_ON(i + n > 6);
  60. memcpy(args, &regs->regs[2 + i], n * sizeof(args[0]));
  61. }
  62. static inline void syscall_set_arguments(struct task_struct *task,
  63. struct pt_regs *regs,
  64. unsigned int i, unsigned int n,
  65. const unsigned long *args)
  66. {
  67. BUG_ON(i + n > 6);
  68. memcpy(&regs->regs[2 + i], args, n * sizeof(args[0]));
  69. }
  70. #endif /* __ASM_SH_SYSCALL_64_H */