blob: 7153dd959082253eb00cb182a4b53bb59b2eb72f [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef S390_CIO_IOASM_H
2#define S390_CIO_IOASM_H
3
Peter Oberparleitere5854a52007-04-27 16:01:31 +02004#include <asm/chpid.h>
Cornelia Hucka8237fc2006-01-06 00:19:21 -08005#include "schid.h"
6
Linus Torvalds1da177e2005-04-16 15:20:36 -07007/*
8 * TPI info structure
9 */
10struct tpi_info {
Cornelia Hucka8237fc2006-01-06 00:19:21 -080011 struct subchannel_id schid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070012 __u32 intparm; /* interruption parameter */
13 __u32 adapter_IO : 1;
14 __u32 reserved2 : 1;
15 __u32 isc : 3;
16 __u32 reserved3 : 12;
17 __u32 int_type : 3;
18 __u32 reserved4 : 12;
19} __attribute__ ((packed));
20
21
22/*
23 * Some S390 specific IO instructions as inline
24 */
25
Cornelia Hucka8237fc2006-01-06 00:19:21 -080026static inline int stsch(struct subchannel_id schid,
27 volatile struct schib *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070028{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020029 register struct subchannel_id reg1 asm ("1") = schid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070030 int ccode;
31
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020032 asm volatile(
33 " stsch 0(%2)\n"
34 " ipm %0\n"
35 " srl %0,28"
36 : "=d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 return ccode;
38}
39
Cornelia Huckfb6958a2006-01-06 00:19:25 -080040static inline int stsch_err(struct subchannel_id schid,
41 volatile struct schib *addr)
42{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020043 register struct subchannel_id reg1 asm ("1") = schid;
44 int ccode = -EIO;
Cornelia Huckfb6958a2006-01-06 00:19:25 -080045
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020046 asm volatile(
47 " stsch 0(%2)\n"
48 "0: ipm %0\n"
49 " srl %0,28\n"
Cornelia Huckfb6958a2006-01-06 00:19:25 -080050 "1:\n"
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020051 EX_TABLE(0b,1b)
52 : "+d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc");
Cornelia Huckfb6958a2006-01-06 00:19:25 -080053 return ccode;
54}
55
Cornelia Hucka8237fc2006-01-06 00:19:21 -080056static inline int msch(struct subchannel_id schid,
57 volatile struct schib *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070058{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020059 register struct subchannel_id reg1 asm ("1") = schid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 int ccode;
61
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020062 asm volatile(
63 " msch 0(%2)\n"
64 " ipm %0\n"
65 " srl %0,28"
66 : "=d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 return ccode;
68}
69
Cornelia Hucka8237fc2006-01-06 00:19:21 -080070static inline int msch_err(struct subchannel_id schid,
71 volatile struct schib *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070072{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020073 register struct subchannel_id reg1 asm ("1") = schid;
74 int ccode = -EIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020076 asm volatile(
77 " msch 0(%2)\n"
78 "0: ipm %0\n"
79 " srl %0,28\n"
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 "1:\n"
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020081 EX_TABLE(0b,1b)
82 : "+d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 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{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020089 register struct subchannel_id reg1 asm ("1") = schid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070090 int ccode;
91
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020092 asm volatile(
93 " tsch 0(%2)\n"
94 " ipm %0\n"
95 " srl %0,28"
96 : "=d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 return ccode;
98}
99
Cornelia Huck4c24da72005-09-03 15:58:01 -0700100static inline int tpi( volatile struct tpi_info *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101{
102 int ccode;
103
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200104 asm volatile(
105 " tpi 0(%1)\n"
106 " ipm %0\n"
107 " srl %0,28"
108 : "=d" (ccode) : "a" (addr), "m" (*addr) : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 return ccode;
110}
111
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800112static inline int ssch(struct subchannel_id schid,
113 volatile struct orb *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200115 register struct subchannel_id reg1 asm ("1") = schid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 int ccode;
117
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200118 asm volatile(
119 " ssch 0(%2)\n"
120 " ipm %0\n"
121 " srl %0,28"
122 : "=d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 return ccode;
124}
125
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800126static inline int rsch(struct subchannel_id schid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200128 register struct subchannel_id reg1 asm ("1") = schid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 int ccode;
130
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200131 asm volatile(
132 " rsch\n"
133 " ipm %0\n"
134 " srl %0,28"
135 : "=d" (ccode) : "d" (reg1) : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136 return ccode;
137}
138
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800139static inline int csch(struct subchannel_id schid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200141 register struct subchannel_id reg1 asm ("1") = schid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 int ccode;
143
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200144 asm volatile(
145 " csch\n"
146 " ipm %0\n"
147 " srl %0,28"
148 : "=d" (ccode) : "d" (reg1) : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149 return ccode;
150}
151
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800152static inline int hsch(struct subchannel_id schid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200154 register struct subchannel_id reg1 asm ("1") = schid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155 int ccode;
156
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200157 asm volatile(
158 " hsch\n"
159 " ipm %0\n"
160 " srl %0,28"
161 : "=d" (ccode) : "d" (reg1) : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162 return ccode;
163}
164
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800165static inline int xsch(struct subchannel_id schid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200167 register struct subchannel_id reg1 asm ("1") = schid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168 int ccode;
169
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200170 asm volatile(
171 " .insn rre,0xb2760000,%1,0\n"
172 " ipm %0\n"
173 " srl %0,28"
174 : "=d" (ccode) : "d" (reg1) : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175 return ccode;
176}
177
Cornelia Huck4c24da72005-09-03 15:58:01 -0700178static inline int chsc(void *chsc_area)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179{
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800180 typedef struct { char _[4096]; } addr_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181 int cc;
182
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200183 asm volatile(
184 " .insn rre,0xb25f0000,%2,0\n"
185 " ipm %0\n"
186 " srl %0,28\n"
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800187 : "=d" (cc), "=m" (*(addr_type *) chsc_area)
188 : "d" (chsc_area), "m" (*(addr_type *) chsc_area)
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200189 : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190 return cc;
191}
192
Peter Oberparleiterf86635f2007-04-27 16:01:26 +0200193static inline int rchp(struct chp_id chpid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194{
Peter Oberparleiterf86635f2007-04-27 16:01:26 +0200195 register struct chp_id reg1 asm ("1") = chpid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 int ccode;
197
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200198 asm volatile(
199 " lr 1,%1\n"
200 " rchp\n"
201 " ipm %0\n"
202 " srl %0,28"
203 : "=d" (ccode) : "d" (reg1) : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204 return ccode;
205}
206
207#endif