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