blob: 759262792633e0ec5fd4ad0d3f43f80d47ad5225 [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>
Cornelia Hucka8237fc2006-01-06 00:19:21 -08006
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
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020026static inline int stsch(struct subchannel_id schid, 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(
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020032 " stsch 0(%3)\n"
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020033 " ipm %0\n"
34 " srl %0,28"
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020035 : "=d" (ccode), "=m" (*addr)
36 : "d" (reg1), "a" (addr)
37 : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 return ccode;
39}
40
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020041static inline int stsch_err(struct subchannel_id schid, struct schib *addr)
Cornelia Huckfb6958a2006-01-06 00:19:25 -080042{
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(
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020047 " stsch 0(%3)\n"
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020048 "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)
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020052 : "+d" (ccode), "=m" (*addr)
53 : "d" (reg1), "a" (addr)
54 : "cc");
Cornelia Huckfb6958a2006-01-06 00:19:25 -080055 return ccode;
56}
57
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020058static inline int msch(struct subchannel_id schid, struct schib *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070059{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020060 register struct subchannel_id reg1 asm ("1") = schid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 int ccode;
62
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020063 asm volatile(
64 " msch 0(%2)\n"
65 " ipm %0\n"
66 " srl %0,28"
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020067 : "=d" (ccode)
68 : "d" (reg1), "a" (addr), "m" (*addr)
69 : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 return ccode;
71}
72
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020073static inline int msch_err(struct subchannel_id schid, struct schib *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070074{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020075 register struct subchannel_id reg1 asm ("1") = schid;
76 int ccode = -EIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -070077
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020078 asm volatile(
79 " msch 0(%2)\n"
80 "0: ipm %0\n"
81 " srl %0,28\n"
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 "1:\n"
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020083 EX_TABLE(0b,1b)
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020084 : "+d" (ccode)
85 : "d" (reg1), "a" (addr), "m" (*addr)
86 : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -070087 return ccode;
88}
89
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020090static inline int tsch(struct subchannel_id schid, struct irb *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070091{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020092 register struct subchannel_id reg1 asm ("1") = schid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 int ccode;
94
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020095 asm volatile(
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020096 " tsch 0(%3)\n"
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020097 " ipm %0\n"
98 " srl %0,28"
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +020099 : "=d" (ccode), "=m" (*addr)
100 : "d" (reg1), "a" (addr)
101 : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 return ccode;
103}
104
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +0200105static inline int tpi(struct tpi_info *addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106{
107 int ccode;
108
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200109 asm volatile(
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +0200110 " tpi 0(%2)\n"
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200111 " ipm %0\n"
112 " srl %0,28"
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +0200113 : "=d" (ccode), "=m" (*addr)
114 : "a" (addr)
115 : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 return ccode;
117}
118
Cornelia Huck4c24da72005-09-03 15:58:01 -0700119static inline int chsc(void *chsc_area)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120{
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800121 typedef struct { char _[4096]; } addr_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 int cc;
123
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200124 asm volatile(
125 " .insn rre,0xb25f0000,%2,0\n"
126 " ipm %0\n"
127 " srl %0,28\n"
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800128 : "=d" (cc), "=m" (*(addr_type *) chsc_area)
129 : "d" (chsc_area), "m" (*(addr_type *) chsc_area)
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200130 : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 return cc;
132}
133
Peter Oberparleiterf86635f2007-04-27 16:01:26 +0200134static inline int rchp(struct chp_id chpid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135{
Peter Oberparleiterf86635f2007-04-27 16:01:26 +0200136 register struct chp_id reg1 asm ("1") = chpid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 int ccode;
138
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200139 asm volatile(
140 " lr 1,%1\n"
141 " rchp\n"
142 " ipm %0\n"
143 " srl %0,28"
144 : "=d" (ccode) : "d" (reg1) : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145 return ccode;
146}
147
148#endif