Committer: Michael Beasley <mike@snafu.setup>
[mikesnafu-overlay.git] / include / asm-powerpc / iseries / vio.h
blobf9ac0d00b9517de34216580b741dc2013592f5f2
1 /* -*- linux-c -*-
3 * iSeries Virtual I/O Message Path header
5 * Authors: Dave Boutcher <boutcher@us.ibm.com>
6 * Ryan Arnold <ryanarn@us.ibm.com>
7 * Colin Devilbiss <devilbis@us.ibm.com>
9 * (C) Copyright 2000 IBM Corporation
11 * This header file is used by the iSeries virtual I/O device
12 * drivers. It defines the interfaces to the common functions
13 * (implemented in drivers/char/viopath.h) as well as defining
14 * common functions and structures. Currently (at the time I
15 * wrote this comment) the iSeries virtual I/O device drivers
16 * that use this are
17 * drivers/block/viodasd.c
18 * drivers/char/viocons.c
19 * drivers/char/viotape.c
20 * drivers/cdrom/viocd.c
22 * The iSeries virtual ethernet support (veth.c) uses a whole
23 * different set of functions.
25 * This program is free software; you can redistribute it and/or
26 * modify it under the terms of the GNU General Public License as
27 * published by the Free Software Foundation; either version 2 of the
28 * License, or (at your option) anyu later version.
30 * This program is distributed in the hope that it will be useful, but
31 * WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
33 * General Public License for more details.
35 * You should have received a copy of the GNU General Public License
36 * along with this program; if not, write to the Free Software Foundation,
37 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
40 #ifndef _ASM_POWERPC_ISERIES_VIO_H
41 #define _ASM_POWERPC_ISERIES_VIO_H
43 #include <asm/iseries/hv_types.h>
44 #include <asm/iseries/hv_lp_event.h>
47 * iSeries virtual I/O events use the subtype field in
48 * HvLpEvent to figure out what kind of vio event is coming
49 * in. We use a table to route these, and this defines
50 * the maximum number of distinct subtypes
52 #define VIO_MAX_SUBTYPES 8
54 #define VIOMAXBLOCKDMA 12
56 struct open_data {
57 u64 disk_size;
58 u16 max_disk;
59 u16 cylinders;
60 u16 tracks;
61 u16 sectors;
62 u16 bytes_per_sector;
65 struct rw_data {
66 u64 offset;
67 struct {
68 u32 token;
69 u32 reserved;
70 u64 len;
71 } dma_info[VIOMAXBLOCKDMA];
74 struct vioblocklpevent {
75 struct HvLpEvent event;
76 u32 reserved;
77 u16 version;
78 u16 sub_result;
79 u16 disk;
80 u16 flags;
81 union {
82 struct open_data open_data;
83 struct rw_data rw_data;
84 u64 changed;
85 } u;
88 #define vioblockflags_ro 0x0001
90 enum vioblocksubtype {
91 vioblockopen = 0x0001,
92 vioblockclose = 0x0002,
93 vioblockread = 0x0003,
94 vioblockwrite = 0x0004,
95 vioblockflush = 0x0005,
96 vioblockcheck = 0x0007
99 struct viocdlpevent {
100 struct HvLpEvent event;
101 u32 reserved;
102 u16 version;
103 u16 sub_result;
104 u16 disk;
105 u16 flags;
106 u32 token;
107 u64 offset; /* On open, max number of disks */
108 u64 len; /* On open, size of the disk */
109 u32 block_size; /* Only set on open */
110 u32 media_size; /* Only set on open */
113 enum viocdsubtype {
114 viocdopen = 0x0001,
115 viocdclose = 0x0002,
116 viocdread = 0x0003,
117 viocdwrite = 0x0004,
118 viocdlockdoor = 0x0005,
119 viocdgetinfo = 0x0006,
120 viocdcheck = 0x0007
123 struct viotapelpevent {
124 struct HvLpEvent event;
125 u32 reserved;
126 u16 version;
127 u16 sub_type_result;
128 u16 tape;
129 u16 flags;
130 u32 token;
131 u64 len;
132 union {
133 struct {
134 u32 tape_op;
135 u32 count;
136 } op;
137 struct {
138 u32 type;
139 u32 resid;
140 u32 dsreg;
141 u32 gstat;
142 u32 erreg;
143 u32 file_no;
144 u32 block_no;
145 } get_status;
146 struct {
147 u32 block_no;
148 } get_pos;
149 } u;
152 enum viotapesubtype {
153 viotapeopen = 0x0001,
154 viotapeclose = 0x0002,
155 viotaperead = 0x0003,
156 viotapewrite = 0x0004,
157 viotapegetinfo = 0x0005,
158 viotapeop = 0x0006,
159 viotapegetpos = 0x0007,
160 viotapesetpos = 0x0008,
161 viotapegetstatus = 0x0009
165 * Each subtype can register a handler to process their events.
166 * The handler must have this interface.
168 typedef void (vio_event_handler_t) (struct HvLpEvent * event);
170 extern int viopath_open(HvLpIndex remoteLp, int subtype, int numReq);
171 extern int viopath_close(HvLpIndex remoteLp, int subtype, int numReq);
172 extern int vio_setHandler(int subtype, vio_event_handler_t * beh);
173 extern int vio_clearHandler(int subtype);
174 extern int viopath_isactive(HvLpIndex lp);
175 extern HvLpInstanceId viopath_sourceinst(HvLpIndex lp);
176 extern HvLpInstanceId viopath_targetinst(HvLpIndex lp);
177 extern void vio_set_hostlp(void);
178 extern void *vio_get_event_buffer(int subtype);
179 extern void vio_free_event_buffer(int subtype, void *buffer);
181 extern struct vio_dev *vio_create_viodasd(u32 unit);
183 extern HvLpIndex viopath_hostLp;
184 extern HvLpIndex viopath_ourLp;
186 #define VIOCHAR_MAX_DATA 200
188 #define VIOMAJOR_SUBTYPE_MASK 0xff00
189 #define VIOMINOR_SUBTYPE_MASK 0x00ff
190 #define VIOMAJOR_SUBTYPE_SHIFT 8
192 #define VIOVERSION 0x0101
195 * This is the general structure for VIO errors; each module should have
196 * a table of them, and each table should be terminated by an entry of
197 * { 0, 0, NULL }. Then, to find a specific error message, a module
198 * should pass its local table and the return code.
200 struct vio_error_entry {
201 u16 rc;
202 int errno;
203 const char *msg;
205 extern const struct vio_error_entry *vio_lookup_rc(
206 const struct vio_error_entry *local_table, u16 rc);
208 enum viosubtypes {
209 viomajorsubtype_monitor = 0x0100,
210 viomajorsubtype_blockio = 0x0200,
211 viomajorsubtype_chario = 0x0300,
212 viomajorsubtype_config = 0x0400,
213 viomajorsubtype_cdio = 0x0500,
214 viomajorsubtype_tape = 0x0600,
215 viomajorsubtype_scsi = 0x0700
218 enum vioconfigsubtype {
219 vioconfigget = 0x0001,
222 enum viorc {
223 viorc_good = 0x0000,
224 viorc_noConnection = 0x0001,
225 viorc_noReceiver = 0x0002,
226 viorc_noBufferAvailable = 0x0003,
227 viorc_invalidMessageType = 0x0004,
228 viorc_invalidRange = 0x0201,
229 viorc_invalidToken = 0x0202,
230 viorc_DMAError = 0x0203,
231 viorc_useError = 0x0204,
232 viorc_releaseError = 0x0205,
233 viorc_invalidDisk = 0x0206,
234 viorc_openRejected = 0x0301
238 * The structure of the events that flow between us and OS/400 for chario
239 * events. You can't mess with this unless the OS/400 side changes too.
241 struct viocharlpevent {
242 struct HvLpEvent event;
243 u32 reserved;
244 u16 version;
245 u16 subtype_result_code;
246 u8 virtual_device;
247 u8 len;
248 u8 data[VIOCHAR_MAX_DATA];
251 #define VIOCHAR_WINDOW 10
253 enum viocharsubtype {
254 viocharopen = 0x0001,
255 viocharclose = 0x0002,
256 viochardata = 0x0003,
257 viocharack = 0x0004,
258 viocharconfig = 0x0005
261 enum viochar_rc {
262 viochar_rc_ebusy = 1
265 #endif /* _ASM_POWERPC_ISERIES_VIO_H */