]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/C/Include/Protocol/DevicePathUtilities.h
d046c86453b20ba05bf3427d47f160d3d0f2c5e8
[mirror_edk2.git] / BaseTools / Source / C / Include / Protocol / DevicePathUtilities.h
1 /** @file
2 EFI_DEVICE_PATH_UTILITIES_PROTOCOL as defined in UEFI 2.0.
3 Use to create and manipulate device paths and device nodes.
4
5 Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #ifndef __DEVICE_PATH_UTILITIES_H__
17 #define __DEVICE_PATH_UTILITIES_H__
18
19 ///
20 /// Device Path Utilities protocol
21 ///
22 #define EFI_DEVICE_PATH_UTILITIES_GUID \
23 { \
24 0x379be4e, 0xd706, 0x437d, {0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4 } \
25 }
26
27 /**
28 Returns the size of the device path, in bytes.
29
30 @param DevicePath Points to the start of the EFI device path.
31
32 @return Size Size of the specified device path, in bytes, including the end-of-path tag.
33 @retval 0 DevicePath is NULL
34
35 **/
36 typedef
37 UINTN
38 ( *EFI_DEVICE_PATH_UTILS_GET_DEVICE_PATH_SIZE)(
39 CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
40 );
41
42
43 /**
44 Create a duplicate of the specified path.
45
46 @param DevicePath Points to the source EFI device path.
47
48 @retval Pointer A pointer to the duplicate device path.
49 @retval NULL insufficient memory or DevicePath is NULL
50
51 **/
52 typedef
53 EFI_DEVICE_PATH_PROTOCOL*
54 ( *EFI_DEVICE_PATH_UTILS_DUP_DEVICE_PATH)(
55 CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
56 );
57
58 /**
59 Create a new path by appending the second device path to the first.
60 If Src1 is NULL and Src2 is non-NULL, then a duplicate of Src2 is returned.
61 If Src1 is non-NULL and Src2 is NULL, then a duplicate of Src1 is returned.
62 If Src1 and Src2 are both NULL, then a copy of an end-of-device-path is returned.
63
64 @param Src1 Points to the first device path.
65 @param Src2 Points to the second device path.
66
67 @retval Pointer A pointer to the newly created device path.
68 @retval NULL Memory could not be allocated
69
70 **/
71 typedef
72 EFI_DEVICE_PATH_PROTOCOL*
73 ( *EFI_DEVICE_PATH_UTILS_APPEND_PATH)(
74 CONST EFI_DEVICE_PATH_PROTOCOL *Src1,
75 CONST EFI_DEVICE_PATH_PROTOCOL *Src2
76 );
77
78 /**
79 Creates a new path by appending the device node to the device path.
80 If DeviceNode is NULL then a copy of DevicePath is returned.
81 If DevicePath is NULL then a copy of DeviceNode, followed by an end-of-device path device node is returned.
82 If both DeviceNode and DevicePath are NULL then a copy of an end-of-device-path device node is returned.
83
84 @param DevicePath Points to the device path.
85 @param DeviceNode Points to the device node.
86
87 @retval Pointer A pointer to the allocated device node.
88 @retval NULL There was insufficient memory.
89
90 **/
91 typedef
92 EFI_DEVICE_PATH_PROTOCOL*
93 ( *EFI_DEVICE_PATH_UTILS_APPEND_NODE)(
94 CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
95 CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode
96 );
97
98 /**
99 Creates a new path by appending the specified device path instance to the specified device path.
100
101 @param DevicePath Points to the device path. If NULL, then ignored.
102 @param DevicePathInstance Points to the device path instance.
103
104 @retval Pointer A pointer to the newly created device path
105 @retval NULL Memory could not be allocated or DevicePathInstance is NULL.
106
107 **/
108 typedef
109 EFI_DEVICE_PATH_PROTOCOL*
110 ( *EFI_DEVICE_PATH_UTILS_APPEND_INSTANCE)(
111 CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
112 CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance
113 );
114
115 /**
116 Creates a copy of the current device path instance and returns a pointer to the next device path
117 instance.
118
119 @param DevicePathInstance On input, this holds the pointer to the current device path
120 instance. On output, this holds the pointer to the next
121 device path instance or NULL if there are no more device
122 path instances in the device path.
123 @param DevicePathInstanceSize On output, this holds the size of the device path instance,
124 in bytes or zero, if DevicePathInstance is NULL.
125 If NULL, then the instance size is not output.
126
127 @retval Pointer A pointer to the copy of the current device path instance.
128 @retval NULL DevicePathInstace was NULL on entry or there was insufficient memory.
129
130 **/
131 typedef
132 EFI_DEVICE_PATH_PROTOCOL*
133 ( *EFI_DEVICE_PATH_UTILS_GET_NEXT_INSTANCE)(
134 EFI_DEVICE_PATH_PROTOCOL **DevicePathInstance,
135 UINTN *DevicePathInstanceSize
136 );
137
138 /**
139 Creates a device node
140
141 @param NodeType NodeType is the device node type (EFI_DEVICE_PATH.Type) for
142 the new device node.
143 @param NodeSubType NodeSubType is the device node sub-type
144 EFI_DEVICE_PATH.SubType) for the new device node.
145 @param NodeLength NodeLength is the length of the device node
146 (EFI_DEVICE_PATH.Length) for the new device node.
147
148 @retval Pointer A pointer to the newly created device node.
149 @retval NULL NodeLength is less than
150 the size of the header or there was insufficient memory.
151
152 **/
153 typedef
154 EFI_DEVICE_PATH_PROTOCOL*
155 ( *EFI_DEVICE_PATH_UTILS_CREATE_NODE)(
156 UINT8 NodeType,
157 UINT8 NodeSubType,
158 UINT16 NodeLength
159 );
160
161 /**
162 Returns whether a device path is multi-instance.
163
164 @param DevicePath Points to the device path. If NULL, then ignored.
165
166 @retval TRUE The device path has more than one instance
167 @retval FALSE The device path is empty or contains only a single instance.
168
169 **/
170 typedef
171 BOOLEAN
172 ( *EFI_DEVICE_PATH_UTILS_IS_MULTI_INSTANCE)(
173 CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
174 );
175
176 ///
177 /// This protocol is used to creates and manipulates device paths and device nodes.
178 ///
179 typedef struct {
180 EFI_DEVICE_PATH_UTILS_GET_DEVICE_PATH_SIZE GetDevicePathSize;
181 EFI_DEVICE_PATH_UTILS_DUP_DEVICE_PATH DuplicateDevicePath;
182 EFI_DEVICE_PATH_UTILS_APPEND_PATH AppendDevicePath;
183 EFI_DEVICE_PATH_UTILS_APPEND_NODE AppendDeviceNode;
184 EFI_DEVICE_PATH_UTILS_APPEND_INSTANCE AppendDevicePathInstance;
185 EFI_DEVICE_PATH_UTILS_GET_NEXT_INSTANCE GetNextDevicePathInstance;
186 EFI_DEVICE_PATH_UTILS_IS_MULTI_INSTANCE IsDevicePathMultiInstance;
187 EFI_DEVICE_PATH_UTILS_CREATE_NODE CreateDeviceNode;
188 } EFI_DEVICE_PATH_UTILITIES_PROTOCOL;
189
190 extern EFI_GUID gEfiDevicePathUtilitiesProtocolGuid;
191
192 VOID
193 SetDevicePathEndNode (
194 VOID *Node
195 );
196
197 BOOLEAN
198 IsDevicePathValid (
199 CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
200 UINTN MaxSize
201 );
202
203 UINT8
204 DevicePathType (
205 CONST VOID *Node
206 );
207
208 UINT8
209 DevicePathSubType (
210 CONST VOID *Node
211 );
212
213 UINTN
214 DevicePathNodeLength (
215 CONST VOID *Node
216 );
217
218 EFI_DEVICE_PATH_PROTOCOL *
219 NextDevicePathNode (
220 CONST VOID *Node
221 );
222
223 BOOLEAN
224 IsDevicePathEndType (
225 CONST VOID *Node
226 );
227
228 BOOLEAN
229 IsDevicePathEnd (
230 CONST VOID *Node
231 );
232 BOOLEAN
233 IsDevicePathEndInstance (
234 CONST VOID *Node
235 );
236
237 UINT16
238 SetDevicePathNodeLength (
239 VOID *Node,
240 UINTN Length
241 );
242
243 VOID
244 SetDevicePathEndNode (
245 VOID *Node
246 );
247
248 UINTN
249 UefiDevicePathLibGetDevicePathSize (
250 CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
251 );
252
253 EFI_DEVICE_PATH_PROTOCOL *
254 UefiDevicePathLibDuplicateDevicePath (
255 CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
256 );
257
258 EFI_DEVICE_PATH_PROTOCOL *
259 UefiDevicePathLibAppendDevicePath (
260 CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath,
261 CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath
262 );
263
264 EFI_DEVICE_PATH_PROTOCOL *
265 UefiDevicePathLibAppendDevicePathNode (
266 CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
267 CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode
268 );
269
270 EFI_DEVICE_PATH_PROTOCOL *
271 UefiDevicePathLibAppendDevicePathInstance (
272 CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
273 CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance
274 );
275
276 EFI_DEVICE_PATH_PROTOCOL *
277 UefiDevicePathLibGetNextDevicePathInstance (
278 EFI_DEVICE_PATH_PROTOCOL **DevicePath,
279 UINTN *Size
280 );
281
282 EFI_DEVICE_PATH_PROTOCOL *
283 UefiDevicePathLibCreateDeviceNode (
284 UINT8 NodeType,
285 UINT8 NodeSubType,
286 UINT16 NodeLength
287 );
288
289 BOOLEAN
290 UefiDevicePathLibIsDevicePathMultiInstance (
291 CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
292 );
293
294 #endif