summaryrefslogtreecommitdiffstats
path: root/include/asm-powerpc/iseries/vio.h
blob: 2555dfd6fac6d573b1310bacdae5e646563e77f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/* -*- linux-c -*-
 *
 *  iSeries Virtual I/O Message Path header
 *
 *  Authors: Dave Boutcher <boutcher@us.ibm.com>
 *           Ryan Arnold <ryanarn@us.ibm.com>
 *           Colin Devilbiss <devilbis@us.ibm.com>
 *
 * (C) Copyright 2000 IBM Corporation
 *
 * This header file is used by the iSeries virtual I/O device
 * drivers.  It defines the interfaces to the common functions
 * (implemented in drivers/char/viopath.h) as well as defining
 * common functions and structures.  Currently (at the time I
 * wrote this comment) the iSeries virtual I/O device drivers
 * that use this are
 *   drivers/block/viodasd.c
 *   drivers/char/viocons.c
 *   drivers/char/viotape.c
 *   drivers/cdrom/viocd.c
 *
 * The iSeries virtual ethernet support (veth.c) uses a whole
 * different set of functions.
 *
 * This program is free software;  you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) anyu later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 */
#ifndef _ASM_POWERPC_ISERIES_VIO_H
#define _ASM_POWERPC_ISERIES_VIO_H

#include <asm/iseries/hv_types.h>
#include <asm/iseries/hv_lp_event.h>

/*
 * iSeries virtual I/O events use the subtype field in
 * HvLpEvent to figure out what kind of vio event is coming
 * in.  We use a table to route these, and this defines
 * the maximum number of distinct subtypes
 */
#define VIO_MAX_SUBTYPES 8

struct viocdlpevent {
	struct HvLpEvent	event;
	u32			reserved;
	u16			version;
	u16			sub_result;
	u16			disk;
	u16			flags;
	u32			token;
	u64			offset;		/* On open, max number of disks */
	u64			len;		/* On open, size of the disk */
	u32			block_size;	/* Only set on open */
	u32			media_size;	/* Only set on open */
};

enum viocdsubtype {
	viocdopen = 0x0001,
	viocdclose = 0x0002,
	viocdread = 0x0003,
	viocdwrite = 0x0004,
	viocdlockdoor = 0x0005,
	viocdgetinfo = 0x0006,
	viocdcheck = 0x0007
};

struct viotapelpevent {
	struct HvLpEvent event;
	u32 reserved;
	u16 version;
	u16 sub_type_result;
	u16 tape;
	u16 flags;
	u32 token;
	u64 len;
	union {
		struct {
			u32 tape_op;
			u32 count;
		} op;
		struct {
			u32 type;
			u32 resid;
			u32 dsreg;
			u32 gstat;
			u32 erreg;
			u32 file_no;
			u32 block_no;
		} get_status;
		struct {
			u32 block_no;
		} get_pos;
	} u;
};

enum viotapesubtype {
	viotapeopen = 0x0001,
	viotapeclose = 0x0002,
	viotaperead = 0x0003,
	viotapewrite = 0x0004,
	viotapegetinfo = 0x0005,
	viotapeop = 0x0006,
	viotapegetpos = 0x0007,
	viotapesetpos = 0x0008,
	viotapegetstatus = 0x0009
};

/*
 * Each subtype can register a handler to process their events.
 * The handler must have this interface.
 */
typedef void (vio_event_handler_t) (struct HvLpEvent * event);

extern int viopath_open(HvLpIndex remoteLp, int subtype, int numReq);
extern int viopath_close(HvLpIndex remoteLp, int subtype, int numReq);
extern int vio_setHandler(int subtype, vio_event_handler_t * beh);
extern int vio_clearHandler(int subtype);
extern int viopath_isactive(HvLpIndex lp);
extern HvLpInstanceId viopath_sourceinst(HvLpIndex lp);
extern HvLpInstanceId viopath_targetinst(HvLpIndex lp);
extern void vio_set_hostlp(void);
extern void *vio_get_event_buffer(int subtype);
extern void vio_free_event_buffer(int subtype, void *buffer);

extern HvLpIndex viopath_hostLp;
extern HvLpIndex viopath_ourLp;

#define VIOCHAR_MAX_DATA	200

#define VIOMAJOR_SUBTYPE_MASK	0xff00
#define VIOMINOR_SUBTYPE_MASK	0x00ff
#define VIOMAJOR_SUBTYPE_SHIFT	8

#define VIOVERSION		0x0101

/*
 * This is the general structure for VIO errors; each module should have
 * a table of them, and each table should be terminated by an entry of
 * { 0, 0, NULL }.  Then, to find a specific error message, a module
 * should pass its local table and the return code.
 */
struct vio_error_entry {
	u16 rc;
	int errno;
	const char *msg;
};
extern const struct vio_error_entry *vio_lookup_rc(
		const struct vio_error_entry *local_table, u16 rc);

enum viosubtypes {
	viomajorsubtype_monitor = 0x0100,
	viomajorsubtype_blockio = 0x0200,
	viomajorsubtype_chario = 0x0300,
	viomajorsubtype_config = 0x0400,
	viomajorsubtype_cdio = 0x0500,
	viomajorsubtype_tape = 0x0600,
	viomajorsubtype_scsi = 0x0700
};

enum vioconfigsubtype {
	vioconfigget = 0x0001,
};

enum viorc {
	viorc_good = 0x0000,
	viorc_noConnection = 0x0001,
	viorc_noReceiver = 0x0002,
	viorc_noBufferAvailable = 0x0003,
	viorc_invalidMessageType = 0x0004,
	viorc_invalidRange = 0x0201,
	viorc_invalidToken = 0x0202,
	viorc_DMAError = 0x0203,
	viorc_useError = 0x0204,
	viorc_releaseError = 0x0205,
	viorc_invalidDisk = 0x0206,
	viorc_openRejected = 0x0301
};

/*
 * The structure of the events that flow between us and OS/400 for chario
 * events.  You can't mess with this unless the OS/400 side changes too.
 */
struct viocharlpevent {
	struct HvLpEvent event;
	u32 reserved;
	u16 version;
	u16 subtype_result_code;
	u8 virtual_device;
	u8 len;
	u8 data[VIOCHAR_MAX_DATA];
};

#define VIOCHAR_WINDOW		10

enum viocharsubtype {
	viocharopen = 0x0001,
	viocharclose = 0x0002,
	viochardata = 0x0003,
	viocharack = 0x0004,
	viocharconfig = 0x0005
};

enum viochar_rc {
	viochar_rc_ebusy = 1
};

#endif /* _ASM_POWERPC_ISERIES_VIO_H */
OpenPOWER on IntegriCloud