syscall_arch.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 SYSCALL_MMAP2_UNIT 8192ULL
  6. static __inline long __syscall0(long n)
  7. {
  8. register unsigned long r11 __asm__("r11") = n;
  9. __asm__ __volatile__ ("l.sys 1"
  10. : "=r"(r11)
  11. : "r"(r11)
  12. : "memory", "r3", "r4", "r5", "r6", "r7", "r8",
  13. "r12", "r13", "r15", "r17", "r19", "r21",
  14. "r23", "r25", "r27", "r29", "r31");
  15. return r11;
  16. }
  17. static inline long __syscall1(long n, long a)
  18. {
  19. register unsigned long r11 __asm__("r11") = n;
  20. register unsigned long r3 __asm__("r3") = a;
  21. __asm__ __volatile__ ("l.sys 1"
  22. : "=r"(r11)
  23. : "r"(r11), "r"(r3)
  24. : "memory", "r4", "r5", "r6", "r7", "r8",
  25. "r12", "r13", "r15", "r17", "r19", "r21",
  26. "r23", "r25", "r27", "r29", "r31");
  27. return r11;
  28. }
  29. static inline long __syscall2(long n, long a, long b)
  30. {
  31. register unsigned long r11 __asm__("r11") = n;
  32. register unsigned long r3 __asm__("r3") = a;
  33. register unsigned long r4 __asm__("r4") = b;
  34. __asm__ __volatile__ ("l.sys 1"
  35. : "=r"(r11)
  36. : "r"(r11), "r"(r3), "r"(r4)
  37. : "memory", "r5", "r6", "r7", "r8",
  38. "r12", "r13", "r15", "r17", "r19", "r21",
  39. "r23", "r25", "r27", "r29", "r31");
  40. return r11;
  41. }
  42. static inline long __syscall3(long n, long a, long b, long c)
  43. {
  44. register unsigned long r11 __asm__("r11") = n;
  45. register unsigned long r3 __asm__("r3") = a;
  46. register unsigned long r4 __asm__("r4") = b;
  47. register unsigned long r5 __asm__("r5") = c;
  48. __asm__ __volatile__ ("l.sys 1"
  49. : "=r"(r11)
  50. : "r"(r11), "r"(r3), "r"(r4), "r"(r5)
  51. : "memory", "r6", "r7", "r8",
  52. "r12", "r13", "r15", "r17", "r19", "r21",
  53. "r23", "r25", "r27", "r29", "r31");
  54. return r11;
  55. }
  56. static inline long __syscall4(long n, long a, long b, long c, long d)
  57. {
  58. register unsigned long r11 __asm__("r11") = n;
  59. register unsigned long r3 __asm__("r3") = a;
  60. register unsigned long r4 __asm__("r4") = b;
  61. register unsigned long r5 __asm__("r5") = c;
  62. register unsigned long r6 __asm__("r6") = d;
  63. __asm__ __volatile__ ("l.sys 1"
  64. : "=r"(r11)
  65. : "r"(r11), "r"(r3), "r"(r4), "r"(r5), "r"(r6)
  66. : "memory", "r7", "r8",
  67. "r12", "r13", "r15", "r17", "r19", "r21",
  68. "r23", "r25", "r27", "r29", "r31");
  69. return r11;
  70. }
  71. static inline long __syscall5(long n, long a, long b, long c, long d, long e)
  72. {
  73. register unsigned long r11 __asm__("r11") = n;
  74. register unsigned long r3 __asm__("r3") = a;
  75. register unsigned long r4 __asm__("r4") = b;
  76. register unsigned long r5 __asm__("r5") = c;
  77. register unsigned long r6 __asm__("r6") = d;
  78. register unsigned long r7 __asm__("r7") = e;
  79. __asm__ __volatile__ ("l.sys 1"
  80. : "=r"(r11)
  81. : "r"(r11), "r"(r3), "r"(r4), "r"(r5), "r"(r6),
  82. "r"(r7)
  83. : "memory", "r8",
  84. "r12", "r13", "r15", "r17", "r19", "r21",
  85. "r23", "r25", "r27", "r29", "r31");
  86. return r11;
  87. }
  88. static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f)
  89. {
  90. register unsigned long r11 __asm__("r11") = n;
  91. register unsigned long r3 __asm__("r3") = a;
  92. register unsigned long r4 __asm__("r4") = b;
  93. register unsigned long r5 __asm__("r5") = c;
  94. register unsigned long r6 __asm__("r6") = d;
  95. register unsigned long r7 __asm__("r7") = e;
  96. register unsigned long r8 __asm__("r8") = f;
  97. __asm__ __volatile__ ("l.sys 1"
  98. : "=r"(r11)
  99. : "r"(r11), "r"(r3), "r"(r4), "r"(r5), "r"(r6),
  100. "r"(r7), "r"(r8)
  101. : "memory",
  102. "r12", "r13", "r15", "r17", "r19", "r21",
  103. "r23", "r25", "r27", "r29", "r31");
  104. return r11;
  105. }
  106. #define IPC_64 0