]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - OvmfPkg/XenBusDxe/XenStore.h
OvmfPkg/PlatformPei: Refactor MiscInitialization
[mirror_edk2.git] / OvmfPkg / XenBusDxe / XenStore.h
... / ...
CommitLineData
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 SPDX-License-Identifier: MIT\r
13**/\r
14\r
15#ifndef _XEN_XENSTORE_XENSTOREVAR_H\r
16#define _XEN_XENSTORE_XENSTOREVAR_H\r
17\r
18#include "XenBusDxe.h"\r
19\r
20#include <IndustryStandard/Xen/io/xs_wire.h>\r
21\r
22typedef struct _XENSTORE_WATCH XENSTORE_WATCH;\r
23\r
24/**\r
25 Fetch the contents of a directory in the XenStore.\r
26\r
27 @param Transaction The XenStore transaction covering this request.\r
28 @param DirectoryPath The dirname of the path to read.\r
29 @param Node The basename of the path to read.\r
30 @param DirectoryCountPtr The returned number of directory entries.\r
31 @param DirectoryListPtr An array of directory entry strings.\r
32\r
33 @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r
34 indicating the type of failure.\r
35\r
36 @note The results buffer is alloced and should be free'd by the\r
37 caller.\r
38**/\r
39XENSTORE_STATUS\r
40XenStoreListDirectory (\r
41 IN CONST XENSTORE_TRANSACTION *Transaction,\r
42 IN CONST CHAR8 *DirectoryPath,\r
43 IN CONST CHAR8 *Node,\r
44 OUT UINT32 *DirectoryCountPtr,\r
45 OUT CONST CHAR8 ***DirectoryListPtr\r
46 );\r
47\r
48/**\r
49 Determine if a path exists in the XenStore.\r
50\r
51 @param Transaction The XenStore transaction covering this request.\r
52 @param Directory The dirname of the path to read.\r
53 @param Node The basename of the path to read.\r
54\r
55 @retval TRUE The path exists.\r
56 @retval FALSE The path does not exist or an error occurred attempting\r
57 to make that determination.\r
58**/\r
59BOOLEAN\r
60XenStorePathExists (\r
61 IN CONST XENSTORE_TRANSACTION *Transaction,\r
62 IN CONST CHAR8 *Directory,\r
63 IN CONST CHAR8 *Node\r
64 );\r
65\r
66/**\r
67 Get the contents of a single "file". Returns the contents in *Result which\r
68 should be freed after use. The length of the value in bytes is returned in\r
69 *LenPtr.\r
70\r
71 @param Transaction The XenStore transaction covering this request.\r
72 @param DirectoryPath The dirname of the file to read.\r
73 @param Node The basename of the file to read.\r
74 @param LenPtr The amount of data read.\r
75 @param Result The returned contents from this file.\r
76\r
77 @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r
78 indicating the type of failure.\r
79\r
80 @note The results buffer is malloced and should be free'd by the\r
81 caller.\r
82**/\r
83XENSTORE_STATUS\r
84XenStoreRead (\r
85 IN CONST XENSTORE_TRANSACTION *Transaction,\r
86 IN CONST CHAR8 *DirectoryPath,\r
87 IN CONST CHAR8 *Node,\r
88 OUT UINT32 *LenPtr OPTIONAL,\r
89 OUT VOID **Result\r
90 );\r
91\r
92/**\r
93 Write to a single file.\r
94\r
95 @param Transaction The XenStore transaction covering this request.\r
96 @param DirectoryPath The dirname of the file to write.\r
97 @param Node The basename of the file to write.\r
98 @param Str The NUL terminated string of data to write.\r
99\r
100 @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r
101 indicating the type of failure.\r
102**/\r
103XENSTORE_STATUS\r
104XenStoreWrite (\r
105 IN CONST XENSTORE_TRANSACTION *Transaction,\r
106 IN CONST CHAR8 *DirectoryPath,\r
107 IN CONST CHAR8 *Node,\r
108 IN CONST CHAR8 *Str\r
109 );\r
110\r
111/**\r
112 Remove a file or directory (directories must be empty).\r
113\r
114 @param Transaction The XenStore transaction covering this request.\r
115 @param DirectoryPath The dirname of the directory to remove.\r
116 @param Node The basename of the directory to remove.\r
117\r
118 @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r
119 indicating the type of failure.\r
120**/\r
121XENSTORE_STATUS\r
122XenStoreRemove (\r
123 IN CONST XENSTORE_TRANSACTION *Transaction,\r
124 IN CONST CHAR8 *DirectoryPath,\r
125 IN CONST CHAR8 *Node\r
126 );\r
127\r
128/**\r
129 Start a transaction.\r
130\r
131 Changes by others will not be seen during the lifetime of this\r
132 transaction, and changes will not be visible to others until it\r
133 is committed (XenStoreTransactionEnd).\r
134\r
135 @param Transaction The returned transaction.\r
136\r
137 @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r
138 indicating the type of failure.\r
139**/\r
140XENSTORE_STATUS\r
141XenStoreTransactionStart (\r
142 OUT XENSTORE_TRANSACTION *Transaction\r
143 );\r
144\r
145/**\r
146 End a transaction.\r
147\r
148 @param Transaction The transaction to end/commit.\r
149 @param Abort If TRUE, the transaction is discarded\r
150 instead of committed.\r
151\r
152 @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r
153 indicating the type of failure.\r
154**/\r
155XENSTORE_STATUS\r
156XenStoreTransactionEnd (\r
157 IN CONST XENSTORE_TRANSACTION *Transaction,\r
158 IN BOOLEAN Abort\r
159 );\r
160\r
161/**\r
162 Printf formatted write to a XenStore file.\r
163\r
164 @param Transaction The XenStore transaction covering this request.\r
165 @param DirectoryPath The dirname of the path to read.\r
166 @param Node The basename of the path to read.\r
167 @param FormatString AsciiSPrint format string followed by a variable number\r
168 of arguments.\r
169\r
170 @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r
171 indicating the type of write failure.\r
172**/\r
173XENSTORE_STATUS\r
174EFIAPI\r
175XenStoreSPrint (\r
176 IN CONST XENSTORE_TRANSACTION *Transaction,\r
177 IN CONST CHAR8 *DirectoryPath,\r
178 IN CONST CHAR8 *Node,\r
179 IN CONST CHAR8 *FormatString,\r
180 ...\r
181 );\r
182\r
183/**\r
184 VA_LIST version of XenStoreSPrint().\r
185\r
186 @param Transaction The XenStore transaction covering this request.\r
187 @param DirectoryPath The dirname of the path to read.\r
188 @param Node The basename of the path to read.\r
189 @param FormatString Printf format string.\r
190 @param Marker VA_LIST of printf arguments.\r
191\r
192 @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r
193 indicating the type of write failure.\r
194**/\r
195XENSTORE_STATUS\r
196EFIAPI\r
197XenStoreVSPrint (\r
198 IN CONST XENSTORE_TRANSACTION *Transaction,\r
199 IN CONST CHAR8 *DirectoryPath,\r
200 IN CONST CHAR8 *Node,\r
201 IN CONST CHAR8 *FormatString,\r
202 IN VA_LIST Marker\r
203 );\r
204\r
205/**\r
206 Register a XenStore watch.\r
207\r
208 XenStore watches allow a client to be notified via a callback (embedded\r
209 within the watch object) of changes to an object in the XenStore.\r
210\r
211 @param DirectoryPath The dirname of the path to watch.\r
212 @param Node The basename of the path to watch.\r
213 @param WatchPtr A returned XENSTORE_WATCH pointer.\r
214\r
215 @return On success, XENSTORE_STATUS_SUCCESS. Otherwise an errno value\r
216 indicating the type of write failure. EEXIST errors from the\r
217 XenStore are suppressed, allowing multiple, physically different,\r
218 xenbus_watch objects, to watch the same path in the XenStore.\r
219**/\r
220XENSTORE_STATUS\r
221XenStoreRegisterWatch (\r
222 IN CONST CHAR8 *DirectoryPath,\r
223 IN CONST CHAR8 *Node,\r
224 OUT XENSTORE_WATCH **WatchPtr\r
225 );\r
226\r
227/**\r
228 Unregister a XenStore watch.\r
229\r
230 @param Watch An XENSTORE_WATCH object previously returned by a successful\r
231 call to XenStoreRegisterWatch ().\r
232**/\r
233VOID\r
234XenStoreUnregisterWatch (\r
235 IN XENSTORE_WATCH *Watch\r
236 );\r
237\r
238/**\r
239 Allocate and return the XenStore path string <DirectoryPath>/<Node>. If name\r
240 is the NUL string, the returned value contains the path string\r
241 <DirectoryPath>.\r
242\r
243 @param DirectoryPath The NUL terminated directory prefix for new path.\r
244 @param Node The NUL terminated basename for the new path.\r
245\r
246 @return A buffer containing the joined path.\r
247 */\r
248CHAR8 *\r
249XenStoreJoin (\r
250 IN CONST CHAR8 *DirectoryPath,\r
251 IN CONST CHAR8 *Node\r
252 );\r
253\r
254/**\r
255 Initialize the XenStore states and rings.\r
256\r
257 @param Dev A pointer to a XENBUS_DEVICE instance.\r
258\r
259 @return EFI_SUCCESS if everything went smoothly.\r
260**/\r
261EFI_STATUS\r
262XenStoreInit (\r
263 XENBUS_DEVICE *Dev\r
264 );\r
265\r
266/**\r
267 Deinitialize the XenStore states and rings.\r
268\r
269 @param Dev A pointer to a XENBUS_DEVICE instance.\r
270**/\r
271VOID\r
272XenStoreDeinit (\r
273 IN XENBUS_DEVICE *Dev\r
274 );\r
275\r
276//\r
277// XENBUS protocol\r
278//\r
279\r
280XENSTORE_STATUS\r
281EFIAPI\r
282XenBusWaitForWatch (\r
283 IN XENBUS_PROTOCOL *This,\r
284 IN VOID *Token\r
285 );\r
286\r
287XENSTORE_STATUS\r
288EFIAPI\r
289XenBusXenStoreRead (\r
290 IN XENBUS_PROTOCOL *This,\r
291 IN CONST XENSTORE_TRANSACTION *Transaction,\r
292 IN CONST CHAR8 *Node,\r
293 OUT VOID **Value\r
294 );\r
295\r
296XENSTORE_STATUS\r
297EFIAPI\r
298XenBusXenStoreBackendRead (\r
299 IN XENBUS_PROTOCOL *This,\r
300 IN CONST XENSTORE_TRANSACTION *Transaction,\r
301 IN CONST CHAR8 *Node,\r
302 OUT VOID **Value\r
303 );\r
304\r
305XENSTORE_STATUS\r
306EFIAPI\r
307XenBusXenStoreRemove (\r
308 IN XENBUS_PROTOCOL *This,\r
309 IN CONST XENSTORE_TRANSACTION *Transaction,\r
310 IN CONST CHAR8 *Node\r
311 );\r
312\r
313XENSTORE_STATUS\r
314EFIAPI\r
315XenBusXenStoreTransactionStart (\r
316 IN XENBUS_PROTOCOL *This,\r
317 OUT XENSTORE_TRANSACTION *Transaction\r
318 );\r
319\r
320XENSTORE_STATUS\r
321EFIAPI\r
322XenBusXenStoreTransactionEnd (\r
323 IN XENBUS_PROTOCOL *This,\r
324 IN CONST XENSTORE_TRANSACTION *Transaction,\r
325 IN BOOLEAN Abort\r
326 );\r
327\r
328XENSTORE_STATUS\r
329EFIAPI\r
330XenBusXenStoreSPrint (\r
331 IN XENBUS_PROTOCOL *This,\r
332 IN CONST XENSTORE_TRANSACTION *Transaction,\r
333 IN CONST CHAR8 *DirectoryPath,\r
334 IN CONST CHAR8 *Node,\r
335 IN CONST CHAR8 *FormatString,\r
336 ...\r
337 );\r
338\r
339XENSTORE_STATUS\r
340EFIAPI\r
341XenBusRegisterWatch (\r
342 IN XENBUS_PROTOCOL *This,\r
343 IN CONST CHAR8 *Node,\r
344 OUT VOID **Token\r
345 );\r
346\r
347XENSTORE_STATUS\r
348EFIAPI\r
349XenBusRegisterWatchBackend (\r
350 IN XENBUS_PROTOCOL *This,\r
351 IN CONST CHAR8 *Node,\r
352 OUT VOID **Token\r
353 );\r
354\r
355VOID\r
356EFIAPI\r
357XenBusUnregisterWatch (\r
358 IN XENBUS_PROTOCOL *This,\r
359 IN VOID *Token\r
360 );\r
361\r
362#endif /* _XEN_XENSTORE_XENSTOREVAR_H */\r