syscall.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Access to user system call parameters and results
  3. *
  4. * Copyright (C) 2012 The Chromium OS Authors <chromium-os-dev@chromium.org>
  5. *
  6. * This copyrighted material is made available to anyone wishing to use,
  7. * modify, copy, or redistribute it subject to the terms and conditions
  8. * of the GNU General Public License v.2.
  9. *
  10. * See asm-generic/syscall.h for descriptions of what we must do here.
  11. */
  12. #ifndef _ASM_ARM_SYSCALL_H
  13. #define _ASM_ARM_SYSCALL_H
  14. #include <linux/audit.h> /* for AUDIT_ARCH_* */
  15. #include <linux/elf.h> /* for ELF_EM */
  16. #include <linux/sched.h>
  17. #include <linux/thread_info.h> /* for task_thread_info */
  18. #include <linux/err.h>
  19. static inline int syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
  20. {
  21. return task_thread_info(task)->syscall;
  22. }
  23. static inline void syscall_rollback(struct task_struct *task,
  24. struct pt_regs *regs)
  25. {
  26. regs->ARM_r0 = regs->ARM_ORIG_r0;
  27. }
  28. static inline long syscall_get_error(struct task_struct *task,
  29. struct pt_regs *regs)
  30. {
  31. unsigned long error = regs->ARM_r0;
  32. return IS_ERR_VALUE(error) ? error : 0;
  33. }
  34. static inline long syscall_get_return_value(struct task_struct *task,
  35. struct pt_regs *regs)
  36. {
  37. return regs->ARM_r0;
  38. }
  39. static inline void syscall_set_return_value(struct task_struct *task,
  40. struct pt_regs *regs,
  41. int error, long val)
  42. {
  43. regs->ARM_r0 = (long) error ?: val;
  44. }
  45. static inline void syscall_get_arguments(struct task_struct *task,
  46. struct pt_regs *regs,
  47. unsigned int i, unsigned int n,
  48. unsigned long *args)
  49. {
  50. BUG_ON(i + n > 6);
  51. memcpy(args, &regs->ARM_r0 + i, n * sizeof(args[0]));
  52. }
  53. static inline void syscall_set_arguments(struct task_struct *task,
  54. struct pt_regs *regs,
  55. unsigned int i, unsigned int n,
  56. const unsigned long *args)
  57. {
  58. BUG_ON(i + n > 6);
  59. memcpy(&regs->ARM_r0 + i, args, n * sizeof(args[0]));
  60. }
  61. static inline int syscall_get_arch(struct task_struct *task,
  62. struct pt_regs *regs)
  63. {
  64. /* ARM tasks don't change audit architectures on the fly. */
  65. #ifdef __ARMEB__
  66. return AUDIT_ARCH_ARMEB;
  67. #else
  68. return AUDIT_ARCH_ARM;
  69. #endif
  70. }
  71. #endif /* _ASM_ARM_SYSCALL_H */