Commit | Line | Data |
---|---|---|
12a16f2d AP |
1 | \r |
2 | /** @file\r | |
3 | XenBus protocol to be used between the XenBus bus driver and Xen PV devices.\r | |
4 | \r | |
5 | DISCLAIMER: the XENBUS_PROTOCOL introduced here is a work in progress, and\r | |
6 | should not be used outside of the EDK II tree.\r | |
7 | \r | |
8 | This protocol provide the necessary for a Xen PV driver frontend to\r | |
9 | communicate with the bus driver, and perform several task to\r | |
10 | initialize/shutdown a PV device and perform IO with a PV backend.\r | |
11 | \r | |
12 | Copyright (C) 2014, Citrix Ltd.\r | |
13 | \r | |
14 | This program and the accompanying materials\r | |
15 | are licensed and made available under the terms and conditions of the BSD License\r | |
16 | which accompanies this distribution. The full text of the license may be found at\r | |
17 | http://opensource.org/licenses/bsd-license.php\r | |
18 | \r | |
19 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
20 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
21 | \r | |
22 | **/\r | |
23 | \r | |
24 | #ifndef __PROTOCOL_XENBUS_H__\r | |
25 | #define __PROTOCOL_XENBUS_H__\r | |
26 | \r | |
27 | #define XENBUS_PROTOCOL_GUID \\r | |
28 | {0x3d3ca290, 0xb9a5, 0x11e3, {0xb7, 0x5d, 0xb8, 0xac, 0x6f, 0x7d, 0x65, 0xe6}}\r | |
29 | \r | |
30 | ///\r | |
31 | /// Forward declaration\r | |
32 | ///\r | |
33 | typedef struct _XENBUS_PROTOCOL XENBUS_PROTOCOL;\r | |
34 | \r | |
a9090a94 AP |
35 | typedef enum xenbus_state XenBusState;\r |
36 | \r | |
37 | typedef struct\r | |
38 | {\r | |
39 | UINT32 Id;\r | |
40 | } XENSTORE_TRANSACTION;\r | |
41 | \r | |
e26a83cd | 42 | #define XST_NIL ((XENSTORE_TRANSACTION *) NULL)\r |
a9090a94 AP |
43 | \r |
44 | typedef enum {\r | |
45 | XENSTORE_STATUS_SUCCESS = 0,\r | |
46 | XENSTORE_STATUS_FAIL,\r | |
47 | XENSTORE_STATUS_EINVAL,\r | |
48 | XENSTORE_STATUS_EACCES,\r | |
49 | XENSTORE_STATUS_EEXIST,\r | |
50 | XENSTORE_STATUS_EISDIR,\r | |
51 | XENSTORE_STATUS_ENOENT,\r | |
52 | XENSTORE_STATUS_ENOMEM,\r | |
53 | XENSTORE_STATUS_ENOSPC,\r | |
54 | XENSTORE_STATUS_EIO,\r | |
55 | XENSTORE_STATUS_ENOTEMPTY,\r | |
56 | XENSTORE_STATUS_ENOSYS,\r | |
57 | XENSTORE_STATUS_EROFS,\r | |
58 | XENSTORE_STATUS_EBUSY,\r | |
59 | XENSTORE_STATUS_EAGAIN,\r | |
60 | XENSTORE_STATUS_EISCONN,\r | |
61 | XENSTORE_STATUS_E2BIG\r | |
62 | } XENSTORE_STATUS;\r | |
63 | \r | |
12a16f2d AP |
64 | \r |
65 | #include <IndustryStandard/Xen/grant_table.h>\r | |
e86895d9 | 66 | #include <IndustryStandard/Xen/event_channel.h>\r |
12a16f2d AP |
67 | \r |
68 | ///\r | |
69 | /// Function prototypes\r | |
70 | ///\r | |
71 | \r | |
c23c037f AP |
72 | /**\r |
73 | Get the contents of the node Node of the PV device. Returns the contents in\r | |
74 | *Result which should be freed after use.\r | |
75 | \r | |
76 | @param This A pointer to XENBUS_PROTOCOL instance.\r | |
77 | @param Transaction The XenStore transaction covering this request.\r | |
78 | @param Node The basename of the file to read.\r | |
79 | @param Result The returned contents from this file.\r | |
80 | \r | |
81 | @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r | |
82 | indicating the type of failure.\r | |
83 | \r | |
84 | @note The results buffer is malloced and should be free'd by the\r | |
85 | caller.\r | |
86 | **/\r | |
87 | typedef\r | |
88 | XENSTORE_STATUS\r | |
89 | (EFIAPI *XENBUS_XS_READ)(\r | |
90 | IN XENBUS_PROTOCOL *This,\r | |
e26a83cd | 91 | IN CONST XENSTORE_TRANSACTION *Transaction,\r |
c23c037f AP |
92 | IN CONST CHAR8 *Node,\r |
93 | OUT VOID **Result\r | |
94 | );\r | |
95 | \r | |
96 | /**\r | |
97 | Get the contents of the node Node of the PV device's backend. Returns the\r | |
98 | contents in *Result which should be freed after use.\r | |
99 | \r | |
100 | @param This A pointer to XENBUS_PROTOCOL instance.\r | |
101 | @param Transaction The XenStore transaction covering this request.\r | |
102 | @param Node The basename of the file to read.\r | |
103 | @param Result The returned contents from this file.\r | |
104 | \r | |
105 | @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r | |
106 | indicating the type of failure.\r | |
107 | \r | |
108 | @note The results buffer is malloced and should be free'd by the\r | |
109 | caller.\r | |
110 | **/\r | |
111 | typedef\r | |
112 | XENSTORE_STATUS\r | |
113 | (EFIAPI *XENBUS_XS_BACKEND_READ)(\r | |
114 | IN XENBUS_PROTOCOL *This,\r | |
e26a83cd | 115 | IN CONST XENSTORE_TRANSACTION *Transaction,\r |
c23c037f AP |
116 | IN CONST CHAR8 *Node,\r |
117 | OUT VOID **Result\r | |
118 | );\r | |
119 | \r | |
120 | /**\r | |
121 | Print formatted write to a XenStore node.\r | |
122 | \r | |
123 | @param This A pointer to XENBUS_PROTOCOL instance.\r | |
124 | @param Transaction The XenStore transaction covering this request.\r | |
125 | @param Directory The dirname of the path to read.\r | |
126 | @param Node The basename of the path to read.\r | |
127 | @param Format AsciiSPrint format string followed by a variable number\r | |
128 | of arguments.\r | |
129 | \r | |
130 | @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r | |
131 | indicating the type of write failure.\r | |
132 | **/\r | |
133 | typedef\r | |
134 | XENSTORE_STATUS\r | |
135 | (EFIAPI *XENBUS_XS_PRINTF) (\r | |
136 | IN XENBUS_PROTOCOL *This,\r | |
e26a83cd | 137 | IN CONST XENSTORE_TRANSACTION *Transaction,\r |
c23c037f AP |
138 | IN CONST CHAR8 *Directory,\r |
139 | IN CONST CHAR8 *Node,\r | |
140 | IN CONST CHAR8 *Format,\r | |
141 | ...\r | |
142 | );\r | |
143 | \r | |
144 | /**\r | |
145 | Remove a node or directory (directories must be empty) of the PV driver's\r | |
146 | subdirectory.\r | |
147 | \r | |
148 | @param This A pointer to XENBUS_PROTOCOL instance.\r | |
149 | @param Transaction The XenStore transaction covering this request.\r | |
150 | @param Node The basename of the node to remove.\r | |
151 | \r | |
152 | @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r | |
153 | indicating the type of failure.\r | |
154 | **/\r | |
155 | typedef\r | |
156 | XENSTORE_STATUS\r | |
157 | (EFIAPI *XENBUS_XS_REMOVE) (\r | |
158 | IN XENBUS_PROTOCOL *This,\r | |
e26a83cd | 159 | IN CONST XENSTORE_TRANSACTION *Transaction,\r |
c23c037f AP |
160 | IN CONST CHAR8 *Node\r |
161 | );\r | |
162 | \r | |
163 | /**\r | |
164 | Start a transaction.\r | |
165 | \r | |
166 | Changes by others will not be seen during the lifetime of this\r | |
167 | transaction, and changes will not be visible to others until it\r | |
168 | is committed (XsTransactionEnd).\r | |
169 | \r | |
170 | @param This A pointer to XENBUS_PROTOCOL instance.\r | |
171 | @param Transaction The returned transaction.\r | |
172 | \r | |
173 | @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r | |
174 | indicating the type of failure.\r | |
175 | **/\r | |
176 | typedef\r | |
177 | XENSTORE_STATUS\r | |
178 | (EFIAPI *XENBUS_XS_TRANSACTION_START)(\r | |
179 | IN XENBUS_PROTOCOL *This,\r | |
180 | OUT XENSTORE_TRANSACTION *Transaction\r | |
181 | );\r | |
182 | \r | |
183 | /**\r | |
184 | End a transaction.\r | |
185 | \r | |
186 | @param This A pointer to XENBUS_PROTOCOL instance.\r | |
187 | @param Transaction The transaction to end/commit.\r | |
188 | @param Abort If TRUE, the transaction is discarded\r | |
189 | instead of committed.\r | |
190 | \r | |
191 | @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r | |
192 | indicating the type of failure.\r | |
193 | **/\r | |
194 | typedef\r | |
195 | XENSTORE_STATUS\r | |
196 | (EFIAPI *XENBUS_XS_TRANSACTION_END) (\r | |
197 | IN XENBUS_PROTOCOL *This,\r | |
e26a83cd | 198 | IN CONST XENSTORE_TRANSACTION *Transaction,\r |
c23c037f AP |
199 | IN BOOLEAN Abort\r |
200 | );\r | |
201 | \r | |
86d968e0 AP |
202 | /**\r |
203 | Set a new state for the frontend of the PV driver.\r | |
204 | \r | |
205 | @param This A pointer to XENBUS_PROTOCOL instance.\r | |
206 | @param Transaction The transaction to end/commit.\r | |
207 | @param State The new state to apply.\r | |
208 | \r | |
209 | @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r | |
210 | indicating the type of failure.\r | |
211 | **/\r | |
212 | typedef\r | |
213 | XENSTORE_STATUS\r | |
214 | (EFIAPI *XENBUS_SET_STATE)(\r | |
215 | IN XENBUS_PROTOCOL *This,\r | |
e26a83cd | 216 | IN CONST XENSTORE_TRANSACTION *Transaction,\r |
86d968e0 AP |
217 | IN XenBusState State\r |
218 | );\r | |
219 | \r | |
12a16f2d AP |
220 | /**\r |
221 | Grant access to the page Frame to the domain DomainId.\r | |
222 | \r | |
223 | @param This A pointer to XENBUS_PROTOCOL instance.\r | |
224 | @param DomainId ID of the domain to grant acces to.\r | |
225 | @param Frame Frame Number of the page to grant access to.\r | |
226 | @param ReadOnly Provide read-only or read-write access.\r | |
b6b33f67 | 227 | @param RefPtr Reference number of the grant will be written to this pointer.\r |
12a16f2d AP |
228 | **/\r |
229 | typedef\r | |
230 | EFI_STATUS\r | |
231 | (EFIAPI *XENBUS_GRANT_ACCESS)(\r | |
232 | IN XENBUS_PROTOCOL *This,\r | |
233 | IN domid_t DomainId,\r | |
234 | IN UINTN Frame,\r | |
235 | IN BOOLEAN ReadOnly,\r | |
236 | OUT grant_ref_t *refp\r | |
237 | );\r | |
238 | \r | |
239 | /**\r | |
240 | End access to grant Ref, previously return by XenBusGrantAccess.\r | |
241 | \r | |
242 | @param This A pointer to XENBUS_PROTOCOL instance.\r | |
243 | @param Ref Reference numeber of a grant previously returned by\r | |
244 | XenBusGrantAccess.\r | |
245 | **/\r | |
246 | typedef\r | |
247 | EFI_STATUS\r | |
248 | (EFIAPI *XENBUS_GRANT_END_ACCESS)(\r | |
249 | IN XENBUS_PROTOCOL *This,\r | |
250 | IN grant_ref_t Ref\r | |
251 | );\r | |
252 | \r | |
e86895d9 AP |
253 | /**\r |
254 | Allocate a port that can be bind from domain DomainId.\r | |
255 | \r | |
256 | @param This A pointer to the XENBUS_PROTOCOL.\r | |
257 | @param DomainId The domain ID that can bind the newly allocated port.\r | |
258 | @param Port A pointer to a evtchn_port_t that will contain the newly\r | |
259 | allocated port.\r | |
260 | \r | |
261 | @retval UINT32 The return value from the hypercall, 0 if success.\r | |
262 | **/\r | |
263 | typedef\r | |
264 | UINT32\r | |
265 | (EFIAPI *XENBUS_EVENT_CHANNEL_ALLOCATE) (\r | |
266 | IN XENBUS_PROTOCOL *This,\r | |
267 | IN domid_t DomainId,\r | |
268 | OUT evtchn_port_t *Port\r | |
269 | );\r | |
270 | \r | |
271 | /**\r | |
272 | Send an event to the remote end of the channel whose local endpoint is Port.\r | |
273 | \r | |
274 | @param This A pointer to the XENBUS_PROTOCOL.\r | |
275 | @param Port Local port to the the event from.\r | |
276 | \r | |
277 | @retval UINT32 The return value from the hypercall, 0 if success.\r | |
278 | **/\r | |
279 | typedef\r | |
280 | UINT32\r | |
281 | (EFIAPI *XENBUS_EVENT_CHANNEL_NOTIFY) (\r | |
282 | IN XENBUS_PROTOCOL *This,\r | |
283 | IN evtchn_port_t Port\r | |
284 | );\r | |
285 | \r | |
286 | /**\r | |
287 | Close a local event channel Port.\r | |
288 | \r | |
289 | @param This A pointer to the XENBUS_PROTOCOL.\r | |
290 | @param Port The event channel to close.\r | |
291 | \r | |
292 | @retval UINT32 The return value from the hypercall, 0 if success.\r | |
293 | **/\r | |
294 | typedef\r | |
295 | UINT32\r | |
296 | (EFIAPI *XENBUS_EVENT_CHANNEL_CLOSE) (\r | |
297 | IN XENBUS_PROTOCOL *This,\r | |
298 | IN evtchn_port_t Port\r | |
299 | );\r | |
300 | \r | |
c23c037f AP |
301 | /**\r |
302 | Register a XenStore watch.\r | |
303 | \r | |
304 | XenStore watches allow a client to wait for changes to an object in the\r | |
305 | XenStore.\r | |
306 | \r | |
307 | @param This A pointer to the XENBUS_PROTOCOL.\r | |
308 | @param Node The basename of the path to watch.\r | |
309 | @param Token A token.\r | |
310 | \r | |
311 | @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r | |
312 | indicating the type of write failure. EEXIST errors from the\r | |
b6b33f67 | 313 | XenStore are suppressed, allowing multiple, physically different,\r |
c23c037f AP |
314 | xenbus_watch objects, to watch the same path in the XenStore.\r |
315 | **/\r | |
316 | typedef\r | |
317 | XENSTORE_STATUS\r | |
318 | (EFIAPI *XENBUS_REGISTER_WATCH) (\r | |
319 | IN XENBUS_PROTOCOL *This,\r | |
320 | IN CONST CHAR8 *Node,\r | |
321 | OUT VOID **Token\r | |
322 | );\r | |
323 | \r | |
324 | /**\r | |
325 | Register a XenStore watch on a backend's node.\r | |
326 | \r | |
327 | XenStore watches allow a client to wait for changes to an object in the\r | |
328 | XenStore.\r | |
329 | \r | |
330 | @param This A pointer to the XENBUS_PROTOCOL.\r | |
331 | @param Node The basename of the path to watch.\r | |
332 | @param Token A token.\r | |
333 | \r | |
334 | @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r | |
335 | indicating the type of write failure. EEXIST errors from the\r | |
b6b33f67 | 336 | XenStore are suppressed, allowing multiple, physically different,\r |
c23c037f AP |
337 | xenbus_watch objects, to watch the same path in the XenStore.\r |
338 | **/\r | |
339 | typedef\r | |
340 | XENSTORE_STATUS\r | |
341 | (EFIAPI *XENBUS_REGISTER_WATCH_BACKEND) (\r | |
342 | IN XENBUS_PROTOCOL *This,\r | |
343 | IN CONST CHAR8 *Node,\r | |
344 | OUT VOID **Token\r | |
345 | );\r | |
346 | \r | |
347 | /**\r | |
348 | Unregister a XenStore watch.\r | |
349 | \r | |
350 | @param This A pointer to the XENBUS_PROTOCOL.\r | |
351 | @param Token An token previously returned by a successful\r | |
352 | call to RegisterWatch ().\r | |
353 | **/\r | |
354 | typedef\r | |
355 | VOID\r | |
356 | (EFIAPI *XENBUS_UNREGISTER_WATCH) (\r | |
357 | IN XENBUS_PROTOCOL *This,\r | |
358 | IN VOID *Token\r | |
359 | );\r | |
360 | \r | |
361 | /**\r | |
362 | Block until the node watch by Token change.\r | |
363 | \r | |
364 | @param This A pointer to the XENBUS_PROTOCOL.\r | |
365 | @param Token An token previously returned by a successful\r | |
366 | call to RegisterWatch or RegisterWatchBackend.\r | |
367 | \r | |
368 | @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r | |
369 | indicating the type of failure.\r | |
370 | **/\r | |
371 | typedef\r | |
372 | XENSTORE_STATUS\r | |
373 | (EFIAPI *XENBUS_WAIT_FOR_WATCH) (\r | |
374 | IN XENBUS_PROTOCOL *This,\r | |
375 | IN VOID *Token\r | |
376 | );\r | |
377 | \r | |
12a16f2d AP |
378 | \r |
379 | ///\r | |
380 | /// Protocol structure\r | |
381 | ///\r | |
382 | /// DISCLAIMER: the XENBUS_PROTOCOL introduced here is a work in progress, and\r | |
383 | /// should not be used outside of the EDK II tree.\r | |
384 | ///\r | |
385 | struct _XENBUS_PROTOCOL {\r | |
c23c037f AP |
386 | XENBUS_XS_READ XsRead;\r |
387 | XENBUS_XS_BACKEND_READ XsBackendRead;\r | |
388 | XENBUS_XS_PRINTF XsPrintf;\r | |
389 | XENBUS_XS_REMOVE XsRemove;\r | |
390 | XENBUS_XS_TRANSACTION_START XsTransactionStart;\r | |
391 | XENBUS_XS_TRANSACTION_END XsTransactionEnd;\r | |
86d968e0 | 392 | XENBUS_SET_STATE SetState;\r |
c23c037f | 393 | \r |
12a16f2d AP |
394 | XENBUS_GRANT_ACCESS GrantAccess;\r |
395 | XENBUS_GRANT_END_ACCESS GrantEndAccess;\r | |
c23c037f | 396 | \r |
e86895d9 AP |
397 | XENBUS_EVENT_CHANNEL_ALLOCATE EventChannelAllocate;\r |
398 | XENBUS_EVENT_CHANNEL_NOTIFY EventChannelNotify;\r | |
399 | XENBUS_EVENT_CHANNEL_CLOSE EventChannelClose;\r | |
400 | \r | |
c23c037f AP |
401 | XENBUS_REGISTER_WATCH RegisterWatch;\r |
402 | XENBUS_REGISTER_WATCH_BACKEND RegisterWatchBackend;\r | |
403 | XENBUS_UNREGISTER_WATCH UnregisterWatch;\r | |
404 | XENBUS_WAIT_FOR_WATCH WaitForWatch;\r | |
12a16f2d AP |
405 | //\r |
406 | // Protocol data fields\r | |
407 | //\r | |
c23c037f AP |
408 | CONST CHAR8 *Type;\r |
409 | UINT16 DeviceId;\r | |
410 | CONST CHAR8 *Node;\r | |
411 | CONST CHAR8 *Backend;\r | |
12a16f2d AP |
412 | };\r |
413 | \r | |
414 | extern EFI_GUID gXenBusProtocolGuid;\r | |
415 | \r | |
416 | #endif\r |