ioasm.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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 __rsch(struct subchannel_id schid)
  152. {
  153. register struct subchannel_id reg1 asm("1") = schid;
  154. int ccode;
  155. asm volatile(
  156. " rsch\n"
  157. " ipm %0\n"
  158. " srl %0,28"
  159. : "=d" (ccode)
  160. : "d" (reg1)
  161. : "cc", "memory");
  162. return ccode;
  163. }
  164. int rsch(struct subchannel_id schid)
  165. {
  166. int ccode;
  167. ccode = __rsch(schid);
  168. trace_s390_cio_rsch(schid, ccode);
  169. return ccode;
  170. }
  171. static inline int __hsch(struct subchannel_id schid)
  172. {
  173. register struct subchannel_id reg1 asm("1") = schid;
  174. int ccode;
  175. asm volatile(
  176. " hsch\n"
  177. " ipm %0\n"
  178. " srl %0,28"
  179. : "=d" (ccode)
  180. : "d" (reg1)
  181. : "cc");
  182. return ccode;
  183. }
  184. int hsch(struct subchannel_id schid)
  185. {
  186. int ccode;
  187. ccode = __hsch(schid);
  188. trace_s390_cio_hsch(schid, ccode);
  189. return ccode;
  190. }
  191. static inline int __xsch(struct subchannel_id schid)
  192. {
  193. register struct subchannel_id reg1 asm("1") = schid;
  194. int ccode;
  195. asm volatile(
  196. " xsch\n"
  197. " ipm %0\n"
  198. " srl %0,28"
  199. : "=d" (ccode)
  200. : "d" (reg1)
  201. : "cc");
  202. return ccode;
  203. }
  204. int xsch(struct subchannel_id schid)
  205. {
  206. int ccode;
  207. ccode = __xsch(schid);
  208. trace_s390_cio_xsch(schid, ccode);
  209. return ccode;
  210. }
  211. int stcrw(struct crw *crw)
  212. {
  213. int ccode;
  214. asm volatile(
  215. " stcrw 0(%2)\n"
  216. " ipm %0\n"
  217. " srl %0,28\n"
  218. : "=d" (ccode), "=m" (*crw)
  219. : "a" (crw)
  220. : "cc");
  221. trace_s390_cio_stcrw(crw, ccode);
  222. return ccode;
  223. }