ioasm.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. #ifndef S390_CIO_IOASM_H
  2. #define S390_CIO_IOASM_H
  3. #include "schid.h"
  4. /*
  5. * TPI info structure
  6. */
  7. struct tpi_info {
  8. struct subchannel_id schid;
  9. __u32 intparm; /* interruption parameter */
  10. __u32 adapter_IO : 1;
  11. __u32 reserved2 : 1;
  12. __u32 isc : 3;
  13. __u32 reserved3 : 12;
  14. __u32 int_type : 3;
  15. __u32 reserved4 : 12;
  16. } __attribute__ ((packed));
  17. /*
  18. * Some S390 specific IO instructions as inline
  19. */
  20. static inline int stsch(struct subchannel_id schid,
  21. volatile struct schib *addr)
  22. {
  23. int ccode;
  24. __asm__ __volatile__(
  25. " lr 1,%1\n"
  26. " stsch 0(%2)\n"
  27. " ipm %0\n"
  28. " srl %0,28"
  29. : "=d" (ccode)
  30. : "d" (schid), "a" (addr), "m" (*addr)
  31. : "cc", "1" );
  32. return ccode;
  33. }
  34. static inline int stsch_err(struct subchannel_id schid,
  35. volatile struct schib *addr)
  36. {
  37. int ccode;
  38. __asm__ __volatile__(
  39. " lhi %0,%3\n"
  40. " lr 1,%1\n"
  41. " stsch 0(%2)\n"
  42. "0: ipm %0\n"
  43. " srl %0,28\n"
  44. "1:\n"
  45. #ifdef CONFIG_64BIT
  46. ".section __ex_table,\"a\"\n"
  47. " .align 8\n"
  48. " .quad 0b,1b\n"
  49. ".previous"
  50. #else
  51. ".section __ex_table,\"a\"\n"
  52. " .align 4\n"
  53. " .long 0b,1b\n"
  54. ".previous"
  55. #endif
  56. : "=&d" (ccode)
  57. : "d" (schid), "a" (addr), "K" (-EIO), "m" (*addr)
  58. : "cc", "1" );
  59. return ccode;
  60. }
  61. static inline int msch(struct subchannel_id schid,
  62. volatile struct schib *addr)
  63. {
  64. int ccode;
  65. __asm__ __volatile__(
  66. " lr 1,%1\n"
  67. " msch 0(%2)\n"
  68. " ipm %0\n"
  69. " srl %0,28"
  70. : "=d" (ccode)
  71. : "d" (schid), "a" (addr), "m" (*addr)
  72. : "cc", "1" );
  73. return ccode;
  74. }
  75. static inline int msch_err(struct subchannel_id schid,
  76. volatile struct schib *addr)
  77. {
  78. int ccode;
  79. __asm__ __volatile__(
  80. " lhi %0,%3\n"
  81. " lr 1,%1\n"
  82. " msch 0(%2)\n"
  83. "0: ipm %0\n"
  84. " srl %0,28\n"
  85. "1:\n"
  86. #ifdef CONFIG_64BIT
  87. ".section __ex_table,\"a\"\n"
  88. " .align 8\n"
  89. " .quad 0b,1b\n"
  90. ".previous"
  91. #else
  92. ".section __ex_table,\"a\"\n"
  93. " .align 4\n"
  94. " .long 0b,1b\n"
  95. ".previous"
  96. #endif
  97. : "=&d" (ccode)
  98. : "d" (schid), "a" (addr), "K" (-EIO), "m" (*addr)
  99. : "cc", "1" );
  100. return ccode;
  101. }
  102. static inline int tsch(struct subchannel_id schid,
  103. volatile struct irb *addr)
  104. {
  105. int ccode;
  106. __asm__ __volatile__(
  107. " lr 1,%1\n"
  108. " tsch 0(%2)\n"
  109. " ipm %0\n"
  110. " srl %0,28"
  111. : "=d" (ccode)
  112. : "d" (schid), "a" (addr), "m" (*addr)
  113. : "cc", "1" );
  114. return ccode;
  115. }
  116. static inline int tpi( volatile struct tpi_info *addr)
  117. {
  118. int ccode;
  119. __asm__ __volatile__(
  120. " tpi 0(%1)\n"
  121. " ipm %0\n"
  122. " srl %0,28"
  123. : "=d" (ccode)
  124. : "a" (addr), "m" (*addr)
  125. : "cc", "1" );
  126. return ccode;
  127. }
  128. static inline int ssch(struct subchannel_id schid,
  129. volatile struct orb *addr)
  130. {
  131. int ccode;
  132. __asm__ __volatile__(
  133. " lr 1,%1\n"
  134. " ssch 0(%2)\n"
  135. " ipm %0\n"
  136. " srl %0,28"
  137. : "=d" (ccode)
  138. : "d" (schid), "a" (addr), "m" (*addr)
  139. : "cc", "1" );
  140. return ccode;
  141. }
  142. static inline int rsch(struct subchannel_id schid)
  143. {
  144. int ccode;
  145. __asm__ __volatile__(
  146. " lr 1,%1\n"
  147. " rsch\n"
  148. " ipm %0\n"
  149. " srl %0,28"
  150. : "=d" (ccode)
  151. : "d" (schid)
  152. : "cc", "1" );
  153. return ccode;
  154. }
  155. static inline int csch(struct subchannel_id schid)
  156. {
  157. int ccode;
  158. __asm__ __volatile__(
  159. " lr 1,%1\n"
  160. " csch\n"
  161. " ipm %0\n"
  162. " srl %0,28"
  163. : "=d" (ccode)
  164. : "d" (schid)
  165. : "cc", "1" );
  166. return ccode;
  167. }
  168. static inline int hsch(struct subchannel_id schid)
  169. {
  170. int ccode;
  171. __asm__ __volatile__(
  172. " lr 1,%1\n"
  173. " hsch\n"
  174. " ipm %0\n"
  175. " srl %0,28"
  176. : "=d" (ccode)
  177. : "d" (schid)
  178. : "cc", "1" );
  179. return ccode;
  180. }
  181. static inline int xsch(struct subchannel_id schid)
  182. {
  183. int ccode;
  184. __asm__ __volatile__(
  185. " lr 1,%1\n"
  186. " .insn rre,0xb2760000,%1,0\n"
  187. " ipm %0\n"
  188. " srl %0,28"
  189. : "=d" (ccode)
  190. : "d" (schid)
  191. : "cc", "1" );
  192. return ccode;
  193. }
  194. static inline int chsc(void *chsc_area)
  195. {
  196. typedef struct { char _[4096]; } addr_type;
  197. int cc;
  198. __asm__ __volatile__ (
  199. ".insn rre,0xb25f0000,%2,0 \n\t"
  200. "ipm %0 \n\t"
  201. "srl %0,28 \n\t"
  202. : "=d" (cc), "=m" (*(addr_type *) chsc_area)
  203. : "d" (chsc_area), "m" (*(addr_type *) chsc_area)
  204. : "cc" );
  205. return cc;
  206. }
  207. static inline int iac( void)
  208. {
  209. int ccode;
  210. __asm__ __volatile__(
  211. " iac 1\n"
  212. " ipm %0\n"
  213. " srl %0,28"
  214. : "=d" (ccode) : : "cc", "1" );
  215. return ccode;
  216. }
  217. static inline int rchp(int chpid)
  218. {
  219. int ccode;
  220. __asm__ __volatile__(
  221. " lr 1,%1\n"
  222. " rchp\n"
  223. " ipm %0\n"
  224. " srl %0,28"
  225. : "=d" (ccode)
  226. : "d" (chpid)
  227. : "cc", "1" );
  228. return ccode;
  229. }
  230. #endif