3 * Copyright © 2010 - 2013 UNISYS CORPORATION
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.
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
18 #ifndef __VISORCHIPSET_H__
19 #define __VISORCHIPSET_H__
23 #include "controlvmchannel.h"
25 #include "procobjecttree.h"
26 #include "vbusdeviceinfo.h"
27 #include "vbushelper.h"
29 /** Describes the state from the perspective of which controlvm messages have
30 * been received for a bus or device.
37 /* Add new fields above. */
38 /* Remaining bits in this 32-bit word are unused. */
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)
46 ADDRTYPE_localPhysical,
48 /** address is guest physical, and withIN the confines of the
49 * physical memory controlled by the running OS.
52 } VISORCHIPSET_ADDRESSTYPE;
59 /** Attributes for a particular Supervisor channel.
62 VISORCHIPSET_ADDRESSTYPE addrType;
63 HOSTADDRESS channelAddr;
64 struct InterruptInfo intr;
69 } VISORCHIPSET_CHANNEL_INFO;
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().
77 struct list_head entry;
81 VISORCHIPSET_STATE state;
82 VISORCHIPSET_CHANNEL_INFO chanInfo;
83 U32 Reserved1; /* CONTROLVM_ID */
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;
91 } VISORCHIPSET_DEVICE_INFO;
93 static inline VISORCHIPSET_DEVICE_INFO *
94 finddevice(struct list_head *list, U32 busNo, U32 devNo)
96 VISORCHIPSET_DEVICE_INFO *p;
98 list_for_each_entry(p, list, entry) {
99 if (p->busNo == busNo && p->devNo == devNo)
105 static inline void delbusdevices(struct list_head *list, U32 busNo)
107 VISORCHIPSET_DEVICE_INFO *p;
109 list_for_each_entry(p, list, entry) {
110 if (p->busNo == busNo) {
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().
124 struct list_head entry;
126 VISORCHIPSET_STATE state;
127 VISORCHIPSET_CHANNEL_INFO chanInfo;
131 U8 *description; /* UTF8 */
134 MYPROCOBJECT *procObject;
137 /* Add new fields above. */
138 /* Remaining bits in this 32-bit word are unused. */
140 CONTROLVM_MESSAGE_HEADER pendingMsgHdr; /* CONTROLVM MsgHdr */
141 /** For private use by the bus driver */
142 void *bus_driver_context;
145 } VISORCHIPSET_BUS_INFO;
147 static inline VISORCHIPSET_BUS_INFO *
148 findbus(struct list_head *list, U32 busNo)
150 VISORCHIPSET_BUS_INFO *p;
152 list_for_each_entry(p, list, entry) {
153 if (p->busNo == busNo)
159 /** Attributes for a particular Supervisor switch.
163 VISORCHIPSET_STATE state;
170 U32 Reserved2; /* CONTROLVM_ID */
173 CONTROLVM_MESSAGE_HEADER pendingMsgHdr;
175 } VISORCHIPSET_SWITCH_INFO;
177 /** Attributes for a particular Supervisor external port, which is connected
178 * to a specific switch.
183 VISORCHIPSET_STATE state;
184 GUID networkZoneGuid;
193 U32 Reserved2; /* CONTROLVM_ID */
196 CONTROLVM_MESSAGE_HEADER pendingMsgHdr;
198 } VISORCHIPSET_EXTERNALPORT_INFO;
200 /** Attributes for a particular Supervisor internal port, which is how a
201 * device connects to a particular switch.
206 VISORCHIPSET_STATE state;
207 U32 busNo; /* valid only when state.attached == 1 */
208 U32 devNo; /* valid only when state.attached == 1 */
210 U32 Reserved2; /* CONTROLVM_ID */
211 CONTROLVM_MESSAGE_HEADER pendingMsgHdr;
212 MYPROCOBJECT *procObject;
214 } VISORCHIPSET_INTERNALPORT_INFO;
216 /* These functions will be called from within visorchipset when certain
217 * events happen. (The implementation of these functions is outside of
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,
229 } VISORCHIPSET_BUSDEV_NOTIFIERS;
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:
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;
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
253 visorchipset_register_busdev_client(VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers,
254 VISORCHIPSET_BUSDEV_RESPONDERS *responders,
255 ULTRA_VBUS_DEVICEINFO *driverInfo);
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
264 visorchipset_register_busdev_server(VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers,
265 VISORCHIPSET_BUSDEV_RESPONDERS *responders,
266 ULTRA_VBUS_DEVICEINFO *driverInfo);
268 typedef void (*SPARREPORTEVENT_COMPLETE_FUNC) (CONTROLVM_MESSAGE *msg,
271 void visorchipset_device_pause_response(ulong busNo, ulong devNo, int response);
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
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,
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,
294 #if defined(TRANSMITFILE_DEBUG) || defined(DEBUG)
295 #define DBG_GETFILE_PAYLOAD(msg, controlvm_header) \
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__)
302 #define DBG_GETFILE_PAYLOAD(msg, controlvm_header)
303 #define DBG_GETFILE(fmt, ...)
304 #define DBG_PUTFILE(fmt, ...)