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>
24 #include "controlvmchannel.h"
25 #include "vbusdeviceinfo.h"
26 #include "vbushelper.h"
30 enum visorchipset_addresstype {
31 /** address is guest physical, but outside of the physical memory
32 * region that is controlled by the running OS (this is the normal
33 * address type for Supervisor channels)
35 ADDRTYPE_LOCALPHYSICAL,
37 /** address is guest physical, and withIN the confines of the
38 * physical memory controlled by the running OS.
43 /** Attributes for a particular Supervisor channel.
45 struct visorchipset_channel_info {
46 enum visorchipset_addresstype addr_type;
50 uuid_le channel_type_uuid;
51 uuid_le channel_inst_uuid;
54 /** Attributes for a particular Supervisor device.
55 * Any visorchipset client can query these attributes using
56 * visorchipset_get_client_device_info() or
57 * visorchipset_get_server_device_info().
59 struct visorchipset_device_info {
60 struct list_head entry;
63 uuid_le dev_inst_uuid;
64 struct visorchipset_state state;
65 struct visorchipset_channel_info chan_info;
66 u32 reserved1; /* control_vm_id */
68 u32 switch_no; /* when devState.attached==1 */
69 u32 internal_port_no; /* when devState.attached==1 */
70 struct controlvm_message_header pending_msg_hdr;/* CONTROLVM_MESSAGE */
71 /** For private use by the bus driver */
72 void *bus_driver_context;
75 /** Attributes for a particular Supervisor bus.
76 * (For a service partition acting as the server for buses/devices, there
77 * is a 1-to-1 relationship between busses and guest partitions.)
78 * Any visorchipset client can query these attributes using
79 * visorchipset_get_client_bus_info() or visorchipset_get_bus_info().
81 struct visorchipset_bus_info {
82 struct list_head entry;
84 struct visorchipset_state state;
85 struct visorchipset_channel_info chan_info;
86 uuid_le partition_uuid;
89 u8 *description; /* UTF8 */
94 /* Add new fields above. */
95 /* Remaining bits in this 32-bit word are unused. */
97 struct controlvm_message_header pending_msg_hdr;/* CONTROLVM MsgHdr */
98 /** For private use by the bus driver */
99 void *bus_driver_context;
102 /* These functions will be called from within visorchipset when certain
103 * events happen. (The implementation of these functions is outside of
106 struct visorchipset_busdev_notifiers {
107 void (*bus_create)(struct visorchipset_bus_info *bus_info);
108 void (*bus_destroy)(struct visorchipset_bus_info *bus_info);
109 void (*device_create)(struct visorchipset_device_info *bus_info);
110 void (*device_destroy)(struct visorchipset_device_info *bus_info);
111 void (*device_pause)(struct visorchipset_device_info *bus_info);
112 void (*device_resume)(struct visorchipset_device_info *bus_info);
115 /* These functions live inside visorchipset, and will be called to indicate
116 * responses to specific events (by code outside of visorchipset).
117 * For now, the value for each response is simply either:
121 struct visorchipset_busdev_responders {
122 void (*bus_create)(struct visorchipset_bus_info *p, int response);
123 void (*bus_destroy)(struct visorchipset_bus_info *p, int response);
124 void (*device_create)(struct visorchipset_device_info *p, int response);
125 void (*device_destroy)(struct visorchipset_device_info *p,
127 void (*device_pause)(struct visorchipset_device_info *p, int response);
128 void (*device_resume)(struct visorchipset_device_info *p, int response);
131 /** Register functions (in the bus driver) to get called by visorchipset
132 * whenever a bus or device appears for which this guest is to be the
133 * client for. visorchipset will fill in <responders>, to indicate
134 * functions the bus driver should call to indicate message responses.
137 visorchipset_register_busdev(
138 struct visorchipset_busdev_notifiers *notifiers,
139 struct visorchipset_busdev_responders *responders,
140 struct ultra_vbus_deviceinfo *driver_info);
142 bool visorchipset_get_bus_info(u32 bus_no,
143 struct visorchipset_bus_info *bus_info);
144 bool visorchipset_get_device_info(u32 bus_no, u32 dev_no,
145 struct visorchipset_device_info *dev_info);
146 bool visorchipset_set_bus_context(struct visorchipset_bus_info *bus_info,
149 /* visorbus init and exit functions */
150 int visorbus_init(void);
151 void visorbus_exit(void);