sys32.S 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. /*
  2. * sys32.S: I-cache tricks for 32-bit compatibility layer simple
  3. * conversions.
  4. *
  5. * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
  6. * Copyright (C) 1998 Jakub Jelinek (jj@ultra.linux.cz)
  7. */
  8. #include <asm/errno.h>
  9. /* NOTE: call as jump breaks return stack, we have to avoid that */
  10. .text
  11. #define SIGN1(STUB,SYSCALL,REG1) \
  12. .align 32; \
  13. .globl STUB; \
  14. STUB: sethi %hi(SYSCALL), %g1; \
  15. jmpl %g1 + %lo(SYSCALL), %g0; \
  16. sra REG1, 0, REG1
  17. #define SIGN2(STUB,SYSCALL,REG1,REG2) \
  18. .align 32; \
  19. .globl STUB; \
  20. STUB: sethi %hi(SYSCALL), %g1; \
  21. sra REG1, 0, REG1; \
  22. jmpl %g1 + %lo(SYSCALL), %g0; \
  23. sra REG2, 0, REG2
  24. #define SIGN3(STUB,SYSCALL,REG1,REG2,REG3) \
  25. .align 32; \
  26. .globl STUB; \
  27. STUB: sra REG1, 0, REG1; \
  28. sethi %hi(SYSCALL), %g1; \
  29. sra REG2, 0, REG2; \
  30. jmpl %g1 + %lo(SYSCALL), %g0; \
  31. sra REG3, 0, REG3
  32. SIGN1(sys32_readahead, compat_sys_readahead, %o0)
  33. SIGN2(sys32_fadvise64, compat_sys_fadvise64, %o0, %o4)
  34. SIGN2(sys32_fadvise64_64, compat_sys_fadvise64_64, %o0, %o5)
  35. SIGN1(sys32_clock_nanosleep, compat_sys_clock_nanosleep, %o1)
  36. SIGN1(sys32_timer_settime, compat_sys_timer_settime, %o1)
  37. SIGN1(sys32_io_submit, compat_sys_io_submit, %o1)
  38. SIGN1(sys32_mq_open, compat_sys_mq_open, %o1)
  39. SIGN1(sys32_select, compat_sys_select, %o0)
  40. SIGN1(sys32_futex, compat_sys_futex, %o1)
  41. SIGN1(sys32_recvfrom, compat_sys_recvfrom, %o0)
  42. SIGN1(sys32_recvmsg, compat_sys_recvmsg, %o0)
  43. SIGN1(sys32_sendmsg, compat_sys_sendmsg, %o0)
  44. SIGN2(sys32_renameat2, sys_renameat2, %o0, %o2)
  45. .globl sys32_mmap2
  46. sys32_mmap2:
  47. sethi %hi(sys_mmap), %g1
  48. jmpl %g1 + %lo(sys_mmap), %g0
  49. sllx %o5, 12, %o5
  50. .align 32
  51. .globl sys32_socketcall
  52. sys32_socketcall: /* %o0=call, %o1=args */
  53. cmp %o0, 1
  54. bl,pn %xcc, do_einval
  55. cmp %o0, 18
  56. bg,pn %xcc, do_einval
  57. sub %o0, 1, %o0
  58. sllx %o0, 5, %o0
  59. sethi %hi(__socketcall_table_begin), %g2
  60. or %g2, %lo(__socketcall_table_begin), %g2
  61. jmpl %g2 + %o0, %g0
  62. nop
  63. do_einval:
  64. retl
  65. mov -EINVAL, %o0
  66. .align 32
  67. __socketcall_table_begin:
  68. /* Each entry is exactly 32 bytes. */
  69. do_sys_socket: /* sys_socket(int, int, int) */
  70. 1: ldswa [%o1 + 0x0] %asi, %o0
  71. sethi %hi(sys_socket), %g1
  72. 2: ldswa [%o1 + 0x8] %asi, %o2
  73. jmpl %g1 + %lo(sys_socket), %g0
  74. 3: ldswa [%o1 + 0x4] %asi, %o1
  75. nop
  76. nop
  77. nop
  78. do_sys_bind: /* sys_bind(int fd, struct sockaddr *, int) */
  79. 4: ldswa [%o1 + 0x0] %asi, %o0
  80. sethi %hi(sys_bind), %g1
  81. 5: ldswa [%o1 + 0x8] %asi, %o2
  82. jmpl %g1 + %lo(sys_bind), %g0
  83. 6: lduwa [%o1 + 0x4] %asi, %o1
  84. nop
  85. nop
  86. nop
  87. do_sys_connect: /* sys_connect(int, struct sockaddr *, int) */
  88. 7: ldswa [%o1 + 0x0] %asi, %o0
  89. sethi %hi(sys_connect), %g1
  90. 8: ldswa [%o1 + 0x8] %asi, %o2
  91. jmpl %g1 + %lo(sys_connect), %g0
  92. 9: lduwa [%o1 + 0x4] %asi, %o1
  93. nop
  94. nop
  95. nop
  96. do_sys_listen: /* sys_listen(int, int) */
  97. 10: ldswa [%o1 + 0x0] %asi, %o0
  98. sethi %hi(sys_listen), %g1
  99. jmpl %g1 + %lo(sys_listen), %g0
  100. 11: ldswa [%o1 + 0x4] %asi, %o1
  101. nop
  102. nop
  103. nop
  104. nop
  105. do_sys_accept: /* sys_accept(int, struct sockaddr *, int *) */
  106. 12: ldswa [%o1 + 0x0] %asi, %o0
  107. sethi %hi(sys_accept), %g1
  108. 13: lduwa [%o1 + 0x8] %asi, %o2
  109. jmpl %g1 + %lo(sys_accept), %g0
  110. 14: lduwa [%o1 + 0x4] %asi, %o1
  111. nop
  112. nop
  113. nop
  114. do_sys_getsockname: /* sys_getsockname(int, struct sockaddr *, int *) */
  115. 15: ldswa [%o1 + 0x0] %asi, %o0
  116. sethi %hi(sys_getsockname), %g1
  117. 16: lduwa [%o1 + 0x8] %asi, %o2
  118. jmpl %g1 + %lo(sys_getsockname), %g0
  119. 17: lduwa [%o1 + 0x4] %asi, %o1
  120. nop
  121. nop
  122. nop
  123. do_sys_getpeername: /* sys_getpeername(int, struct sockaddr *, int *) */
  124. 18: ldswa [%o1 + 0x0] %asi, %o0
  125. sethi %hi(sys_getpeername), %g1
  126. 19: lduwa [%o1 + 0x8] %asi, %o2
  127. jmpl %g1 + %lo(sys_getpeername), %g0
  128. 20: lduwa [%o1 + 0x4] %asi, %o1
  129. nop
  130. nop
  131. nop
  132. do_sys_socketpair: /* sys_socketpair(int, int, int, int *) */
  133. 21: ldswa [%o1 + 0x0] %asi, %o0
  134. sethi %hi(sys_socketpair), %g1
  135. 22: ldswa [%o1 + 0x8] %asi, %o2
  136. 23: lduwa [%o1 + 0xc] %asi, %o3
  137. jmpl %g1 + %lo(sys_socketpair), %g0
  138. 24: ldswa [%o1 + 0x4] %asi, %o1
  139. nop
  140. nop
  141. do_sys_send: /* sys_send(int, void *, size_t, unsigned int) */
  142. 25: ldswa [%o1 + 0x0] %asi, %o0
  143. sethi %hi(sys_send), %g1
  144. 26: lduwa [%o1 + 0x8] %asi, %o2
  145. 27: lduwa [%o1 + 0xc] %asi, %o3
  146. jmpl %g1 + %lo(sys_send), %g0
  147. 28: lduwa [%o1 + 0x4] %asi, %o1
  148. nop
  149. nop
  150. do_sys_recv: /* sys_recv(int, void *, size_t, unsigned int) */
  151. 29: ldswa [%o1 + 0x0] %asi, %o0
  152. sethi %hi(sys_recv), %g1
  153. 30: lduwa [%o1 + 0x8] %asi, %o2
  154. 31: lduwa [%o1 + 0xc] %asi, %o3
  155. jmpl %g1 + %lo(sys_recv), %g0
  156. 32: lduwa [%o1 + 0x4] %asi, %o1
  157. nop
  158. nop
  159. do_sys_sendto: /* sys_sendto(int, u32, compat_size_t, unsigned int, u32, int) */
  160. 33: ldswa [%o1 + 0x0] %asi, %o0
  161. sethi %hi(sys_sendto), %g1
  162. 34: lduwa [%o1 + 0x8] %asi, %o2
  163. 35: lduwa [%o1 + 0xc] %asi, %o3
  164. 36: lduwa [%o1 + 0x10] %asi, %o4
  165. 37: ldswa [%o1 + 0x14] %asi, %o5
  166. jmpl %g1 + %lo(sys_sendto), %g0
  167. 38: lduwa [%o1 + 0x4] %asi, %o1
  168. do_sys_recvfrom: /* sys_recvfrom(int, u32, compat_size_t, unsigned int, u32, u32) */
  169. 39: ldswa [%o1 + 0x0] %asi, %o0
  170. sethi %hi(sys_recvfrom), %g1
  171. 40: lduwa [%o1 + 0x8] %asi, %o2
  172. 41: lduwa [%o1 + 0xc] %asi, %o3
  173. 42: lduwa [%o1 + 0x10] %asi, %o4
  174. 43: lduwa [%o1 + 0x14] %asi, %o5
  175. jmpl %g1 + %lo(sys_recvfrom), %g0
  176. 44: lduwa [%o1 + 0x4] %asi, %o1
  177. do_sys_shutdown: /* sys_shutdown(int, int) */
  178. 45: ldswa [%o1 + 0x0] %asi, %o0
  179. sethi %hi(sys_shutdown), %g1
  180. jmpl %g1 + %lo(sys_shutdown), %g0
  181. 46: ldswa [%o1 + 0x4] %asi, %o1
  182. nop
  183. nop
  184. nop
  185. nop
  186. do_sys_setsockopt: /* compat_sys_setsockopt(int, int, int, char *, int) */
  187. 47: ldswa [%o1 + 0x0] %asi, %o0
  188. sethi %hi(compat_sys_setsockopt), %g1
  189. 48: ldswa [%o1 + 0x8] %asi, %o2
  190. 49: lduwa [%o1 + 0xc] %asi, %o3
  191. 50: ldswa [%o1 + 0x10] %asi, %o4
  192. jmpl %g1 + %lo(compat_sys_setsockopt), %g0
  193. 51: ldswa [%o1 + 0x4] %asi, %o1
  194. nop
  195. do_sys_getsockopt: /* compat_sys_getsockopt(int, int, int, u32, u32) */
  196. 52: ldswa [%o1 + 0x0] %asi, %o0
  197. sethi %hi(compat_sys_getsockopt), %g1
  198. 53: ldswa [%o1 + 0x8] %asi, %o2
  199. 54: lduwa [%o1 + 0xc] %asi, %o3
  200. 55: lduwa [%o1 + 0x10] %asi, %o4
  201. jmpl %g1 + %lo(compat_sys_getsockopt), %g0
  202. 56: ldswa [%o1 + 0x4] %asi, %o1
  203. nop
  204. do_sys_sendmsg: /* compat_sys_sendmsg(int, struct compat_msghdr *, unsigned int) */
  205. 57: ldswa [%o1 + 0x0] %asi, %o0
  206. sethi %hi(compat_sys_sendmsg), %g1
  207. 58: lduwa [%o1 + 0x8] %asi, %o2
  208. jmpl %g1 + %lo(compat_sys_sendmsg), %g0
  209. 59: lduwa [%o1 + 0x4] %asi, %o1
  210. nop
  211. nop
  212. nop
  213. do_sys_recvmsg: /* compat_sys_recvmsg(int, struct compat_msghdr *, unsigned int) */
  214. 60: ldswa [%o1 + 0x0] %asi, %o0
  215. sethi %hi(compat_sys_recvmsg), %g1
  216. 61: lduwa [%o1 + 0x8] %asi, %o2
  217. jmpl %g1 + %lo(compat_sys_recvmsg), %g0
  218. 62: lduwa [%o1 + 0x4] %asi, %o1
  219. nop
  220. nop
  221. nop
  222. do_sys_accept4: /* sys_accept4(int, struct sockaddr *, int *, int) */
  223. 63: ldswa [%o1 + 0x0] %asi, %o0
  224. sethi %hi(sys_accept4), %g1
  225. 64: lduwa [%o1 + 0x8] %asi, %o2
  226. 65: ldswa [%o1 + 0xc] %asi, %o3
  227. jmpl %g1 + %lo(sys_accept4), %g0
  228. 66: lduwa [%o1 + 0x4] %asi, %o1
  229. nop
  230. nop
  231. .section __ex_table,"a"
  232. .align 4
  233. .word 1b, __retl_efault, 2b, __retl_efault
  234. .word 3b, __retl_efault, 4b, __retl_efault
  235. .word 5b, __retl_efault, 6b, __retl_efault
  236. .word 7b, __retl_efault, 8b, __retl_efault
  237. .word 9b, __retl_efault, 10b, __retl_efault
  238. .word 11b, __retl_efault, 12b, __retl_efault
  239. .word 13b, __retl_efault, 14b, __retl_efault
  240. .word 15b, __retl_efault, 16b, __retl_efault
  241. .word 17b, __retl_efault, 18b, __retl_efault
  242. .word 19b, __retl_efault, 20b, __retl_efault
  243. .word 21b, __retl_efault, 22b, __retl_efault
  244. .word 23b, __retl_efault, 24b, __retl_efault
  245. .word 25b, __retl_efault, 26b, __retl_efault
  246. .word 27b, __retl_efault, 28b, __retl_efault
  247. .word 29b, __retl_efault, 30b, __retl_efault
  248. .word 31b, __retl_efault, 32b, __retl_efault
  249. .word 33b, __retl_efault, 34b, __retl_efault
  250. .word 35b, __retl_efault, 36b, __retl_efault
  251. .word 37b, __retl_efault, 38b, __retl_efault
  252. .word 39b, __retl_efault, 40b, __retl_efault
  253. .word 41b, __retl_efault, 42b, __retl_efault
  254. .word 43b, __retl_efault, 44b, __retl_efault
  255. .word 45b, __retl_efault, 46b, __retl_efault
  256. .word 47b, __retl_efault, 48b, __retl_efault
  257. .word 49b, __retl_efault, 50b, __retl_efault
  258. .word 51b, __retl_efault, 52b, __retl_efault
  259. .word 53b, __retl_efault, 54b, __retl_efault
  260. .word 55b, __retl_efault, 56b, __retl_efault
  261. .word 57b, __retl_efault, 58b, __retl_efault
  262. .word 59b, __retl_efault, 60b, __retl_efault
  263. .word 61b, __retl_efault, 62b, __retl_efault
  264. .word 63b, __retl_efault, 64b, __retl_efault
  265. .word 65b, __retl_efault, 66b, __retl_efault
  266. .previous