fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / s390 / cio / ioasm.h
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         register struct subchannel_id reg1 asm ("1") = schid;
29         int ccode;
30
31         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");
36         return ccode;
37 }
38
39 static inline int stsch_err(struct subchannel_id schid,
40                                 volatile struct schib *addr)
41 {
42         register struct subchannel_id reg1 asm ("1") = schid;
43         int ccode = -EIO;
44
45         asm volatile(
46                 "       stsch   0(%2)\n"
47                 "0:     ipm     %0\n"
48                 "       srl     %0,28\n"
49                 "1:\n"
50                 EX_TABLE(0b,1b)
51                 : "+d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc");
52         return ccode;
53 }
54
55 static inline int msch(struct subchannel_id schid,
56                            volatile struct schib *addr)
57 {
58         register struct subchannel_id reg1 asm ("1") = schid;
59         int ccode;
60
61         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");
66         return ccode;
67 }
68
69 static inline int msch_err(struct subchannel_id schid,
70                                volatile struct schib *addr)
71 {
72         register struct subchannel_id reg1 asm ("1") = schid;
73         int ccode = -EIO;
74
75         asm volatile(
76                 "       msch    0(%2)\n"
77                 "0:     ipm     %0\n"
78                 "       srl     %0,28\n"
79                 "1:\n"
80                 EX_TABLE(0b,1b)
81                 : "+d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc");
82         return ccode;
83 }
84
85 static inline int tsch(struct subchannel_id schid,
86                            volatile struct irb *addr)
87 {
88         register struct subchannel_id reg1 asm ("1") = schid;
89         int ccode;
90
91         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");
96         return ccode;
97 }
98
99 static inline int tpi( volatile struct tpi_info *addr)
100 {
101         int ccode;
102
103         asm volatile(
104                 "       tpi     0(%1)\n"
105                 "       ipm     %0\n"
106                 "       srl     %0,28"
107                 : "=d" (ccode) : "a" (addr), "m" (*addr) : "cc");
108         return ccode;
109 }
110
111 static inline int ssch(struct subchannel_id schid,
112                            volatile struct orb *addr)
113 {
114         register struct subchannel_id reg1 asm ("1") = schid;
115         int ccode;
116
117         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");
122         return ccode;
123 }
124
125 static inline int rsch(struct subchannel_id schid)
126 {
127         register struct subchannel_id reg1 asm ("1") = schid;
128         int ccode;
129
130         asm volatile(
131                 "       rsch\n"
132                 "       ipm     %0\n"
133                 "       srl     %0,28"
134                 : "=d" (ccode) : "d" (reg1) : "cc");
135         return ccode;
136 }
137
138 static inline int csch(struct subchannel_id schid)
139 {
140         register struct subchannel_id reg1 asm ("1") = schid;
141         int ccode;
142
143         asm volatile(
144                 "       csch\n"
145                 "       ipm     %0\n"
146                 "       srl     %0,28"
147                 : "=d" (ccode) : "d" (reg1) : "cc");
148         return ccode;
149 }
150
151 static inline int hsch(struct subchannel_id schid)
152 {
153         register struct subchannel_id reg1 asm ("1") = schid;
154         int ccode;
155
156         asm volatile(
157                 "       hsch\n"
158                 "       ipm     %0\n"
159                 "       srl     %0,28"
160                 : "=d" (ccode) : "d" (reg1) : "cc");
161         return ccode;
162 }
163
164 static inline int xsch(struct subchannel_id schid)
165 {
166         register struct subchannel_id reg1 asm ("1") = schid;
167         int ccode;
168
169         asm volatile(
170                 "       .insn   rre,0xb2760000,%1,0\n"
171                 "       ipm     %0\n"
172                 "       srl     %0,28"
173                 : "=d" (ccode) : "d" (reg1) : "cc");
174         return ccode;
175 }
176
177 static inline int chsc(void *chsc_area)
178 {
179         typedef struct { char _[4096]; } addr_type;
180         int cc;
181
182         asm volatile(
183                 "       .insn   rre,0xb25f0000,%2,0\n"
184                 "       ipm     %0\n"
185                 "       srl     %0,28\n"
186                 : "=d" (cc), "=m" (*(addr_type *) chsc_area)
187                 : "d" (chsc_area), "m" (*(addr_type *) chsc_area)
188                 : "cc");
189         return cc;
190 }
191
192 static inline int rchp(int chpid)
193 {
194         register unsigned int reg1 asm ("1") = chpid;
195         int ccode;
196
197         asm volatile(
198                 "       lr      1,%1\n"
199                 "       rchp\n"
200                 "       ipm     %0\n"
201                 "       srl     %0,28"
202                 : "=d" (ccode) : "d" (reg1) : "cc");
203         return ccode;
204 }
205
206 #endif