]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - drivers/staging/unisys/visorchipset/visorchipset.h
Merge branch 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[karo-tx-linux.git] / drivers / staging / unisys / visorchipset / visorchipset.h
1 /* visorchipset.h
2  *
3  * Copyright © 2010 - 2013 UNISYS CORPORATION
4  * All rights reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or (at
9  * your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
14  * NON INFRINGEMENT.  See the GNU General Public License for more
15  * details.
16  */
17
18 #ifndef __VISORCHIPSET_H__
19 #define __VISORCHIPSET_H__
20
21 #include "timskmod.h"
22 #include "channel.h"
23 #include "controlvmchannel.h"
24 #include "parser.h"
25 #include "procobjecttree.h"
26 #include "vbusdeviceinfo.h"
27 #include "vbushelper.h"
28
29 /** Describes the state from the perspective of which controlvm messages have
30  *  been received for a bus or device.
31  */
32 typedef struct {
33         U32 created:1;
34         U32 attached:1;
35         U32 configured:1;
36         U32 running:1;
37         /* Add new fields above. */
38         /* Remaining bits in this 32-bit word are unused. */
39 } VISORCHIPSET_STATE;
40
41 typedef enum {
42         /** address is guest physical, but outside of the physical memory
43          *  region that is controlled by the running OS (this is the normal
44          *  address type for Supervisor channels)
45          */
46         ADDRTYPE_localPhysical,
47
48         /** address is guest physical, and withIN the confines of the
49          *  physical memory controlled by the running OS.
50          */
51         ADDRTYPE_localTest,
52 } VISORCHIPSET_ADDRESSTYPE;
53
54 typedef enum {
55         CRASH_dev,
56         CRASH_bus,
57 } CRASH_OBJ_TYPE;
58
59 /** Attributes for a particular Supervisor channel.
60  */
61 typedef struct {
62         VISORCHIPSET_ADDRESSTYPE addrType;
63         HOSTADDRESS channelAddr;
64         struct InterruptInfo intr;
65         U64 nChannelBytes;
66         GUID channelTypeGuid;
67         GUID channelInstGuid;
68
69 } VISORCHIPSET_CHANNEL_INFO;
70
71 /** Attributes for a particular Supervisor device.
72  *  Any visorchipset client can query these attributes using
73  *  visorchipset_get_client_device_info() or
74  *  visorchipset_get_server_device_info().
75  */
76 typedef struct {
77         struct list_head entry;
78         U32 busNo;
79         U32 devNo;
80         GUID devInstGuid;
81         VISORCHIPSET_STATE state;
82         VISORCHIPSET_CHANNEL_INFO chanInfo;
83         U32 Reserved1;          /* CONTROLVM_ID */
84         U64 Reserved2;
85         U32 switchNo;           /* when devState.attached==1 */
86         U32 internalPortNo;     /* when devState.attached==1 */
87         CONTROLVM_MESSAGE_HEADER pendingMsgHdr; /* CONTROLVM_MESSAGE */
88         /** For private use by the bus driver */
89         void *bus_driver_context;
90
91 } VISORCHIPSET_DEVICE_INFO;
92
93 static inline VISORCHIPSET_DEVICE_INFO *
94 finddevice(struct list_head *list, U32 busNo, U32 devNo)
95 {
96         VISORCHIPSET_DEVICE_INFO *p;
97
98         list_for_each_entry(p, list, entry) {
99                 if (p->busNo == busNo && p->devNo == devNo)
100                         return p;
101         }
102         return NULL;
103 }
104
105 static inline void delbusdevices(struct list_head *list, U32 busNo)
106 {
107         VISORCHIPSET_DEVICE_INFO *p, *tmp;
108
109         list_for_each_entry_safe(p, tmp, list, entry) {
110                 if (p->busNo == busNo) {
111                         list_del(&p->entry);
112                         kfree(p);
113                 }
114         }
115 }
116
117 /** Attributes for a particular Supervisor bus.
118  *  (For a service partition acting as the server for buses/devices, there
119  *  is a 1-to-1 relationship between busses and guest partitions.)
120  *  Any visorchipset client can query these attributes using
121  *  visorchipset_get_client_bus_info() or visorchipset_get_bus_info().
122  */
123 typedef struct {
124         struct list_head entry;
125         U32 busNo;
126         VISORCHIPSET_STATE state;
127         VISORCHIPSET_CHANNEL_INFO chanInfo;
128         GUID partitionGuid;
129         U64 partitionHandle;
130         U8 *name;               /* UTF8 */
131         U8 *description;        /* UTF8 */
132         U64 Reserved1;
133         U32 Reserved2;
134         MYPROCOBJECT *procObject;
135         struct {
136                 U32 server:1;
137                 /* Add new fields above. */
138                 /* Remaining bits in this 32-bit word are unused. */
139         } flags;
140         CONTROLVM_MESSAGE_HEADER pendingMsgHdr; /* CONTROLVM MsgHdr */
141         /** For private use by the bus driver */
142         void *bus_driver_context;
143         U64 devNo;
144
145 } VISORCHIPSET_BUS_INFO;
146
147 static inline VISORCHIPSET_BUS_INFO *
148 findbus(struct list_head *list, U32 busNo)
149 {
150         VISORCHIPSET_BUS_INFO *p;
151
152         list_for_each_entry(p, list, entry) {
153                 if (p->busNo == busNo)
154                         return p;
155         }
156         return NULL;
157 }
158
159 /** Attributes for a particular Supervisor switch.
160  */
161 typedef struct {
162         U32 switchNo;
163         VISORCHIPSET_STATE state;
164         GUID switchTypeGuid;
165         U8 *authService1;
166         U8 *authService2;
167         U8 *authService3;
168         U8 *securityContext;
169         U64 Reserved;
170         U32 Reserved2;          /* CONTROLVM_ID */
171         struct device dev;
172         BOOL dev_exists;
173         CONTROLVM_MESSAGE_HEADER pendingMsgHdr;
174
175 } VISORCHIPSET_SWITCH_INFO;
176
177 /** Attributes for a particular Supervisor external port, which is connected
178  *  to a specific switch.
179  */
180 typedef struct {
181         U32 switchNo;
182         U32 externalPortNo;
183         VISORCHIPSET_STATE state;
184         GUID networkZoneGuid;
185         int pdPort;
186         U8 *ip;
187         U8 *ipNetmask;
188         U8 *ipBroadcast;
189         U8 *ipNetwork;
190         U8 *ipGateway;
191         U8 *ipDNS;
192         U64 Reserved1;
193         U32 Reserved2;          /* CONTROLVM_ID */
194         struct device dev;
195         BOOL dev_exists;
196         CONTROLVM_MESSAGE_HEADER pendingMsgHdr;
197
198 } VISORCHIPSET_EXTERNALPORT_INFO;
199
200 /** Attributes for a particular Supervisor internal port, which is how a
201  *  device connects to a particular switch.
202  */
203 typedef struct {
204         U32 switchNo;
205         U32 internalPortNo;
206         VISORCHIPSET_STATE state;
207         U32 busNo;              /* valid only when state.attached == 1 */
208         U32 devNo;              /* valid only when state.attached == 1 */
209         U64 Reserved1;
210         U32 Reserved2;          /* CONTROLVM_ID */
211         CONTROLVM_MESSAGE_HEADER pendingMsgHdr;
212         MYPROCOBJECT *procObject;
213
214 } VISORCHIPSET_INTERNALPORT_INFO;
215
216 /*  These functions will be called from within visorchipset when certain
217  *  events happen.  (The implementation of these functions is outside of
218  *  visorchipset.)
219  */
220 typedef struct {
221         void (*bus_create)(ulong busNo);
222         void (*bus_destroy)(ulong busNo);
223         void (*device_create)(ulong busNo, ulong devNo);
224         void (*device_destroy)(ulong busNo, ulong devNo);
225         void (*device_pause)(ulong busNo, ulong devNo);
226         void (*device_resume)(ulong busNo, ulong devNo);
227         int (*get_channel_info)(GUID typeGuid, ulong *minSize,
228                                  ulong *maxSize);
229 } VISORCHIPSET_BUSDEV_NOTIFIERS;
230
231 /*  These functions live inside visorchipset, and will be called to indicate
232  *  responses to specific events (by code outside of visorchipset).
233  *  For now, the value for each response is simply either:
234  *       0 = it worked
235  *      -1 = it failed
236  */
237 typedef struct {
238         void (*bus_create)(ulong busNo, int response);
239         void (*bus_destroy)(ulong busNo, int response);
240         void (*device_create)(ulong busNo, ulong devNo, int response);
241         void (*device_destroy)(ulong busNo, ulong devNo, int response);
242         void (*device_pause)(ulong busNo, ulong devNo, int response);
243         void (*device_resume)(ulong busNo, ulong devNo, int response);
244 } VISORCHIPSET_BUSDEV_RESPONDERS;
245
246 /** Register functions (in the bus driver) to get called by visorchipset
247  *  whenever a bus or device appears for which this service partition is
248  *  to be the server for.  visorchipset will fill in <responders>, to
249  *  indicate functions the bus driver should call to indicate message
250  *  responses.
251  */
252 void
253 visorchipset_register_busdev_client(VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers,
254                                     VISORCHIPSET_BUSDEV_RESPONDERS *responders,
255                                     ULTRA_VBUS_DEVICEINFO *driverInfo);
256
257 /** Register functions (in the bus driver) to get called by visorchipset
258  *  whenever a bus or device appears for which this service partition is
259  *  to be the client for.  visorchipset will fill in <responders>, to
260  *  indicate functions the bus driver should call to indicate message
261  *  responses.
262  */
263 void
264 visorchipset_register_busdev_server(VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers,
265                                     VISORCHIPSET_BUSDEV_RESPONDERS *responders,
266                                     ULTRA_VBUS_DEVICEINFO *driverInfo);
267
268 typedef void (*SPARREPORTEVENT_COMPLETE_FUNC) (CONTROLVM_MESSAGE *msg,
269                                                int status);
270
271 void visorchipset_device_pause_response(ulong busNo, ulong devNo, int response);
272
273 BOOL visorchipset_get_bus_info(ulong busNo, VISORCHIPSET_BUS_INFO *busInfo);
274 BOOL visorchipset_get_device_info(ulong busNo, ulong devNo,
275                                   VISORCHIPSET_DEVICE_INFO *devInfo);
276 BOOL visorchipset_get_switch_info(ulong switchNo,
277                                   VISORCHIPSET_SWITCH_INFO *switchInfo);
278 BOOL visorchipset_get_externalport_info(ulong switchNo, ulong externalPortNo,
279                                         VISORCHIPSET_EXTERNALPORT_INFO
280                                         *externalPortInfo);
281 BOOL visorchipset_set_bus_context(ulong busNo, void *context);
282 BOOL visorchipset_set_device_context(ulong busNo, ulong devNo, void *context);
283 int visorchipset_chipset_ready(void);
284 int visorchipset_chipset_selftest(void);
285 int visorchipset_chipset_notready(void);
286 void visorchipset_controlvm_respond_reportEvent(CONTROLVM_MESSAGE *msg,
287                                                 void *payload);
288 void visorchipset_save_message(CONTROLVM_MESSAGE *msg, CRASH_OBJ_TYPE type);
289 void *visorchipset_cache_alloc(struct kmem_cache *pool,
290                                BOOL ok_to_block, char *fn, int ln);
291 void visorchipset_cache_free(struct kmem_cache *pool, void *p,
292                              char *fn, int ln);
293
294 #if defined(TRANSMITFILE_DEBUG) || defined(DEBUG)
295 #define DBG_GETFILE_PAYLOAD(msg, controlvm_header)      \
296         LOGINF(msg,                                     \
297                (ulong)controlvm_header.PayloadVmOffset, \
298                (ulong)controlvm_header.PayloadMaxBytes)
299 #define DBG_GETFILE(fmt, ...)  LOGINF(fmt, ##__VA_ARGS__)
300 #define DBG_PUTFILE(fmt, ...)  LOGINF(fmt, ##__VA_ARGS__)
301 #else
302 #define DBG_GETFILE_PAYLOAD(msg, controlvm_header)
303 #define DBG_GETFILE(fmt, ...)
304 #define DBG_PUTFILE(fmt, ...)
305 #endif
306
307 #endif