]>
Commit | Line | Data |
---|---|---|
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 | |
34131e1b | 12 | SPDX-License-Identifier: MIT\r |
a9090a94 AP |
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 | |
22 | typedef 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 | |
39 | XENSTORE_STATUS\r | |
40 | XenStoreListDirectory (\r | |
e26a83cd | 41 | IN CONST XENSTORE_TRANSACTION *Transaction,\r |
a9090a94 AP |
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 | |
59 | BOOLEAN\r | |
60 | XenStorePathExists (\r | |
e26a83cd | 61 | IN CONST XENSTORE_TRANSACTION *Transaction,\r |
a9090a94 AP |
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 | |
83 | XENSTORE_STATUS\r | |
84 | XenStoreRead (\r | |
e26a83cd | 85 | IN CONST XENSTORE_TRANSACTION *Transaction,\r |
a9090a94 AP |
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 | |
103 | XENSTORE_STATUS\r | |
104 | XenStoreWrite (\r | |
e26a83cd | 105 | IN CONST XENSTORE_TRANSACTION *Transaction,\r |
a9090a94 AP |
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 | |
121 | XENSTORE_STATUS\r | |
122 | XenStoreRemove (\r | |
e26a83cd | 123 | IN CONST XENSTORE_TRANSACTION *Transaction,\r |
a9090a94 AP |
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 | |
140 | XENSTORE_STATUS\r | |
141 | XenStoreTransactionStart (\r | |
e26a83cd | 142 | OUT XENSTORE_TRANSACTION *Transaction\r |
a9090a94 AP |
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 | |
155 | XENSTORE_STATUS\r | |
156 | XenStoreTransactionEnd (\r | |
e26a83cd | 157 | IN CONST XENSTORE_TRANSACTION *Transaction,\r |
a9090a94 AP |
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 | |
173 | XENSTORE_STATUS\r | |
174 | EFIAPI\r | |
175 | XenStoreSPrint (\r | |
e26a83cd | 176 | IN CONST XENSTORE_TRANSACTION *Transaction,\r |
a9090a94 AP |
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 | |
195 | XENSTORE_STATUS\r | |
c5c9e7e2 | 196 | EFIAPI\r |
a9090a94 | 197 | XenStoreVSPrint (\r |
e26a83cd | 198 | IN CONST XENSTORE_TRANSACTION *Transaction,\r |
a9090a94 AP |
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 | |
b6b33f67 | 217 | XenStore are suppressed, allowing multiple, physically different,\r |
a9090a94 AP |
218 | xenbus_watch objects, to watch the same path in the XenStore.\r |
219 | **/\r | |
220 | XENSTORE_STATUS\r | |
221 | XenStoreRegisterWatch (\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 | |
233 | VOID\r | |
234 | XenStoreUnregisterWatch (\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 | |
248 | CHAR8 *\r | |
249 | XenStoreJoin (\r | |
250 | IN CONST CHAR8 *DirectoryPath,\r | |
251 | IN CONST CHAR8 *Node\r | |
252 | );\r | |
253 | \r | |
254 | \r | |
255 | /**\r | |
256 | Initialize the XenStore states and rings.\r | |
257 | \r | |
258 | @param Dev A pointer to a XENBUS_DEVICE instance.\r | |
259 | \r | |
260 | @return EFI_SUCCESS if everything went smoothly.\r | |
261 | **/\r | |
262 | EFI_STATUS\r | |
263 | XenStoreInit (\r | |
264 | XENBUS_DEVICE *Dev\r | |
265 | );\r | |
266 | \r | |
267 | /**\r | |
268 | Deinitialize the XenStore states and rings.\r | |
269 | \r | |
270 | @param Dev A pointer to a XENBUS_DEVICE instance.\r | |
271 | **/\r | |
272 | VOID\r | |
273 | XenStoreDeinit (\r | |
274 | IN XENBUS_DEVICE *Dev\r | |
275 | );\r | |
276 | \r | |
c23c037f AP |
277 | \r |
278 | //\r | |
279 | // XENBUS protocol\r | |
280 | //\r | |
281 | \r | |
282 | XENSTORE_STATUS\r | |
283 | EFIAPI\r | |
284 | XenBusWaitForWatch (\r | |
285 | IN XENBUS_PROTOCOL *This,\r | |
286 | IN VOID *Token\r | |
287 | );\r | |
288 | \r | |
289 | XENSTORE_STATUS\r | |
290 | EFIAPI\r | |
291 | XenBusXenStoreRead (\r | |
292 | IN XENBUS_PROTOCOL *This,\r | |
e26a83cd | 293 | IN CONST XENSTORE_TRANSACTION *Transaction,\r |
c23c037f AP |
294 | IN CONST CHAR8 *Node,\r |
295 | OUT VOID **Value\r | |
296 | );\r | |
297 | \r | |
298 | XENSTORE_STATUS\r | |
299 | EFIAPI\r | |
300 | XenBusXenStoreBackendRead (\r | |
301 | IN XENBUS_PROTOCOL *This,\r | |
e26a83cd | 302 | IN CONST XENSTORE_TRANSACTION *Transaction,\r |
c23c037f AP |
303 | IN CONST CHAR8 *Node,\r |
304 | OUT VOID **Value\r | |
305 | );\r | |
306 | \r | |
307 | XENSTORE_STATUS\r | |
308 | EFIAPI\r | |
309 | XenBusXenStoreRemove (\r | |
310 | IN XENBUS_PROTOCOL *This,\r | |
e26a83cd | 311 | IN CONST XENSTORE_TRANSACTION *Transaction,\r |
c23c037f AP |
312 | IN CONST CHAR8 *Node\r |
313 | );\r | |
314 | \r | |
315 | XENSTORE_STATUS\r | |
316 | EFIAPI\r | |
317 | XenBusXenStoreTransactionStart (\r | |
318 | IN XENBUS_PROTOCOL *This,\r | |
319 | OUT XENSTORE_TRANSACTION *Transaction\r | |
320 | );\r | |
321 | \r | |
322 | XENSTORE_STATUS\r | |
323 | EFIAPI\r | |
324 | XenBusXenStoreTransactionEnd (\r | |
325 | IN XENBUS_PROTOCOL *This,\r | |
e26a83cd | 326 | IN CONST XENSTORE_TRANSACTION *Transaction,\r |
c23c037f AP |
327 | IN BOOLEAN Abort\r |
328 | );\r | |
329 | \r | |
330 | XENSTORE_STATUS\r | |
331 | EFIAPI\r | |
332 | XenBusXenStoreSPrint (\r | |
333 | IN XENBUS_PROTOCOL *This,\r | |
e26a83cd | 334 | IN CONST XENSTORE_TRANSACTION *Transaction,\r |
c23c037f AP |
335 | IN CONST CHAR8 *DirectoryPath,\r |
336 | IN CONST CHAR8 *Node,\r | |
337 | IN CONST CHAR8 *FormatString,\r | |
338 | ...\r | |
339 | );\r | |
340 | \r | |
341 | XENSTORE_STATUS\r | |
342 | EFIAPI\r | |
343 | XenBusRegisterWatch (\r | |
344 | IN XENBUS_PROTOCOL *This,\r | |
345 | IN CONST CHAR8 *Node,\r | |
346 | OUT VOID **Token\r | |
347 | );\r | |
348 | \r | |
349 | XENSTORE_STATUS\r | |
350 | EFIAPI\r | |
351 | XenBusRegisterWatchBackend (\r | |
352 | IN XENBUS_PROTOCOL *This,\r | |
353 | IN CONST CHAR8 *Node,\r | |
354 | OUT VOID **Token\r | |
355 | );\r | |
356 | \r | |
357 | VOID\r | |
358 | EFIAPI\r | |
359 | XenBusUnregisterWatch (\r | |
360 | IN XENBUS_PROTOCOL *This,\r | |
361 | IN VOID *Token\r | |
362 | );\r | |
363 | \r | |
a9090a94 | 364 | #endif /* _XEN_XENSTORE_XENSTOREVAR_H */\r |