blob: 4d80fc67a06b140639b6410f2668ff21e21e545f [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 Huck9d92a7e2008-07-14 09:59:05 +02005#include <asm/schid.h>
Sebastian Ottdbda8ce2011-03-15 17:08:24 +01006#include "orb.h"
7#include "cio.h"
Cornelia Hucka8237fc2006-01-06 00:19:21 -08008
Linus Torvalds1da177e2005-04-16 15:20:36 -07009/*
10 * TPI info structure
11 */
12struct tpi_info {
Cornelia Hucka8237fc2006-01-06 00:19:21 -080013 struct subchannel_id schid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070014 __u32 intparm; /* interruption parameter */
15 __u32 adapter_IO : 1;
16 __u32 reserved2 : 1;
17 __u32 isc : 3;
18 __u32 reserved3 : 12;
19 __u32 int_type : 3;
20 __u32 reserved4 : 12;
21} __attribute__ ((packed));
22
23
24/*
25 * Some S390 specific IO instructions as inline
26 */
27
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020028static inline int stsch_err(struct subchannel_id schid, struct schib *addr)
Cornelia Huckfb6958a2006-01-06 00:19:25 -080029{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020030 register struct subchannel_id reg1 asm ("1") = schid;
31 int ccode = -EIO;
Cornelia Huckfb6958a2006-01-06 00:19:25 -080032
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020033 asm volatile(
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020034 " stsch 0(%3)\n"
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020035 "0: ipm %0\n"
36 " srl %0,28\n"
Cornelia Huckfb6958a2006-01-06 00:19:25 -080037 "1:\n"
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020038 EX_TABLE(0b,1b)
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020039 : "+d" (ccode), "=m" (*addr)
40 : "d" (reg1), "a" (addr)
41 : "cc");
Cornelia Huckfb6958a2006-01-06 00:19:25 -080042 return ccode;
43}
44
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020045static inline int msch(struct subchannel_id schid, struct schib *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070046{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020047 register struct subchannel_id reg1 asm ("1") = schid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 int ccode;
49
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020050 asm volatile(
51 " msch 0(%2)\n"
52 " ipm %0\n"
53 " srl %0,28"
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020054 : "=d" (ccode)
55 : "d" (reg1), "a" (addr), "m" (*addr)
56 : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 return ccode;
58}
59
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020060static inline int msch_err(struct subchannel_id schid, struct schib *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070061{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020062 register struct subchannel_id reg1 asm ("1") = schid;
63 int ccode = -EIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020065 asm volatile(
66 " msch 0(%2)\n"
67 "0: ipm %0\n"
68 " srl %0,28\n"
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 "1:\n"
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020070 EX_TABLE(0b,1b)
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020071 : "+d" (ccode)
72 : "d" (reg1), "a" (addr), "m" (*addr)
73 : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 return ccode;
75}
76
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020077static inline int tsch(struct subchannel_id schid, struct irb *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070078{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020079 register struct subchannel_id reg1 asm ("1") = schid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 int ccode;
81
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020082 asm volatile(
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020083 " tsch 0(%3)\n"
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020084 " ipm %0\n"
85 " srl %0,28"
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020086 : "=d" (ccode), "=m" (*addr)
87 : "d" (reg1), "a" (addr)
88 : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 return ccode;
90}
91
Sebastian Ottdbda8ce2011-03-15 17:08:24 +010092static inline int ssch(struct subchannel_id schid, union orb *addr)
93{
94 register struct subchannel_id reg1 asm("1") = schid;
95 int ccode = -EIO;
96
97 asm volatile(
98 " ssch 0(%2)\n"
99 "0: ipm %0\n"
100 " srl %0,28\n"
101 "1:\n"
102 EX_TABLE(0b, 1b)
103 : "+d" (ccode)
104 : "d" (reg1), "a" (addr), "m" (*addr)
105 : "cc", "memory");
106 return ccode;
107}
108
109static inline int csch(struct subchannel_id schid)
110{
111 register struct subchannel_id reg1 asm("1") = schid;
112 int ccode;
113
114 asm volatile(
115 " csch\n"
116 " ipm %0\n"
117 " srl %0,28"
118 : "=d" (ccode)
119 : "d" (reg1)
120 : "cc");
121 return ccode;
122}
123
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +0200124static inline int tpi(struct tpi_info *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125{
126 int ccode;
127
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200128 asm volatile(
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +0200129 " tpi 0(%2)\n"
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200130 " ipm %0\n"
131 " srl %0,28"
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +0200132 : "=d" (ccode), "=m" (*addr)
133 : "a" (addr)
134 : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 return ccode;
136}
137
Cornelia Huck4c24da72005-09-03 15:58:01 -0700138static inline int chsc(void *chsc_area)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139{
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800140 typedef struct { char _[4096]; } addr_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 int cc;
142
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200143 asm volatile(
144 " .insn rre,0xb25f0000,%2,0\n"
145 " ipm %0\n"
146 " srl %0,28\n"
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800147 : "=d" (cc), "=m" (*(addr_type *) chsc_area)
148 : "d" (chsc_area), "m" (*(addr_type *) chsc_area)
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200149 : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 return cc;
151}
152
Peter Oberparleiterf86635f2007-04-27 16:01:26 +0200153static inline int rchp(struct chp_id chpid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154{
Peter Oberparleiterf86635f2007-04-27 16:01:26 +0200155 register struct chp_id reg1 asm ("1") = chpid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 int ccode;
157
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200158 asm volatile(
159 " lr 1,%1\n"
160 " rchp\n"
161 " ipm %0\n"
162 " srl %0,28"
163 : "=d" (ccode) : "d" (reg1) : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164 return ccode;
165}
166
167#endif