blob: 11e255a4fbadb27e542a21d7d876b1dc28722224 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef S390_CIO_IOASM_H
2#define S390_CIO_IOASM_H
3
Peter Oberparleitere5854a52007-04-27 16:01:31 +02004#include <asm/chpid.h>
Cornelia Huck9d92a7e2008-07-14 09:59:05 +02005#include <asm/schid.h>
Peter Oberparleiter2ab59de2015-12-18 12:59:32 +01006#include <asm/crw.h>
Sebastian Ottdbda8ce2011-03-15 17:08:24 +01007#include "orb.h"
8#include "cio.h"
Peter Oberparleiter42248972015-12-18 12:59:36 +01009#include "trace.h"
Cornelia Hucka8237fc2006-01-06 00:19:21 -080010
Linus Torvalds1da177e2005-04-16 15:20:36 -070011/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070012 * Some S390 specific IO instructions as inline
13 */
14
Peter Oberparleiter62e65da2015-12-18 12:58:47 +010015static inline int stsch(struct subchannel_id schid, struct schib *addr)
Cornelia Huckfb6958a2006-01-06 00:19:25 -080016{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020017 register struct subchannel_id reg1 asm ("1") = schid;
18 int ccode = -EIO;
Cornelia Huckfb6958a2006-01-06 00:19:25 -080019
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020020 asm volatile(
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020021 " stsch 0(%3)\n"
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020022 "0: ipm %0\n"
23 " srl %0,28\n"
Cornelia Huckfb6958a2006-01-06 00:19:25 -080024 "1:\n"
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020025 EX_TABLE(0b,1b)
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020026 : "+d" (ccode), "=m" (*addr)
27 : "d" (reg1), "a" (addr)
28 : "cc");
Peter Oberparleiter42248972015-12-18 12:59:36 +010029 trace_s390_cio_stsch(schid, addr, ccode);
30
Cornelia Huckfb6958a2006-01-06 00:19:25 -080031 return ccode;
32}
33
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020034static inline int msch(struct subchannel_id schid, struct schib *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070035{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020036 register struct subchannel_id reg1 asm ("1") = schid;
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020037 int ccode = -EIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020039 asm volatile(
40 " msch 0(%2)\n"
41 "0: ipm %0\n"
42 " srl %0,28\n"
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 "1:\n"
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020044 EX_TABLE(0b,1b)
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020045 : "+d" (ccode)
46 : "d" (reg1), "a" (addr), "m" (*addr)
47 : "cc");
Peter Oberparleiter42248972015-12-18 12:59:36 +010048 trace_s390_cio_msch(schid, addr, ccode);
49
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 return ccode;
51}
52
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020053static inline int tsch(struct subchannel_id schid, struct irb *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070054{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020055 register struct subchannel_id reg1 asm ("1") = schid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 int ccode;
57
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020058 asm volatile(
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020059 " tsch 0(%3)\n"
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020060 " ipm %0\n"
61 " srl %0,28"
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020062 : "=d" (ccode), "=m" (*addr)
63 : "d" (reg1), "a" (addr)
64 : "cc");
Peter Oberparleiter42248972015-12-18 12:59:36 +010065 trace_s390_cio_tsch(schid, addr, ccode);
66
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 return ccode;
68}
69
Sebastian Ottdbda8ce2011-03-15 17:08:24 +010070static inline int ssch(struct subchannel_id schid, union orb *addr)
71{
72 register struct subchannel_id reg1 asm("1") = schid;
73 int ccode = -EIO;
74
75 asm volatile(
76 " ssch 0(%2)\n"
77 "0: ipm %0\n"
78 " srl %0,28\n"
79 "1:\n"
80 EX_TABLE(0b, 1b)
81 : "+d" (ccode)
82 : "d" (reg1), "a" (addr), "m" (*addr)
83 : "cc", "memory");
Peter Oberparleiter42248972015-12-18 12:59:36 +010084 trace_s390_cio_ssch(schid, addr, ccode);
85
Sebastian Ottdbda8ce2011-03-15 17:08:24 +010086 return ccode;
87}
88
89static inline int csch(struct subchannel_id schid)
90{
91 register struct subchannel_id reg1 asm("1") = schid;
92 int ccode;
93
94 asm volatile(
95 " csch\n"
96 " ipm %0\n"
97 " srl %0,28"
98 : "=d" (ccode)
99 : "d" (reg1)
100 : "cc");
Peter Oberparleiter42248972015-12-18 12:59:36 +0100101 trace_s390_cio_csch(schid, ccode);
102
Sebastian Ottdbda8ce2011-03-15 17:08:24 +0100103 return ccode;
104}
105
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +0200106static inline int tpi(struct tpi_info *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107{
108 int ccode;
109
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200110 asm volatile(
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +0200111 " tpi 0(%2)\n"
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200112 " ipm %0\n"
113 " srl %0,28"
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +0200114 : "=d" (ccode), "=m" (*addr)
115 : "a" (addr)
116 : "cc");
Peter Oberparleiter42248972015-12-18 12:59:36 +0100117 trace_s390_cio_tpi(addr, ccode);
118
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 return ccode;
120}
121
Cornelia Huck4c24da72005-09-03 15:58:01 -0700122static inline int chsc(void *chsc_area)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123{
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800124 typedef struct { char _[4096]; } addr_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 int cc;
126
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200127 asm volatile(
128 " .insn rre,0xb25f0000,%2,0\n"
129 " ipm %0\n"
130 " srl %0,28\n"
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800131 : "=d" (cc), "=m" (*(addr_type *) chsc_area)
132 : "d" (chsc_area), "m" (*(addr_type *) chsc_area)
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200133 : "cc");
Peter Oberparleiter42248972015-12-18 12:59:36 +0100134 trace_s390_cio_chsc(chsc_area, cc);
135
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136 return cc;
137}
138
Peter Oberparleiterf86635f2007-04-27 16:01:26 +0200139static inline int rchp(struct chp_id chpid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140{
Peter Oberparleiterf86635f2007-04-27 16:01:26 +0200141 register struct chp_id reg1 asm ("1") = chpid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 int ccode;
143
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200144 asm volatile(
145 " lr 1,%1\n"
146 " rchp\n"
147 " ipm %0\n"
148 " srl %0,28"
149 : "=d" (ccode) : "d" (reg1) : "cc");
Peter Oberparleiter42248972015-12-18 12:59:36 +0100150 trace_s390_cio_rchp(chpid, ccode);
151
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152 return ccode;
153}
154
Peter Oberparleiter2ab59de2015-12-18 12:59:32 +0100155static inline int rsch(struct subchannel_id schid)
156{
157 register struct subchannel_id reg1 asm("1") = schid;
158 int ccode;
159
160 asm volatile(
161 " rsch\n"
162 " ipm %0\n"
163 " srl %0,28"
164 : "=d" (ccode)
165 : "d" (reg1)
166 : "cc", "memory");
Peter Oberparleiter42248972015-12-18 12:59:36 +0100167 trace_s390_cio_rsch(schid, ccode);
168
Peter Oberparleiter2ab59de2015-12-18 12:59:32 +0100169 return ccode;
170}
171
172static inline int hsch(struct subchannel_id schid)
173{
174 register struct subchannel_id reg1 asm("1") = schid;
175 int ccode;
176
177 asm volatile(
178 " hsch\n"
179 " ipm %0\n"
180 " srl %0,28"
181 : "=d" (ccode)
182 : "d" (reg1)
183 : "cc");
Peter Oberparleiter42248972015-12-18 12:59:36 +0100184 trace_s390_cio_hsch(schid, ccode);
185
Peter Oberparleiter2ab59de2015-12-18 12:59:32 +0100186 return ccode;
187}
188
189static inline int xsch(struct subchannel_id schid)
190{
191 register struct subchannel_id reg1 asm("1") = schid;
192 int ccode;
193
194 asm volatile(
195 " xsch\n"
196 " ipm %0\n"
197 " srl %0,28"
198 : "=d" (ccode)
199 : "d" (reg1)
200 : "cc");
Peter Oberparleiter42248972015-12-18 12:59:36 +0100201 trace_s390_cio_xsch(schid, ccode);
202
Peter Oberparleiter2ab59de2015-12-18 12:59:32 +0100203 return ccode;
204}
205
206static inline int stcrw(struct crw *crw)
207{
208 int ccode;
209
210 asm volatile(
211 " stcrw 0(%2)\n"
212 " ipm %0\n"
213 " srl %0,28\n"
214 : "=d" (ccode), "=m" (*crw)
215 : "a" (crw)
216 : "cc");
Peter Oberparleiter42248972015-12-18 12:59:36 +0100217 trace_s390_cio_stcrw(crw, ccode);
218
Peter Oberparleiter2ab59de2015-12-18 12:59:32 +0100219 return ccode;
220}
221
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222#endif