blob: 8225da6190148a44e5a729d9d56a186ca0da6dfe [file] [log] [blame]
Peter Oberparleiter11b64c82015-12-18 12:59:40 +01001/*
2 * Channel subsystem I/O instructions.
3 */
4
5#include <linux/export.h>
6
7#include <asm/chpid.h>
8#include <asm/schid.h>
9#include <asm/crw.h>
10
11#include "ioasm.h"
12#include "orb.h"
13#include "cio.h"
14
Heiko Carstensa4d9b972016-06-20 14:03:52 +020015static inline int __stsch(struct subchannel_id schid, struct schib *addr)
Peter Oberparleiter11b64c82015-12-18 12:59:40 +010016{
17 register struct subchannel_id reg1 asm ("1") = schid;
18 int ccode = -EIO;
19
20 asm volatile(
21 " stsch 0(%3)\n"
22 "0: ipm %0\n"
23 " srl %0,28\n"
24 "1:\n"
25 EX_TABLE(0b, 1b)
26 : "+d" (ccode), "=m" (*addr)
27 : "d" (reg1), "a" (addr)
28 : "cc");
Heiko Carstensa4d9b972016-06-20 14:03:52 +020029 return ccode;
30}
31
32int stsch(struct subchannel_id schid, struct schib *addr)
33{
34 int ccode;
35
36 ccode = __stsch(schid, addr);
Peter Oberparleiter11b64c82015-12-18 12:59:40 +010037 trace_s390_cio_stsch(schid, addr, ccode);
38
39 return ccode;
40}
41EXPORT_SYMBOL(stsch);
42
Heiko Carstensa4d9b972016-06-20 14:03:52 +020043static inline int __msch(struct subchannel_id schid, struct schib *addr)
Peter Oberparleiter11b64c82015-12-18 12:59:40 +010044{
45 register struct subchannel_id reg1 asm ("1") = schid;
46 int ccode = -EIO;
47
48 asm volatile(
49 " msch 0(%2)\n"
50 "0: ipm %0\n"
51 " srl %0,28\n"
52 "1:\n"
53 EX_TABLE(0b, 1b)
54 : "+d" (ccode)
55 : "d" (reg1), "a" (addr), "m" (*addr)
56 : "cc");
Heiko Carstensa4d9b972016-06-20 14:03:52 +020057 return ccode;
58}
59
60int msch(struct subchannel_id schid, struct schib *addr)
61{
62 int ccode;
63
64 ccode = __msch(schid, addr);
Peter Oberparleiter11b64c82015-12-18 12:59:40 +010065 trace_s390_cio_msch(schid, addr, ccode);
66
67 return ccode;
68}
69
Heiko Carstensa4d9b972016-06-20 14:03:52 +020070static inline int __tsch(struct subchannel_id schid, struct irb *addr)
Peter Oberparleiter11b64c82015-12-18 12:59:40 +010071{
72 register struct subchannel_id reg1 asm ("1") = schid;
73 int ccode;
74
75 asm volatile(
76 " tsch 0(%3)\n"
77 " ipm %0\n"
78 " srl %0,28"
79 : "=d" (ccode), "=m" (*addr)
80 : "d" (reg1), "a" (addr)
81 : "cc");
Heiko Carstensa4d9b972016-06-20 14:03:52 +020082 return ccode;
83}
84
85int tsch(struct subchannel_id schid, struct irb *addr)
86{
87 int ccode;
88
89 ccode = __tsch(schid, addr);
Peter Oberparleiter11b64c82015-12-18 12:59:40 +010090 trace_s390_cio_tsch(schid, addr, ccode);
91
92 return ccode;
93}
94
Heiko Carstensa4d9b972016-06-20 14:03:52 +020095static inline int __ssch(struct subchannel_id schid, union orb *addr)
Peter Oberparleiter11b64c82015-12-18 12:59:40 +010096{
97 register struct subchannel_id reg1 asm("1") = schid;
98 int ccode = -EIO;
99
100 asm volatile(
101 " ssch 0(%2)\n"
102 "0: ipm %0\n"
103 " srl %0,28\n"
104 "1:\n"
105 EX_TABLE(0b, 1b)
106 : "+d" (ccode)
107 : "d" (reg1), "a" (addr), "m" (*addr)
108 : "cc", "memory");
Heiko Carstensa4d9b972016-06-20 14:03:52 +0200109 return ccode;
110}
111
112int ssch(struct subchannel_id schid, union orb *addr)
113{
114 int ccode;
115
116 ccode = __ssch(schid, addr);
Peter Oberparleiter11b64c82015-12-18 12:59:40 +0100117 trace_s390_cio_ssch(schid, addr, ccode);
118
119 return ccode;
120}
121EXPORT_SYMBOL(ssch);
122
Heiko Carstensa4d9b972016-06-20 14:03:52 +0200123static inline int __csch(struct subchannel_id schid)
Peter Oberparleiter11b64c82015-12-18 12:59:40 +0100124{
125 register struct subchannel_id reg1 asm("1") = schid;
126 int ccode;
127
128 asm volatile(
129 " csch\n"
130 " ipm %0\n"
131 " srl %0,28"
132 : "=d" (ccode)
133 : "d" (reg1)
134 : "cc");
Heiko Carstensa4d9b972016-06-20 14:03:52 +0200135 return ccode;
136}
137
138int csch(struct subchannel_id schid)
139{
140 int ccode;
141
142 ccode = __csch(schid);
Peter Oberparleiter11b64c82015-12-18 12:59:40 +0100143 trace_s390_cio_csch(schid, ccode);
144
145 return ccode;
146}
147EXPORT_SYMBOL(csch);
148
149int tpi(struct tpi_info *addr)
150{
151 int ccode;
152
153 asm volatile(
154 " tpi 0(%2)\n"
155 " ipm %0\n"
156 " srl %0,28"
157 : "=d" (ccode), "=m" (*addr)
158 : "a" (addr)
159 : "cc");
160 trace_s390_cio_tpi(addr, ccode);
161
162 return ccode;
163}
164
165int chsc(void *chsc_area)
166{
167 typedef struct { char _[4096]; } addr_type;
168 int cc;
169
170 asm volatile(
171 " .insn rre,0xb25f0000,%2,0\n"
172 " ipm %0\n"
173 " srl %0,28\n"
174 : "=d" (cc), "=m" (*(addr_type *) chsc_area)
175 : "d" (chsc_area), "m" (*(addr_type *) chsc_area)
176 : "cc");
177 trace_s390_cio_chsc(chsc_area, cc);
178
179 return cc;
180}
181EXPORT_SYMBOL(chsc);
182
Heiko Carstensa4d9b972016-06-20 14:03:52 +0200183static inline int __rchp(struct chp_id chpid)
Peter Oberparleiter11b64c82015-12-18 12:59:40 +0100184{
185 register struct chp_id reg1 asm ("1") = chpid;
186 int ccode;
187
188 asm volatile(
189 " lr 1,%1\n"
190 " rchp\n"
191 " ipm %0\n"
192 " srl %0,28"
193 : "=d" (ccode) : "d" (reg1) : "cc");
Heiko Carstensa4d9b972016-06-20 14:03:52 +0200194 return ccode;
195}
196
197int rchp(struct chp_id chpid)
198{
199 int ccode;
200
201 ccode = __rchp(chpid);
Peter Oberparleiter11b64c82015-12-18 12:59:40 +0100202 trace_s390_cio_rchp(chpid, ccode);
203
204 return ccode;
205}
206
Heiko Carstensa4d9b972016-06-20 14:03:52 +0200207static inline int __rsch(struct subchannel_id schid)
Peter Oberparleiter11b64c82015-12-18 12:59:40 +0100208{
209 register struct subchannel_id reg1 asm("1") = schid;
210 int ccode;
211
212 asm volatile(
213 " rsch\n"
214 " ipm %0\n"
215 " srl %0,28"
216 : "=d" (ccode)
217 : "d" (reg1)
218 : "cc", "memory");
Heiko Carstensa4d9b972016-06-20 14:03:52 +0200219
220 return ccode;
221}
222
223int rsch(struct subchannel_id schid)
224{
225 int ccode;
226
227 ccode = __rsch(schid);
Peter Oberparleiter11b64c82015-12-18 12:59:40 +0100228 trace_s390_cio_rsch(schid, ccode);
229
230 return ccode;
231}
232
Heiko Carstensa4d9b972016-06-20 14:03:52 +0200233static inline int __hsch(struct subchannel_id schid)
Peter Oberparleiter11b64c82015-12-18 12:59:40 +0100234{
235 register struct subchannel_id reg1 asm("1") = schid;
236 int ccode;
237
238 asm volatile(
239 " hsch\n"
240 " ipm %0\n"
241 " srl %0,28"
242 : "=d" (ccode)
243 : "d" (reg1)
244 : "cc");
Heiko Carstensa4d9b972016-06-20 14:03:52 +0200245 return ccode;
246}
247
248int hsch(struct subchannel_id schid)
249{
250 int ccode;
251
252 ccode = __hsch(schid);
Peter Oberparleiter11b64c82015-12-18 12:59:40 +0100253 trace_s390_cio_hsch(schid, ccode);
254
255 return ccode;
256}
257
Heiko Carstensa4d9b972016-06-20 14:03:52 +0200258static inline int __xsch(struct subchannel_id schid)
Peter Oberparleiter11b64c82015-12-18 12:59:40 +0100259{
260 register struct subchannel_id reg1 asm("1") = schid;
261 int ccode;
262
263 asm volatile(
264 " xsch\n"
265 " ipm %0\n"
266 " srl %0,28"
267 : "=d" (ccode)
268 : "d" (reg1)
269 : "cc");
Heiko Carstensa4d9b972016-06-20 14:03:52 +0200270 return ccode;
271}
272
273int xsch(struct subchannel_id schid)
274{
275 int ccode;
276
277 ccode = __xsch(schid);
Peter Oberparleiter11b64c82015-12-18 12:59:40 +0100278 trace_s390_cio_xsch(schid, ccode);
279
280 return ccode;
281}
282
283int stcrw(struct crw *crw)
284{
285 int ccode;
286
287 asm volatile(
288 " stcrw 0(%2)\n"
289 " ipm %0\n"
290 " srl %0,28\n"
291 : "=d" (ccode), "=m" (*crw)
292 : "a" (crw)
293 : "cc");
294 trace_s390_cio_stcrw(crw, ccode);
295
296 return ccode;
297}