syscall_arch.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #define __SYSCALL_LL_E(x) (x)
  2. #define __SYSCALL_LL_O(x) (x)
  3. #define __asm_syscall(ret, ...) do { \
  4. __asm__ __volatile__ ("svc 0\n" \
  5. : ret : __VA_ARGS__ : "memory"); \
  6. return r2; \
  7. } while (0)
  8. static inline long __syscall0(long n)
  9. {
  10. register long r1 __asm__("r1") = n;
  11. register long r2 __asm__("r2");
  12. __asm_syscall("=r"(r2), "r"(r1));
  13. }
  14. static inline long __syscall1(long n, long a)
  15. {
  16. register long r1 __asm__("r1") = n;
  17. register long r2 __asm__("r2") = a;
  18. __asm_syscall("+r"(r2), "r"(r1));
  19. }
  20. static inline long __syscall2(long n, long a, long b)
  21. {
  22. register long r1 __asm__("r1") = n;
  23. register long r2 __asm__("r2") = a;
  24. register long r3 __asm__("r3") = b;
  25. __asm_syscall("+r"(r2), "r"(r1), "r"(r3));
  26. }
  27. static inline long __syscall3(long n, long a, long b, long c)
  28. {
  29. register long r1 __asm__("r1") = n;
  30. register long r2 __asm__("r2") = a;
  31. register long r3 __asm__("r3") = b;
  32. register long r4 __asm__("r4") = c;
  33. __asm_syscall("+r"(r2), "r"(r1), "r"(r3), "r"(r4));
  34. }
  35. static inline long __syscall4(long n, long a, long b, long c, long d)
  36. {
  37. register long r1 __asm__("r1") = n;
  38. register long r2 __asm__("r2") = a;
  39. register long r3 __asm__("r3") = b;
  40. register long r4 __asm__("r4") = c;
  41. register long r5 __asm__("r5") = d;
  42. __asm_syscall("+r"(r2), "r"(r1), "r"(r3), "r"(r4), "r"(r5));
  43. }
  44. static inline long __syscall5(long n, long a, long b, long c, long d, long e)
  45. {
  46. register long r1 __asm__("r1") = n;
  47. register long r2 __asm__("r2") = a;
  48. register long r3 __asm__("r3") = b;
  49. register long r4 __asm__("r4") = c;
  50. register long r5 __asm__("r5") = d;
  51. register long r6 __asm__("r6") = e;
  52. __asm_syscall("+r"(r2), "r"(r1), "r"(r3), "r"(r4), "r"(r5), "r"(r6));
  53. }
  54. static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f)
  55. {
  56. if (n == SYS_mmap) return __syscall1(n, (long)(long[]){a,b,c,d,e,f});
  57. register long r1 __asm__("r1") = n;
  58. register long r2 __asm__("r2") = a;
  59. register long r3 __asm__("r3") = b;
  60. register long r4 __asm__("r4") = c;
  61. register long r5 __asm__("r5") = d;
  62. register long r6 __asm__("r6") = e;
  63. register long r7 __asm__("r7") = f;
  64. __asm_syscall("+r"(r2), "r"(r1), "r"(r3), "r"(r4), "r"(r5), "r"(r6), "r"(r7));
  65. }
  66. #define VDSO_USEFUL
  67. #define VDSO_CGT_SYM "__kernel_clock_gettime"
  68. #define VDSO_CGT_VER "LINUX_2.6.29"