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