syscall.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * Copyright (C) 2011 Texas Instruments Incorporated
  3. * Author: Mark Salter <msalter@redhat.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. */
  10. #ifndef __ASM_C6X_SYSCALL_H
  11. #define __ASM_C6X_SYSCALL_H
  12. #include <linux/err.h>
  13. #include <linux/sched.h>
  14. static inline int syscall_get_nr(struct task_struct *task,
  15. struct pt_regs *regs)
  16. {
  17. return regs->b0;
  18. }
  19. static inline void syscall_rollback(struct task_struct *task,
  20. struct pt_regs *regs)
  21. {
  22. /* do nothing */
  23. }
  24. static inline long syscall_get_error(struct task_struct *task,
  25. struct pt_regs *regs)
  26. {
  27. return IS_ERR_VALUE(regs->a4) ? regs->a4 : 0;
  28. }
  29. static inline long syscall_get_return_value(struct task_struct *task,
  30. struct pt_regs *regs)
  31. {
  32. return regs->a4;
  33. }
  34. static inline void syscall_set_return_value(struct task_struct *task,
  35. struct pt_regs *regs,
  36. int error, long val)
  37. {
  38. regs->a4 = error ?: val;
  39. }
  40. static inline void syscall_get_arguments(struct task_struct *task,
  41. struct pt_regs *regs, unsigned int i,
  42. unsigned int n, unsigned long *args)
  43. {
  44. switch (i) {
  45. case 0:
  46. if (!n--)
  47. break;
  48. *args++ = regs->a4;
  49. case 1:
  50. if (!n--)
  51. break;
  52. *args++ = regs->b4;
  53. case 2:
  54. if (!n--)
  55. break;
  56. *args++ = regs->a6;
  57. case 3:
  58. if (!n--)
  59. break;
  60. *args++ = regs->b6;
  61. case 4:
  62. if (!n--)
  63. break;
  64. *args++ = regs->a8;
  65. case 5:
  66. if (!n--)
  67. break;
  68. *args++ = regs->b8;
  69. case 6:
  70. if (!n--)
  71. break;
  72. default:
  73. BUG();
  74. }
  75. }
  76. static inline void syscall_set_arguments(struct task_struct *task,
  77. struct pt_regs *regs,
  78. unsigned int i, unsigned int n,
  79. const unsigned long *args)
  80. {
  81. switch (i) {
  82. case 0:
  83. if (!n--)
  84. break;
  85. regs->a4 = *args++;
  86. case 1:
  87. if (!n--)
  88. break;
  89. regs->b4 = *args++;
  90. case 2:
  91. if (!n--)
  92. break;
  93. regs->a6 = *args++;
  94. case 3:
  95. if (!n--)
  96. break;
  97. regs->b6 = *args++;
  98. case 4:
  99. if (!n--)
  100. break;
  101. regs->a8 = *args++;
  102. case 5:
  103. if (!n--)
  104. break;
  105. regs->a9 = *args++;
  106. case 6:
  107. if (!n)
  108. break;
  109. default:
  110. BUG();
  111. }
  112. }
  113. #endif /* __ASM_C6X_SYSCALLS_H */