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.
34 struct visorchipset_state {
39 /* Add new fields above. */
40 /* Remaining bits in this 32-bit word are unused. */
43 enum visorchipset_addresstype {
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.
61 /** Attributes for a particular Supervisor channel.
63 struct visorchipset_channel_info {
64 enum visorchipset_addresstype addr_type;
65 HOSTADDRESS channel_addr;
68 uuid_le channel_type_uuid;
69 uuid_le channel_inst_uuid;
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().
78 struct visorchipset_device_info {
79 struct list_head entry;
82 uuid_le dev_inst_uuid;
83 struct visorchipset_state state;
84 struct visorchipset_channel_info chan_info;
85 u32 reserved1; /* control_vm_id */
87 u32 switch_no; /* when devState.attached==1 */
88 u32 internal_port_no; /* when devState.attached==1 */
89 struct controlvm_message_header pending_msg_hdr;/* CONTROLVM_MESSAGE */
90 /** For private use by the bus driver */
91 void *bus_driver_context;
95 static inline struct visorchipset_device_info *finddevice(
96 struct list_head *list, u32 bus_no, u32 dev_no)
98 struct visorchipset_device_info *p;
100 list_for_each_entry(p, list, entry) {
101 if (p->bus_no == bus_no && p->dev_no == dev_no)
107 static inline void delbusdevices(struct list_head *list, u32 bus_no)
109 struct visorchipset_device_info *p, *tmp;
111 list_for_each_entry_safe(p, tmp, list, entry) {
112 if (p->bus_no == bus_no) {
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().
125 struct visorchipset_bus_info {
126 struct list_head entry;
128 struct visorchipset_state state;
129 struct visorchipset_channel_info chan_info;
130 uuid_le partition_uuid;
131 u64 partition_handle;
133 u8 *description; /* UTF8 */
138 /* Add new fields above. */
139 /* Remaining bits in this 32-bit word are unused. */
141 struct controlvm_message_header pending_msg_hdr;/* CONTROLVM MsgHdr */
142 /** For private use by the bus driver */
143 void *bus_driver_context;
148 static inline struct visorchipset_bus_info *
149 findbus(struct list_head *list, u32 bus_no)
151 struct visorchipset_bus_info *p;
153 list_for_each_entry(p, list, entry) {
154 if (p->bus_no == bus_no)
160 /* These functions will be called from within visorchipset when certain
161 * events happen. (The implementation of these functions is outside of
164 struct visorchipset_busdev_notifiers {
165 void (*bus_create)(ulong bus_no);
166 void (*bus_destroy)(ulong bus_no);
167 void (*device_create)(ulong bus_no, ulong dev_no);
168 void (*device_destroy)(ulong bus_no, ulong dev_no);
169 void (*device_pause)(ulong bus_no, ulong dev_no);
170 void (*device_resume)(ulong bus_no, ulong dev_no);
171 int (*get_channel_info)(uuid_le type_uuid, ulong *min_size,
175 /* These functions live inside visorchipset, and will be called to indicate
176 * responses to specific events (by code outside of visorchipset).
177 * For now, the value for each response is simply either:
181 struct visorchipset_busdev_responders {
182 void (*bus_create)(ulong bus_no, int response);
183 void (*bus_destroy)(ulong bus_no, int response);
184 void (*device_create)(ulong bus_no, ulong dev_no, int response);
185 void (*device_destroy)(ulong bus_no, ulong dev_no, int response);
186 void (*device_pause)(ulong bus_no, ulong dev_no, int response);
187 void (*device_resume)(ulong bus_no, ulong dev_no, int response);
190 /** Register functions (in the bus driver) to get called by visorchipset
191 * whenever a bus or device appears for which this service partition is
192 * to be the server for. visorchipset will fill in <responders>, to
193 * indicate functions the bus driver should call to indicate message
197 visorchipset_register_busdev_client(
198 struct visorchipset_busdev_notifiers *notifiers,
199 struct visorchipset_busdev_responders *responders,
200 struct ultra_vbus_deviceinfo *driver_info);
202 /** Register functions (in the bus driver) to get called by visorchipset
203 * whenever a bus or device appears for which this service partition is
204 * to be the client for. visorchipset will fill in <responders>, to
205 * indicate functions the bus driver should call to indicate message
209 visorchipset_register_busdev_server(
210 struct visorchipset_busdev_notifiers *notifiers,
211 struct visorchipset_busdev_responders *responders,
212 struct ultra_vbus_deviceinfo *driver_info);
214 typedef void (*SPARREPORTEVENT_COMPLETE_FUNC) (struct controlvm_message *msg,
217 void visorchipset_device_pause_response(ulong bus_no, ulong dev_no,
220 BOOL visorchipset_get_bus_info(ulong bus_no,
221 struct visorchipset_bus_info *bus_info);
222 BOOL visorchipset_get_device_info(ulong bus_no, ulong dev_no,
223 struct visorchipset_device_info *dev_info);
224 BOOL visorchipset_set_bus_context(ulong bus_no, void *context);
225 BOOL visorchipset_set_device_context(ulong bus_no, ulong dev_no, void *context);
226 int visorchipset_chipset_ready(void);
227 int visorchipset_chipset_selftest(void);
228 int visorchipset_chipset_notready(void);
229 void visorchipset_save_message(struct controlvm_message *msg,
230 enum crash_obj_type type);
231 void *visorchipset_cache_alloc(struct kmem_cache *pool,
232 BOOL ok_to_block, char *fn, int ln);
233 void visorchipset_cache_free(struct kmem_cache *pool, void *p,