2 Device Path services. The thing to remember is device paths are built out of
3 nodes. The device path is terminated by an end node that is length
4 sizeof(EFI_DEVICE_PATH_PROTOCOL). That would be why there is sizeof(EFI_DEVICE_PATH_PROTOCOL)
7 The only place where multi-instance device paths are supported is in
8 environment varibles. Multi-instance device paths should never be placed
11 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
12 SPDX-License-Identifier: BSD-2-Clause-Patent
17 #include "UefiDevicePathLib.h"
20 Returns the size of a device path in bytes.
22 This function returns the size, in bytes, of the device path data structure
23 specified by DevicePath including the end of device path node.
24 If DevicePath is NULL or invalid, then 0 is returned.
26 @param DevicePath A pointer to a device path data structure.
28 @retval 0 If DevicePath is NULL or invalid.
29 @retval Others The size of a device path in bytes.
35 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
38 return UefiDevicePathLibGetDevicePathSize (DevicePath
);
42 Creates a new copy of an existing device path.
44 This function allocates space for a new copy of the device path specified by DevicePath.
45 If DevicePath is NULL, then NULL is returned. If the memory is successfully
46 allocated, then the contents of DevicePath are copied to the newly allocated
47 buffer, and a pointer to that buffer is returned. Otherwise, NULL is returned.
48 The memory for the new device path is allocated from EFI boot services memory.
49 It is the responsibility of the caller to free the memory allocated.
51 @param DevicePath A pointer to a device path data structure.
53 @retval NULL DevicePath is NULL or invalid.
54 @retval Others A pointer to the duplicated device path.
57 EFI_DEVICE_PATH_PROTOCOL
*
60 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
63 return UefiDevicePathLibDuplicateDevicePath (DevicePath
);
67 Creates a new device path by appending a second device path to a first device path.
69 This function creates a new device path by appending a copy of SecondDevicePath
70 to a copy of FirstDevicePath in a newly allocated buffer. Only the end-of-device-path
71 device node from SecondDevicePath is retained. The newly created device path is
72 returned. If FirstDevicePath is NULL, then it is ignored, and a duplicate of
73 SecondDevicePath is returned. If SecondDevicePath is NULL, then it is ignored,
74 and a duplicate of FirstDevicePath is returned. If both FirstDevicePath and
75 SecondDevicePath are NULL, then a copy of an end-of-device-path is returned.
77 If there is not enough memory for the newly allocated buffer, then NULL is returned.
78 The memory for the new device path is allocated from EFI boot services memory.
79 It is the responsibility of the caller to free the memory allocated.
81 @param FirstDevicePath A pointer to a device path data structure.
82 @param SecondDevicePath A pointer to a device path data structure.
84 @retval NULL If there is not enough memory for the newly allocated buffer.
85 @retval NULL If FirstDevicePath or SecondDevicePath is invalid.
86 @retval Others A pointer to the new device path if success.
87 Or a copy an end-of-device-path if both FirstDevicePath and SecondDevicePath are NULL.
90 EFI_DEVICE_PATH_PROTOCOL
*
93 IN CONST EFI_DEVICE_PATH_PROTOCOL
*FirstDevicePath
, OPTIONAL
94 IN CONST EFI_DEVICE_PATH_PROTOCOL
*SecondDevicePath OPTIONAL
97 return UefiDevicePathLibAppendDevicePath (FirstDevicePath
, SecondDevicePath
);
101 Creates a new path by appending the device node to the device path.
103 This function creates a new device path by appending a copy of the device node
104 specified by DevicePathNode to a copy of the device path specified by DevicePath
105 in an allocated buffer. The end-of-device-path device node is moved after the
106 end of the appended device node.
107 If DevicePathNode is NULL then a copy of DevicePath is returned.
108 If DevicePath is NULL then a copy of DevicePathNode, followed by an end-of-device
109 path device node is returned.
110 If both DevicePathNode and DevicePath are NULL then a copy of an end-of-device-path
111 device node is returned.
112 If there is not enough memory to allocate space for the new device path, then
114 The memory is allocated from EFI boot services memory. It is the responsibility
115 of the caller to free the memory allocated.
117 @param DevicePath A pointer to a device path data structure.
118 @param DevicePathNode A pointer to a single device path node.
120 @retval NULL If there is not enough memory for the new device path.
121 @retval Others A pointer to the new device path if success.
122 A copy of DevicePathNode followed by an end-of-device-path node
123 if both FirstDevicePath and SecondDevicePath are NULL.
124 A copy of an end-of-device-path node if both FirstDevicePath
125 and SecondDevicePath are NULL.
128 EFI_DEVICE_PATH_PROTOCOL
*
130 AppendDevicePathNode (
131 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
, OPTIONAL
132 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode OPTIONAL
135 return UefiDevicePathLibAppendDevicePathNode (DevicePath
, DevicePathNode
);
139 Creates a new device path by appending the specified device path instance to the specified device
142 This function creates a new device path by appending a copy of the device path
143 instance specified by DevicePathInstance to a copy of the device path specified
144 by DevicePath in a allocated buffer.
145 The end-of-device-path device node is moved after the end of the appended device
146 path instance and a new end-of-device-path-instance node is inserted between.
147 If DevicePath is NULL, then a copy if DevicePathInstance is returned.
148 If DevicePathInstance is NULL, then NULL is returned.
149 If DevicePath or DevicePathInstance is invalid, then NULL is returned.
150 If there is not enough memory to allocate space for the new device path, then
152 The memory is allocated from EFI boot services memory. It is the responsibility
153 of the caller to free the memory allocated.
155 @param DevicePath A pointer to a device path data structure.
156 @param DevicePathInstance A pointer to a device path instance.
158 @return A pointer to the new device path.
161 EFI_DEVICE_PATH_PROTOCOL
*
163 AppendDevicePathInstance (
164 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
, OPTIONAL
165 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePathInstance OPTIONAL
168 return UefiDevicePathLibAppendDevicePathInstance (DevicePath
, DevicePathInstance
);
172 Creates a copy of the current device path instance and returns a pointer to the next device path
175 This function creates a copy of the current device path instance. It also updates
176 DevicePath to point to the next device path instance in the device path (or NULL
177 if no more) and updates Size to hold the size of the device path instance copy.
178 If DevicePath is NULL, then NULL is returned.
179 If DevicePath points to a invalid device path, then NULL is returned.
180 If there is not enough memory to allocate space for the new device path, then
182 The memory is allocated from EFI boot services memory. It is the responsibility
183 of the caller to free the memory allocated.
184 If Size is NULL, then ASSERT().
186 @param DevicePath On input, this holds the pointer to the current
187 device path instance. On output, this holds
188 the pointer to the next device path instance
189 or NULL if there are no more device path
190 instances in the device path pointer to a
191 device path data structure.
192 @param Size On output, this holds the size of the device
193 path instance, in bytes or zero, if DevicePath
196 @return A pointer to the current device path instance.
199 EFI_DEVICE_PATH_PROTOCOL
*
201 GetNextDevicePathInstance (
202 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
,
206 return UefiDevicePathLibGetNextDevicePathInstance (DevicePath
, Size
);
210 Creates a device node.
212 This function creates a new device node in a newly allocated buffer of size
213 NodeLength and initializes the device path node header with NodeType and NodeSubType.
214 The new device path node is returned.
215 If NodeLength is smaller than a device path header, then NULL is returned.
216 If there is not enough memory to allocate space for the new device path, then
218 The memory is allocated from EFI boot services memory. It is the responsibility
219 of the caller to free the memory allocated.
221 @param NodeType The device node type for the new device node.
222 @param NodeSubType The device node sub-type for the new device node.
223 @param NodeLength The length of the new device node.
225 @return The new device path.
228 EFI_DEVICE_PATH_PROTOCOL
*
232 IN UINT8 NodeSubType
,
236 return UefiDevicePathLibCreateDeviceNode (NodeType
, NodeSubType
, NodeLength
);
240 Determines if a device path is single or multi-instance.
242 This function returns TRUE if the device path specified by DevicePath is
244 Otherwise, FALSE is returned.
245 If DevicePath is NULL or invalid, then FALSE is returned.
247 @param DevicePath A pointer to a device path data structure.
249 @retval TRUE DevicePath is multi-instance.
250 @retval FALSE DevicePath is not multi-instance, or DevicePath
256 IsDevicePathMultiInstance (
257 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
260 return UefiDevicePathLibIsDevicePathMultiInstance (DevicePath
);
264 Converts a device node to its string representation.
266 @param DeviceNode A Pointer to the device node to be converted.
267 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
268 of the display node is used, where applicable. If DisplayOnly
269 is FALSE, then the longer text representation of the display node
271 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
272 representation for a device node can be used, where applicable.
274 @return A pointer to the allocated text representation of the device node or NULL if DeviceNode
275 is NULL or there was insufficient memory.
280 ConvertDeviceNodeToText (
281 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
,
282 IN BOOLEAN DisplayOnly
,
283 IN BOOLEAN AllowShortcuts
286 return UefiDevicePathLibConvertDeviceNodeToText (DeviceNode
, DisplayOnly
, AllowShortcuts
);
290 Converts a device path to its text representation.
292 @param DevicePath A Pointer to the device to be converted.
293 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
294 of the display node is used, where applicable. If DisplayOnly
295 is FALSE, then the longer text representation of the display node
297 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
298 representation for a device node can be used, where applicable.
300 @return A pointer to the allocated text representation of the device path or
301 NULL if DeviceNode is NULL or there was insufficient memory.
306 ConvertDevicePathToText (
307 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
308 IN BOOLEAN DisplayOnly
,
309 IN BOOLEAN AllowShortcuts
312 return UefiDevicePathLibConvertDevicePathToText (DevicePath
, DisplayOnly
, AllowShortcuts
);
316 Convert text to the binary representation of a device node.
318 @param TextDeviceNode TextDeviceNode points to the text representation of a device
319 node. Conversion starts with the first character and continues
320 until the first non-device node character.
322 @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was
323 insufficient memory or text unsupported.
326 EFI_DEVICE_PATH_PROTOCOL
*
328 ConvertTextToDeviceNode (
329 IN CONST CHAR16
*TextDeviceNode
332 return UefiDevicePathLibConvertTextToDeviceNode (TextDeviceNode
);
336 Convert text to the binary representation of a device path.
339 @param TextDevicePath TextDevicePath points to the text representation of a device
340 path. Conversion starts with the first character and continues
341 until the first non-device node character.
343 @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or
344 there was insufficient memory.
347 EFI_DEVICE_PATH_PROTOCOL
*
349 ConvertTextToDevicePath (
350 IN CONST CHAR16
*TextDevicePath
353 return UefiDevicePathLibConvertTextToDevicePath (TextDevicePath
);