]>
Commit | Line | Data |
---|---|---|
13d40edd | 1 | /** @file\r |
2 | Implementation file for Device Path Utilities Protocol\r | |
95276127 | 3 | \r |
13d40edd | 4 | Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r |
5 | All rights reserved. This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
95276127 | 9 | \r |
13d40edd | 10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
95276127 | 12 | \r |
13d40edd | 13 | **/\r |
95276127 | 14 | \r |
95276127 | 15 | #include "DevicePath.h"\r |
16 | \r | |
572f5d8a | 17 | /**\r |
18 | Returns the size of a device path in bytes.\r | |
19 | \r | |
20 | This function returns the size, in bytes, of the device path data structure specified by\r | |
21 | DevicePath including the end of device path node. If DevicePath is NULL, then 0 is returned.\r | |
22 | \r | |
23 | @param DevicePath A pointer to a device path data structure.\r | |
24 | \r | |
25 | @return The size of a device path in bytes.\r | |
26 | \r | |
27 | **/\r | |
95276127 | 28 | UINTN\r |
572f5d8a | 29 | EFIAPI\r |
95276127 | 30 | GetDevicePathSizeProtocolInterface (\r |
31 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
32 | )\r | |
572f5d8a | 33 | {\r |
34 | return GetDevicePathSize (DevicePath);\r | |
35 | }\r | |
95276127 | 36 | \r |
95276127 | 37 | \r |
572f5d8a | 38 | /**\r |
39 | Creates a new device path by appending a second device path to a first device path.\r | |
95276127 | 40 | \r |
572f5d8a | 41 | This function allocates space for a new copy of the device path specified by DevicePath. If\r |
42 | DevicePath is NULL, then NULL is returned. If the memory is successfully allocated, then the\r | |
43 | contents of DevicePath are copied to the newly allocated buffer, and a pointer to that buffer\r | |
44 | is returned. Otherwise, NULL is returned.\r | |
95276127 | 45 | \r |
572f5d8a | 46 | @param DevicePath A pointer to a device path data structure.\r |
47 | \r | |
48 | @return A pointer to the duplicated device path.\r | |
95276127 | 49 | \r |
572f5d8a | 50 | **/\r |
95276127 | 51 | EFI_DEVICE_PATH_PROTOCOL *\r |
572f5d8a | 52 | EFIAPI\r |
95276127 | 53 | DuplicateDevicePathProtocolInterface (\r |
54 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
55 | )\r | |
572f5d8a | 56 | {\r |
57 | return DuplicateDevicePath (DevicePath);\r | |
58 | }\r | |
95276127 | 59 | \r |
572f5d8a | 60 | /**\r |
61 | Creates a new device path by appending a second device path to a first device path.\r | |
95276127 | 62 | \r |
572f5d8a | 63 | This function creates a new device path by appending a copy of SecondDevicePath to a copy of\r |
64 | FirstDevicePath in a newly allocated buffer. Only the end-of-device-path device node from\r | |
65 | SecondDevicePath is retained. The newly created device path is returned.\r | |
66 | If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned.\r | |
67 | If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned.\r | |
68 | If both FirstDevicePath and SecondDevicePath are NULL, then a copy of an end-of-device-path is\r | |
69 | returned.\r | |
70 | If there is not enough memory for the newly allocated buffer, then NULL is returned.\r | |
71 | The memory for the new device path is allocated from EFI boot services memory. It is the\r | |
72 | responsibility of the caller to free the memory allocated.\r | |
95276127 | 73 | \r |
572f5d8a | 74 | @param FirstDevicePath A pointer to a device path data structure.\r |
75 | @param SecondDevicePath A pointer to a device path data structure.\r | |
95276127 | 76 | \r |
572f5d8a | 77 | @return A pointer to the new device path.\r |
95276127 | 78 | \r |
572f5d8a | 79 | **/\r |
95276127 | 80 | EFI_DEVICE_PATH_PROTOCOL *\r |
572f5d8a | 81 | EFIAPI\r |
95276127 | 82 | AppendDevicePathProtocolInterface (\r |
572f5d8a | 83 | IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath,\r |
84 | IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath\r | |
95276127 | 85 | )\r |
572f5d8a | 86 | {\r |
87 | return AppendDevicePath (FirstDevicePath, SecondDevicePath);\r | |
88 | }\r | |
95276127 | 89 | \r |
572f5d8a | 90 | /**\r |
91 | Creates a new path by appending the device node to the device path.\r | |
95276127 | 92 | \r |
572f5d8a | 93 | This function creates a new device path by appending a copy of the device node specified by\r |
94 | DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer.\r | |
95 | The end-of-device-path device node is moved after the end of the appended device node.\r | |
96 | If DevicePathNode is NULL then a copy of DevicePath is returned.\r | |
97 | If DevicePath is NULL then a copy of DevicePathNode, followed by an end-of-device path device\r | |
98 | node is returned.\r | |
99 | If both DevicePathNode and DevicePath are NULL then a copy of an end-of-device-path device node\r | |
100 | is returned.\r | |
101 | If there is not enough memory to allocate space for the new device path, then NULL is returned.\r | |
102 | The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r | |
103 | free the memory allocated.\r | |
95276127 | 104 | \r |
572f5d8a | 105 | @param DevicePath A pointer to a device path data structure.\r |
106 | @param DevicePathNode A pointer to a single device path node.\r | |
95276127 | 107 | \r |
572f5d8a | 108 | @return A pointer to the new device path.\r |
95276127 | 109 | \r |
572f5d8a | 110 | **/\r |
95276127 | 111 | EFI_DEVICE_PATH_PROTOCOL *\r |
572f5d8a | 112 | EFIAPI\r |
95276127 | 113 | AppendDeviceNodeProtocolInterface (\r |
114 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r | |
572f5d8a | 115 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode\r |
95276127 | 116 | )\r |
572f5d8a | 117 | {\r |
118 | return AppendDevicePathNode (DevicePath, DevicePathNode);\r | |
119 | }\r | |
95276127 | 120 | \r |
572f5d8a | 121 | /**\r |
122 | Creates a new device path by appending the specified device path instance to the specified device\r | |
123 | path.\r | |
95276127 | 124 | \r |
572f5d8a | 125 | This function creates a new device path by appending a copy of the device path instance specified\r |
5755841f | 126 | by DevicePathInstance to a copy of the device path specified by DevicePath in a allocated buffer.\r |
572f5d8a | 127 | The end-of-device-path device node is moved after the end of the appended device path instance\r |
128 | and a new end-of-device-path-instance node is inserted between.\r | |
129 | If DevicePath is NULL, then a copy if DevicePathInstance is returned.\r | |
130 | If DevicePathInstance is NULL, then NULL is returned.\r | |
131 | If there is not enough memory to allocate space for the new device path, then NULL is returned.\r | |
132 | The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r | |
133 | free the memory allocated.\r | |
95276127 | 134 | \r |
572f5d8a | 135 | @param DevicePath A pointer to a device path data structure.\r |
136 | @param DevicePathInstance A pointer to a device path instance.\r | |
95276127 | 137 | \r |
572f5d8a | 138 | @return A pointer to the new device path.\r |
95276127 | 139 | \r |
572f5d8a | 140 | **/\r |
95276127 | 141 | EFI_DEVICE_PATH_PROTOCOL *\r |
572f5d8a | 142 | EFIAPI\r |
95276127 | 143 | AppendDevicePathInstanceProtocolInterface (\r |
144 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r | |
145 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance\r | |
146 | )\r | |
95276127 | 147 | {\r |
148 | return AppendDevicePathInstance (DevicePath, DevicePathInstance);\r | |
149 | }\r | |
150 | \r | |
572f5d8a | 151 | /**\r |
152 | Creates a copy of the current device path instance and returns a pointer to the next device path\r | |
153 | instance.\r | |
154 | \r | |
155 | This function creates a copy of the current device path instance. It also updates DevicePath to\r | |
156 | point to the next device path instance in the device path (or NULL if no more) and updates Size\r | |
157 | to hold the size of the device path instance copy.\r | |
158 | If DevicePath is NULL, then NULL is returned.\r | |
159 | If there is not enough memory to allocate space for the new device path, then NULL is returned.\r | |
160 | The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r | |
161 | free the memory allocated.\r | |
162 | If Size is NULL, then ASSERT().\r | |
163 | \r | |
164 | @param DevicePath On input, this holds the pointer to the current device path\r | |
165 | instance. On output, this holds the pointer to the next device\r | |
166 | path instance or NULL if there are no more device path\r | |
167 | instances in the device path pointer to a device path data\r | |
168 | structure.\r | |
169 | @param Size On output, this holds the size of the device path instance, in\r | |
170 | bytes or zero, if DevicePath is NULL.\r | |
171 | \r | |
172 | @return A pointer to the current device path instance.\r | |
173 | \r | |
174 | **/\r | |
95276127 | 175 | EFI_DEVICE_PATH_PROTOCOL *\r |
572f5d8a | 176 | EFIAPI\r |
95276127 | 177 | GetNextDevicePathInstanceProtocolInterface (\r |
572f5d8a | 178 | IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,\r |
179 | OUT UINTN *Size\r | |
95276127 | 180 | )\r |
572f5d8a | 181 | {\r |
182 | return GetNextDevicePathInstance (DevicePath, Size);\r | |
183 | }\r | |
95276127 | 184 | \r |
572f5d8a | 185 | /**\r |
186 | Determines if a device path is single or multi-instance.\r | |
95276127 | 187 | \r |
572f5d8a | 188 | This function returns TRUE if the device path specified by DevicePath is multi-instance.\r |
189 | Otherwise, FALSE is returned. If DevicePath is NULL, then FALSE is returned.\r | |
95276127 | 190 | \r |
572f5d8a | 191 | @param DevicePath A pointer to a device path data structure.\r |
95276127 | 192 | \r |
572f5d8a | 193 | @retval TRUE DevicePath is multi-instance.\r |
194 | @retval FALSE DevicePath is not multi-instance or DevicePath is NULL.\r | |
95276127 | 195 | \r |
572f5d8a | 196 | **/\r |
95276127 | 197 | BOOLEAN\r |
572f5d8a | 198 | EFIAPI\r |
95276127 | 199 | IsDevicePathMultiInstanceProtocolInterface (\r |
200 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
201 | )\r | |
572f5d8a | 202 | {\r |
203 | return IsDevicePathMultiInstance (DevicePath);\r | |
204 | }\r | |
95276127 | 205 | \r |
572f5d8a | 206 | /**\r |
207 | Creates a copy of the current device path instance and returns a pointer to the next device path\r | |
208 | instance.\r | |
95276127 | 209 | \r |
572f5d8a | 210 | This function creates a new device node in a newly allocated buffer of size NodeLength and\r |
211 | initializes the device path node header with NodeType and NodeSubType. The new device path node\r | |
212 | is returned.\r | |
213 | If NodeLength is smaller than a device path header, then NULL is returned.\r | |
214 | If there is not enough memory to allocate space for the new device path, then NULL is returned.\r | |
215 | The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r | |
216 | free the memory allocated.\r | |
95276127 | 217 | \r |
572f5d8a | 218 | @param NodeType The device node type for the new device node.\r |
219 | @param NodeSubType The device node sub-type for the new device node.\r | |
220 | @param NodeLength The length of the new device node.\r | |
95276127 | 221 | \r |
572f5d8a | 222 | @return The new device path.\r |
95276127 | 223 | \r |
572f5d8a | 224 | **/\r |
95276127 | 225 | EFI_DEVICE_PATH_PROTOCOL *\r |
572f5d8a | 226 | EFIAPI\r |
95276127 | 227 | CreateDeviceNodeProtocolInterface (\r |
228 | IN UINT8 NodeType,\r | |
229 | IN UINT8 NodeSubType,\r | |
230 | IN UINT16 NodeLength\r | |
231 | )\r | |
95276127 | 232 | {\r |
233 | return CreateDeviceNode (NodeType, NodeSubType, NodeLength);\r | |
234 | }\r |