blob: 66c882e52f32aaef4a9a965225a02d2039cda2ec [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 Hucka8237fc2006-01-06 00:19:21 -080041static inline int msch(struct subchannel_id schid,
42 volatile struct schib *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070043{
44 int ccode;
45
46 __asm__ __volatile__(
47 " lr 1,%1\n"
48 " msch 0(%2)\n"
49 " ipm %0\n"
50 " srl %0,28"
51 : "=d" (ccode)
Cornelia Hucka8237fc2006-01-06 00:19:21 -080052 : "d" (schid), "a" (addr), "m" (*addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 : "cc", "1" );
54 return ccode;
55}
56
Cornelia Hucka8237fc2006-01-06 00:19:21 -080057static inline int msch_err(struct subchannel_id schid,
58 volatile struct schib *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070059{
60 int ccode;
61
62 __asm__ __volatile__(
63 " lhi %0,%3\n"
64 " lr 1,%1\n"
65 " msch 0(%2)\n"
66 "0: ipm %0\n"
67 " srl %0,28\n"
68 "1:\n"
69#ifdef CONFIG_ARCH_S390X
70 ".section __ex_table,\"a\"\n"
71 " .align 8\n"
72 " .quad 0b,1b\n"
73 ".previous"
74#else
75 ".section __ex_table,\"a\"\n"
76 " .align 4\n"
77 " .long 0b,1b\n"
78 ".previous"
79#endif
80 : "=&d" (ccode)
Cornelia Hucka8237fc2006-01-06 00:19:21 -080081 : "d" (schid), "a" (addr), "K" (-EIO), "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 tsch(struct subchannel_id schid,
87 volatile struct irb *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070088{
89 int ccode;
90
91 __asm__ __volatile__(
92 " lr 1,%1\n"
93 " tsch 0(%2)\n"
94 " ipm %0\n"
95 " srl %0,28"
96 : "=d" (ccode)
Cornelia Hucka8237fc2006-01-06 00:19:21 -080097 : "d" (schid), "a" (addr), "m" (*addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 : "cc", "1" );
99 return ccode;
100}
101
Cornelia Huck4c24da72005-09-03 15:58:01 -0700102static inline int tpi( volatile struct tpi_info *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103{
104 int ccode;
105
106 __asm__ __volatile__(
107 " tpi 0(%1)\n"
108 " ipm %0\n"
109 " srl %0,28"
110 : "=d" (ccode)
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800111 : "a" (addr), "m" (*addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112 : "cc", "1" );
113 return ccode;
114}
115
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800116static inline int ssch(struct subchannel_id schid,
117 volatile struct orb *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118{
119 int ccode;
120
121 __asm__ __volatile__(
122 " lr 1,%1\n"
123 " ssch 0(%2)\n"
124 " ipm %0\n"
125 " srl %0,28"
126 : "=d" (ccode)
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800127 : "d" (schid), "a" (addr), "m" (*addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128 : "cc", "1" );
129 return ccode;
130}
131
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800132static inline int rsch(struct subchannel_id schid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133{
134 int ccode;
135
136 __asm__ __volatile__(
137 " lr 1,%1\n"
138 " rsch\n"
139 " ipm %0\n"
140 " srl %0,28"
141 : "=d" (ccode)
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800142 : "d" (schid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 : "cc", "1" );
144 return ccode;
145}
146
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800147static inline int csch(struct subchannel_id schid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148{
149 int ccode;
150
151 __asm__ __volatile__(
152 " lr 1,%1\n"
153 " csch\n"
154 " ipm %0\n"
155 " srl %0,28"
156 : "=d" (ccode)
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800157 : "d" (schid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158 : "cc", "1" );
159 return ccode;
160}
161
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800162static inline int hsch(struct subchannel_id schid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163{
164 int ccode;
165
166 __asm__ __volatile__(
167 " lr 1,%1\n"
168 " hsch\n"
169 " ipm %0\n"
170 " srl %0,28"
171 : "=d" (ccode)
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800172 : "d" (schid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173 : "cc", "1" );
174 return ccode;
175}
176
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800177static inline int xsch(struct subchannel_id schid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178{
179 int ccode;
180
181 __asm__ __volatile__(
182 " lr 1,%1\n"
183 " .insn rre,0xb2760000,%1,0\n"
184 " ipm %0\n"
185 " srl %0,28"
186 : "=d" (ccode)
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800187 : "d" (schid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188 : "cc", "1" );
189 return ccode;
190}
191
Cornelia Huck4c24da72005-09-03 15:58:01 -0700192static inline int chsc(void *chsc_area)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193{
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800194 typedef struct { char _[4096]; } addr_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195 int cc;
196
197 __asm__ __volatile__ (
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800198 ".insn rre,0xb25f0000,%2,0 \n\t"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199 "ipm %0 \n\t"
200 "srl %0,28 \n\t"
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800201 : "=d" (cc), "=m" (*(addr_type *) chsc_area)
202 : "d" (chsc_area), "m" (*(addr_type *) chsc_area)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 : "cc" );
204
205 return cc;
206}
207
Cornelia Huck4c24da72005-09-03 15:58:01 -0700208static inline int iac( void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209{
210 int ccode;
211
212 __asm__ __volatile__(
213 " iac 1\n"
214 " ipm %0\n"
215 " srl %0,28"
216 : "=d" (ccode) : : "cc", "1" );
217 return ccode;
218}
219
Cornelia Huck4c24da72005-09-03 15:58:01 -0700220static inline int rchp(int chpid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221{
222 int ccode;
223
224 __asm__ __volatile__(
225 " lr 1,%1\n"
226 " rchp\n"
227 " ipm %0\n"
228 " srl %0,28"
229 : "=d" (ccode)
230 : "d" (chpid)
231 : "cc", "1" );
232 return ccode;
233}
234
235#endif