]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/XenBusDxe/XenStore.h
OvmfPkg/Xen*: Pass struct XENSTORE_TRANSACTION argument as a pointer
[mirror_edk2.git] / OvmfPkg / XenBusDxe / XenStore.h
CommitLineData
a9090a94
AP
1/** @file\r
2 Method declarations and structures for accessing the XenStore\r
3\r
4 Copyright (C) 2005 Rusty Russell, IBM Corporation\r
5 Copyright (C) 2005 XenSource Ltd.\r
6 Copyright (C) 2009,2010 Spectra Logic Corporation\r
7 Copyright (C) 2014, Citrix Ltd.\r
8\r
9 This file may be distributed separately from the Linux kernel, or\r
10 incorporated into other software packages, subject to the following license:\r
11\r
12 Permission is hereby granted, free of charge, to any person obtaining a copy\r
13 of this source file (the "Software"), to deal in the Software without\r
14 restriction, including without limitation the rights to use, copy, modify,\r
15 merge, publish, distribute, sublicense, and/or sell copies of the Software,\r
16 and to permit persons to whom the Software is furnished to do so, subject to\r
17 the following conditions:\r
18\r
19 The above copyright notice and this permission notice shall be included in\r
20 all copies or substantial portions of the Software.\r
21\r
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
23 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
24 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
25 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
26 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\r
27 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\r
28 IN THE SOFTWARE.\r
29**/\r
30\r
31#ifndef _XEN_XENSTORE_XENSTOREVAR_H\r
32#define _XEN_XENSTORE_XENSTOREVAR_H\r
33\r
34#include "XenBusDxe.h"\r
35\r
36#include <IndustryStandard/Xen/io/xs_wire.h>\r
37\r
38typedef struct _XENSTORE_WATCH XENSTORE_WATCH;\r
39\r
40/**\r
41 Fetch the contents of a directory in the XenStore.\r
42\r
43 @param Transaction The XenStore transaction covering this request.\r
44 @param DirectoryPath The dirname of the path to read.\r
45 @param Node The basename of the path to read.\r
46 @param DirectoryCountPtr The returned number of directory entries.\r
47 @param DirectoryListPtr An array of directory entry strings.\r
48\r
49 @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r
50 indicating the type of failure.\r
51\r
52 @note The results buffer is alloced and should be free'd by the\r
53 caller.\r
54**/\r
55XENSTORE_STATUS\r
56XenStoreListDirectory (\r
e26a83cd 57 IN CONST XENSTORE_TRANSACTION *Transaction,\r
a9090a94
AP
58 IN CONST CHAR8 *DirectoryPath,\r
59 IN CONST CHAR8 *Node,\r
60 OUT UINT32 *DirectoryCountPtr,\r
61 OUT CONST CHAR8 ***DirectoryListPtr\r
62 );\r
63\r
64/**\r
65 Determine if a path exists in the XenStore.\r
66\r
67 @param Transaction The XenStore transaction covering this request.\r
68 @param Directory The dirname of the path to read.\r
69 @param Node The basename of the path to read.\r
70\r
71 @retval TRUE The path exists.\r
72 @retval FALSE The path does not exist or an error occurred attempting\r
73 to make that determination.\r
74**/\r
75BOOLEAN\r
76XenStorePathExists (\r
e26a83cd 77 IN CONST XENSTORE_TRANSACTION *Transaction,\r
a9090a94
AP
78 IN CONST CHAR8 *Directory,\r
79 IN CONST CHAR8 *Node\r
80 );\r
81\r
82/**\r
83 Get the contents of a single "file". Returns the contents in *Result which\r
84 should be freed after use. The length of the value in bytes is returned in\r
85 *LenPtr.\r
86\r
87 @param Transaction The XenStore transaction covering this request.\r
88 @param DirectoryPath The dirname of the file to read.\r
89 @param Node The basename of the file to read.\r
90 @param LenPtr The amount of data read.\r
91 @param Result The returned contents from this file.\r
92\r
93 @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r
94 indicating the type of failure.\r
95\r
96 @note The results buffer is malloced and should be free'd by the\r
97 caller.\r
98**/\r
99XENSTORE_STATUS\r
100XenStoreRead (\r
e26a83cd 101 IN CONST XENSTORE_TRANSACTION *Transaction,\r
a9090a94
AP
102 IN CONST CHAR8 *DirectoryPath,\r
103 IN CONST CHAR8 *Node,\r
104 OUT UINT32 *LenPtr OPTIONAL,\r
105 OUT VOID **Result\r
106 );\r
107\r
108/**\r
109 Write to a single file.\r
110\r
111 @param Transaction The XenStore transaction covering this request.\r
112 @param DirectoryPath The dirname of the file to write.\r
113 @param Node The basename of the file to write.\r
114 @param Str The NUL terminated string of data to write.\r
115\r
116 @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r
117 indicating the type of failure.\r
118**/\r
119XENSTORE_STATUS\r
120XenStoreWrite (\r
e26a83cd 121 IN CONST XENSTORE_TRANSACTION *Transaction,\r
a9090a94
AP
122 IN CONST CHAR8 *DirectoryPath,\r
123 IN CONST CHAR8 *Node,\r
124 IN CONST CHAR8 *Str\r
125 );\r
126\r
127/**\r
128 Remove a file or directory (directories must be empty).\r
129\r
130 @param Transaction The XenStore transaction covering this request.\r
131 @param DirectoryPath The dirname of the directory to remove.\r
132 @param Node The basename of the directory to remove.\r
133\r
134 @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r
135 indicating the type of failure.\r
136**/\r
137XENSTORE_STATUS\r
138XenStoreRemove (\r
e26a83cd 139 IN CONST XENSTORE_TRANSACTION *Transaction,\r
a9090a94
AP
140 IN CONST CHAR8 *DirectoryPath,\r
141 IN CONST CHAR8 *Node\r
142 );\r
143\r
144/**\r
145 Start a transaction.\r
146\r
147 Changes by others will not be seen during the lifetime of this\r
148 transaction, and changes will not be visible to others until it\r
149 is committed (XenStoreTransactionEnd).\r
150\r
151 @param Transaction The returned transaction.\r
152\r
153 @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r
154 indicating the type of failure.\r
155**/\r
156XENSTORE_STATUS\r
157XenStoreTransactionStart (\r
e26a83cd 158 OUT XENSTORE_TRANSACTION *Transaction\r
a9090a94
AP
159 );\r
160\r
161/**\r
162 End a transaction.\r
163\r
164 @param Transaction The transaction to end/commit.\r
165 @param Abort If TRUE, the transaction is discarded\r
166 instead of committed.\r
167\r
168 @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r
169 indicating the type of failure.\r
170**/\r
171XENSTORE_STATUS\r
172XenStoreTransactionEnd (\r
e26a83cd 173 IN CONST XENSTORE_TRANSACTION *Transaction,\r
a9090a94
AP
174 IN BOOLEAN Abort\r
175 );\r
176\r
177/**\r
178 Printf formatted write to a XenStore file.\r
179\r
180 @param Transaction The XenStore transaction covering this request.\r
181 @param DirectoryPath The dirname of the path to read.\r
182 @param Node The basename of the path to read.\r
183 @param FormatString AsciiSPrint format string followed by a variable number\r
184 of arguments.\r
185\r
186 @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r
187 indicating the type of write failure.\r
188**/\r
189XENSTORE_STATUS\r
190EFIAPI\r
191XenStoreSPrint (\r
e26a83cd 192 IN CONST XENSTORE_TRANSACTION *Transaction,\r
a9090a94
AP
193 IN CONST CHAR8 *DirectoryPath,\r
194 IN CONST CHAR8 *Node,\r
195 IN CONST CHAR8 *FormatString,\r
196 ...\r
197 );\r
198\r
199/**\r
200 VA_LIST version of XenStoreSPrint().\r
201\r
202 @param Transaction The XenStore transaction covering this request.\r
203 @param DirectoryPath The dirname of the path to read.\r
204 @param Node The basename of the path to read.\r
205 @param FormatString Printf format string.\r
206 @param Marker VA_LIST of printf arguments.\r
207\r
208 @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r
209 indicating the type of write failure.\r
210**/\r
211XENSTORE_STATUS\r
212XenStoreVSPrint (\r
e26a83cd 213 IN CONST XENSTORE_TRANSACTION *Transaction,\r
a9090a94
AP
214 IN CONST CHAR8 *DirectoryPath,\r
215 IN CONST CHAR8 *Node,\r
216 IN CONST CHAR8 *FormatString,\r
217 IN VA_LIST Marker\r
218 );\r
219\r
220/**\r
221 Register a XenStore watch.\r
222\r
223 XenStore watches allow a client to be notified via a callback (embedded\r
224 within the watch object) of changes to an object in the XenStore.\r
225\r
226 @param DirectoryPath The dirname of the path to watch.\r
227 @param Node The basename of the path to watch.\r
228 @param WatchPtr A returned XENSTORE_WATCH pointer.\r
229\r
230 @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r
231 indicating the type of write failure. EEXIST errors from the\r
232 XenStore are supressed, allowing multiple, physically different,\r
233 xenbus_watch objects, to watch the same path in the XenStore.\r
234**/\r
235XENSTORE_STATUS\r
236XenStoreRegisterWatch (\r
237 IN CONST CHAR8 *DirectoryPath,\r
238 IN CONST CHAR8 *Node,\r
239 OUT XENSTORE_WATCH **WatchPtr\r
240 );\r
241\r
242/**\r
243 Unregister a XenStore watch.\r
244\r
245 @param Watch An XENSTORE_WATCH object previously returned by a successful\r
246 call to XenStoreRegisterWatch ().\r
247**/\r
248VOID\r
249XenStoreUnregisterWatch (\r
250 IN XENSTORE_WATCH *Watch\r
251 );\r
252\r
253/**\r
254 Allocate and return the XenStore path string <DirectoryPath>/<Node>. If name\r
255 is the NUL string, the returned value contains the path string\r
256 <DirectoryPath>.\r
257\r
258 @param DirectoryPath The NUL terminated directory prefix for new path.\r
259 @param Node The NUL terminated basename for the new path.\r
260\r
261 @return A buffer containing the joined path.\r
262 */\r
263CHAR8 *\r
264XenStoreJoin (\r
265 IN CONST CHAR8 *DirectoryPath,\r
266 IN CONST CHAR8 *Node\r
267 );\r
268\r
269\r
270/**\r
271 Initialize the XenStore states and rings.\r
272\r
273 @param Dev A pointer to a XENBUS_DEVICE instance.\r
274\r
275 @return EFI_SUCCESS if everything went smoothly.\r
276**/\r
277EFI_STATUS\r
278XenStoreInit (\r
279 XENBUS_DEVICE *Dev\r
280 );\r
281\r
282/**\r
283 Deinitialize the XenStore states and rings.\r
284\r
285 @param Dev A pointer to a XENBUS_DEVICE instance.\r
286**/\r
287VOID\r
288XenStoreDeinit (\r
289 IN XENBUS_DEVICE *Dev\r
290 );\r
291\r
c23c037f
AP
292\r
293//\r
294// XENBUS protocol\r
295//\r
296\r
297XENSTORE_STATUS\r
298EFIAPI\r
299XenBusWaitForWatch (\r
300 IN XENBUS_PROTOCOL *This,\r
301 IN VOID *Token\r
302 );\r
303\r
304XENSTORE_STATUS\r
305EFIAPI\r
306XenBusXenStoreRead (\r
307 IN XENBUS_PROTOCOL *This,\r
e26a83cd 308 IN CONST XENSTORE_TRANSACTION *Transaction,\r
c23c037f
AP
309 IN CONST CHAR8 *Node,\r
310 OUT VOID **Value\r
311 );\r
312\r
313XENSTORE_STATUS\r
314EFIAPI\r
315XenBusXenStoreBackendRead (\r
316 IN XENBUS_PROTOCOL *This,\r
e26a83cd 317 IN CONST XENSTORE_TRANSACTION *Transaction,\r
c23c037f
AP
318 IN CONST CHAR8 *Node,\r
319 OUT VOID **Value\r
320 );\r
321\r
322XENSTORE_STATUS\r
323EFIAPI\r
324XenBusXenStoreRemove (\r
325 IN XENBUS_PROTOCOL *This,\r
e26a83cd 326 IN CONST XENSTORE_TRANSACTION *Transaction,\r
c23c037f
AP
327 IN CONST CHAR8 *Node\r
328 );\r
329\r
330XENSTORE_STATUS\r
331EFIAPI\r
332XenBusXenStoreTransactionStart (\r
333 IN XENBUS_PROTOCOL *This,\r
334 OUT XENSTORE_TRANSACTION *Transaction\r
335 );\r
336\r
337XENSTORE_STATUS\r
338EFIAPI\r
339XenBusXenStoreTransactionEnd (\r
340 IN XENBUS_PROTOCOL *This,\r
e26a83cd 341 IN CONST XENSTORE_TRANSACTION *Transaction,\r
c23c037f
AP
342 IN BOOLEAN Abort\r
343 );\r
344\r
345XENSTORE_STATUS\r
346EFIAPI\r
347XenBusXenStoreSPrint (\r
348 IN XENBUS_PROTOCOL *This,\r
e26a83cd 349 IN CONST XENSTORE_TRANSACTION *Transaction,\r
c23c037f
AP
350 IN CONST CHAR8 *DirectoryPath,\r
351 IN CONST CHAR8 *Node,\r
352 IN CONST CHAR8 *FormatString,\r
353 ...\r
354 );\r
355\r
356XENSTORE_STATUS\r
357EFIAPI\r
358XenBusRegisterWatch (\r
359 IN XENBUS_PROTOCOL *This,\r
360 IN CONST CHAR8 *Node,\r
361 OUT VOID **Token\r
362 );\r
363\r
364XENSTORE_STATUS\r
365EFIAPI\r
366XenBusRegisterWatchBackend (\r
367 IN XENBUS_PROTOCOL *This,\r
368 IN CONST CHAR8 *Node,\r
369 OUT VOID **Token\r
370 );\r
371\r
372VOID\r
373EFIAPI\r
374XenBusUnregisterWatch (\r
375 IN XENBUS_PROTOCOL *This,\r
376 IN VOID *Token\r
377 );\r
378\r
a9090a94 379#endif /* _XEN_XENSTORE_XENSTOREVAR_H */\r