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