Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / drivers / s390 / cio / ioasm.c
blob4fa9ee1d09fa93c5207d87c2252bb3d0c82cbf4f
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 __rchp(struct chp_id chpid)
188 register struct chp_id reg1 asm ("1") = chpid;
189 int ccode;
191 asm volatile(
192 " lr 1,%1\n"
193 " rchp\n"
194 " ipm %0\n"
195 " srl %0,28"
196 : "=d" (ccode) : "d" (reg1) : "cc");
197 return ccode;
200 int rchp(struct chp_id chpid)
202 int ccode;
204 ccode = __rchp(chpid);
205 trace_s390_cio_rchp(chpid, ccode);
207 return ccode;
210 static inline int __rsch(struct subchannel_id schid)
212 register struct subchannel_id reg1 asm("1") = schid;
213 int ccode;
215 asm volatile(
216 " rsch\n"
217 " ipm %0\n"
218 " srl %0,28"
219 : "=d" (ccode)
220 : "d" (reg1)
221 : "cc", "memory");
223 return ccode;
226 int rsch(struct subchannel_id schid)
228 int ccode;
230 ccode = __rsch(schid);
231 trace_s390_cio_rsch(schid, ccode);
233 return ccode;
236 static inline int __hsch(struct subchannel_id schid)
238 register struct subchannel_id reg1 asm("1") = schid;
239 int ccode;
241 asm volatile(
242 " hsch\n"
243 " ipm %0\n"
244 " srl %0,28"
245 : "=d" (ccode)
246 : "d" (reg1)
247 : "cc");
248 return ccode;
251 int hsch(struct subchannel_id schid)
253 int ccode;
255 ccode = __hsch(schid);
256 trace_s390_cio_hsch(schid, ccode);
258 return ccode;
261 static inline int __xsch(struct subchannel_id schid)
263 register struct subchannel_id reg1 asm("1") = schid;
264 int ccode;
266 asm volatile(
267 " xsch\n"
268 " ipm %0\n"
269 " srl %0,28"
270 : "=d" (ccode)
271 : "d" (reg1)
272 : "cc");
273 return ccode;
276 int xsch(struct subchannel_id schid)
278 int ccode;
280 ccode = __xsch(schid);
281 trace_s390_cio_xsch(schid, ccode);
283 return ccode;
286 int stcrw(struct crw *crw)
288 int ccode;
290 asm volatile(
291 " stcrw 0(%2)\n"
292 " ipm %0\n"
293 " srl %0,28\n"
294 : "=d" (ccode), "=m" (*crw)
295 : "a" (crw)
296 : "cc");
297 trace_s390_cio_stcrw(crw, ccode);
299 return ccode;