blob: ad6d829400691826659cf3de58ff35f0fa8eed98 [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{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020028 register struct subchannel_id reg1 asm ("1") = schid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070029 int ccode;
30
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020031 asm volatile(
32 " stsch 0(%2)\n"
33 " ipm %0\n"
34 " srl %0,28"
35 : "=d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 return ccode;
37}
38
Cornelia Huckfb6958a2006-01-06 00:19:25 -080039static inline int stsch_err(struct subchannel_id schid,
40 volatile struct schib *addr)
41{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020042 register struct subchannel_id reg1 asm ("1") = schid;
43 int ccode = -EIO;
Cornelia Huckfb6958a2006-01-06 00:19:25 -080044
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020045 asm volatile(
46 " stsch 0(%2)\n"
47 "0: ipm %0\n"
48 " srl %0,28\n"
Cornelia Huckfb6958a2006-01-06 00:19:25 -080049 "1:\n"
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020050 EX_TABLE(0b,1b)
51 : "+d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc");
Cornelia Huckfb6958a2006-01-06 00:19:25 -080052 return ccode;
53}
54
Cornelia Hucka8237fc2006-01-06 00:19:21 -080055static inline int msch(struct subchannel_id schid,
56 volatile struct schib *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070057{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020058 register struct subchannel_id reg1 asm ("1") = schid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 int ccode;
60
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020061 asm volatile(
62 " msch 0(%2)\n"
63 " ipm %0\n"
64 " srl %0,28"
65 : "=d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 return ccode;
67}
68
Cornelia Hucka8237fc2006-01-06 00:19:21 -080069static inline int msch_err(struct subchannel_id schid,
70 volatile struct schib *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070071{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020072 register struct subchannel_id reg1 asm ("1") = schid;
73 int ccode = -EIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -070074
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020075 asm volatile(
76 " msch 0(%2)\n"
77 "0: ipm %0\n"
78 " srl %0,28\n"
Linus Torvalds1da177e2005-04-16 15:20:36 -070079 "1:\n"
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020080 EX_TABLE(0b,1b)
81 : "+d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 return ccode;
83}
84
Cornelia Hucka8237fc2006-01-06 00:19:21 -080085static inline int tsch(struct subchannel_id schid,
86 volatile struct irb *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070087{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020088 register struct subchannel_id reg1 asm ("1") = schid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 int ccode;
90
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020091 asm volatile(
92 " tsch 0(%2)\n"
93 " ipm %0\n"
94 " srl %0,28"
95 : "=d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 return ccode;
97}
98
Cornelia Huck4c24da72005-09-03 15:58:01 -070099static inline int tpi( volatile struct tpi_info *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100{
101 int ccode;
102
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200103 asm volatile(
104 " tpi 0(%1)\n"
105 " ipm %0\n"
106 " srl %0,28"
107 : "=d" (ccode) : "a" (addr), "m" (*addr) : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 return ccode;
109}
110
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800111static inline int ssch(struct subchannel_id schid,
112 volatile struct orb *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200114 register struct subchannel_id reg1 asm ("1") = schid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 int ccode;
116
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200117 asm volatile(
118 " ssch 0(%2)\n"
119 " ipm %0\n"
120 " srl %0,28"
121 : "=d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 return ccode;
123}
124
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800125static inline int rsch(struct subchannel_id schid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200127 register struct subchannel_id reg1 asm ("1") = schid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128 int ccode;
129
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200130 asm volatile(
131 " rsch\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
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800138static inline int csch(struct subchannel_id schid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200140 register struct subchannel_id reg1 asm ("1") = schid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 int ccode;
142
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200143 asm volatile(
144 " csch\n"
145 " ipm %0\n"
146 " srl %0,28"
147 : "=d" (ccode) : "d" (reg1) : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 return ccode;
149}
150
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800151static inline int hsch(struct subchannel_id schid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200153 register struct subchannel_id reg1 asm ("1") = schid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154 int ccode;
155
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200156 asm volatile(
157 " hsch\n"
158 " ipm %0\n"
159 " srl %0,28"
160 : "=d" (ccode) : "d" (reg1) : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 return ccode;
162}
163
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800164static inline int xsch(struct subchannel_id schid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200166 register struct subchannel_id reg1 asm ("1") = schid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167 int ccode;
168
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200169 asm volatile(
170 " .insn rre,0xb2760000,%1,0\n"
171 " ipm %0\n"
172 " srl %0,28"
173 : "=d" (ccode) : "d" (reg1) : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174 return ccode;
175}
176
Cornelia Huck4c24da72005-09-03 15:58:01 -0700177static inline int chsc(void *chsc_area)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178{
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800179 typedef struct { char _[4096]; } addr_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180 int cc;
181
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200182 asm volatile(
183 " .insn rre,0xb25f0000,%2,0\n"
184 " ipm %0\n"
185 " srl %0,28\n"
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800186 : "=d" (cc), "=m" (*(addr_type *) chsc_area)
187 : "d" (chsc_area), "m" (*(addr_type *) chsc_area)
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200188 : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189 return cc;
190}
191
Cornelia Huck4c24da72005-09-03 15:58:01 -0700192static inline int rchp(int chpid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200194 register unsigned int reg1 asm ("1") = chpid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195 int ccode;
196
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200197 asm volatile(
198 " lr 1,%1\n"
199 " rchp\n"
200 " ipm %0\n"
201 " srl %0,28"
202 : "=d" (ccode) : "d" (reg1) : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 return ccode;
204}
205
206#endif