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