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 | |
42 | #define XST_NIL ((XENSTORE_TRANSACTION) { 0 })\r | |
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 | |
66 | \r | |
67 | ///\r | |
68 | /// Function prototypes\r | |
69 | ///\r | |
70 | \r | |
c23c037f AP |
71 | /**\r |
72 | Get the contents of the node Node of the PV device. Returns the contents in\r | |
73 | *Result which should be freed after use.\r | |
74 | \r | |
75 | @param This A pointer to XENBUS_PROTOCOL instance.\r | |
76 | @param Transaction The XenStore transaction covering this request.\r | |
77 | @param Node The basename of the file to read.\r | |
78 | @param Result The returned contents from this file.\r | |
79 | \r | |
80 | @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r | |
81 | indicating the type of failure.\r | |
82 | \r | |
83 | @note The results buffer is malloced and should be free'd by the\r | |
84 | caller.\r | |
85 | **/\r | |
86 | typedef\r | |
87 | XENSTORE_STATUS\r | |
88 | (EFIAPI *XENBUS_XS_READ)(\r | |
89 | IN XENBUS_PROTOCOL *This,\r | |
90 | IN XENSTORE_TRANSACTION Transaction,\r | |
91 | IN CONST CHAR8 *Node,\r | |
92 | OUT VOID **Result\r | |
93 | );\r | |
94 | \r | |
95 | /**\r | |
96 | Get the contents of the node Node of the PV device's backend. Returns the\r | |
97 | contents in *Result which should be freed after use.\r | |
98 | \r | |
99 | @param This A pointer to XENBUS_PROTOCOL instance.\r | |
100 | @param Transaction The XenStore transaction covering this request.\r | |
101 | @param Node The basename of the file to read.\r | |
102 | @param Result The returned contents from this file.\r | |
103 | \r | |
104 | @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r | |
105 | indicating the type of failure.\r | |
106 | \r | |
107 | @note The results buffer is malloced and should be free'd by the\r | |
108 | caller.\r | |
109 | **/\r | |
110 | typedef\r | |
111 | XENSTORE_STATUS\r | |
112 | (EFIAPI *XENBUS_XS_BACKEND_READ)(\r | |
113 | IN XENBUS_PROTOCOL *This,\r | |
114 | IN XENSTORE_TRANSACTION Transaction,\r | |
115 | IN CONST CHAR8 *Node,\r | |
116 | OUT VOID **Result\r | |
117 | );\r | |
118 | \r | |
119 | /**\r | |
120 | Print formatted write to a XenStore node.\r | |
121 | \r | |
122 | @param This A pointer to XENBUS_PROTOCOL instance.\r | |
123 | @param Transaction The XenStore transaction covering this request.\r | |
124 | @param Directory The dirname of the path to read.\r | |
125 | @param Node The basename of the path to read.\r | |
126 | @param Format AsciiSPrint format string followed by a variable number\r | |
127 | of arguments.\r | |
128 | \r | |
129 | @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r | |
130 | indicating the type of write failure.\r | |
131 | **/\r | |
132 | typedef\r | |
133 | XENSTORE_STATUS\r | |
134 | (EFIAPI *XENBUS_XS_PRINTF) (\r | |
135 | IN XENBUS_PROTOCOL *This,\r | |
136 | IN XENSTORE_TRANSACTION Transaction,\r | |
137 | IN CONST CHAR8 *Directory,\r | |
138 | IN CONST CHAR8 *Node,\r | |
139 | IN CONST CHAR8 *Format,\r | |
140 | ...\r | |
141 | );\r | |
142 | \r | |
143 | /**\r | |
144 | Remove a node or directory (directories must be empty) of the PV driver's\r | |
145 | subdirectory.\r | |
146 | \r | |
147 | @param This A pointer to XENBUS_PROTOCOL instance.\r | |
148 | @param Transaction The XenStore transaction covering this request.\r | |
149 | @param Node The basename of the node to remove.\r | |
150 | \r | |
151 | @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r | |
152 | indicating the type of failure.\r | |
153 | **/\r | |
154 | typedef\r | |
155 | XENSTORE_STATUS\r | |
156 | (EFIAPI *XENBUS_XS_REMOVE) (\r | |
157 | IN XENBUS_PROTOCOL *This,\r | |
158 | IN XENSTORE_TRANSACTION Transaction,\r | |
159 | IN CONST CHAR8 *Node\r | |
160 | );\r | |
161 | \r | |
162 | /**\r | |
163 | Start a transaction.\r | |
164 | \r | |
165 | Changes by others will not be seen during the lifetime of this\r | |
166 | transaction, and changes will not be visible to others until it\r | |
167 | is committed (XsTransactionEnd).\r | |
168 | \r | |
169 | @param This A pointer to XENBUS_PROTOCOL instance.\r | |
170 | @param Transaction The returned transaction.\r | |
171 | \r | |
172 | @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r | |
173 | indicating the type of failure.\r | |
174 | **/\r | |
175 | typedef\r | |
176 | XENSTORE_STATUS\r | |
177 | (EFIAPI *XENBUS_XS_TRANSACTION_START)(\r | |
178 | IN XENBUS_PROTOCOL *This,\r | |
179 | OUT XENSTORE_TRANSACTION *Transaction\r | |
180 | );\r | |
181 | \r | |
182 | /**\r | |
183 | End a transaction.\r | |
184 | \r | |
185 | @param This A pointer to XENBUS_PROTOCOL instance.\r | |
186 | @param Transaction The transaction to end/commit.\r | |
187 | @param Abort If TRUE, the transaction is discarded\r | |
188 | instead of committed.\r | |
189 | \r | |
190 | @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r | |
191 | indicating the type of failure.\r | |
192 | **/\r | |
193 | typedef\r | |
194 | XENSTORE_STATUS\r | |
195 | (EFIAPI *XENBUS_XS_TRANSACTION_END) (\r | |
196 | IN XENBUS_PROTOCOL *This,\r | |
197 | IN XENSTORE_TRANSACTION Transaction,\r | |
198 | IN BOOLEAN Abort\r | |
199 | );\r | |
200 | \r | |
86d968e0 AP |
201 | /**\r |
202 | Set a new state for the frontend of the PV driver.\r | |
203 | \r | |
204 | @param This A pointer to XENBUS_PROTOCOL instance.\r | |
205 | @param Transaction The transaction to end/commit.\r | |
206 | @param State The new state to apply.\r | |
207 | \r | |
208 | @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r | |
209 | indicating the type of failure.\r | |
210 | **/\r | |
211 | typedef\r | |
212 | XENSTORE_STATUS\r | |
213 | (EFIAPI *XENBUS_SET_STATE)(\r | |
214 | IN XENBUS_PROTOCOL *This,\r | |
215 | IN XENSTORE_TRANSACTION Transaction,\r | |
216 | IN XenBusState State\r | |
217 | );\r | |
218 | \r | |
12a16f2d AP |
219 | /**\r |
220 | Grant access to the page Frame to the domain DomainId.\r | |
221 | \r | |
222 | @param This A pointer to XENBUS_PROTOCOL instance.\r | |
223 | @param DomainId ID of the domain to grant acces to.\r | |
224 | @param Frame Frame Number of the page to grant access to.\r | |
225 | @param ReadOnly Provide read-only or read-write access.\r | |
226 | @param RefPtr Reference number of the grant will be writen to this pointer.\r | |
227 | **/\r | |
228 | typedef\r | |
229 | EFI_STATUS\r | |
230 | (EFIAPI *XENBUS_GRANT_ACCESS)(\r | |
231 | IN XENBUS_PROTOCOL *This,\r | |
232 | IN domid_t DomainId,\r | |
233 | IN UINTN Frame,\r | |
234 | IN BOOLEAN ReadOnly,\r | |
235 | OUT grant_ref_t *refp\r | |
236 | );\r | |
237 | \r | |
238 | /**\r | |
239 | End access to grant Ref, previously return by XenBusGrantAccess.\r | |
240 | \r | |
241 | @param This A pointer to XENBUS_PROTOCOL instance.\r | |
242 | @param Ref Reference numeber of a grant previously returned by\r | |
243 | XenBusGrantAccess.\r | |
244 | **/\r | |
245 | typedef\r | |
246 | EFI_STATUS\r | |
247 | (EFIAPI *XENBUS_GRANT_END_ACCESS)(\r | |
248 | IN XENBUS_PROTOCOL *This,\r | |
249 | IN grant_ref_t Ref\r | |
250 | );\r | |
251 | \r | |
c23c037f AP |
252 | /**\r |
253 | Register a XenStore watch.\r | |
254 | \r | |
255 | XenStore watches allow a client to wait for changes to an object in the\r | |
256 | XenStore.\r | |
257 | \r | |
258 | @param This A pointer to the XENBUS_PROTOCOL.\r | |
259 | @param Node The basename of the path to watch.\r | |
260 | @param Token A token.\r | |
261 | \r | |
262 | @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r | |
263 | indicating the type of write failure. EEXIST errors from the\r | |
264 | XenStore are supressed, allowing multiple, physically different,\r | |
265 | xenbus_watch objects, to watch the same path in the XenStore.\r | |
266 | **/\r | |
267 | typedef\r | |
268 | XENSTORE_STATUS\r | |
269 | (EFIAPI *XENBUS_REGISTER_WATCH) (\r | |
270 | IN XENBUS_PROTOCOL *This,\r | |
271 | IN CONST CHAR8 *Node,\r | |
272 | OUT VOID **Token\r | |
273 | );\r | |
274 | \r | |
275 | /**\r | |
276 | Register a XenStore watch on a backend's node.\r | |
277 | \r | |
278 | XenStore watches allow a client to wait for changes to an object in the\r | |
279 | XenStore.\r | |
280 | \r | |
281 | @param This A pointer to the XENBUS_PROTOCOL.\r | |
282 | @param Node The basename of the path to watch.\r | |
283 | @param Token A token.\r | |
284 | \r | |
285 | @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r | |
286 | indicating the type of write failure. EEXIST errors from the\r | |
287 | XenStore are supressed, allowing multiple, physically different,\r | |
288 | xenbus_watch objects, to watch the same path in the XenStore.\r | |
289 | **/\r | |
290 | typedef\r | |
291 | XENSTORE_STATUS\r | |
292 | (EFIAPI *XENBUS_REGISTER_WATCH_BACKEND) (\r | |
293 | IN XENBUS_PROTOCOL *This,\r | |
294 | IN CONST CHAR8 *Node,\r | |
295 | OUT VOID **Token\r | |
296 | );\r | |
297 | \r | |
298 | /**\r | |
299 | Unregister a XenStore watch.\r | |
300 | \r | |
301 | @param This A pointer to the XENBUS_PROTOCOL.\r | |
302 | @param Token An token previously returned by a successful\r | |
303 | call to RegisterWatch ().\r | |
304 | **/\r | |
305 | typedef\r | |
306 | VOID\r | |
307 | (EFIAPI *XENBUS_UNREGISTER_WATCH) (\r | |
308 | IN XENBUS_PROTOCOL *This,\r | |
309 | IN VOID *Token\r | |
310 | );\r | |
311 | \r | |
312 | /**\r | |
313 | Block until the node watch by Token change.\r | |
314 | \r | |
315 | @param This A pointer to the XENBUS_PROTOCOL.\r | |
316 | @param Token An token previously returned by a successful\r | |
317 | call to RegisterWatch or RegisterWatchBackend.\r | |
318 | \r | |
319 | @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r | |
320 | indicating the type of failure.\r | |
321 | **/\r | |
322 | typedef\r | |
323 | XENSTORE_STATUS\r | |
324 | (EFIAPI *XENBUS_WAIT_FOR_WATCH) (\r | |
325 | IN XENBUS_PROTOCOL *This,\r | |
326 | IN VOID *Token\r | |
327 | );\r | |
328 | \r | |
12a16f2d AP |
329 | \r |
330 | ///\r | |
331 | /// Protocol structure\r | |
332 | ///\r | |
333 | /// DISCLAIMER: the XENBUS_PROTOCOL introduced here is a work in progress, and\r | |
334 | /// should not be used outside of the EDK II tree.\r | |
335 | ///\r | |
336 | struct _XENBUS_PROTOCOL {\r | |
c23c037f AP |
337 | XENBUS_XS_READ XsRead;\r |
338 | XENBUS_XS_BACKEND_READ XsBackendRead;\r | |
339 | XENBUS_XS_PRINTF XsPrintf;\r | |
340 | XENBUS_XS_REMOVE XsRemove;\r | |
341 | XENBUS_XS_TRANSACTION_START XsTransactionStart;\r | |
342 | XENBUS_XS_TRANSACTION_END XsTransactionEnd;\r | |
86d968e0 | 343 | XENBUS_SET_STATE SetState;\r |
c23c037f | 344 | \r |
12a16f2d AP |
345 | XENBUS_GRANT_ACCESS GrantAccess;\r |
346 | XENBUS_GRANT_END_ACCESS GrantEndAccess;\r | |
c23c037f AP |
347 | \r |
348 | XENBUS_REGISTER_WATCH RegisterWatch;\r | |
349 | XENBUS_REGISTER_WATCH_BACKEND RegisterWatchBackend;\r | |
350 | XENBUS_UNREGISTER_WATCH UnregisterWatch;\r | |
351 | XENBUS_WAIT_FOR_WATCH WaitForWatch;\r | |
12a16f2d AP |
352 | //\r |
353 | // Protocol data fields\r | |
354 | //\r | |
c23c037f AP |
355 | CONST CHAR8 *Type;\r |
356 | UINT16 DeviceId;\r | |
357 | CONST CHAR8 *Node;\r | |
358 | CONST CHAR8 *Backend;\r | |
12a16f2d AP |
359 | };\r |
360 | \r | |
361 | extern EFI_GUID gXenBusProtocolGuid;\r | |
362 | \r | |
363 | #endif\r |