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