3 * Copyright (C) 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__
21 #include <linux/uuid.h>
25 #include "controlvmchannel.h"
27 #include "procobjecttree.h"
28 #include "vbusdeviceinfo.h"
29 #include "vbushelper.h"
31 /** Describes the state from the perspective of which controlvm messages have
32 * been received for a bus or device.
39 /* Add new fields above. */
40 /* Remaining bits in this 32-bit word are unused. */
44 /** address is guest physical, but outside of the physical memory
45 * region that is controlled by the running OS (this is the normal
46 * address type for Supervisor channels)
48 ADDRTYPE_localPhysical,
50 /** address is guest physical, and withIN the confines of the
51 * physical memory controlled by the running OS.
54 } VISORCHIPSET_ADDRESSTYPE;
61 /** Attributes for a particular Supervisor channel.
64 VISORCHIPSET_ADDRESSTYPE addrType;
65 HOSTADDRESS channelAddr;
66 struct InterruptInfo intr;
68 uuid_le channelTypeGuid;
69 uuid_le channelInstGuid;
71 } VISORCHIPSET_CHANNEL_INFO;
73 /** Attributes for a particular Supervisor device.
74 * Any visorchipset client can query these attributes using
75 * visorchipset_get_client_device_info() or
76 * visorchipset_get_server_device_info().
79 struct list_head entry;
83 VISORCHIPSET_STATE state;
84 VISORCHIPSET_CHANNEL_INFO chanInfo;
85 u32 Reserved1; /* CONTROLVM_ID */
87 u32 switchNo; /* when devState.attached==1 */
88 u32 internalPortNo; /* when devState.attached==1 */
89 CONTROLVM_MESSAGE_HEADER pendingMsgHdr; /* CONTROLVM_MESSAGE */
90 /** For private use by the bus driver */
91 void *bus_driver_context;
93 } VISORCHIPSET_DEVICE_INFO;
95 static inline VISORCHIPSET_DEVICE_INFO *
96 finddevice(struct list_head *list, u32 busNo, u32 devNo)
98 VISORCHIPSET_DEVICE_INFO *p;
100 list_for_each_entry(p, list, entry) {
101 if (p->busNo == busNo && p->devNo == devNo)
107 static inline void delbusdevices(struct list_head *list, u32 busNo)
109 VISORCHIPSET_DEVICE_INFO *p, *tmp;
111 list_for_each_entry_safe(p, tmp, list, entry) {
112 if (p->busNo == busNo) {
119 /** Attributes for a particular Supervisor bus.
120 * (For a service partition acting as the server for buses/devices, there
121 * is a 1-to-1 relationship between busses and guest partitions.)
122 * Any visorchipset client can query these attributes using
123 * visorchipset_get_client_bus_info() or visorchipset_get_bus_info().
126 struct list_head entry;
128 VISORCHIPSET_STATE state;
129 VISORCHIPSET_CHANNEL_INFO chanInfo;
130 uuid_le partitionGuid;
133 u8 *description; /* UTF8 */
136 MYPROCOBJECT *procObject;
139 /* Add new fields above. */
140 /* Remaining bits in this 32-bit word are unused. */
142 CONTROLVM_MESSAGE_HEADER pendingMsgHdr; /* CONTROLVM MsgHdr */
143 /** For private use by the bus driver */
144 void *bus_driver_context;
147 } VISORCHIPSET_BUS_INFO;
149 static inline VISORCHIPSET_BUS_INFO *
150 findbus(struct list_head *list, u32 busNo)
152 VISORCHIPSET_BUS_INFO *p;
154 list_for_each_entry(p, list, entry) {
155 if (p->busNo == busNo)
161 /** Attributes for a particular Supervisor switch.
165 VISORCHIPSET_STATE state;
166 uuid_le switchTypeGuid;
172 u32 Reserved2; /* CONTROLVM_ID */
175 CONTROLVM_MESSAGE_HEADER pendingMsgHdr;
177 } VISORCHIPSET_SWITCH_INFO;
179 /** Attributes for a particular Supervisor external port, which is connected
180 * to a specific switch.
185 VISORCHIPSET_STATE state;
186 uuid_le networkZoneGuid;
195 u32 Reserved2; /* CONTROLVM_ID */
198 CONTROLVM_MESSAGE_HEADER pendingMsgHdr;
200 } VISORCHIPSET_EXTERNALPORT_INFO;
202 /** Attributes for a particular Supervisor internal port, which is how a
203 * device connects to a particular switch.
208 VISORCHIPSET_STATE state;
209 u32 busNo; /* valid only when state.attached == 1 */
210 u32 devNo; /* valid only when state.attached == 1 */
212 u32 Reserved2; /* CONTROLVM_ID */
213 CONTROLVM_MESSAGE_HEADER pendingMsgHdr;
214 MYPROCOBJECT *procObject;
216 } VISORCHIPSET_INTERNALPORT_INFO;
218 /* These functions will be called from within visorchipset when certain
219 * events happen. (The implementation of these functions is outside of
223 void (*bus_create)(ulong busNo);
224 void (*bus_destroy)(ulong busNo);
225 void (*device_create)(ulong busNo, ulong devNo);
226 void (*device_destroy)(ulong busNo, ulong devNo);
227 void (*device_pause)(ulong busNo, ulong devNo);
228 void (*device_resume)(ulong busNo, ulong devNo);
229 int (*get_channel_info)(uuid_le typeGuid, ulong *minSize,
231 } VISORCHIPSET_BUSDEV_NOTIFIERS;
233 /* These functions live inside visorchipset, and will be called to indicate
234 * responses to specific events (by code outside of visorchipset).
235 * For now, the value for each response is simply either:
240 void (*bus_create)(ulong busNo, int response);
241 void (*bus_destroy)(ulong busNo, int response);
242 void (*device_create)(ulong busNo, ulong devNo, int response);
243 void (*device_destroy)(ulong busNo, ulong devNo, int response);
244 void (*device_pause)(ulong busNo, ulong devNo, int response);
245 void (*device_resume)(ulong busNo, ulong devNo, int response);
246 } VISORCHIPSET_BUSDEV_RESPONDERS;
248 /** Register functions (in the bus driver) to get called by visorchipset
249 * whenever a bus or device appears for which this service partition is
250 * to be the server for. visorchipset will fill in <responders>, to
251 * indicate functions the bus driver should call to indicate message
255 visorchipset_register_busdev_client(VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers,
256 VISORCHIPSET_BUSDEV_RESPONDERS *responders,
257 ULTRA_VBUS_DEVICEINFO *driverInfo);
259 /** Register functions (in the bus driver) to get called by visorchipset
260 * whenever a bus or device appears for which this service partition is
261 * to be the client for. visorchipset will fill in <responders>, to
262 * indicate functions the bus driver should call to indicate message
266 visorchipset_register_busdev_server(VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers,
267 VISORCHIPSET_BUSDEV_RESPONDERS *responders,
268 ULTRA_VBUS_DEVICEINFO *driverInfo);
270 typedef void (*SPARREPORTEVENT_COMPLETE_FUNC) (CONTROLVM_MESSAGE *msg,
273 void visorchipset_device_pause_response(ulong busNo, ulong devNo, int response);
275 BOOL visorchipset_get_bus_info(ulong busNo, VISORCHIPSET_BUS_INFO *busInfo);
276 BOOL visorchipset_get_device_info(ulong busNo, ulong devNo,
277 VISORCHIPSET_DEVICE_INFO *devInfo);
278 BOOL visorchipset_get_switch_info(ulong switchNo,
279 VISORCHIPSET_SWITCH_INFO *switchInfo);
280 BOOL visorchipset_get_externalport_info(ulong switchNo, ulong externalPortNo,
281 VISORCHIPSET_EXTERNALPORT_INFO
283 BOOL visorchipset_set_bus_context(ulong busNo, void *context);
284 BOOL visorchipset_set_device_context(ulong busNo, ulong devNo, void *context);
285 int visorchipset_chipset_ready(void);
286 int visorchipset_chipset_selftest(void);
287 int visorchipset_chipset_notready(void);
288 void visorchipset_controlvm_respond_reportEvent(CONTROLVM_MESSAGE *msg,
290 void visorchipset_save_message(CONTROLVM_MESSAGE *msg, CRASH_OBJ_TYPE type);
291 void *visorchipset_cache_alloc(struct kmem_cache *pool,
292 BOOL ok_to_block, char *fn, int ln);
293 void visorchipset_cache_free(struct kmem_cache *pool, void *p,
296 #if defined(TRANSMITFILE_DEBUG) || defined(DEBUG)
297 #define DBG_GETFILE_PAYLOAD(msg, controlvm_header) \
299 (ulong)controlvm_header.PayloadVmOffset, \
300 (ulong)controlvm_header.PayloadMaxBytes)
301 #define DBG_GETFILE(fmt, ...) LOGINF(fmt, ##__VA_ARGS__)
302 #define DBG_PUTFILE(fmt, ...) LOGINF(fmt, ##__VA_ARGS__)
304 #define DBG_GETFILE_PAYLOAD(msg, controlvm_header)
305 #define DBG_GETFILE(fmt, ...)
306 #define DBG_PUTFILE(fmt, ...)