ioasm.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Channel subsystem I/O instructions.
  4. */
  5. #include <linux/export.h>
  6. #include <asm/chpid.h>
  7. #include <asm/schid.h>
  8. #include <asm/crw.h>
  9. #include "ioasm.h"
  10. #include "orb.h"
  11. #include "cio.h"
  12. static inline int __stsch(struct subchannel_id schid, struct schib *addr)
  13. {
  14. register struct subchannel_id reg1 asm ("1") = schid;
  15. int ccode = -EIO;
  16. asm volatile(
  17. " stsch 0(%3)\n"
  18. "0: ipm %0\n"
  19. " srl %0,28\n"
  20. "1:\n"
  21. EX_TABLE(0b, 1b)
  22. : "+d" (ccode), "=m" (*addr)
  23. : "d" (reg1), "a" (addr)
  24. : "cc");
  25. return ccode;
  26. }
  27. int stsch(struct subchannel_id schid, struct schib *addr)
  28. {
  29. int ccode;
  30. ccode = __stsch(schid, addr);
  31. trace_s390_cio_stsch(schid, addr, ccode);
  32. return ccode;
  33. }
  34. EXPORT_SYMBOL(stsch);
  35. static inline int __msch(struct subchannel_id schid, struct schib *addr)
  36. {
  37. register struct subchannel_id reg1 asm ("1") = schid;
  38. int ccode = -EIO;
  39. asm volatile(
  40. " msch 0(%2)\n"
  41. "0: ipm %0\n"
  42. " srl %0,28\n"
  43. "1:\n"
  44. EX_TABLE(0b, 1b)
  45. : "+d" (ccode)
  46. : "d" (reg1), "a" (addr), "m" (*addr)
  47. : "cc");
  48. return ccode;
  49. }
  50. int msch(struct subchannel_id schid, struct schib *addr)
  51. {
  52. int ccode;
  53. ccode = __msch(schid, addr);
  54. trace_s390_cio_msch(schid, addr, ccode);
  55. return ccode;
  56. }
  57. static inline int __tsch(struct subchannel_id schid, struct irb *addr)
  58. {
  59. register struct subchannel_id reg1 asm ("1") = schid;
  60. int ccode;
  61. asm volatile(
  62. " tsch 0(%3)\n"
  63. " ipm %0\n"
  64. " srl %0,28"
  65. : "=d" (ccode), "=m" (*addr)
  66. : "d" (reg1), "a" (addr)
  67. : "cc");
  68. return ccode;
  69. }
  70. int tsch(struct subchannel_id schid, struct irb *addr)
  71. {
  72. int ccode;
  73. ccode = __tsch(schid, addr);
  74. trace_s390_cio_tsch(schid, addr, ccode);
  75. return ccode;
  76. }
  77. static inline int __ssch(struct subchannel_id schid, union orb *addr)
  78. {
  79. register struct subchannel_id reg1 asm("1") = schid;
  80. int ccode = -EIO;
  81. asm volatile(
  82. " ssch 0(%2)\n"
  83. "0: ipm %0\n"
  84. " srl %0,28\n"
  85. "1:\n"
  86. EX_TABLE(0b, 1b)
  87. : "+d" (ccode)
  88. : "d" (reg1), "a" (addr), "m" (*addr)
  89. : "cc", "memory");
  90. return ccode;
  91. }
  92. int ssch(struct subchannel_id schid, union orb *addr)
  93. {
  94. int ccode;
  95. ccode = __ssch(schid, addr);
  96. trace_s390_cio_ssch(schid, addr, ccode);
  97. return ccode;
  98. }
  99. EXPORT_SYMBOL(ssch);
  100. static inline int __csch(struct subchannel_id schid)
  101. {
  102. register struct subchannel_id reg1 asm("1") = schid;
  103. int ccode;
  104. asm volatile(
  105. " csch\n"
  106. " ipm %0\n"
  107. " srl %0,28"
  108. : "=d" (ccode)
  109. : "d" (reg1)
  110. : "cc");
  111. return ccode;
  112. }
  113. int csch(struct subchannel_id schid)
  114. {
  115. int ccode;
  116. ccode = __csch(schid);
  117. trace_s390_cio_csch(schid, ccode);
  118. return ccode;
  119. }
  120. EXPORT_SYMBOL(csch);
  121. int tpi(struct tpi_info *addr)
  122. {
  123. int ccode;
  124. asm volatile(
  125. " tpi 0(%2)\n"
  126. " ipm %0\n"
  127. " srl %0,28"
  128. : "=d" (ccode), "=m" (*addr)
  129. : "a" (addr)
  130. : "cc");
  131. trace_s390_cio_tpi(addr, ccode);
  132. return ccode;
  133. }
  134. int chsc(void *chsc_area)
  135. {
  136. typedef struct { char _[4096]; } addr_type;
  137. int cc = -EIO;
  138. asm volatile(
  139. " .insn rre,0xb25f0000,%2,0\n"
  140. "0: ipm %0\n"
  141. " srl %0,28\n"
  142. "1:\n"
  143. EX_TABLE(0b, 1b)
  144. : "+d" (cc), "=m" (*(addr_type *) chsc_area)
  145. : "d" (chsc_area), "m" (*(addr_type *) chsc_area)
  146. : "cc");
  147. trace_s390_cio_chsc(chsc_area, cc);
  148. return cc;
  149. }
  150. EXPORT_SYMBOL(chsc);
  151. static inline int __rchp(struct chp_id chpid)
  152. {
  153. register struct chp_id reg1 asm ("1") = chpid;
  154. int ccode;
  155. asm volatile(
  156. " lr 1,%1\n"
  157. " rchp\n"
  158. " ipm %0\n"
  159. " srl %0,28"
  160. : "=d" (ccode) : "d" (reg1) : "cc");
  161. return ccode;
  162. }
  163. int rchp(struct chp_id chpid)
  164. {
  165. int ccode;
  166. ccode = __rchp(chpid);
  167. trace_s390_cio_rchp(chpid, ccode);
  168. return ccode;
  169. }
  170. static inline int __rsch(struct subchannel_id schid)
  171. {
  172. register struct subchannel_id reg1 asm("1") = schid;
  173. int ccode;
  174. asm volatile(
  175. " rsch\n"
  176. " ipm %0\n"
  177. " srl %0,28"
  178. : "=d" (ccode)
  179. : "d" (reg1)
  180. : "cc", "memory");
  181. return ccode;
  182. }
  183. int rsch(struct subchannel_id schid)
  184. {
  185. int ccode;
  186. ccode = __rsch(schid);
  187. trace_s390_cio_rsch(schid, ccode);
  188. return ccode;
  189. }
  190. static inline int __hsch(struct subchannel_id schid)
  191. {
  192. register struct subchannel_id reg1 asm("1") = schid;
  193. int ccode;
  194. asm volatile(
  195. " hsch\n"
  196. " ipm %0\n"
  197. " srl %0,28"
  198. : "=d" (ccode)
  199. : "d" (reg1)
  200. : "cc");
  201. return ccode;
  202. }
  203. int hsch(struct subchannel_id schid)
  204. {
  205. int ccode;
  206. ccode = __hsch(schid);
  207. trace_s390_cio_hsch(schid, ccode);
  208. return ccode;
  209. }
  210. static inline int __xsch(struct subchannel_id schid)
  211. {
  212. register struct subchannel_id reg1 asm("1") = schid;
  213. int ccode;
  214. asm volatile(
  215. " xsch\n"
  216. " ipm %0\n"
  217. " srl %0,28"
  218. : "=d" (ccode)
  219. : "d" (reg1)
  220. : "cc");
  221. return ccode;
  222. }
  223. int xsch(struct subchannel_id schid)
  224. {
  225. int ccode;
  226. ccode = __xsch(schid);
  227. trace_s390_cio_xsch(schid, ccode);
  228. return ccode;
  229. }
  230. int stcrw(struct crw *crw)
  231. {
  232. int ccode;
  233. asm volatile(
  234. " stcrw 0(%2)\n"
  235. " ipm %0\n"
  236. " srl %0,28\n"
  237. : "=d" (ccode), "=m" (*crw)
  238. : "a" (crw)
  239. : "cc");
  240. trace_s390_cio_stcrw(crw, ccode);
  241. return ccode;
  242. }