xref: /openbmc/linux/drivers/s390/cio/ioasm.h (revision 87c2ce3b)
1 #ifndef S390_CIO_IOASM_H
2 #define S390_CIO_IOASM_H
3 
4 #include "schid.h"
5 
6 /*
7  * TPI info structure
8  */
9 struct tpi_info {
10 	struct subchannel_id schid;
11 	__u32 intparm;		 /* interruption parameter */
12 	__u32 adapter_IO : 1;
13 	__u32 reserved2	 : 1;
14 	__u32 isc	 : 3;
15 	__u32 reserved3	 : 12;
16 	__u32 int_type	 : 3;
17 	__u32 reserved4	 : 12;
18 } __attribute__ ((packed));
19 
20 
21 /*
22  * Some S390 specific IO instructions as inline
23  */
24 
25 static inline int stsch(struct subchannel_id schid,
26 			    volatile struct schib *addr)
27 {
28 	int ccode;
29 
30 	__asm__ __volatile__(
31 		"   lr	  1,%1\n"
32 		"   stsch 0(%2)\n"
33 		"   ipm	  %0\n"
34 		"   srl	  %0,28"
35 		: "=d" (ccode)
36 		: "d" (schid), "a" (addr), "m" (*addr)
37 		: "cc", "1" );
38 	return ccode;
39 }
40 
41 static inline int stsch_err(struct subchannel_id schid,
42 				volatile struct schib *addr)
43 {
44 	int ccode;
45 
46 	__asm__ __volatile__(
47 		"    lhi  %0,%3\n"
48 		"    lr	  1,%1\n"
49 		"    stsch 0(%2)\n"
50 		"0:  ipm  %0\n"
51 		"    srl  %0,28\n"
52 		"1:\n"
53 #ifdef CONFIG_64BIT
54 		".section __ex_table,\"a\"\n"
55 		"   .align 8\n"
56 		"   .quad 0b,1b\n"
57 		".previous"
58 #else
59 		".section __ex_table,\"a\"\n"
60 		"   .align 4\n"
61 		"   .long 0b,1b\n"
62 		".previous"
63 #endif
64 		: "=&d" (ccode)
65 		: "d" (schid), "a" (addr), "K" (-EIO), "m" (*addr)
66 		: "cc", "1" );
67 	return ccode;
68 }
69 
70 static inline int msch(struct subchannel_id schid,
71 			   volatile struct schib *addr)
72 {
73 	int ccode;
74 
75 	__asm__ __volatile__(
76 		"   lr	  1,%1\n"
77 		"   msch  0(%2)\n"
78 		"   ipm	  %0\n"
79 		"   srl	  %0,28"
80 		: "=d" (ccode)
81 		: "d" (schid), "a" (addr), "m" (*addr)
82 		: "cc", "1" );
83 	return ccode;
84 }
85 
86 static inline int msch_err(struct subchannel_id schid,
87 			       volatile struct schib *addr)
88 {
89 	int ccode;
90 
91 	__asm__ __volatile__(
92 		"    lhi  %0,%3\n"
93 		"    lr	  1,%1\n"
94 		"    msch 0(%2)\n"
95 		"0:  ipm  %0\n"
96 		"    srl  %0,28\n"
97 		"1:\n"
98 #ifdef CONFIG_64BIT
99 		".section __ex_table,\"a\"\n"
100 		"   .align 8\n"
101 		"   .quad 0b,1b\n"
102 		".previous"
103 #else
104 		".section __ex_table,\"a\"\n"
105 		"   .align 4\n"
106 		"   .long 0b,1b\n"
107 		".previous"
108 #endif
109 		: "=&d" (ccode)
110 		: "d" (schid), "a" (addr), "K" (-EIO), "m" (*addr)
111 		: "cc", "1" );
112 	return ccode;
113 }
114 
115 static inline int tsch(struct subchannel_id schid,
116 			   volatile struct irb *addr)
117 {
118 	int ccode;
119 
120 	__asm__ __volatile__(
121 		"   lr	  1,%1\n"
122 		"   tsch  0(%2)\n"
123 		"   ipm	  %0\n"
124 		"   srl	  %0,28"
125 		: "=d" (ccode)
126 		: "d" (schid), "a" (addr), "m" (*addr)
127 		: "cc", "1" );
128 	return ccode;
129 }
130 
131 static inline int tpi( volatile struct tpi_info *addr)
132 {
133 	int ccode;
134 
135 	__asm__ __volatile__(
136 		"   tpi	  0(%1)\n"
137 		"   ipm	  %0\n"
138 		"   srl	  %0,28"
139 		: "=d" (ccode)
140 		: "a" (addr), "m" (*addr)
141 		: "cc", "1" );
142 	return ccode;
143 }
144 
145 static inline int ssch(struct subchannel_id schid,
146 			   volatile struct orb *addr)
147 {
148 	int ccode;
149 
150 	__asm__ __volatile__(
151 		"   lr	  1,%1\n"
152 		"   ssch  0(%2)\n"
153 		"   ipm	  %0\n"
154 		"   srl	  %0,28"
155 		: "=d" (ccode)
156 		: "d" (schid), "a" (addr), "m" (*addr)
157 		: "cc", "1" );
158 	return ccode;
159 }
160 
161 static inline int rsch(struct subchannel_id schid)
162 {
163 	int ccode;
164 
165 	__asm__ __volatile__(
166 		"   lr	  1,%1\n"
167 		"   rsch\n"
168 		"   ipm	  %0\n"
169 		"   srl	  %0,28"
170 		: "=d" (ccode)
171 		: "d" (schid)
172 		: "cc", "1" );
173 	return ccode;
174 }
175 
176 static inline int csch(struct subchannel_id schid)
177 {
178 	int ccode;
179 
180 	__asm__ __volatile__(
181 		"   lr	  1,%1\n"
182 		"   csch\n"
183 		"   ipm	  %0\n"
184 		"   srl	  %0,28"
185 		: "=d" (ccode)
186 		: "d" (schid)
187 		: "cc", "1" );
188 	return ccode;
189 }
190 
191 static inline int hsch(struct subchannel_id schid)
192 {
193 	int ccode;
194 
195 	__asm__ __volatile__(
196 		"   lr	  1,%1\n"
197 		"   hsch\n"
198 		"   ipm	  %0\n"
199 		"   srl	  %0,28"
200 		: "=d" (ccode)
201 		: "d" (schid)
202 		: "cc", "1" );
203 	return ccode;
204 }
205 
206 static inline int xsch(struct subchannel_id schid)
207 {
208 	int ccode;
209 
210 	__asm__ __volatile__(
211 		"   lr	  1,%1\n"
212 		"   .insn rre,0xb2760000,%1,0\n"
213 		"   ipm	  %0\n"
214 		"   srl	  %0,28"
215 		: "=d" (ccode)
216 		: "d" (schid)
217 		: "cc", "1" );
218 	return ccode;
219 }
220 
221 static inline int chsc(void *chsc_area)
222 {
223 	typedef struct { char _[4096]; } addr_type;
224 	int cc;
225 
226 	__asm__ __volatile__ (
227 		".insn	rre,0xb25f0000,%2,0	\n\t"
228 		"ipm	%0	\n\t"
229 		"srl	%0,28	\n\t"
230 		: "=d" (cc), "=m" (*(addr_type *) chsc_area)
231 		: "d" (chsc_area), "m" (*(addr_type *) chsc_area)
232 		: "cc" );
233 
234 	return cc;
235 }
236 
237 static inline int iac( void)
238 {
239 	int ccode;
240 
241 	__asm__ __volatile__(
242 		"   iac	  1\n"
243 		"   ipm	  %0\n"
244 		"   srl	  %0,28"
245 		: "=d" (ccode) : : "cc", "1" );
246 	return ccode;
247 }
248 
249 static inline int rchp(int chpid)
250 {
251 	int ccode;
252 
253 	__asm__ __volatile__(
254 		"   lr	  1,%1\n"
255 		"   rchp\n"
256 		"   ipm	  %0\n"
257 		"   srl	  %0,28"
258 		: "=d" (ccode)
259 		: "d" (chpid)
260 		: "cc", "1" );
261 	return ccode;
262 }
263 
264 #endif
265