ioasm.h 3.9 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3
#ifndef S390_CIO_IOASM_H
#define S390_CIO_IOASM_H

4 5
#include "schid.h"

L
Linus Torvalds 已提交
6 7 8 9
/*
 * TPI info structure
 */
struct tpi_info {
10
	struct subchannel_id schid;
L
Linus Torvalds 已提交
11 12 13 14 15 16 17 18 19 20 21 22 23 24
	__u32 intparm;		 /* interruption parameter */
	__u32 adapter_IO : 1;
	__u32 reserved2	 : 1;
	__u32 isc	 : 3;
	__u32 reserved3	 : 12;
	__u32 int_type	 : 3;
	__u32 reserved4	 : 12;
} __attribute__ ((packed));


/*
 * Some S390 specific IO instructions as inline
 */

25 26
static inline int stsch(struct subchannel_id schid,
			    volatile struct schib *addr)
L
Linus Torvalds 已提交
27
{
28
	register struct subchannel_id reg1 asm ("1") = schid;
L
Linus Torvalds 已提交
29 30
	int ccode;

31 32 33 34 35
	asm volatile(
		"	stsch	0(%2)\n"
		"	ipm	%0\n"
		"	srl	%0,28"
		: "=d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc");
L
Linus Torvalds 已提交
36 37 38
	return ccode;
}

39 40 41
static inline int stsch_err(struct subchannel_id schid,
				volatile struct schib *addr)
{
42 43
	register struct subchannel_id reg1 asm ("1") = schid;
	int ccode = -EIO;
44

45 46 47 48
	asm volatile(
		"	stsch	0(%2)\n"
		"0:	ipm	%0\n"
		"	srl	%0,28\n"
49
		"1:\n"
50 51
		EX_TABLE(0b,1b)
		: "+d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc");
52 53 54
	return ccode;
}

55 56
static inline int msch(struct subchannel_id schid,
			   volatile struct schib *addr)
L
Linus Torvalds 已提交
57
{
58
	register struct subchannel_id reg1 asm ("1") = schid;
L
Linus Torvalds 已提交
59 60
	int ccode;

61 62 63 64 65
	asm volatile(
		"	msch	0(%2)\n"
		"	ipm	%0\n"
		"	srl	%0,28"
		: "=d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc");
L
Linus Torvalds 已提交
66 67 68
	return ccode;
}

69 70
static inline int msch_err(struct subchannel_id schid,
			       volatile struct schib *addr)
L
Linus Torvalds 已提交
71
{
72 73
	register struct subchannel_id reg1 asm ("1") = schid;
	int ccode = -EIO;
L
Linus Torvalds 已提交
74

75 76 77 78
	asm volatile(
		"	msch	0(%2)\n"
		"0:	ipm	%0\n"
		"	srl	%0,28\n"
L
Linus Torvalds 已提交
79
		"1:\n"
80 81
		EX_TABLE(0b,1b)
		: "+d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc");
L
Linus Torvalds 已提交
82 83 84
	return ccode;
}

85 86
static inline int tsch(struct subchannel_id schid,
			   volatile struct irb *addr)
L
Linus Torvalds 已提交
87
{
88
	register struct subchannel_id reg1 asm ("1") = schid;
L
Linus Torvalds 已提交
89 90
	int ccode;

91 92 93 94 95
	asm volatile(
		"	tsch	0(%2)\n"
		"	ipm	%0\n"
		"	srl	%0,28"
		: "=d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc");
L
Linus Torvalds 已提交
96 97 98
	return ccode;
}

99
static inline int tpi( volatile struct tpi_info *addr)
L
Linus Torvalds 已提交
100 101 102
{
	int ccode;

103 104 105 106 107
	asm volatile(
		"	tpi	0(%1)\n"
		"	ipm	%0\n"
		"	srl	%0,28"
		: "=d" (ccode) : "a" (addr), "m" (*addr) : "cc");
L
Linus Torvalds 已提交
108 109 110
	return ccode;
}

111 112
static inline int ssch(struct subchannel_id schid,
			   volatile struct orb *addr)
L
Linus Torvalds 已提交
113
{
114
	register struct subchannel_id reg1 asm ("1") = schid;
L
Linus Torvalds 已提交
115 116
	int ccode;

117 118 119 120 121
	asm volatile(
		"	ssch	0(%2)\n"
		"	ipm	%0\n"
		"	srl	%0,28"
		: "=d" (ccode) : "d" (reg1), "a" (addr), "m" (*addr) : "cc");
L
Linus Torvalds 已提交
122 123 124
	return ccode;
}

125
static inline int rsch(struct subchannel_id schid)
L
Linus Torvalds 已提交
126
{
127
	register struct subchannel_id reg1 asm ("1") = schid;
L
Linus Torvalds 已提交
128 129
	int ccode;

130 131 132 133 134
	asm volatile(
		"	rsch\n"
		"	ipm	%0\n"
		"	srl	%0,28"
		: "=d" (ccode) : "d" (reg1) : "cc");
L
Linus Torvalds 已提交
135 136 137
	return ccode;
}

138
static inline int csch(struct subchannel_id schid)
L
Linus Torvalds 已提交
139
{
140
	register struct subchannel_id reg1 asm ("1") = schid;
L
Linus Torvalds 已提交
141 142
	int ccode;

143 144 145 146 147
	asm volatile(
		"	csch\n"
		"	ipm	%0\n"
		"	srl	%0,28"
		: "=d" (ccode) : "d" (reg1) : "cc");
L
Linus Torvalds 已提交
148 149 150
	return ccode;
}

151
static inline int hsch(struct subchannel_id schid)
L
Linus Torvalds 已提交
152
{
153
	register struct subchannel_id reg1 asm ("1") = schid;
L
Linus Torvalds 已提交
154 155
	int ccode;

156 157 158 159 160
	asm volatile(
		"	hsch\n"
		"	ipm	%0\n"
		"	srl	%0,28"
		: "=d" (ccode) : "d" (reg1) : "cc");
L
Linus Torvalds 已提交
161 162 163
	return ccode;
}

164
static inline int xsch(struct subchannel_id schid)
L
Linus Torvalds 已提交
165
{
166
	register struct subchannel_id reg1 asm ("1") = schid;
L
Linus Torvalds 已提交
167 168
	int ccode;

169 170 171 172 173
	asm volatile(
		"	.insn	rre,0xb2760000,%1,0\n"
		"	ipm	%0\n"
		"	srl	%0,28"
		: "=d" (ccode) : "d" (reg1) : "cc");
L
Linus Torvalds 已提交
174 175 176
	return ccode;
}

177
static inline int chsc(void *chsc_area)
L
Linus Torvalds 已提交
178
{
179
	typedef struct { char _[4096]; } addr_type;
L
Linus Torvalds 已提交
180 181
	int cc;

182 183 184 185
	asm volatile(
		"	.insn	rre,0xb25f0000,%2,0\n"
		"	ipm	%0\n"
		"	srl	%0,28\n"
186 187
		: "=d" (cc), "=m" (*(addr_type *) chsc_area)
		: "d" (chsc_area), "m" (*(addr_type *) chsc_area)
188
		: "cc");
L
Linus Torvalds 已提交
189 190 191
	return cc;
}

192
static inline int rchp(int chpid)
L
Linus Torvalds 已提交
193
{
194
	register unsigned int reg1 asm ("1") = chpid;
L
Linus Torvalds 已提交
195 196
	int ccode;

197 198 199 200 201 202
	asm volatile(
		"	lr	1,%1\n"
		"	rchp\n"
		"	ipm	%0\n"
		"	srl	%0,28"
		: "=d" (ccode) : "d" (reg1) : "cc");
L
Linus Torvalds 已提交
203 204 205 206
	return ccode;
}

#endif