syscall-arm64.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * linux/include/asm-arm/unistd.h
  3. *
  4. * Copyright (C) 2001-2005 Russell King
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * Please forward _all_ changes to this file to rmk@arm.linux.org.uk,
  11. * no matter what the change is. Thanks!
  12. */
  13. #define __NR_io_setup 0
  14. #define __NR_io_destroy 1
  15. #define __NR_io_submit 2
  16. #define __NR_io_cancel 3
  17. #define __NR_io_getevents 4
  18. #define __sys2(x) #x
  19. #define __sys1(x) __sys2(x)
  20. #define __SYS_REG(name) register long __sysreg __asm__("w8") = __NR_##name;
  21. #define __SYS_REG_LIST(regs...) "r" (__sysreg) , ##regs
  22. #define __syscall(name) "svc\t#0"
  23. #define io_syscall1(type,fname,sname,type1,arg1) \
  24. type fname(type1 arg1) { \
  25. __SYS_REG(sname) \
  26. register long __x0 __asm__("x0") = (long)arg1; \
  27. register long __res_x0 __asm__("x0"); \
  28. __asm__ __volatile__ ( \
  29. __syscall(sname) \
  30. : "=r" (__res_x0) \
  31. : __SYS_REG_LIST( "0" (__x0) ) \
  32. : "memory" ); \
  33. return (type) __res_x0; \
  34. }
  35. #define io_syscall2(type,fname,sname,type1,arg1,type2,arg2) \
  36. type fname(type1 arg1,type2 arg2) { \
  37. __SYS_REG(sname) \
  38. register long __x0 __asm__("x0") = (long)arg1; \
  39. register long __x1 __asm__("x1") = (long)arg2; \
  40. register long __res_x0 __asm__("x0"); \
  41. __asm__ __volatile__ ( \
  42. __syscall(sname) \
  43. : "=r" (__res_x0) \
  44. : __SYS_REG_LIST( "0" (__x0), "r" (__x1) ) \
  45. : "memory" ); \
  46. return (type) __res_x0; \
  47. }
  48. #define io_syscall3(type,fname,sname,type1,arg1,type2,arg2,type3,arg3) \
  49. type fname(type1 arg1,type2 arg2,type3 arg3) { \
  50. __SYS_REG(sname) \
  51. register long __x0 __asm__("x0") = (long)arg1; \
  52. register long __x1 __asm__("x1") = (long)arg2; \
  53. register long __x2 __asm__("x2") = (long)arg3; \
  54. register long __res_x0 __asm__("x0"); \
  55. __asm__ __volatile__ ( \
  56. __syscall(sname) \
  57. : "=r" (__res_x0) \
  58. : __SYS_REG_LIST( "0" (__x0), "r" (__x1), "r" (__x2) ) \
  59. : "memory" ); \
  60. return (type) __res_x0; \
  61. }
  62. #define io_syscall4(type,fname,sname,type1,arg1,type2,arg2,type3,arg3,type4,arg4)\
  63. type fname(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \
  64. __SYS_REG(sname) \
  65. register long __x0 __asm__("x0") = (long)arg1; \
  66. register long __x1 __asm__("x1") = (long)arg2; \
  67. register long __x2 __asm__("x2") = (long)arg3; \
  68. register long __x3 __asm__("x3") = (long)arg4; \
  69. register long __res_x0 __asm__("x0"); \
  70. __asm__ __volatile__ ( \
  71. __syscall(sname) \
  72. : "=r" (__res_x0) \
  73. : __SYS_REG_LIST( "0" (__x0), "r" (__x1), "r" (__x2), "r" (__x3) ) \
  74. : "memory" ); \
  75. return (type) __res_x0; \
  76. }
  77. #define io_syscall5(type,fname,sname,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
  78. type fname(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) {\
  79. __SYS_REG(sname) \
  80. register long __x0 __asm__("x0") = (long)arg1; \
  81. register long __x1 __asm__("x1") = (long)arg2; \
  82. register long __x2 __asm__("x2") = (long)arg3; \
  83. register long __x3 __asm__("x3") = (long)arg4; \
  84. register long __x4 __asm__("x4") = (long)arg5; \
  85. register long __res_x0 __asm__("x0"); \
  86. __asm__ __volatile__ ( \
  87. __syscall(sname) \
  88. : "=r" (__res_x0) \
  89. : __SYS_REG_LIST( "0" (__x0), "r" (__x1), "r" (__x2), \
  90. "r" (__x3), "r" (__x4) ) \
  91. : "memory" ); \
  92. return (type) __res_x0; \
  93. }