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

4
#include <asm/chpid.h>
5
#include <asm/schid.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
static inline int stsch_err(struct subchannel_id schid, struct schib *addr)
27
{
28 29
	register struct subchannel_id reg1 asm ("1") = schid;
	int ccode = -EIO;
30

31
	asm volatile(
32
		"	stsch	0(%3)\n"
33 34
		"0:	ipm	%0\n"
		"	srl	%0,28\n"
35
		"1:\n"
36
		EX_TABLE(0b,1b)
37 38 39
		: "+d" (ccode), "=m" (*addr)
		: "d" (reg1), "a" (addr)
		: "cc");
40 41 42
	return ccode;
}

43
static inline int msch(struct subchannel_id schid, struct schib *addr)
L
Linus Torvalds 已提交
44
{
45
	register struct subchannel_id reg1 asm ("1") = schid;
L
Linus Torvalds 已提交
46 47
	int ccode;

48 49 50 51
	asm volatile(
		"	msch	0(%2)\n"
		"	ipm	%0\n"
		"	srl	%0,28"
52 53 54
		: "=d" (ccode)
		: "d" (reg1), "a" (addr), "m" (*addr)
		: "cc");
L
Linus Torvalds 已提交
55 56 57
	return ccode;
}

58
static inline int msch_err(struct subchannel_id schid, struct schib *addr)
L
Linus Torvalds 已提交
59
{
60 61
	register struct subchannel_id reg1 asm ("1") = schid;
	int ccode = -EIO;
L
Linus Torvalds 已提交
62

63 64 65 66
	asm volatile(
		"	msch	0(%2)\n"
		"0:	ipm	%0\n"
		"	srl	%0,28\n"
L
Linus Torvalds 已提交
67
		"1:\n"
68
		EX_TABLE(0b,1b)
69 70 71
		: "+d" (ccode)
		: "d" (reg1), "a" (addr), "m" (*addr)
		: "cc");
L
Linus Torvalds 已提交
72 73 74
	return ccode;
}

75
static inline int tsch(struct subchannel_id schid, struct irb *addr)
L
Linus Torvalds 已提交
76
{
77
	register struct subchannel_id reg1 asm ("1") = schid;
L
Linus Torvalds 已提交
78 79
	int ccode;

80
	asm volatile(
81
		"	tsch	0(%3)\n"
82 83
		"	ipm	%0\n"
		"	srl	%0,28"
84 85 86
		: "=d" (ccode), "=m" (*addr)
		: "d" (reg1), "a" (addr)
		: "cc");
L
Linus Torvalds 已提交
87 88 89
	return ccode;
}

90
static inline int tpi(struct tpi_info *addr)
L
Linus Torvalds 已提交
91 92 93
{
	int ccode;

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

104
static inline int chsc(void *chsc_area)
L
Linus Torvalds 已提交
105
{
106
	typedef struct { char _[4096]; } addr_type;
L
Linus Torvalds 已提交
107 108
	int cc;

109 110 111 112
	asm volatile(
		"	.insn	rre,0xb25f0000,%2,0\n"
		"	ipm	%0\n"
		"	srl	%0,28\n"
113 114
		: "=d" (cc), "=m" (*(addr_type *) chsc_area)
		: "d" (chsc_area), "m" (*(addr_type *) chsc_area)
115
		: "cc");
L
Linus Torvalds 已提交
116 117 118
	return cc;
}

119
static inline int rchp(struct chp_id chpid)
L
Linus Torvalds 已提交
120
{
121
	register struct chp_id reg1 asm ("1") = chpid;
L
Linus Torvalds 已提交
122 123
	int ccode;

124 125 126 127 128 129
	asm volatile(
		"	lr	1,%1\n"
		"	rchp\n"
		"	ipm	%0\n"
		"	srl	%0,28"
		: "=d" (ccode) : "d" (reg1) : "cc");
L
Linus Torvalds 已提交
130 131 132 133
	return ccode;
}

#endif