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

4
#include "schid.h"
5
#include "chpid.h"
6

L
Linus Torvalds 已提交
7 8 9 10
/*
 * TPI info structure
 */
struct tpi_info {
11
	struct subchannel_id schid;
L
Linus Torvalds 已提交
12 13 14 15 16 17 18 19 20 21 22 23 24 25
	__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
 */

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

#endif