syscall_64.h 1.8 KB

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