syscall_arch.h 2.1 KB

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