blob: 95a9462f9a911ccc74faea8b9a39235f4b6cebc3 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef S390_CIO_IOASM_H
2#define S390_CIO_IOASM_H
3
Cornelia Hucka8237fc2006-01-06 00:19:21 -08004#include "schid.h"
5
Linus Torvalds1da177e2005-04-16 15:20:36 -07006/*
7 * TPI info structure
8 */
9struct tpi_info {
Cornelia Hucka8237fc2006-01-06 00:19:21 -080010 struct subchannel_id schid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070011 __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
Cornelia Hucka8237fc2006-01-06 00:19:21 -080025static inline int stsch(struct subchannel_id schid,
26 volatile struct schib *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070027{
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)
Cornelia Hucka8237fc2006-01-06 00:19:21 -080036 : "d" (schid), "a" (addr), "m" (*addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 : "cc", "1" );
38 return ccode;
39}
40
Cornelia Huckfb6958a2006-01-06 00:19:25 -080041static 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"
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -080053#ifdef CONFIG_64BIT
Cornelia Huckfb6958a2006-01-06 00:19:25 -080054 ".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
Cornelia Hucka8237fc2006-01-06 00:19:21 -080070static inline int msch(struct subchannel_id schid,
71 volatile struct schib *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070072{
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)
Cornelia Hucka8237fc2006-01-06 00:19:21 -080081 : "d" (schid), "a" (addr), "m" (*addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 : "cc", "1" );
83 return ccode;
84}
85
Cornelia Hucka8237fc2006-01-06 00:19:21 -080086static inline int msch_err(struct subchannel_id schid,
87 volatile struct schib *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070088{
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"
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -080098#ifdef CONFIG_64BIT
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 ".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)
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800110 : "d" (schid), "a" (addr), "K" (-EIO), "m" (*addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111 : "cc", "1" );
112 return ccode;
113}
114
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800115static inline int tsch(struct subchannel_id schid,
116 volatile struct irb *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117{
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)
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800126 : "d" (schid), "a" (addr), "m" (*addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 : "cc", "1" );
128 return ccode;
129}
130
Cornelia Huck4c24da72005-09-03 15:58:01 -0700131static inline int tpi( volatile struct tpi_info *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132{
133 int ccode;
134
135 __asm__ __volatile__(
136 " tpi 0(%1)\n"
137 " ipm %0\n"
138 " srl %0,28"
139 : "=d" (ccode)
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800140 : "a" (addr), "m" (*addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 : "cc", "1" );
142 return ccode;
143}
144
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800145static inline int ssch(struct subchannel_id schid,
146 volatile struct orb *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147{
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)
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800156 : "d" (schid), "a" (addr), "m" (*addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 : "cc", "1" );
158 return ccode;
159}
160
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800161static inline int rsch(struct subchannel_id schid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162{
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)
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800171 : "d" (schid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 : "cc", "1" );
173 return ccode;
174}
175
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800176static inline int csch(struct subchannel_id schid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177{
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)
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800186 : "d" (schid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187 : "cc", "1" );
188 return ccode;
189}
190
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800191static inline int hsch(struct subchannel_id schid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192{
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)
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800201 : "d" (schid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202 : "cc", "1" );
203 return ccode;
204}
205
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800206static inline int xsch(struct subchannel_id schid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207{
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)
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800216 : "d" (schid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217 : "cc", "1" );
218 return ccode;
219}
220
Cornelia Huck4c24da72005-09-03 15:58:01 -0700221static inline int chsc(void *chsc_area)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222{
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800223 typedef struct { char _[4096]; } addr_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224 int cc;
225
226 __asm__ __volatile__ (
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800227 ".insn rre,0xb25f0000,%2,0 \n\t"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 "ipm %0 \n\t"
229 "srl %0,28 \n\t"
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800230 : "=d" (cc), "=m" (*(addr_type *) chsc_area)
231 : "d" (chsc_area), "m" (*(addr_type *) chsc_area)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232 : "cc" );
233
234 return cc;
235}
236
Cornelia Huck4c24da72005-09-03 15:58:01 -0700237static inline int iac( void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238{
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
Cornelia Huck4c24da72005-09-03 15:58:01 -0700249static inline int rchp(int chpid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250{
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