Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / s390 / cio / ioasm.c
blob08eb10283b180e8ad7e011310ba67c87cb5af995
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Channel subsystem I/O instructions.
4 */
6 #include <linux/export.h>
8 #include <asm/chpid.h>
9 #include <asm/schid.h>
10 #include <asm/crw.h>
12 #include "ioasm.h"
13 #include "orb.h"
14 #include "cio.h"
16 static inline int __stsch(struct subchannel_id schid, struct schib *addr)
18 register struct subchannel_id reg1 asm ("1") = schid;
19 int ccode = -EIO;
21 asm volatile(
22 " stsch 0(%3)\n"
23 "0: ipm %0\n"
24 " srl %0,28\n"
25 "1:\n"
26 EX_TABLE(0b, 1b)
27 : "+d" (ccode), "=m" (*addr)
28 : "d" (reg1), "a" (addr)
29 : "cc");
30 return ccode;
33 int stsch(struct subchannel_id schid, struct schib *addr)
35 int ccode;
37 ccode = __stsch(schid, addr);
38 trace_s390_cio_stsch(schid, addr, ccode);
40 return ccode;
42 EXPORT_SYMBOL(stsch);
44 static inline int __msch(struct subchannel_id schid, struct schib *addr)
46 register struct subchannel_id reg1 asm ("1") = schid;
47 int ccode = -EIO;
49 asm volatile(
50 " msch 0(%2)\n"
51 "0: ipm %0\n"
52 " srl %0,28\n"
53 "1:\n"
54 EX_TABLE(0b, 1b)
55 : "+d" (ccode)
56 : "d" (reg1), "a" (addr), "m" (*addr)
57 : "cc");
58 return ccode;
61 int msch(struct subchannel_id schid, struct schib *addr)
63 int ccode;
65 ccode = __msch(schid, addr);
66 trace_s390_cio_msch(schid, addr, ccode);
68 return ccode;
71 static inline int __tsch(struct subchannel_id schid, struct irb *addr)
73 register struct subchannel_id reg1 asm ("1") = schid;
74 int ccode;
76 asm volatile(
77 " tsch 0(%3)\n"
78 " ipm %0\n"
79 " srl %0,28"
80 : "=d" (ccode), "=m" (*addr)
81 : "d" (reg1), "a" (addr)
82 : "cc");
83 return ccode;
86 int tsch(struct subchannel_id schid, struct irb *addr)
88 int ccode;
90 ccode = __tsch(schid, addr);
91 trace_s390_cio_tsch(schid, addr, ccode);
93 return ccode;
96 static inline int __ssch(struct subchannel_id schid, union orb *addr)
98 register struct subchannel_id reg1 asm("1") = schid;
99 int ccode = -EIO;
101 asm volatile(
102 " ssch 0(%2)\n"
103 "0: ipm %0\n"
104 " srl %0,28\n"
105 "1:\n"
106 EX_TABLE(0b, 1b)
107 : "+d" (ccode)
108 : "d" (reg1), "a" (addr), "m" (*addr)
109 : "cc", "memory");
110 return ccode;
113 int ssch(struct subchannel_id schid, union orb *addr)
115 int ccode;
117 ccode = __ssch(schid, addr);
118 trace_s390_cio_ssch(schid, addr, ccode);
120 return ccode;
122 EXPORT_SYMBOL(ssch);
124 static inline int __csch(struct subchannel_id schid)
126 register struct subchannel_id reg1 asm("1") = schid;
127 int ccode;
129 asm volatile(
130 " csch\n"
131 " ipm %0\n"
132 " srl %0,28"
133 : "=d" (ccode)
134 : "d" (reg1)
135 : "cc");
136 return ccode;
139 int csch(struct subchannel_id schid)
141 int ccode;
143 ccode = __csch(schid);
144 trace_s390_cio_csch(schid, ccode);
146 return ccode;
148 EXPORT_SYMBOL(csch);
150 int tpi(struct tpi_info *addr)
152 int ccode;
154 asm volatile(
155 " tpi 0(%2)\n"
156 " ipm %0\n"
157 " srl %0,28"
158 : "=d" (ccode), "=m" (*addr)
159 : "a" (addr)
160 : "cc");
161 trace_s390_cio_tpi(addr, ccode);
163 return ccode;
166 int chsc(void *chsc_area)
168 typedef struct { char _[4096]; } addr_type;
169 int cc = -EIO;
171 asm volatile(
172 " .insn rre,0xb25f0000,%2,0\n"
173 "0: ipm %0\n"
174 " srl %0,28\n"
175 "1:\n"
176 EX_TABLE(0b, 1b)
177 : "+d" (cc), "=m" (*(addr_type *) chsc_area)
178 : "d" (chsc_area), "m" (*(addr_type *) chsc_area)
179 : "cc");
180 trace_s390_cio_chsc(chsc_area, cc);
182 return cc;
184 EXPORT_SYMBOL(chsc);
186 static inline int __rsch(struct subchannel_id schid)
188 register struct subchannel_id reg1 asm("1") = schid;
189 int ccode;
191 asm volatile(
192 " rsch\n"
193 " ipm %0\n"
194 " srl %0,28"
195 : "=d" (ccode)
196 : "d" (reg1)
197 : "cc", "memory");
199 return ccode;
202 int rsch(struct subchannel_id schid)
204 int ccode;
206 ccode = __rsch(schid);
207 trace_s390_cio_rsch(schid, ccode);
209 return ccode;
212 static inline int __hsch(struct subchannel_id schid)
214 register struct subchannel_id reg1 asm("1") = schid;
215 int ccode;
217 asm volatile(
218 " hsch\n"
219 " ipm %0\n"
220 " srl %0,28"
221 : "=d" (ccode)
222 : "d" (reg1)
223 : "cc");
224 return ccode;
227 int hsch(struct subchannel_id schid)
229 int ccode;
231 ccode = __hsch(schid);
232 trace_s390_cio_hsch(schid, ccode);
234 return ccode;
236 EXPORT_SYMBOL(hsch);
238 static inline int __xsch(struct subchannel_id schid)
240 register struct subchannel_id reg1 asm("1") = schid;
241 int ccode;
243 asm volatile(
244 " xsch\n"
245 " ipm %0\n"
246 " srl %0,28"
247 : "=d" (ccode)
248 : "d" (reg1)
249 : "cc");
250 return ccode;
253 int xsch(struct subchannel_id schid)
255 int ccode;
257 ccode = __xsch(schid);
258 trace_s390_cio_xsch(schid, ccode);
260 return ccode;
263 int stcrw(struct crw *crw)
265 int ccode;
267 asm volatile(
268 " stcrw 0(%2)\n"
269 " ipm %0\n"
270 " srl %0,28\n"
271 : "=d" (ccode), "=m" (*crw)
272 : "a" (crw)
273 : "cc");
274 trace_s390_cio_stcrw(crw, ccode);
276 return ccode;