2 Implementation file for Device Path Utilities Protocol
4 Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
5 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 #include "DevicePath.h"
18 Returns the size of a device path in bytes.
20 This function returns the size, in bytes, of the device path data structure specified by
21 DevicePath including the end of device path node. If DevicePath is NULL, then 0 is returned.
23 @param DevicePath A pointer to a device path data structure.
25 @return The size of a device path in bytes.
30 GetDevicePathSizeProtocolInterface (
31 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
34 return GetDevicePathSize (DevicePath
);
39 Creates a new device path by appending a second device path to a first device path.
41 This function allocates space for a new copy of the device path specified by DevicePath. If
42 DevicePath is NULL, then NULL is returned. If the memory is successfully allocated, then the
43 contents of DevicePath are copied to the newly allocated buffer, and a pointer to that buffer
44 is returned. Otherwise, NULL is returned.
46 @param DevicePath A pointer to a device path data structure.
48 @return A pointer to the duplicated device path.
51 EFI_DEVICE_PATH_PROTOCOL
*
53 DuplicateDevicePathProtocolInterface (
54 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
57 return DuplicateDevicePath (DevicePath
);
61 Creates a new device path by appending a second device path to a first device path.
63 This function creates a new device path by appending a copy of SecondDevicePath to a copy of
64 FirstDevicePath in a newly allocated buffer. Only the end-of-device-path device node from
65 SecondDevicePath is retained. The newly created device path is returned.
66 If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned.
67 If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned.
68 If both FirstDevicePath and SecondDevicePath are NULL, then a copy of an end-of-device-path is
70 If there is not enough memory for the newly allocated buffer, then NULL is returned.
71 The memory for the new device path is allocated from EFI boot services memory. It is the
72 responsibility of the caller to free the memory allocated.
74 @param FirstDevicePath A pointer to a device path data structure.
75 @param SecondDevicePath A pointer to a device path data structure.
77 @return A pointer to the new device path.
80 EFI_DEVICE_PATH_PROTOCOL
*
82 AppendDevicePathProtocolInterface (
83 IN CONST EFI_DEVICE_PATH_PROTOCOL
*FirstDevicePath
,
84 IN CONST EFI_DEVICE_PATH_PROTOCOL
*SecondDevicePath
87 return AppendDevicePath (FirstDevicePath
, SecondDevicePath
);
91 Creates a new path by appending the device node to the device path.
93 This function creates a new device path by appending a copy of the device node specified by
94 DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer.
95 The end-of-device-path device node is moved after the end of the appended device node.
96 If DevicePathNode is NULL then a copy of DevicePath is returned.
97 If DevicePath is NULL then a copy of DevicePathNode, followed by an end-of-device path device
99 If both DevicePathNode and DevicePath are NULL then a copy of an end-of-device-path device node
101 If there is not enough memory to allocate space for the new device path, then NULL is returned.
102 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
103 free the memory allocated.
105 @param DevicePath A pointer to a device path data structure.
106 @param DevicePathNode A pointer to a single device path node.
108 @return A pointer to the new device path.
111 EFI_DEVICE_PATH_PROTOCOL
*
113 AppendDeviceNodeProtocolInterface (
114 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
115 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
118 return AppendDevicePathNode (DevicePath
, DevicePathNode
);
122 Creates a new device path by appending the specified device path instance to the specified device
125 This function creates a new device path by appending a copy of the device path instance specified
126 by DevicePathInstance to a copy of the device path specified by DevicePath in a allocated buffer.
127 The end-of-device-path device node is moved after the end of the appended device path instance
128 and a new end-of-device-path-instance node is inserted between.
129 If DevicePath is NULL, then a copy if DevicePathInstance is returned.
130 If DevicePathInstance is NULL, then NULL is returned.
131 If there is not enough memory to allocate space for the new device path, then NULL is returned.
132 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
133 free the memory allocated.
135 @param DevicePath A pointer to a device path data structure.
136 @param DevicePathInstance A pointer to a device path instance.
138 @return A pointer to the new device path.
141 EFI_DEVICE_PATH_PROTOCOL
*
143 AppendDevicePathInstanceProtocolInterface (
144 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
145 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePathInstance
148 return AppendDevicePathInstance (DevicePath
, DevicePathInstance
);
152 Creates a copy of the current device path instance and returns a pointer to the next device path
155 This function creates a copy of the current device path instance. It also updates DevicePath to
156 point to the next device path instance in the device path (or NULL if no more) and updates Size
157 to hold the size of the device path instance copy.
158 If DevicePath is NULL, then NULL is returned.
159 If there is not enough memory to allocate space for the new device path, then NULL is returned.
160 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
161 free the memory allocated.
162 If Size is NULL, then ASSERT().
164 @param DevicePath On input, this holds the pointer to the current device path
165 instance. On output, this holds the pointer to the next device
166 path instance or NULL if there are no more device path
167 instances in the device path pointer to a device path data
169 @param Size On output, this holds the size of the device path instance, in
170 bytes or zero, if DevicePath is NULL.
172 @return A pointer to the current device path instance.
175 EFI_DEVICE_PATH_PROTOCOL
*
177 GetNextDevicePathInstanceProtocolInterface (
178 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
,
182 return GetNextDevicePathInstance (DevicePath
, Size
);
186 Determines if a device path is single or multi-instance.
188 This function returns TRUE if the device path specified by DevicePath is multi-instance.
189 Otherwise, FALSE is returned. If DevicePath is NULL, then FALSE is returned.
191 @param DevicePath A pointer to a device path data structure.
193 @retval TRUE DevicePath is multi-instance.
194 @retval FALSE DevicePath is not multi-instance or DevicePath is NULL.
199 IsDevicePathMultiInstanceProtocolInterface (
200 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
203 return IsDevicePathMultiInstance (DevicePath
);
207 Creates a copy of the current device path instance and returns a pointer to the next device path
210 This function creates a new device node in a newly allocated buffer of size NodeLength and
211 initializes the device path node header with NodeType and NodeSubType. The new device path node
213 If NodeLength is smaller than a device path header, then NULL is returned.
214 If there is not enough memory to allocate space for the new device path, then NULL is returned.
215 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
216 free the memory allocated.
218 @param NodeType The device node type for the new device node.
219 @param NodeSubType The device node sub-type for the new device node.
220 @param NodeLength The length of the new device node.
222 @return The new device path.
225 EFI_DEVICE_PATH_PROTOCOL
*
227 CreateDeviceNodeProtocolInterface (
229 IN UINT8 NodeSubType
,
233 return CreateDeviceNode (NodeType
, NodeSubType
, NodeLength
);