ioasm.h 2.7 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 6
#include "schid.h"

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
static inline int chsc(void *chsc_area)
L
Linus Torvalds 已提交
113
{
114
	typedef struct { char _[4096]; } addr_type;
L
Linus Torvalds 已提交
115 116
	int cc;

117 118 119 120
	asm volatile(
		"	.insn	rre,0xb25f0000,%2,0\n"
		"	ipm	%0\n"
		"	srl	%0,28\n"
121 122
		: "=d" (cc), "=m" (*(addr_type *) chsc_area)
		: "d" (chsc_area), "m" (*(addr_type *) chsc_area)
123
		: "cc");
L
Linus Torvalds 已提交
124 125 126
	return cc;
}

127
static inline int rchp(struct chp_id chpid)
L
Linus Torvalds 已提交
128
{
129
	register struct chp_id reg1 asm ("1") = chpid;
L
Linus Torvalds 已提交
130 131
	int ccode;

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

#endif