]>
Commit | Line | Data |
---|---|---|
12e364b9 KC |
1 | /* visorchipset.h |
2 | * | |
f6d0c1e6 | 3 | * Copyright (C) 2010 - 2013 UNISYS CORPORATION |
12e364b9 KC |
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 | ||
90addb02 BR |
21 | #include <linux/uuid.h> |
22 | ||
12e364b9 KC |
23 | #include "timskmod.h" |
24 | #include "channel.h" | |
25 | #include "controlvmchannel.h" | |
26 | #include "parser.h" | |
27 | #include "procobjecttree.h" | |
28 | #include "vbusdeviceinfo.h" | |
29 | #include "vbushelper.h" | |
30 | ||
31 | /** Describes the state from the perspective of which controlvm messages have | |
32 | * been received for a bus or device. | |
33 | */ | |
37951dab | 34 | struct visorchipset_state { |
b3c55b13 BR |
35 | u32 created:1; |
36 | u32 attached:1; | |
37 | u32 configured:1; | |
38 | u32 running:1; | |
12e364b9 KC |
39 | /* Add new fields above. */ |
40 | /* Remaining bits in this 32-bit word are unused. */ | |
37951dab | 41 | }; |
12e364b9 | 42 | |
6fb23e18 | 43 | enum visorchipset_addresstype { |
12e364b9 KC |
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) | |
47 | */ | |
6fb23e18 | 48 | ADDRTYPE_LOCALPHYSICAL, |
12e364b9 KC |
49 | |
50 | /** address is guest physical, and withIN the confines of the | |
51 | * physical memory controlled by the running OS. | |
52 | */ | |
6fb23e18 BR |
53 | ADDRTYPE_LOCALTEST, |
54 | }; | |
12e364b9 | 55 | |
2c683cde BR |
56 | enum crash_obj_type { |
57 | CRASH_DEV, | |
58 | CRASH_BUS, | |
59 | }; | |
12e364b9 KC |
60 | |
61 | /** Attributes for a particular Supervisor channel. | |
62 | */ | |
9b1caee7 BR |
63 | struct visorchipset_channel_info { |
64 | enum visorchipset_addresstype addr_type; | |
65 | HOSTADDRESS channel_addr; | |
4eddbf13 | 66 | struct irq_info intr; |
9b1caee7 BR |
67 | u64 n_channel_bytes; |
68 | uuid_le channel_type_uuid; | |
69 | uuid_le channel_inst_uuid; | |
12e364b9 | 70 | |
9b1caee7 | 71 | }; |
12e364b9 KC |
72 | |
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(). | |
77 | */ | |
246e0cd0 | 78 | struct visorchipset_device_info { |
12e364b9 | 79 | struct list_head entry; |
246e0cd0 BR |
80 | u32 bus_no; |
81 | u32 dev_no; | |
82 | uuid_le dev_inst_uuid; | |
37951dab | 83 | struct visorchipset_state state; |
246e0cd0 BR |
84 | struct visorchipset_channel_info chan_info; |
85 | u32 reserved1; /* control_vm_id */ | |
86 | u64 reserved2; | |
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 */ | |
12e364b9 KC |
90 | /** For private use by the bus driver */ |
91 | void *bus_driver_context; | |
92 | ||
246e0cd0 | 93 | }; |
12e364b9 | 94 | |
0a96ec72 BR |
95 | static inline struct visorchipset_device_info *finddevice( |
96 | struct list_head *list, u32 bus_no, u32 dev_no) | |
12e364b9 | 97 | { |
246e0cd0 | 98 | struct visorchipset_device_info *p; |
12e364b9 KC |
99 | |
100 | list_for_each_entry(p, list, entry) { | |
0a96ec72 | 101 | if (p->bus_no == bus_no && p->dev_no == dev_no) |
12e364b9 KC |
102 | return p; |
103 | } | |
104 | return NULL; | |
105 | } | |
106 | ||
8f67b5bc | 107 | static inline void delbusdevices(struct list_head *list, u32 bus_no) |
12e364b9 | 108 | { |
246e0cd0 | 109 | struct visorchipset_device_info *p, *tmp; |
12e364b9 | 110 | |
e6b1ea77 | 111 | list_for_each_entry_safe(p, tmp, list, entry) { |
8f67b5bc | 112 | if (p->bus_no == bus_no) { |
12e364b9 KC |
113 | list_del(&p->entry); |
114 | kfree(p); | |
115 | } | |
116 | } | |
117 | } | |
118 | ||
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(). | |
124 | */ | |
33192fa1 | 125 | struct visorchipset_bus_info { |
12e364b9 | 126 | struct list_head entry; |
33192fa1 | 127 | u32 bus_no; |
37951dab | 128 | struct visorchipset_state state; |
33192fa1 BR |
129 | struct visorchipset_channel_info chan_info; |
130 | uuid_le partition_uuid; | |
131 | u64 partition_handle; | |
c242233e BR |
132 | u8 *name; /* UTF8 */ |
133 | u8 *description; /* UTF8 */ | |
33192fa1 BR |
134 | u64 reserved1; |
135 | u32 reserved2; | |
12e364b9 | 136 | struct { |
b3c55b13 | 137 | u32 server:1; |
12e364b9 KC |
138 | /* Add new fields above. */ |
139 | /* Remaining bits in this 32-bit word are unused. */ | |
140 | } flags; | |
33192fa1 | 141 | struct controlvm_message_header pending_msg_hdr;/* CONTROLVM MsgHdr */ |
12e364b9 KC |
142 | /** For private use by the bus driver */ |
143 | void *bus_driver_context; | |
33192fa1 | 144 | u64 dev_no; |
12e364b9 | 145 | |
33192fa1 | 146 | }; |
12e364b9 | 147 | |
33192fa1 | 148 | static inline struct visorchipset_bus_info * |
b4d55e39 | 149 | findbus(struct list_head *list, u32 bus_no) |
12e364b9 | 150 | { |
33192fa1 | 151 | struct visorchipset_bus_info *p; |
12e364b9 KC |
152 | |
153 | list_for_each_entry(p, list, entry) { | |
b4d55e39 | 154 | if (p->bus_no == bus_no) |
12e364b9 KC |
155 | return p; |
156 | } | |
157 | return NULL; | |
158 | } | |
159 | ||
12e364b9 KC |
160 | /* These functions will be called from within visorchipset when certain |
161 | * events happen. (The implementation of these functions is outside of | |
162 | * visorchipset.) | |
163 | */ | |
fe90d892 BR |
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, | |
172 | ulong *max_size); | |
173 | }; | |
12e364b9 KC |
174 | |
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: | |
178 | * 0 = it worked | |
179 | * -1 = it failed | |
180 | */ | |
929aa8ae BR |
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); | |
188 | }; | |
12e364b9 KC |
189 | |
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 | |
194 | * responses. | |
195 | */ | |
196 | void | |
fe90d892 BR |
197 | visorchipset_register_busdev_client( |
198 | struct visorchipset_busdev_notifiers *notifiers, | |
929aa8ae | 199 | struct visorchipset_busdev_responders *responders, |
43fce019 | 200 | struct ultra_vbus_deviceinfo *driver_info); |
12e364b9 KC |
201 | |
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 | |
206 | * responses. | |
207 | */ | |
208 | void | |
fe90d892 BR |
209 | visorchipset_register_busdev_server( |
210 | struct visorchipset_busdev_notifiers *notifiers, | |
929aa8ae | 211 | struct visorchipset_busdev_responders *responders, |
1e7a59c1 | 212 | struct ultra_vbus_deviceinfo *driver_info); |
12e364b9 | 213 | |
3ab47701 | 214 | typedef void (*SPARREPORTEVENT_COMPLETE_FUNC) (struct controlvm_message *msg, |
12e364b9 KC |
215 | int status); |
216 | ||
8420f417 BR |
217 | void visorchipset_device_pause_response(ulong bus_no, ulong dev_no, |
218 | int response); | |
12e364b9 | 219 | |
77db7127 BR |
220 | BOOL visorchipset_get_bus_info(ulong bus_no, |
221 | struct visorchipset_bus_info *bus_info); | |
b486df19 BR |
222 | BOOL visorchipset_get_device_info(ulong bus_no, ulong dev_no, |
223 | struct visorchipset_device_info *dev_info); | |
58dd8f2d | 224 | BOOL visorchipset_set_bus_context(ulong bus_no, void *context); |
cf0bd0b5 | 225 | BOOL visorchipset_set_device_context(ulong bus_no, ulong dev_no, void *context); |
12e364b9 KC |
226 | int visorchipset_chipset_ready(void); |
227 | int visorchipset_chipset_selftest(void); | |
228 | int visorchipset_chipset_notready(void); | |
3ab47701 | 229 | void visorchipset_save_message(struct controlvm_message *msg, |
2c683cde | 230 | enum crash_obj_type type); |
12e364b9 KC |
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, | |
234 | char *fn, int ln); | |
235 | ||
12e364b9 | 236 | #endif |