2 XenBus protocol to be used between the XenBus bus driver and Xen PV devices.
4 DISCLAIMER: the XENBUS_PROTOCOL introduced here is a work in progress, and
5 should not be used outside of the EDK II tree.
7 This protocol provide the necessary for a Xen PV driver frontend to
8 communicate with the bus driver, and perform several task to
9 initialize/shutdown a PV device and perform IO with a PV backend.
11 Copyright (C) 2014, Citrix Ltd.
13 SPDX-License-Identifier: BSD-2-Clause-Patent
17 #ifndef __PROTOCOL_XENBUS_H__
18 #define __PROTOCOL_XENBUS_H__
20 #define XENBUS_PROTOCOL_GUID \
21 {0x3d3ca290, 0xb9a5, 0x11e3, {0xb7, 0x5d, 0xb8, 0xac, 0x6f, 0x7d, 0x65, 0xe6}}
24 /// Forward declaration
26 typedef struct _XENBUS_PROTOCOL XENBUS_PROTOCOL
;
28 typedef enum xenbus_state XenBusState
;
32 } XENSTORE_TRANSACTION
;
34 #define XST_NIL ((XENSTORE_TRANSACTION *) NULL)
37 XENSTORE_STATUS_SUCCESS
= 0,
39 XENSTORE_STATUS_EINVAL
,
40 XENSTORE_STATUS_EACCES
,
41 XENSTORE_STATUS_EEXIST
,
42 XENSTORE_STATUS_EISDIR
,
43 XENSTORE_STATUS_ENOENT
,
44 XENSTORE_STATUS_ENOMEM
,
45 XENSTORE_STATUS_ENOSPC
,
47 XENSTORE_STATUS_ENOTEMPTY
,
48 XENSTORE_STATUS_ENOSYS
,
49 XENSTORE_STATUS_EROFS
,
50 XENSTORE_STATUS_EBUSY
,
51 XENSTORE_STATUS_EAGAIN
,
52 XENSTORE_STATUS_EISCONN
,
56 #include <IndustryStandard/Xen/grant_table.h>
57 #include <IndustryStandard/Xen/event_channel.h>
60 /// Function prototypes
64 Get the contents of the node Node of the PV device. Returns the contents in
65 *Result which should be freed after use.
67 @param This A pointer to XENBUS_PROTOCOL instance.
68 @param Transaction The XenStore transaction covering this request.
69 @param Node The basename of the file to read.
70 @param Result The returned contents from this file.
72 @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value
73 indicating the type of failure.
75 @note The results buffer is malloced and should be free'd by the
80 (EFIAPI
*XENBUS_XS_READ
)(
81 IN XENBUS_PROTOCOL
*This
,
82 IN CONST XENSTORE_TRANSACTION
*Transaction
,
88 Get the contents of the node Node of the PV device's backend. Returns the
89 contents in *Result which should be freed after use.
91 @param This A pointer to XENBUS_PROTOCOL instance.
92 @param Transaction The XenStore transaction covering this request.
93 @param Node The basename of the file to read.
94 @param Result The returned contents from this file.
96 @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value
97 indicating the type of failure.
99 @note The results buffer is malloced and should be free'd by the
104 (EFIAPI
*XENBUS_XS_BACKEND_READ
)(
105 IN XENBUS_PROTOCOL
*This
,
106 IN CONST XENSTORE_TRANSACTION
*Transaction
,
107 IN CONST CHAR8
*Node
,
112 Print formatted write to a XenStore node.
114 @param This A pointer to XENBUS_PROTOCOL instance.
115 @param Transaction The XenStore transaction covering this request.
116 @param Directory The dirname of the path to read.
117 @param Node The basename of the path to read.
118 @param Format AsciiSPrint format string followed by a variable number
121 @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value
122 indicating the type of write failure.
126 (EFIAPI
*XENBUS_XS_PRINTF
)(
127 IN XENBUS_PROTOCOL
*This
,
128 IN CONST XENSTORE_TRANSACTION
*Transaction
,
129 IN CONST CHAR8
*Directory
,
130 IN CONST CHAR8
*Node
,
131 IN CONST CHAR8
*Format
,
136 Remove a node or directory (directories must be empty) of the PV driver's
139 @param This A pointer to XENBUS_PROTOCOL instance.
140 @param Transaction The XenStore transaction covering this request.
141 @param Node The basename of the node to remove.
143 @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value
144 indicating the type of failure.
148 (EFIAPI
*XENBUS_XS_REMOVE
)(
149 IN XENBUS_PROTOCOL
*This
,
150 IN CONST XENSTORE_TRANSACTION
*Transaction
,
157 Changes by others will not be seen during the lifetime of this
158 transaction, and changes will not be visible to others until it
159 is committed (XsTransactionEnd).
161 @param This A pointer to XENBUS_PROTOCOL instance.
162 @param Transaction The returned transaction.
164 @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value
165 indicating the type of failure.
169 (EFIAPI
*XENBUS_XS_TRANSACTION_START
)(
170 IN XENBUS_PROTOCOL
*This
,
171 OUT XENSTORE_TRANSACTION
*Transaction
177 @param This A pointer to XENBUS_PROTOCOL instance.
178 @param Transaction The transaction to end/commit.
179 @param Abort If TRUE, the transaction is discarded
180 instead of committed.
182 @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value
183 indicating the type of failure.
187 (EFIAPI
*XENBUS_XS_TRANSACTION_END
)(
188 IN XENBUS_PROTOCOL
*This
,
189 IN CONST XENSTORE_TRANSACTION
*Transaction
,
194 Set a new state for the frontend of the PV driver.
196 @param This A pointer to XENBUS_PROTOCOL instance.
197 @param Transaction The transaction to end/commit.
198 @param State The new state to apply.
200 @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value
201 indicating the type of failure.
205 (EFIAPI
*XENBUS_SET_STATE
)(
206 IN XENBUS_PROTOCOL
*This
,
207 IN CONST XENSTORE_TRANSACTION
*Transaction
,
212 Grant access to the page Frame to the domain DomainId.
214 @param This A pointer to XENBUS_PROTOCOL instance.
215 @param DomainId ID of the domain to grant access to.
216 @param Frame Frame Number of the page to grant access to.
217 @param ReadOnly Provide read-only or read-write access.
218 @param RefPtr Reference number of the grant will be written to this pointer.
222 (EFIAPI
*XENBUS_GRANT_ACCESS
)(
223 IN XENBUS_PROTOCOL
*This
,
227 OUT grant_ref_t
*refp
231 End access to grant Ref, previously return by XenBusGrantAccess.
233 @param This A pointer to XENBUS_PROTOCOL instance.
234 @param Ref Reference numeber of a grant previously returned by
239 (EFIAPI
*XENBUS_GRANT_END_ACCESS
)(
240 IN XENBUS_PROTOCOL
*This
,
245 Allocate a port that can be bind from domain DomainId.
247 @param This A pointer to the XENBUS_PROTOCOL.
248 @param DomainId The domain ID that can bind the newly allocated port.
249 @param Port A pointer to a evtchn_port_t that will contain the newly
252 @retval UINT32 The return value from the hypercall, 0 if success.
256 (EFIAPI
*XENBUS_EVENT_CHANNEL_ALLOCATE
)(
257 IN XENBUS_PROTOCOL
*This
,
259 OUT evtchn_port_t
*Port
263 Send an event to the remote end of the channel whose local endpoint is Port.
265 @param This A pointer to the XENBUS_PROTOCOL.
266 @param Port Local port to the event from.
268 @retval UINT32 The return value from the hypercall, 0 if success.
272 (EFIAPI
*XENBUS_EVENT_CHANNEL_NOTIFY
)(
273 IN XENBUS_PROTOCOL
*This
,
274 IN evtchn_port_t Port
278 Close a local event channel Port.
280 @param This A pointer to the XENBUS_PROTOCOL.
281 @param Port The event channel to close.
283 @retval UINT32 The return value from the hypercall, 0 if success.
287 (EFIAPI
*XENBUS_EVENT_CHANNEL_CLOSE
)(
288 IN XENBUS_PROTOCOL
*This
,
289 IN evtchn_port_t Port
293 Register a XenStore watch.
295 XenStore watches allow a client to wait for changes to an object in the
298 @param This A pointer to the XENBUS_PROTOCOL.
299 @param Node The basename of the path to watch.
300 @param Token A token.
302 @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value
303 indicating the type of write failure. EEXIST errors from the
304 XenStore are suppressed, allowing multiple, physically different,
305 xenbus_watch objects, to watch the same path in the XenStore.
309 (EFIAPI
*XENBUS_REGISTER_WATCH
)(
310 IN XENBUS_PROTOCOL
*This
,
311 IN CONST CHAR8
*Node
,
316 Register a XenStore watch on a backend's node.
318 XenStore watches allow a client to wait for changes to an object in the
321 @param This A pointer to the XENBUS_PROTOCOL.
322 @param Node The basename of the path to watch.
323 @param Token A token.
325 @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value
326 indicating the type of write failure. EEXIST errors from the
327 XenStore are suppressed, allowing multiple, physically different,
328 xenbus_watch objects, to watch the same path in the XenStore.
332 (EFIAPI
*XENBUS_REGISTER_WATCH_BACKEND
)(
333 IN XENBUS_PROTOCOL
*This
,
334 IN CONST CHAR8
*Node
,
339 Unregister a XenStore watch.
341 @param This A pointer to the XENBUS_PROTOCOL.
342 @param Token An token previously returned by a successful
343 call to RegisterWatch ().
347 (EFIAPI
*XENBUS_UNREGISTER_WATCH
)(
348 IN XENBUS_PROTOCOL
*This
,
353 Block until the node watch by Token change.
355 @param This A pointer to the XENBUS_PROTOCOL.
356 @param Token An token previously returned by a successful
357 call to RegisterWatch or RegisterWatchBackend.
359 @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value
360 indicating the type of failure.
364 (EFIAPI
*XENBUS_WAIT_FOR_WATCH
)(
365 IN XENBUS_PROTOCOL
*This
,
370 /// Protocol structure
372 /// DISCLAIMER: the XENBUS_PROTOCOL introduced here is a work in progress, and
373 /// should not be used outside of the EDK II tree.
375 struct _XENBUS_PROTOCOL
{
376 XENBUS_XS_READ XsRead
;
377 XENBUS_XS_BACKEND_READ XsBackendRead
;
378 XENBUS_XS_PRINTF XsPrintf
;
379 XENBUS_XS_REMOVE XsRemove
;
380 XENBUS_XS_TRANSACTION_START XsTransactionStart
;
381 XENBUS_XS_TRANSACTION_END XsTransactionEnd
;
382 XENBUS_SET_STATE SetState
;
384 XENBUS_GRANT_ACCESS GrantAccess
;
385 XENBUS_GRANT_END_ACCESS GrantEndAccess
;
387 XENBUS_EVENT_CHANNEL_ALLOCATE EventChannelAllocate
;
388 XENBUS_EVENT_CHANNEL_NOTIFY EventChannelNotify
;
389 XENBUS_EVENT_CHANNEL_CLOSE EventChannelClose
;
391 XENBUS_REGISTER_WATCH RegisterWatch
;
392 XENBUS_REGISTER_WATCH_BACKEND RegisterWatchBackend
;
393 XENBUS_UNREGISTER_WATCH UnregisterWatch
;
394 XENBUS_WAIT_FOR_WATCH WaitForWatch
;
396 // Protocol data fields
401 CONST CHAR8
*Backend
;
404 extern EFI_GUID gXenBusProtocolGuid
;