4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef __DEVICE_PATH_LIB_H__
16 #define __DEVICE_PATH_LIB_H__
19 Returns the size of a device path in bytes.
21 This function returns the size, in bytes, of the device path data structure specified by
22 DevicePath including the end of device path node. If DevicePath is NULL, then 0 is returned.
24 @param DevicePath A pointer to a device path data structure.
26 @return The size of a device path in bytes.
32 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
36 Creates a new device path by appending a second device path to a first device path.
38 This function allocates space for a new copy of the device path specified by DevicePath. If
39 DevicePath is NULL, then NULL is returned. If the memory is successfully allocated, then the
40 contents of DevicePath are copied to the newly allocated buffer, and a pointer to that buffer
41 is returned. Otherwise, NULL is returned.
43 @param DevicePath A pointer to a device path data structure.
45 @return A pointer to the duplicated device path.
48 EFI_DEVICE_PATH_PROTOCOL
*
51 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
55 Creates a new device path by appending a second device path to a first device path.
57 This function creates a new device path by appending a copy of SecondDevicePath to a copy of
58 FirstDevicePath in a newly allocated buffer. Only the end-of-device-path device node from
59 SecondDevicePath is retained. The newly created device path is returned.
60 If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned.
61 If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned.
62 If both FirstDevicePath and SecondDevicePath are NULL, then a copy of an end-of-device-path is
64 If there is not enough memory for the newly allocated buffer, then NULL is returned.
65 The memory for the new device path is allocated from EFI boot services memory. It is the
66 responsibility of the caller to free the memory allocated.
68 @param FirstDevicePath A pointer to a device path data structure.
69 @param SecondDevicePath A pointer to a device path data structure.
71 @return A pointer to the new device path.
74 EFI_DEVICE_PATH_PROTOCOL
*
77 IN CONST EFI_DEVICE_PATH_PROTOCOL
*FirstDevicePath
, OPTIONAL
78 IN CONST EFI_DEVICE_PATH_PROTOCOL
*SecondDevicePath OPTIONAL
82 Creates a new path by appending the device node to the device path.
84 This function creates a new device path by appending a copy of the device node specified by
85 DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer.
86 The end-of-device-path device node is moved after the end of the appended device node.
87 If DeviceNode is NULL then a copy of DevicePath is returned.
88 If DevicePathNode is NULL then a copy of DevicePath is returned.
89 If both DevicePathNode and DevicePath are NULL then a copy of an end-of-device-path device node
91 If there is not enough memory to allocate space for the new device path, then NULL is returned.
92 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
93 free the memory allocated.
95 @param DevicePath A pointer to a device path data structure.
96 @param DevicePathNode A pointer to a single device path node.
98 @return A pointer to the new device path.
101 EFI_DEVICE_PATH_PROTOCOL
*
103 AppendDevicePathNode (
104 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
, OPTIONAL
105 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode OPTIONAL
109 Creates a new device path by appending the specified device path instance to the specified device
112 This function creates a new device path by appending a copy of the device path instance specified
113 by DevicePathInstance to a copy of the device path secified by DevicePath in a allocated buffer.
114 The end-of-device-path device node is moved after the end of the appended device path instance
115 and a new end-of-device-path-instance node is inserted between.
116 If DevicePath is NULL, then a copy if DevicePathInstance is returned.
117 If DevicePathInstance is NULL, then NULL is returned.
118 If there is not enough memory to allocate space for the new device path, then NULL is returned.
119 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
120 free the memory allocated.
122 @param DevicePath A pointer to a device path data structure.
123 @param DevicePathInstance A pointer to a device path instance.
125 @return A pointer to the new device path.
128 EFI_DEVICE_PATH_PROTOCOL
*
130 AppendDevicePathInstance (
131 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
, OPTIONAL
132 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePathInstance OPTIONAL
136 Creates a copy of the current device path instance and returns a pointer to the next device path
139 This function creates a copy of the current device path instance. It also updates DevicePath to
140 point to the next device path instance in the device path (or NULL if no more) and updates Size
141 to hold the size of the device path instance copy.
142 If DevicePath is NULL, then NULL is returned.
143 If there is not enough memory to allocate space for the new device path, then NULL is returned.
144 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
145 free the memory allocated.
146 If Size is NULL, then ASSERT().
148 @param DevicePath On input, this holds the pointer to the current device path
149 instance. On output, this holds the pointer to the next device
150 path instance or NULL if there are no more device path
151 instances in the device path pointer to a device path data
153 @param Size On output, this holds the size of the device path instance, in
154 bytes or zero, if DevicePath is NULL.
156 @return A pointer to the current device path instance.
159 EFI_DEVICE_PATH_PROTOCOL
*
161 GetNextDevicePathInstance (
162 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
,
167 Creates a copy of the current device path instance and returns a pointer to the next device path
170 This function creates a new device node in a newly allocated buffer of size NodeLength and
171 initializes the device path node header with NodeType and NodeSubType. The new device path node
173 If NodeLength is smaller than a device path header, then NULL is returned.
174 If there is not enough memory to allocate space for the new device path, then NULL is returned.
175 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
176 free the memory allocated.
178 @param NodeType The device node type for the new device node.
179 @param NodeSubType The device node sub-type for the new device node.
180 @param NodeLength The length of the new device node.
182 @return The new device path.
185 EFI_DEVICE_PATH_PROTOCOL
*
189 IN UINT8 NodeSubType
,
194 Determines if a device path is single or multi-instance.
196 This function returns TRUE if the device path specified by DevicePath is multi-instance.
197 Otherwise, FALSE is returned. If DevicePath is NULL, then FALSE is returned.
199 @param DevicePath A pointer to a device path data structure.
201 @retval TRUE DevicePath is multi-instance.
202 @retval FALSE DevicePath is not multi-instance or DevicePath is NULL.
207 IsDevicePathMultiInstance (
208 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
212 Retrieves the device path protocol from a handle.
214 This function returns the device path protocol from the handle specified by Handle. If Handle is
215 NULL or Handle does not contain a device path protocol, then NULL is returned.
217 @param Handle The handle from which to retrieve the device path protocol.
219 @return The device path protocol from the handle specified by Handle.
222 EFI_DEVICE_PATH_PROTOCOL
*
224 DevicePathFromHandle (
229 Allocates a device path for a file and appends it to an existing device path.
231 If Device is a valid device handle that contains a device path protocol, then a device path for
232 the file specified by FileName is allocated and appended to the device path associated with the
233 handle Device. The allocated device path is returned. If Device is NULL or Device is a handle
234 that does not support the device path protocol, then a device path containing a single device
235 path node for the file specified by FileName is allocated and returned.
236 If FileName is NULL, then ASSERT().
238 @param Device A pointer to a device handle. This parameter is optional and
240 @param FileName A pointer to a Null-terminated Unicode string.
242 @return The allocated device path.
245 EFI_DEVICE_PATH_PROTOCOL
*
248 IN EFI_HANDLE Device
, OPTIONAL
249 IN CONST CHAR16
*FileName