syscall.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Access to user system call parameters and results
  3. *
  4. * Copyright (C) 2008 Intel Corp. Shaohua Li <shaohua.li@intel.com>
  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_SYSCALL_H
  13. #define _ASM_SYSCALL_H 1
  14. #include <uapi/linux/audit.h>
  15. #include <linux/sched.h>
  16. #include <linux/err.h>
  17. static inline long syscall_get_nr(struct task_struct *task,
  18. struct pt_regs *regs)
  19. {
  20. if ((long)regs->cr_ifs < 0) /* Not a syscall */
  21. return -1;
  22. return regs->r15;
  23. }
  24. static inline void syscall_rollback(struct task_struct *task,
  25. struct pt_regs *regs)
  26. {
  27. /* do nothing */
  28. }
  29. static inline long syscall_get_error(struct task_struct *task,
  30. struct pt_regs *regs)
  31. {
  32. return regs->r10 == -1 ? regs->r8:0;
  33. }
  34. static inline long syscall_get_return_value(struct task_struct *task,
  35. struct pt_regs *regs)
  36. {
  37. return regs->r8;
  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. if (error) {
  44. /* error < 0, but ia64 uses > 0 return value */
  45. regs->r8 = -error;
  46. regs->r10 = -1;
  47. } else {
  48. regs->r8 = val;
  49. regs->r10 = 0;
  50. }
  51. }
  52. extern void ia64_syscall_get_set_arguments(struct task_struct *task,
  53. struct pt_regs *regs, unsigned int i, unsigned int n,
  54. unsigned long *args, int rw);
  55. static inline void syscall_get_arguments(struct task_struct *task,
  56. struct pt_regs *regs,
  57. unsigned int i, unsigned int n,
  58. unsigned long *args)
  59. {
  60. BUG_ON(i + n > 6);
  61. ia64_syscall_get_set_arguments(task, regs, i, n, args, 0);
  62. }
  63. static inline void syscall_set_arguments(struct task_struct *task,
  64. struct pt_regs *regs,
  65. unsigned int i, unsigned int n,
  66. unsigned long *args)
  67. {
  68. BUG_ON(i + n > 6);
  69. ia64_syscall_get_set_arguments(task, regs, i, n, args, 1);
  70. }
  71. static inline int syscall_get_arch(void)
  72. {
  73. return AUDIT_ARCH_IA64;
  74. }
  75. #endif /* _ASM_SYSCALL_H */