blob: dce25500812aa5d08a24ee18687c0423bcc625f1 [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"
Cornelia Hucka8237fc2006-01-06 00:19:21 -08009
Linus Torvalds1da177e2005-04-16 15:20:36 -070010/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070011 * Some S390 specific IO instructions as inline
12 */
13
Peter Oberparleiter62e65da2015-12-18 12:58:47 +010014static inline int stsch(struct subchannel_id schid, struct schib *addr)
Cornelia Huckfb6958a2006-01-06 00:19:25 -080015{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020016 register struct subchannel_id reg1 asm ("1") = schid;
17 int ccode = -EIO;
Cornelia Huckfb6958a2006-01-06 00:19:25 -080018
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020019 asm volatile(
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020020 " stsch 0(%3)\n"
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020021 "0: ipm %0\n"
22 " srl %0,28\n"
Cornelia Huckfb6958a2006-01-06 00:19:25 -080023 "1:\n"
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020024 EX_TABLE(0b,1b)
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020025 : "+d" (ccode), "=m" (*addr)
26 : "d" (reg1), "a" (addr)
27 : "cc");
Cornelia Huckfb6958a2006-01-06 00:19:25 -080028 return ccode;
29}
30
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020031static inline int msch(struct subchannel_id schid, struct schib *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070032{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020033 register struct subchannel_id reg1 asm ("1") = schid;
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020034 int ccode = -EIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020036 asm volatile(
37 " msch 0(%2)\n"
38 "0: ipm %0\n"
39 " srl %0,28\n"
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 "1:\n"
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020041 EX_TABLE(0b,1b)
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020042 : "+d" (ccode)
43 : "d" (reg1), "a" (addr), "m" (*addr)
44 : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 return ccode;
46}
47
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020048static inline int tsch(struct subchannel_id schid, struct irb *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070049{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020050 register struct subchannel_id reg1 asm ("1") = schid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 int ccode;
52
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020053 asm volatile(
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020054 " tsch 0(%3)\n"
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020055 " ipm %0\n"
56 " srl %0,28"
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020057 : "=d" (ccode), "=m" (*addr)
58 : "d" (reg1), "a" (addr)
59 : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 return ccode;
61}
62
Sebastian Ottdbda8ce2011-03-15 17:08:24 +010063static inline int ssch(struct subchannel_id schid, union orb *addr)
64{
65 register struct subchannel_id reg1 asm("1") = schid;
66 int ccode = -EIO;
67
68 asm volatile(
69 " ssch 0(%2)\n"
70 "0: ipm %0\n"
71 " srl %0,28\n"
72 "1:\n"
73 EX_TABLE(0b, 1b)
74 : "+d" (ccode)
75 : "d" (reg1), "a" (addr), "m" (*addr)
76 : "cc", "memory");
77 return ccode;
78}
79
80static inline int csch(struct subchannel_id schid)
81{
82 register struct subchannel_id reg1 asm("1") = schid;
83 int ccode;
84
85 asm volatile(
86 " csch\n"
87 " ipm %0\n"
88 " srl %0,28"
89 : "=d" (ccode)
90 : "d" (reg1)
91 : "cc");
92 return ccode;
93}
94
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020095static inline int tpi(struct tpi_info *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070096{
97 int ccode;
98
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020099 asm volatile(
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +0200100 " tpi 0(%2)\n"
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200101 " ipm %0\n"
102 " srl %0,28"
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +0200103 : "=d" (ccode), "=m" (*addr)
104 : "a" (addr)
105 : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106 return ccode;
107}
108
Cornelia Huck4c24da72005-09-03 15:58:01 -0700109static inline int chsc(void *chsc_area)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110{
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800111 typedef struct { char _[4096]; } addr_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112 int cc;
113
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200114 asm volatile(
115 " .insn rre,0xb25f0000,%2,0\n"
116 " ipm %0\n"
117 " srl %0,28\n"
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800118 : "=d" (cc), "=m" (*(addr_type *) chsc_area)
119 : "d" (chsc_area), "m" (*(addr_type *) chsc_area)
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200120 : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 return cc;
122}
123
Peter Oberparleiterf86635f2007-04-27 16:01:26 +0200124static inline int rchp(struct chp_id chpid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125{
Peter Oberparleiterf86635f2007-04-27 16:01:26 +0200126 register struct chp_id reg1 asm ("1") = chpid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 int ccode;
128
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200129 asm volatile(
130 " lr 1,%1\n"
131 " rchp\n"
132 " ipm %0\n"
133 " srl %0,28"
134 : "=d" (ccode) : "d" (reg1) : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 return ccode;
136}
137
Peter Oberparleiter2ab59de2015-12-18 12:59:32 +0100138static inline int rsch(struct subchannel_id schid)
139{
140 register struct subchannel_id reg1 asm("1") = schid;
141 int ccode;
142
143 asm volatile(
144 " rsch\n"
145 " ipm %0\n"
146 " srl %0,28"
147 : "=d" (ccode)
148 : "d" (reg1)
149 : "cc", "memory");
150 return ccode;
151}
152
153static inline int hsch(struct subchannel_id schid)
154{
155 register struct subchannel_id reg1 asm("1") = schid;
156 int ccode;
157
158 asm volatile(
159 " hsch\n"
160 " ipm %0\n"
161 " srl %0,28"
162 : "=d" (ccode)
163 : "d" (reg1)
164 : "cc");
165 return ccode;
166}
167
168static inline int xsch(struct subchannel_id schid)
169{
170 register struct subchannel_id reg1 asm("1") = schid;
171 int ccode;
172
173 asm volatile(
174 " xsch\n"
175 " ipm %0\n"
176 " srl %0,28"
177 : "=d" (ccode)
178 : "d" (reg1)
179 : "cc");
180 return ccode;
181}
182
183static inline int stcrw(struct crw *crw)
184{
185 int ccode;
186
187 asm volatile(
188 " stcrw 0(%2)\n"
189 " ipm %0\n"
190 " srl %0,28\n"
191 : "=d" (ccode), "=m" (*crw)
192 : "a" (crw)
193 : "cc");
194 return ccode;
195}
196
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197#endif