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 variables. Multi-instance device paths should never be placed
11 Copyright (c) 2017, 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.
34 CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
37 return UefiDevicePathLibGetDevicePathSize (DevicePath
);
41 Creates a new copy of an existing device path.
43 This function allocates space for a new copy of the device path specified by DevicePath.
44 If DevicePath is NULL, then NULL is returned. If the memory is successfully
45 allocated, then the contents of DevicePath are copied to the newly allocated
46 buffer, and a pointer to that buffer is returned. Otherwise, NULL is returned.
47 The memory for the new device path is allocated from EFI boot services memory.
48 It is the responsibility of the caller to free the memory allocated.
50 @param DevicePath A pointer to a device path data structure.
52 @retval NULL DevicePath is NULL or invalid.
53 @retval Others A pointer to the duplicated device path.
56 EFI_DEVICE_PATH_PROTOCOL
*
58 CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
61 return UefiDevicePathLibDuplicateDevicePath (DevicePath
);
65 Creates a new device path by appending a second device path to a first device path.
67 This function creates a new device path by appending a copy of SecondDevicePath
68 to a copy of FirstDevicePath in a newly allocated buffer. Only the end-of-device-path
69 device node from SecondDevicePath is retained. The newly created device path is
70 returned. If FirstDevicePath is NULL, then it is ignored, and a duplicate of
71 SecondDevicePath is returned. If SecondDevicePath is NULL, then it is ignored,
72 and a duplicate of FirstDevicePath is returned. If both FirstDevicePath and
73 SecondDevicePath are NULL, then a copy of an end-of-device-path is returned.
75 If there is not enough memory for the newly allocated buffer, then NULL is returned.
76 The memory for the new device path is allocated from EFI boot services memory.
77 It is the responsibility of the caller to free the memory allocated.
79 @param FirstDevicePath A pointer to a device path data structure.
80 @param SecondDevicePath A pointer to a device path data structure.
82 @retval NULL If there is not enough memory for the newly allocated buffer.
83 @retval NULL If FirstDevicePath or SecondDevicePath is invalid.
84 @retval Others A pointer to the new device path if success.
85 Or a copy an end-of-device-path if both FirstDevicePath and SecondDevicePath are NULL.
88 EFI_DEVICE_PATH_PROTOCOL
*
90 CONST EFI_DEVICE_PATH_PROTOCOL
*FirstDevicePath
, OPTIONAL
91 CONST EFI_DEVICE_PATH_PROTOCOL
*SecondDevicePath OPTIONAL
94 return UefiDevicePathLibAppendDevicePath (FirstDevicePath
, SecondDevicePath
);
98 Creates a new path by appending the device node to the device path.
100 This function creates a new device path by appending a copy of the device node
101 specified by DevicePathNode to a copy of the device path specified by DevicePath
102 in an allocated buffer. The end-of-device-path device node is moved after the
103 end of the appended device node.
104 If DevicePathNode is NULL then a copy of DevicePath is returned.
105 If DevicePath is NULL then a copy of DevicePathNode, followed by an end-of-device
106 path device node is returned.
107 If both DevicePathNode and DevicePath are NULL then a copy of an end-of-device-path
108 device node is returned.
109 If there is not enough memory to allocate space for the new device path, then
111 The memory is allocated from EFI boot services memory. It is the responsibility
112 of the caller to free the memory allocated.
114 @param DevicePath A pointer to a device path data structure.
115 @param DevicePathNode A pointer to a single device path node.
117 @retval NULL If there is not enough memory for the new device path.
118 @retval Others A pointer to the new device path if success.
119 A copy of DevicePathNode followed by an end-of-device-path node
120 if both FirstDevicePath and SecondDevicePath are NULL.
121 A copy of an end-of-device-path node if both FirstDevicePath
122 and SecondDevicePath are NULL.
125 EFI_DEVICE_PATH_PROTOCOL
*
126 AppendDevicePathNode (
127 CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
, OPTIONAL
128 CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode OPTIONAL
131 return UefiDevicePathLibAppendDevicePathNode (DevicePath
, DevicePathNode
);
135 Creates a new device path by appending the specified device path instance to the specified device
138 This function creates a new device path by appending a copy of the device path
139 instance specified by DevicePathInstance to a copy of the device path specified
140 by DevicePath in a allocated buffer.
141 The end-of-device-path device node is moved after the end of the appended device
142 path instance and a new end-of-device-path-instance node is inserted between.
143 If DevicePath is NULL, then a copy if DevicePathInstance is returned.
144 If DevicePathInstance is NULL, then NULL is returned.
145 If DevicePath or DevicePathInstance is invalid, then NULL is returned.
146 If there is not enough memory to allocate space for the new device path, then
148 The memory is allocated from EFI boot services memory. It is the responsibility
149 of the caller to free the memory allocated.
151 @param DevicePath A pointer to a device path data structure.
152 @param DevicePathInstance A pointer to a device path instance.
154 @return A pointer to the new device path.
157 EFI_DEVICE_PATH_PROTOCOL
*
158 AppendDevicePathInstance (
159 CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
, OPTIONAL
160 CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePathInstance OPTIONAL
163 return UefiDevicePathLibAppendDevicePathInstance (DevicePath
, DevicePathInstance
);
167 Creates a copy of the current device path instance and returns a pointer to the next device path
170 This function creates a copy of the current device path instance. It also updates
171 DevicePath to point to the next device path instance in the device path (or NULL
172 if no more) and updates Size to hold the size of the device path instance copy.
173 If DevicePath is NULL, then NULL is returned.
174 If DevicePath points to a invalid device path, then NULL is returned.
175 If there is not enough memory to allocate space for the new device path, then
177 The memory is allocated from EFI boot services memory. It is the responsibility
178 of the caller to free the memory allocated.
179 If Size is NULL, then ASSERT().
181 @param DevicePath On input, this holds the pointer to the current
182 device path instance. On output, this holds
183 the pointer to the next device path instance
184 or NULL if there are no more device path
185 instances in the device path pointer to a
186 device path data structure.
187 @param Size On output, this holds the size of the device
188 path instance, in bytes or zero, if DevicePath
191 @return A pointer to the current device path instance.
194 EFI_DEVICE_PATH_PROTOCOL
*
195 GetNextDevicePathInstance (
196 EFI_DEVICE_PATH_PROTOCOL
**DevicePath
,
200 return UefiDevicePathLibGetNextDevicePathInstance (DevicePath
, Size
);
204 Creates a device node.
206 This function creates a new device node in a newly allocated buffer of size
207 NodeLength and initializes the device path node header with NodeType and NodeSubType.
208 The new device path node is returned.
209 If NodeLength is smaller than a device path header, then NULL is returned.
210 If there is not enough memory to allocate space for the new device path, then
212 The memory is allocated from EFI boot services memory. It is the responsibility
213 of the caller to free the memory allocated.
215 @param NodeType The device node type for the new device node.
216 @param NodeSubType The device node sub-type for the new device node.
217 @param NodeLength The length of the new device node.
219 @return The new device path.
222 EFI_DEVICE_PATH_PROTOCOL
*
229 return UefiDevicePathLibCreateDeviceNode (NodeType
, NodeSubType
, NodeLength
);
233 Determines if a device path is single or multi-instance.
235 This function returns TRUE if the device path specified by DevicePath is
237 Otherwise, FALSE is returned.
238 If DevicePath is NULL or invalid, then FALSE is returned.
240 @param DevicePath A pointer to a device path data structure.
242 @retval TRUE DevicePath is multi-instance.
243 @retval FALSE DevicePath is not multi-instance, or DevicePath
248 IsDevicePathMultiInstance (
249 CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
252 return UefiDevicePathLibIsDevicePathMultiInstance (DevicePath
);
256 Convert text to the binary representation of a device node.
258 @param TextDeviceNode TextDeviceNode points to the text representation of a device
259 node. Conversion starts with the first character and continues
260 until the first non-device node character.
262 @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was
263 insufficient memory or text unsupported.
266 EFI_DEVICE_PATH_PROTOCOL
*
267 ConvertTextToDeviceNode (
268 CONST CHAR16
*TextDeviceNode
271 return UefiDevicePathLibConvertTextToDeviceNode (TextDeviceNode
);
275 Convert text to the binary representation of a device path.
278 @param TextDevicePath TextDevicePath points to the text representation of a device
279 path. Conversion starts with the first character and continues
280 until the first non-device node character.
282 @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or
283 there was insufficient memory.
286 EFI_DEVICE_PATH_PROTOCOL
*
287 ConvertTextToDevicePath (
288 CONST CHAR16
*TextDevicePath
291 return UefiDevicePathLibConvertTextToDevicePath (TextDevicePath
);