779c5668034960bea6088bf23263c21c68b8603a
[linux-flexiantxendom0-3.2.10.git] / include / asm-ppc64 / iSeries / vio.h
1 /* -*- linux-c -*-
2  *  drivers/char/vio.h
3  *
4  *  iSeries Virtual I/O Message Path header
5  *
6  *  Authors: Dave Boutcher <boutcher@us.ibm.com>
7  *           Ryan Arnold <ryanarn@us.ibm.com>
8  *           Colin Devilbiss <devilbis@us.ibm.com>
9  *
10  * (C) Copyright 2000 IBM Corporation
11  * 
12  * This header file is used by the iSeries virtual I/O device
13  * drivers.  It defines the interfaces to the common functions
14  * (implemented in drivers/char/viopath.h) as well as defining
15  * common functions and structures.  Currently (at the time I 
16  * wrote this comment) the iSeries virtual I/O device drivers
17  * that use this are 
18  *   drivers/block/viodasd.c 
19  *   drivers/char/viocons.c
20  *   drivers/char/viotape.c
21  *   drivers/cdrom/viocd.c
22  *
23  * The iSeries virtual ethernet support (veth.c) uses a whole
24  * different set of functions.
25  * 
26  * This program is free software;  you can redistribute it and/or
27  * modify it under the terms of the GNU General Public License as
28  * published by the Free Software Foundation; either version 2 of the
29  * License, or (at your option) anyu later version.
30  *
31  * This program is distributed in the hope that it will be useful, but
32  * WITHOUT ANY WARRANTY; without even the implied warranty of 
33  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
34  * General Public License for more details.  
35  *
36  * You should have received a copy of the GNU General Public License 
37  * along with this program; if not, write to the Free Software Foundation,
38  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
39  *
40  */
41 #ifndef _VIO_H
42 #define _VIO_H
43
44 #include <asm/iSeries/HvTypes.h>
45 #include <asm/iSeries/HvLpEvent.h>
46
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
51  */
52 #define VIO_MAX_SUBTYPES 7
53
54 /* Each subtype can register a handler to process their events.
55  * The handler must have this interface.
56  */
57 typedef void (vio_event_handler_t) (struct HvLpEvent * event);
58
59 int viopath_open(HvLpIndex remoteLp, int subtype, int numReq);
60 int viopath_close(HvLpIndex remoteLp, int subtype, int numReq);
61 int vio_setHandler(int subtype, vio_event_handler_t * beh);
62 int vio_clearHandler(int subtype);
63 int viopath_isactive(HvLpIndex lp);
64 HvLpInstanceId viopath_sourceinst(HvLpIndex lp);
65 HvLpInstanceId viopath_targetinst(HvLpIndex lp);
66 void vio_set_hostlp(void);
67 void *vio_get_event_buffer(int subtype);
68 void vio_free_event_buffer(int subtype, void *buffer);
69
70 extern HvLpIndex viopath_hostLp;
71 extern HvLpIndex viopath_ourLp;
72
73 #define VIO_MESSAGE "iSeries virtual I/O: "
74 #define KERN_DEBUG_VIO KERN_DEBUG VIO_MESSAGE
75 #define KERN_INFO_VIO KERN_INFO VIO_MESSAGE
76 #define KERN_WARNING_VIO KERN_WARNING VIO_MESSAGE
77
78 #define VIOCHAR_MAX_DATA 200
79
80 #define VIOMAJOR_SUBTYPE_MASK 0xff00
81 #define VIOMINOR_SUBTYPE_MASK 0x00ff
82 #define VIOMAJOR_SUBTYPE_SHIFT 8
83
84 #define VIOVERSION            0x0101
85
86 /*
87 This is the general structure for VIO errors; each module should have a table
88 of them, and each table should be terminated by an entry of { 0, 0, NULL }.
89 Then, to find a specific error message, a module should pass its local table
90 and the return code.
91 */
92 struct vio_error_entry {
93         u16 rc;
94         int errno;
95         const char *msg;
96 };
97 const struct vio_error_entry *vio_lookup_rc(const struct vio_error_entry
98                                             *local_table, u16 rc);
99
100 enum viosubtypes {
101         viomajorsubtype_monitor = 0x0100,
102         viomajorsubtype_blockio = 0x0200,
103         viomajorsubtype_chario = 0x0300,
104         viomajorsubtype_config = 0x0400,
105         viomajorsubtype_cdio = 0x0500,
106         viomajorsubtype_tape = 0x0600
107 };
108
109
110 enum vioconfigsubtype {
111         vioconfigget = 0x0001,
112 };
113
114 enum viorc {
115         viorc_good = 0x0000,
116         viorc_noConnection = 0x0001,
117         viorc_noReceiver = 0x0002,
118         viorc_noBufferAvailable = 0x0003,
119         viorc_invalidMessageType = 0x0004,
120         viorc_invalidRange = 0x0201,
121         viorc_invalidToken = 0x0202,
122         viorc_DMAError = 0x0203,
123         viorc_useError = 0x0204,
124         viorc_releaseError = 0x0205,
125         viorc_invalidDisk = 0x0206,
126         viorc_openRejected = 0x0301
127 };
128
129 #endif /* _VIO_H */