1
0

syscall_arch.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #define __SYSCALL_LL_E(x) \
  2. ((union { long long ll; long l[2]; }){ .ll = x }).l[0], \
  3. ((union { long long ll; long l[2]; }){ .ll = x }).l[1]
  4. #define __SYSCALL_LL_O(x) __SYSCALL_LL_E((x))
  5. #define __asm_syscall(...) \
  6. __asm__ __volatile__ ("ecall\n\t" \
  7. : "=r"(a0) : __VA_ARGS__ : "memory"); \
  8. return a0; \
  9. static inline long __syscall0(long n)
  10. {
  11. register long a7 __asm__("a7") = n;
  12. register long a0 __asm__("a0");
  13. __asm_syscall("r"(a7))
  14. }
  15. static inline long __syscall1(long n, long a)
  16. {
  17. register long a7 __asm__("a7") = n;
  18. register long a0 __asm__("a0") = a;
  19. __asm_syscall("r"(a7), "0"(a0))
  20. }
  21. static inline long __syscall2(long n, long a, long b)
  22. {
  23. register long a7 __asm__("a7") = n;
  24. register long a0 __asm__("a0") = a;
  25. register long a1 __asm__("a1") = b;
  26. __asm_syscall("r"(a7), "0"(a0), "r"(a1))
  27. }
  28. static inline long __syscall3(long n, long a, long b, long c)
  29. {
  30. register long a7 __asm__("a7") = n;
  31. register long a0 __asm__("a0") = a;
  32. register long a1 __asm__("a1") = b;
  33. register long a2 __asm__("a2") = c;
  34. __asm_syscall("r"(a7), "0"(a0), "r"(a1), "r"(a2))
  35. }
  36. static inline long __syscall4(long n, long a, long b, long c, long d)
  37. {
  38. register long a7 __asm__("a7") = n;
  39. register long a0 __asm__("a0") = a;
  40. register long a1 __asm__("a1") = b;
  41. register long a2 __asm__("a2") = c;
  42. register long a3 __asm__("a3") = d;
  43. __asm_syscall("r"(a7), "0"(a0), "r"(a1), "r"(a2), "r"(a3))
  44. }
  45. static inline long __syscall5(long n, long a, long b, long c, long d, long e)
  46. {
  47. register long a7 __asm__("a7") = n;
  48. register long a0 __asm__("a0") = a;
  49. register long a1 __asm__("a1") = b;
  50. register long a2 __asm__("a2") = c;
  51. register long a3 __asm__("a3") = d;
  52. register long a4 __asm__("a4") = e;
  53. __asm_syscall("r"(a7), "0"(a0), "r"(a1), "r"(a2), "r"(a3), "r"(a4))
  54. }
  55. static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f)
  56. {
  57. register long a7 __asm__("a7") = n;
  58. register long a0 __asm__("a0") = a;
  59. register long a1 __asm__("a1") = b;
  60. register long a2 __asm__("a2") = c;
  61. register long a3 __asm__("a3") = d;
  62. register long a4 __asm__("a4") = e;
  63. register long a5 __asm__("a5") = f;
  64. __asm_syscall("r"(a7), "0"(a0), "r"(a1), "r"(a2), "r"(a3), "r"(a4), "r"(a5))
  65. }
  66. #define VDSO_USEFUL
  67. /* We don't have a clock_gettime function.
  68. #define VDSO_CGT_SYM "__vdso_clock_gettime"
  69. #define VDSO_CGT_VER "LINUX_2.6" */
  70. #define IPC_64 0