]>
Commit | Line | Data |
---|---|---|
fb3df220 | 1 | /** @file\r |
50a64e5b | 2 | Provides library functions to construct and parse UEFI Device Paths.\r |
fb3df220 | 3 | \r |
d80b2f71 | 4 | This library provides defines, macros, and functions to help create and parse \r |
5 | EFI_DEVICE_PATH_PROTOCOL structures. The macros that help create and parse device \r | |
6 | path nodes make use of the ReadUnaligned16() and WriteUnaligned16() functions from \r | |
7 | the Base Library, so this library class has an implied dependency on the Base Library.\r | |
8 | \r | |
5cba121d | 9 | Copyright (c) 2006 - 2009, Intel Corporation<BR>\r |
50a64e5b | 10 | All rights reserved. This program and the accompanying materials\r |
11 | are licensed and made available under the terms and conditions of the BSD License\r | |
12 | which accompanies this distribution. The full text of the license may be found at\r | |
13 | http://opensource.org/licenses/bsd-license.php\r | |
fb3df220 | 14 | \r |
50a64e5b | 15 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
16 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
fb3df220 | 17 | \r |
fb3df220 | 18 | **/\r |
19 | \r | |
20 | #ifndef __DEVICE_PATH_LIB_H__\r | |
21 | #define __DEVICE_PATH_LIB_H__\r | |
22 | \r | |
e5dab016 | 23 | #define END_DEVICE_PATH_LENGTH (sizeof (EFI_DEVICE_PATH_PROTOCOL))\r |
d80b2f71 | 24 | \r |
25 | /**\r | |
3dc728fb | 26 | Returns the Type field of a device path node.\r |
d80b2f71 | 27 | \r |
28 | Returns the Type field of the device path node specified by Node.\r | |
29 | \r | |
3dc728fb | 30 | If Node is NULL, then ASSERT().\r |
31 | \r | |
d80b2f71 | 32 | @param Node A pointer to a device path node data structure.\r |
33 | \r | |
34 | @return The Type field of the device path node specified by Node.\r | |
35 | \r | |
36 | **/\r | |
3dc728fb | 37 | UINT8\r |
5cba121d | 38 | EFIAPI\r |
3dc728fb | 39 | DevicePathType (\r |
40 | IN CONST VOID *Node\r | |
41 | );\r | |
d80b2f71 | 42 | \r |
43 | /**\r | |
3dc728fb | 44 | Returns the SubType field of a device path node.\r |
d80b2f71 | 45 | \r |
46 | Returns the SubType field of the device path node specified by Node.\r | |
47 | \r | |
3dc728fb | 48 | If Node is NULL, then ASSERT().\r |
49 | \r | |
d80b2f71 | 50 | @param Node A pointer to a device path node data structure.\r |
51 | \r | |
52 | @return The SubType field of the device path node specified by Node.\r | |
53 | \r | |
54 | **/\r | |
3dc728fb | 55 | UINT8\r |
5cba121d | 56 | EFIAPI\r |
3dc728fb | 57 | DevicePathSubType (\r |
58 | IN CONST VOID *Node\r | |
59 | );\r | |
d80b2f71 | 60 | \r |
61 | /**\r | |
3dc728fb | 62 | Returns the 16-bit Length field of a device path node.\r |
d80b2f71 | 63 | \r |
3dc728fb | 64 | Returns the 16-bit Length field of the device path node specified by Node. \r |
65 | Node is not required to be aligned on a 16-bit boundary, so it is recommended\r | |
66 | that a function such as ReadUnaligned16() be used to extract the contents of \r | |
67 | the Length field.\r | |
68 | \r | |
69 | If Node is NULL, then ASSERT().\r | |
d80b2f71 | 70 | \r |
71 | @param Node A pointer to a device path node data structure.\r | |
72 | \r | |
73 | @return The 16-bit Length field of the device path node specified by Node.\r | |
74 | \r | |
75 | **/\r | |
3dc728fb | 76 | UINTN\r |
5cba121d | 77 | EFIAPI\r |
3dc728fb | 78 | DevicePathNodeLength (\r |
79 | IN CONST VOID *Node\r | |
80 | );\r | |
d80b2f71 | 81 | \r |
82 | /**\r | |
3dc728fb | 83 | Returns a pointer to the next node in a device path.\r |
d80b2f71 | 84 | \r |
85 | Returns a pointer to the device path node that follows the device path node specified by Node.\r | |
86 | \r | |
3dc728fb | 87 | If Node is NULL, then ASSERT().\r |
88 | \r | |
d80b2f71 | 89 | @param Node A pointer to a device path node data structure.\r |
90 | \r | |
91 | @return a pointer to the device path node that follows the device path node specified by Node.\r | |
92 | \r | |
93 | **/\r | |
3dc728fb | 94 | EFI_DEVICE_PATH_PROTOCOL *\r |
5cba121d | 95 | EFIAPI\r |
3dc728fb | 96 | NextDevicePathNode (\r |
97 | IN CONST VOID *Node\r | |
98 | );\r | |
d80b2f71 | 99 | \r |
100 | /**\r | |
3dc728fb | 101 | Determines if a device path node is an end node of a device path.\r |
d80b2f71 | 102 | This includes nodes that are the end of a device path instance and nodes that are the end of an entire device path.\r |
103 | \r | |
104 | Determines if the device path node specified by Node is an end node of a device path. \r | |
105 | This includes nodes that are the end of a device path instance and nodes that are the \r | |
106 | end of an entire device path. If Node represents an end node of a device path, \r | |
107 | then TRUE is returned. Otherwise, FALSE is returned.\r | |
108 | \r | |
3dc728fb | 109 | If Node is NULL, then ASSERT().\r |
110 | \r | |
d80b2f71 | 111 | @param Node A pointer to a device path node data structure.\r |
112 | \r | |
113 | @retval TRUE The device path node specified by Node is an end node of a device path.\r | |
114 | @retval FALSE The device path node specified by Node is not an end node of a device path.\r | |
115 | \r | |
116 | **/\r | |
3dc728fb | 117 | BOOLEAN\r |
5cba121d | 118 | EFIAPI\r |
3dc728fb | 119 | IsDevicePathEndType (\r |
120 | IN CONST VOID *Node\r | |
121 | );\r | |
d80b2f71 | 122 | \r |
123 | /**\r | |
3dc728fb | 124 | Determines if a device path node is an end node of an entire device path.\r |
d80b2f71 | 125 | \r |
126 | Determines if a device path node specified by Node is an end node of an entire device path.\r | |
127 | If Node represents the end of an entire device path, then TRUE is returned. Otherwise, FALSE is returned.\r | |
128 | \r | |
3dc728fb | 129 | If Node is NULL, then ASSERT().\r |
130 | \r | |
d80b2f71 | 131 | @param Node A pointer to a device path node data structure.\r |
132 | \r | |
133 | @retval TRUE The device path node specified by Node is the end of an entire device path.\r | |
134 | @retval FALSE The device path node specified by Node is not the end of an entire device path.\r | |
135 | \r | |
136 | **/\r | |
3dc728fb | 137 | BOOLEAN\r |
5cba121d | 138 | EFIAPI\r |
3dc728fb | 139 | IsDevicePathEnd (\r |
140 | IN CONST VOID *Node\r | |
141 | );\r | |
d80b2f71 | 142 | \r |
143 | /**\r | |
3dc728fb | 144 | Determines if a device path node is an end node of a device path instance.\r |
d80b2f71 | 145 | \r |
146 | Determines if a device path node specified by Node is an end node of a device path instance.\r | |
147 | If Node represents the end of a device path instance, then TRUE is returned. Otherwise, FALSE is returned.\r | |
148 | \r | |
3dc728fb | 149 | If Node is NULL, then ASSERT().\r |
150 | \r | |
d80b2f71 | 151 | @param Node A pointer to a device path node data structure.\r |
152 | \r | |
153 | @retval TRUE The device path node specified by Node is the end of a device path instance.\r | |
154 | @retval FALSE The device path node specified by Node is not the end of a device path instance.\r | |
155 | \r | |
156 | **/\r | |
3dc728fb | 157 | BOOLEAN\r |
5cba121d | 158 | EFIAPI\r |
3dc728fb | 159 | IsDevicePathEndInstance (\r |
160 | IN CONST VOID *Node\r | |
161 | );\r | |
e5dab016 | 162 | \r |
d80b2f71 | 163 | /**\r |
3dc728fb | 164 | Sets the length, in bytes, of a device path node.\r |
165 | \r | |
166 | Sets the length of the device path node specified by Node to the value specified \r | |
167 | by NodeLength. NodeLength is returned. Node is not required to be aligned on \r | |
168 | a 16-bit boundary, so it is recommended that a function such as WriteUnaligned16()\r | |
169 | be used to set the contents of the Length field.\r | |
d80b2f71 | 170 | \r |
3dc728fb | 171 | If Node is NULL, then ASSERT().\r |
172 | If NodeLength >= 0x10000, then ASSERT().\r | |
d80b2f71 | 173 | \r |
174 | @param Node A pointer to a device path node data structure.\r | |
175 | @param Length The length, in bytes, of the device path node.\r | |
176 | \r | |
177 | @return Length\r | |
178 | \r | |
179 | **/\r | |
3dc728fb | 180 | UINT16\r |
5cba121d | 181 | EFIAPI\r |
3dc728fb | 182 | SetDevicePathNodeLength (\r |
9bb407c6 | 183 | IN OUT VOID *Node,\r |
184 | IN UINTN Length\r | |
3dc728fb | 185 | );\r |
d80b2f71 | 186 | \r |
187 | /**\r | |
3dc728fb | 188 | Fills in all the fields of a device path node that is the end of an entire device path.\r |
d80b2f71 | 189 | \r |
3dc728fb | 190 | Fills in all the fields of a device path node specified by Node so Node represents \r |
191 | the end of an entire device path. The Type field of Node is set to \r | |
192 | END_DEVICE_PATH_TYPE, the SubType field of Node is set to \r | |
193 | END_ENTIRE_DEVICE_PATH_SUBTYPE, and the Length field of Node is set to \r | |
194 | END_DEVICE_PATH_LENGTH. Node is not required to be aligned on a 16-bit boundary, \r | |
195 | so it is recommended that a function such as WriteUnaligned16() be used to set \r | |
196 | the contents of the Length field. \r | |
197 | \r | |
198 | If Node is NULL, then ASSERT(). \r | |
d80b2f71 | 199 | \r |
200 | @param Node A pointer to a device path node data structure.\r | |
201 | \r | |
202 | **/\r | |
3dc728fb | 203 | VOID\r |
5cba121d | 204 | EFIAPI\r |
3dc728fb | 205 | SetDevicePathEndNode (\r |
9bb407c6 | 206 | OUT VOID *Node\r |
3dc728fb | 207 | );\r |
e5dab016 | 208 | \r |
fb3df220 | 209 | /**\r |
210 | Returns the size of a device path in bytes.\r | |
211 | \r | |
212 | This function returns the size, in bytes, of the device path data structure specified by\r | |
213 | DevicePath including the end of device path node. If DevicePath is NULL, then 0 is returned.\r | |
214 | \r | |
215 | @param DevicePath A pointer to a device path data structure.\r | |
d80b2f71 | 216 | \r |
217 | @retval 0 If DevicePath is NULL.\r | |
218 | @retval Others The size of a device path in bytes.\r | |
fb3df220 | 219 | \r |
220 | **/\r | |
221 | UINTN\r | |
222 | EFIAPI\r | |
223 | GetDevicePathSize (\r | |
224 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
225 | );\r | |
226 | \r | |
227 | /**\r | |
bc7e6003 | 228 | Creates a new copy of an existing device path.\r |
fb3df220 | 229 | \r |
230 | This function allocates space for a new copy of the device path specified by DevicePath. If\r | |
231 | DevicePath is NULL, then NULL is returned. If the memory is successfully allocated, then the\r | |
232 | contents of DevicePath are copied to the newly allocated buffer, and a pointer to that buffer\r | |
233 | is returned. Otherwise, NULL is returned. \r | |
d80b2f71 | 234 | The memory for the new device path is allocated from EFI boot services memory. \r |
235 | It is the responsibility of the caller to free the memory allocated. \r | |
fb3df220 | 236 | \r |
237 | @param DevicePath A pointer to a device path data structure.\r | |
238 | \r | |
d80b2f71 | 239 | @retval NULL If DevicePath is NULL.\r |
240 | @retval Others A pointer to the duplicated device path.\r | |
241 | \r | |
fb3df220 | 242 | **/\r |
243 | EFI_DEVICE_PATH_PROTOCOL *\r | |
244 | EFIAPI\r | |
245 | DuplicateDevicePath (\r | |
246 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
247 | );\r | |
248 | \r | |
249 | /**\r | |
250 | Creates a new device path by appending a second device path to a first device path.\r | |
251 | \r | |
252 | This function creates a new device path by appending a copy of SecondDevicePath to a copy of\r | |
253 | FirstDevicePath in a newly allocated buffer. Only the end-of-device-path device node from\r | |
254 | SecondDevicePath is retained. The newly created device path is returned. \r | |
255 | If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned. \r | |
256 | If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned. \r | |
98a14db6 | 257 | If both FirstDevicePath and SecondDevicePath are NULL, then a copy of an end-of-device-path is\r |
258 | returned. \r | |
fb3df220 | 259 | If there is not enough memory for the newly allocated buffer, then NULL is returned.\r |
260 | The memory for the new device path is allocated from EFI boot services memory. It is the\r | |
261 | responsibility of the caller to free the memory allocated.\r | |
262 | \r | |
263 | @param FirstDevicePath A pointer to a device path data structure.\r | |
264 | @param SecondDevicePath A pointer to a device path data structure.\r | |
d80b2f71 | 265 | \r |
266 | @retval NULL If there is not enough memory for the newly allocated buffer.\r | |
267 | @retval Others A pointer to the new device path if success.\r | |
268 | Or a copy an end-of-device-path if both FirstDevicePath and SecondDevicePath are NULL.\r | |
fb3df220 | 269 | \r |
270 | **/\r | |
271 | EFI_DEVICE_PATH_PROTOCOL *\r | |
272 | EFIAPI\r | |
273 | AppendDevicePath (\r | |
274 | IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath, OPTIONAL\r | |
275 | IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath OPTIONAL\r | |
276 | );\r | |
277 | \r | |
278 | /**\r | |
279 | Creates a new path by appending the device node to the device path.\r | |
280 | \r | |
281 | This function creates a new device path by appending a copy of the device node specified by\r | |
282 | DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer.\r | |
283 | The end-of-device-path device node is moved after the end of the appended device node.\r | |
98a14db6 | 284 | If DevicePathNode is NULL then a copy of DevicePath is returned.\r |
6336a895 | 285 | If DevicePath is NULL then a copy of DevicePathNode, followed by an end-of-device path device\r |
286 | node is returned.\r | |
98a14db6 | 287 | If both DevicePathNode and DevicePath are NULL then a copy of an end-of-device-path device node\r |
288 | is returned.\r | |
fb3df220 | 289 | If there is not enough memory to allocate space for the new device path, then NULL is returned. \r |
290 | The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r | |
291 | free the memory allocated.\r | |
292 | \r | |
293 | @param DevicePath A pointer to a device path data structure.\r | |
294 | @param DevicePathNode A pointer to a single device path node.\r | |
295 | \r | |
d80b2f71 | 296 | @retval NULL If there is not enough memory for the new device path.\r |
297 | @retval Others A pointer to the new device path if success.\r | |
298 | A copy of DevicePathNode followed by an end-of-device-path node \r | |
299 | if both FirstDevicePath and SecondDevicePath are NULL.\r | |
300 | A copy of an end-of-device-path node if both FirstDevicePath and SecondDevicePath are NULL.\r | |
fb3df220 | 301 | \r |
302 | **/\r | |
303 | EFI_DEVICE_PATH_PROTOCOL *\r | |
304 | EFIAPI\r | |
305 | AppendDevicePathNode (\r | |
306 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL\r | |
307 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL\r | |
308 | );\r | |
309 | \r | |
310 | /**\r | |
311 | Creates a new device path by appending the specified device path instance to the specified device\r | |
312 | path.\r | |
313 | \r | |
314 | This function creates a new device path by appending a copy of the device path instance specified\r | |
315 | by DevicePathInstance to a copy of the device path secified by DevicePath in a allocated buffer.\r | |
316 | The end-of-device-path device node is moved after the end of the appended device path instance\r | |
317 | and a new end-of-device-path-instance node is inserted between. \r | |
318 | If DevicePath is NULL, then a copy if DevicePathInstance is returned.\r | |
319 | If DevicePathInstance is NULL, then NULL is returned.\r | |
320 | If there is not enough memory to allocate space for the new device path, then NULL is returned. \r | |
321 | The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r | |
322 | free the memory allocated.\r | |
323 | \r | |
324 | @param DevicePath A pointer to a device path data structure.\r | |
325 | @param DevicePathInstance A pointer to a device path instance.\r | |
326 | \r | |
327 | @return A pointer to the new device path.\r | |
328 | \r | |
329 | **/\r | |
330 | EFI_DEVICE_PATH_PROTOCOL *\r | |
331 | EFIAPI\r | |
332 | AppendDevicePathInstance (\r | |
333 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL\r | |
334 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance OPTIONAL\r | |
335 | );\r | |
336 | \r | |
337 | /**\r | |
338 | Creates a copy of the current device path instance and returns a pointer to the next device path\r | |
339 | instance.\r | |
340 | \r | |
341 | This function creates a copy of the current device path instance. It also updates DevicePath to\r | |
342 | point to the next device path instance in the device path (or NULL if no more) and updates Size\r | |
343 | to hold the size of the device path instance copy.\r | |
344 | If DevicePath is NULL, then NULL is returned.\r | |
345 | If there is not enough memory to allocate space for the new device path, then NULL is returned. \r | |
346 | The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r | |
347 | free the memory allocated.\r | |
348 | If Size is NULL, then ASSERT().\r | |
349 | \r | |
350 | @param DevicePath On input, this holds the pointer to the current device path\r | |
351 | instance. On output, this holds the pointer to the next device\r | |
352 | path instance or NULL if there are no more device path\r | |
353 | instances in the device path pointer to a device path data\r | |
354 | structure.\r | |
355 | @param Size On output, this holds the size of the device path instance, in\r | |
356 | bytes or zero, if DevicePath is NULL.\r | |
357 | \r | |
358 | @return A pointer to the current device path instance.\r | |
359 | \r | |
360 | **/\r | |
361 | EFI_DEVICE_PATH_PROTOCOL *\r | |
362 | EFIAPI\r | |
363 | GetNextDevicePathInstance (\r | |
364 | IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,\r | |
365 | OUT UINTN *Size\r | |
366 | );\r | |
367 | \r | |
368 | /**\r | |
d80b2f71 | 369 | Creates a device node.\r |
fb3df220 | 370 | \r |
371 | This function creates a new device node in a newly allocated buffer of size NodeLength and\r | |
372 | initializes the device path node header with NodeType and NodeSubType. The new device path node\r | |
373 | is returned.\r | |
374 | If NodeLength is smaller than a device path header, then NULL is returned. \r | |
375 | If there is not enough memory to allocate space for the new device path, then NULL is returned. \r | |
376 | The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r | |
377 | free the memory allocated.\r | |
378 | \r | |
379 | @param NodeType The device node type for the new device node.\r | |
380 | @param NodeSubType The device node sub-type for the new device node.\r | |
381 | @param NodeLength The length of the new device node.\r | |
382 | \r | |
383 | @return The new device path.\r | |
384 | \r | |
385 | **/\r | |
386 | EFI_DEVICE_PATH_PROTOCOL *\r | |
387 | EFIAPI\r | |
388 | CreateDeviceNode (\r | |
389 | IN UINT8 NodeType,\r | |
390 | IN UINT8 NodeSubType,\r | |
391 | IN UINT16 NodeLength\r | |
392 | );\r | |
393 | \r | |
394 | /**\r | |
395 | Determines if a device path is single or multi-instance.\r | |
396 | \r | |
397 | This function returns TRUE if the device path specified by DevicePath is multi-instance.\r | |
398 | Otherwise, FALSE is returned. If DevicePath is NULL, then FALSE is returned.\r | |
399 | \r | |
400 | @param DevicePath A pointer to a device path data structure.\r | |
401 | \r | |
402 | @retval TRUE DevicePath is multi-instance.\r | |
403 | @retval FALSE DevicePath is not multi-instance or DevicePath is NULL.\r | |
404 | \r | |
405 | **/\r | |
406 | BOOLEAN\r | |
407 | EFIAPI\r | |
408 | IsDevicePathMultiInstance (\r | |
409 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
410 | );\r | |
411 | \r | |
412 | /**\r | |
413 | Retrieves the device path protocol from a handle.\r | |
414 | \r | |
415 | This function returns the device path protocol from the handle specified by Handle. If Handle is\r | |
416 | NULL or Handle does not contain a device path protocol, then NULL is returned.\r | |
417 | \r | |
418 | @param Handle The handle from which to retrieve the device path protocol.\r | |
419 | \r | |
420 | @return The device path protocol from the handle specified by Handle.\r | |
421 | \r | |
422 | **/\r | |
423 | EFI_DEVICE_PATH_PROTOCOL *\r | |
424 | EFIAPI\r | |
425 | DevicePathFromHandle (\r | |
426 | IN EFI_HANDLE Handle\r | |
427 | );\r | |
428 | \r | |
429 | /**\r | |
430 | Allocates a device path for a file and appends it to an existing device path.\r | |
431 | \r | |
432 | If Device is a valid device handle that contains a device path protocol, then a device path for\r | |
433 | the file specified by FileName is allocated and appended to the device path associated with the\r | |
434 | handle Device. The allocated device path is returned. If Device is NULL or Device is a handle\r | |
435 | that does not support the device path protocol, then a device path containing a single device\r | |
436 | path node for the file specified by FileName is allocated and returned.\r | |
d80b2f71 | 437 | The memory for the new device path is allocated from EFI boot services memory. It is the responsibility\r |
438 | of the caller to free the memory allocated.\r | |
439 | \r | |
fb3df220 | 440 | If FileName is NULL, then ASSERT().\r |
d80b2f71 | 441 | If FileName is not aligned on a 16-bit boundary, then ASSERT().\r |
fb3df220 | 442 | \r |
443 | @param Device A pointer to a device handle. This parameter is optional and\r | |
444 | may be NULL.\r | |
445 | @param FileName A pointer to a Null-terminated Unicode string.\r | |
446 | \r | |
447 | @return The allocated device path.\r | |
448 | \r | |
449 | **/\r | |
450 | EFI_DEVICE_PATH_PROTOCOL *\r | |
451 | EFIAPI\r | |
452 | FileDevicePath (\r | |
453 | IN EFI_HANDLE Device, OPTIONAL\r | |
454 | IN CONST CHAR16 *FileName\r | |
455 | );\r | |
456 | \r | |
457 | #endif\r |