syscall.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 <linux/sched.h>
  15. #include <linux/err.h>
  16. static inline long syscall_get_nr(struct task_struct *task,
  17. struct pt_regs *regs)
  18. {
  19. if ((long)regs->cr_ifs < 0) /* Not a syscall */
  20. return -1;
  21. return regs->r15;
  22. }
  23. static inline void syscall_rollback(struct task_struct *task,
  24. struct pt_regs *regs)
  25. {
  26. /* do nothing */
  27. }
  28. static inline long syscall_get_error(struct task_struct *task,
  29. struct pt_regs *regs)
  30. {
  31. return regs->r10 == -1 ? regs->r8:0;
  32. }
  33. static inline long syscall_get_return_value(struct task_struct *task,
  34. struct pt_regs *regs)
  35. {
  36. return regs->r8;
  37. }
  38. static inline void syscall_set_return_value(struct task_struct *task,
  39. struct pt_regs *regs,
  40. int error, long val)
  41. {
  42. if (error) {
  43. /* error < 0, but ia64 uses > 0 return value */
  44. regs->r8 = -error;
  45. regs->r10 = -1;
  46. } else {
  47. regs->r8 = val;
  48. regs->r10 = 0;
  49. }
  50. }
  51. extern void ia64_syscall_get_set_arguments(struct task_struct *task,
  52. struct pt_regs *regs, unsigned int i, unsigned int n,
  53. unsigned long *args, int rw);
  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. ia64_syscall_get_set_arguments(task, regs, i, n, 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. unsigned long *args)
  66. {
  67. BUG_ON(i + n > 6);
  68. ia64_syscall_get_set_arguments(task, regs, i, n, args, 1);
  69. }
  70. #endif /* _ASM_SYSCALL_H */