]>
Commit | Line | Data |
---|---|---|
13d40edd | 1 | /** @file\r |
2 | Definition for Device Path Utilities driver\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 |
15 | #ifndef _DEVICE_PATH_DRIVER_H\r | |
16 | #define _DEVICE_PATH_DRIVER_H\r | |
17 | \r | |
859b72fa A |
18 | #include <PiDxe.h>\r |
19 | #include <Protocol/DevicePathUtilities.h>\r | |
20 | #include <Protocol/DebugPort.h>\r | |
21 | #include <Protocol/DevicePathToText.h>\r | |
22 | #include <Protocol/DevicePathFromText.h>\r | |
23 | #include <Guid/PcAnsi.h>\r | |
24 | #include <Library/DebugLib.h>\r | |
25 | #include <Library/PrintLib.h>\r | |
26 | #include <Library/UefiDriverEntryPoint.h>\r | |
27 | #include <Library/BaseLib.h>\r | |
28 | #include <Library/BaseMemoryLib.h>\r | |
29 | #include <Library/MemoryAllocationLib.h>\r | |
30 | #include <Library/UefiBootServicesTableLib.h>\r | |
31 | #include <Library/DevicePathLib.h>\r | |
32 | #include <Library/PcdLib.h>\r | |
95276127 | 33 | \r |
34 | extern const EFI_GUID mEfiDevicePathMessagingUartFlowControlGuid;\r | |
35 | extern const EFI_GUID mEfiDevicePathMessagingSASGuid;\r | |
36 | \r | |
37 | #define MAX_CHAR 480\r | |
38 | \r | |
39 | #define MIN_ALIGNMENT_SIZE sizeof(UINTN)\r | |
40 | #define ALIGN_SIZE(a) ((a % MIN_ALIGNMENT_SIZE) ? MIN_ALIGNMENT_SIZE - (a % MIN_ALIGNMENT_SIZE) : 0)\r | |
41 | \r | |
42 | #define IS_COMMA(a) ((a) == L',')\r | |
43 | #define IS_HYPHEN(a) ((a) == L'-')\r | |
44 | #define IS_DOT(a) ((a) == L'.')\r | |
45 | #define IS_LEFT_PARENTH(a) ((a) == L'(')\r | |
46 | #define IS_RIGHT_PARENTH(a) ((a) == L')')\r | |
47 | #define IS_SLASH(a) ((a) == L'/')\r | |
48 | #define IS_NULL(a) ((a) == L'\0')\r | |
49 | \r | |
50 | #define DEVICE_NODE_END 1\r | |
51 | #define DEVICE_PATH_INSTANCE_END 2\r | |
52 | #define DEVICE_PATH_END 3\r | |
53 | \r | |
54 | #define SetDevicePathInstanceEndNode(a) { \\r | |
55 | (a)->Type = END_DEVICE_PATH_TYPE; \\r | |
56 | (a)->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE; \\r | |
57 | (a)->Length[0] = sizeof (EFI_DEVICE_PATH_PROTOCOL); \\r | |
58 | (a)->Length[1] = 0; \\r | |
59 | }\r | |
60 | \r | |
61 | //\r | |
62 | // Private Data structure\r | |
63 | //\r | |
64 | typedef struct {\r | |
65 | CHAR16 *Str;\r | |
66 | UINTN Len;\r | |
67 | UINTN MaxLen;\r | |
68 | } POOL_PRINT;\r | |
69 | \r | |
70 | typedef struct {\r | |
71 | UINT8 Type;\r | |
72 | UINT8 SubType;\r | |
73 | VOID (*Function) (POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);\r | |
74 | } DEVICE_PATH_TO_TEXT_TABLE;\r | |
75 | \r | |
76 | typedef struct {\r | |
77 | CHAR16 *DevicePathNodeText;\r | |
78 | EFI_DEVICE_PATH_PROTOCOL * (*Function) (CHAR16 *);\r | |
79 | } DEVICE_PATH_FROM_TEXT_TABLE;\r | |
80 | \r | |
81 | typedef struct {\r | |
82 | BOOLEAN ClassExist;\r | |
83 | UINT8 Class;\r | |
84 | BOOLEAN SubClassExist;\r | |
85 | UINT8 SubClass;\r | |
86 | } USB_CLASS_TEXT;\r | |
87 | \r | |
88 | #define USB_CLASS_AUDIO 1\r | |
89 | #define USB_CLASS_CDCCONTROL 2\r | |
90 | #define USB_CLASS_HID 3\r | |
91 | #define USB_CLASS_IMAGE 6\r | |
92 | #define USB_CLASS_PRINTER 7\r | |
93 | #define USB_CLASS_MASS_STORAGE 8\r | |
94 | #define USB_CLASS_HUB 9\r | |
95 | #define USB_CLASS_CDCDATA 10\r | |
96 | #define USB_CLASS_SMART_CARD 11\r | |
97 | #define USB_CLASS_VIDEO 14\r | |
98 | #define USB_CLASS_DIAGNOSTIC 220\r | |
99 | #define USB_CLASS_WIRELESS 224\r | |
100 | \r | |
101 | #define USB_CLASS_RESERVE 254\r | |
102 | #define USB_SUBCLASS_FW_UPDATE 1\r | |
103 | #define USB_SUBCLASS_IRDA_BRIDGE 2\r | |
104 | #define USB_SUBCLASS_TEST 3\r | |
105 | \r | |
cf40f28a | 106 | #pragma pack(1)\r |
107 | \r | |
95276127 | 108 | typedef struct {\r |
109 | EFI_DEVICE_PATH_PROTOCOL Header;\r | |
110 | EFI_GUID Guid;\r | |
111 | UINT8 VendorDefinedData[1];\r | |
112 | } VENDOR_DEFINED_HARDWARE_DEVICE_PATH;\r | |
113 | \r | |
114 | typedef struct {\r | |
115 | EFI_DEVICE_PATH_PROTOCOL Header;\r | |
116 | EFI_GUID Guid;\r | |
117 | UINT8 VendorDefinedData[1];\r | |
118 | } VENDOR_DEFINED_MESSAGING_DEVICE_PATH;\r | |
119 | \r | |
120 | typedef struct {\r | |
121 | EFI_DEVICE_PATH_PROTOCOL Header;\r | |
122 | EFI_GUID Guid;\r | |
123 | UINT8 VendorDefinedData[1];\r | |
124 | } VENDOR_DEFINED_MEDIA_DEVICE_PATH;\r | |
125 | \r | |
126 | typedef struct {\r | |
127 | EFI_DEVICE_PATH_PROTOCOL Header;\r | |
128 | UINT32 HID;\r | |
129 | UINT32 UID;\r | |
130 | UINT32 CID;\r | |
131 | CHAR8 HidUidCidStr[3];\r | |
132 | } ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR;\r | |
133 | \r | |
134 | typedef struct {\r | |
135 | EFI_DEVICE_PATH_PROTOCOL Header;\r | |
136 | UINT16 NetworkProtocol;\r | |
137 | UINT16 LoginOption;\r | |
95276127 | 138 | UINT64 Lun;\r |
cf40f28a | 139 | UINT16 TargetPortalGroupTag;\r |
140 | CHAR8 iSCSITargetName[1];\r | |
95276127 | 141 | } ISCSI_DEVICE_PATH_WITH_NAME;\r |
142 | \r | |
143 | typedef struct {\r | |
144 | EFI_DEVICE_PATH_PROTOCOL Header;\r | |
145 | EFI_GUID Guid;\r | |
146 | UINT8 VendorDefinedData[1];\r | |
147 | } VENDOR_DEVICE_PATH_WITH_DATA;\r | |
148 | \r | |
cf40f28a | 149 | #pragma pack()\r |
150 | \r | |
95276127 | 151 | CHAR16 *\r |
152 | ConvertDeviceNodeToText (\r | |
153 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,\r | |
154 | IN BOOLEAN DisplayOnly,\r | |
155 | IN BOOLEAN AllowShortcuts\r | |
156 | )\r | |
157 | /*++\r | |
158 | \r | |
159 | Routine Description:\r | |
160 | Convert a device node to its text representation.\r | |
161 | \r | |
162 | Arguments:\r | |
163 | DeviceNode - Points to the device node to be converted.\r | |
164 | DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation\r | |
165 | of the display node is used, where applicable. If DisplayOnly\r | |
166 | is FALSE, then the longer text representation of the display node\r | |
167 | is used.\r | |
168 | AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
169 | representation for a device node can be used, where applicable.\r | |
170 | \r | |
171 | Returns:\r | |
172 | A pointer - a pointer to the allocated text representation of the device node.\r | |
173 | NULL - if DeviceNode is NULL or there was insufficient memory.\r | |
174 | \r | |
175 | --*/\r | |
176 | ;\r | |
177 | \r | |
178 | CHAR16 *\r | |
179 | ConvertDevicePathToText (\r | |
180 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,\r | |
181 | IN BOOLEAN DisplayOnly,\r | |
182 | IN BOOLEAN AllowShortcuts\r | |
183 | )\r | |
184 | /*++\r | |
185 | \r | |
186 | Routine Description:\r | |
187 | Convert a device path to its text representation.\r | |
188 | \r | |
189 | Arguments:\r | |
190 | DeviceNode - Points to the device path to be converted.\r | |
191 | DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation\r | |
192 | of the display node is used, where applicable. If DisplayOnly\r | |
193 | is FALSE, then the longer text representation of the display node\r | |
194 | is used.\r | |
195 | AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text\r | |
196 | representation for a device node can be used, where applicable.\r | |
197 | \r | |
198 | Returns:\r | |
199 | A pointer - a pointer to the allocated text representation of the device path.\r | |
200 | NULL - if DeviceNode is NULL or there was insufficient memory.\r | |
201 | \r | |
202 | --*/\r | |
203 | ;\r | |
204 | \r | |
205 | EFI_DEVICE_PATH_PROTOCOL *\r | |
206 | ConvertTextToDeviceNode (\r | |
207 | IN CONST CHAR16 *TextDeviceNode\r | |
208 | )\r | |
209 | /*++\r | |
210 | \r | |
211 | Routine Description:\r | |
212 | Convert text to the binary representation of a device node.\r | |
213 | \r | |
214 | Arguments:\r | |
215 | TextDeviceNode - TextDeviceNode points to the text representation of a device\r | |
216 | node. Conversion starts with the first character and continues\r | |
217 | until the first non-device node character.\r | |
218 | \r | |
219 | Returns:\r | |
220 | A pointer - Pointer to the EFI device node.\r | |
221 | NULL - if TextDeviceNode is NULL or there was insufficient memory.\r | |
222 | \r | |
223 | --*/\r | |
224 | ;\r | |
225 | \r | |
226 | EFI_DEVICE_PATH_PROTOCOL *\r | |
227 | ConvertTextToDevicePath (\r | |
228 | IN CONST CHAR16 *TextDevicePath\r | |
229 | )\r | |
230 | /*++\r | |
231 | \r | |
232 | Routine Description:\r | |
233 | Convert text to the binary representation of a device path.\r | |
234 | \r | |
235 | Arguments:\r | |
236 | TextDevicePath - TextDevicePath points to the text representation of a device\r | |
237 | path. Conversion starts with the first character and continues\r | |
238 | until the first non-device node character.\r | |
239 | \r | |
240 | Returns:\r | |
241 | A pointer - Pointer to the allocated device path.\r | |
242 | NULL - if TextDeviceNode is NULL or there was insufficient memory.\r | |
243 | \r | |
244 | --*/\r | |
245 | ;\r | |
246 | \r | |
247 | UINTN\r | |
248 | GetDevicePathSizeProtocolInterface (\r | |
249 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
250 | )\r | |
251 | /*++\r | |
252 | \r | |
253 | Routine Description:\r | |
254 | Returns the size of the device path, in bytes.\r | |
255 | \r | |
256 | Arguments:\r | |
257 | DevicePath - Points to the start of the EFI device path.\r | |
258 | \r | |
259 | Returns:\r | |
260 | Size - Size of the specified device path, in bytes, including the end-of-path tag.\r | |
261 | \r | |
262 | --*/\r | |
263 | ;\r | |
264 | \r | |
265 | EFI_DEVICE_PATH_PROTOCOL *\r | |
266 | DuplicateDevicePathProtocolInterface (\r | |
267 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
268 | )\r | |
269 | /*++\r | |
270 | \r | |
271 | Routine Description:\r | |
272 | Create a duplicate of the specified path.\r | |
273 | \r | |
274 | Arguments:\r | |
275 | DevicePath - Points to the source EFI device path.\r | |
276 | \r | |
277 | Returns:\r | |
278 | Pointer - A pointer to the duplicate device path.\r | |
279 | NULL - Insufficient memory.\r | |
280 | \r | |
281 | --*/\r | |
282 | ;\r | |
283 | \r | |
284 | EFI_DEVICE_PATH_PROTOCOL *\r | |
285 | AppendDevicePathProtocolInterface (\r | |
286 | IN CONST EFI_DEVICE_PATH_PROTOCOL *Src1,\r | |
287 | IN CONST EFI_DEVICE_PATH_PROTOCOL *Src2\r | |
288 | )\r | |
289 | /*++\r | |
290 | \r | |
291 | Routine Description:\r | |
292 | Create a new path by appending the second device path to the first.\r | |
293 | \r | |
294 | Arguments:\r | |
295 | Src1 - Points to the first device path. If NULL, then it is ignored.\r | |
296 | Src2 - Points to the second device path. If NULL, then it is ignored.\r | |
297 | \r | |
298 | Returns:\r | |
299 | Pointer - A pointer to the newly created device path.\r | |
300 | NULL - Memory could not be allocated\r | |
301 | or either DevicePath or DeviceNode is NULL.\r | |
302 | \r | |
303 | --*/\r | |
304 | ;\r | |
305 | \r | |
306 | EFI_DEVICE_PATH_PROTOCOL *\r | |
307 | AppendDeviceNodeProtocolInterface (\r | |
308 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r | |
309 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode\r | |
310 | )\r | |
311 | /*++\r | |
312 | \r | |
313 | Routine Description:\r | |
314 | Creates a new path by appending the device node to the device path.\r | |
315 | \r | |
316 | Arguments:\r | |
317 | DevicePath - Points to the device path.\r | |
318 | DeviceNode - Points to the device node.\r | |
319 | \r | |
320 | Returns:\r | |
321 | Pointer - A pointer to the allocated device node.\r | |
322 | NULL - Memory could not be allocated\r | |
323 | or either DevicePath or DeviceNode is NULL.\r | |
324 | \r | |
325 | --*/\r | |
326 | ;\r | |
327 | \r | |
328 | EFI_DEVICE_PATH_PROTOCOL *\r | |
329 | AppendDevicePathInstanceProtocolInterface (\r | |
330 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r | |
331 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance\r | |
332 | )\r | |
333 | /*++\r | |
334 | \r | |
335 | Routine Description:\r | |
336 | Creates a new path by appending the specified device path instance to the specified device path.\r | |
337 | \r | |
338 | Arguments:\r | |
339 | DevicePath - Points to the device path. If NULL, then ignored.\r | |
340 | DevicePathInstance - Points to the device path instance.\r | |
341 | \r | |
342 | Returns:\r | |
343 | Pointer - A pointer to the newly created device path\r | |
344 | NULL - Memory could not be allocated or DevicePathInstance is NULL.\r | |
345 | \r | |
346 | --*/\r | |
347 | ;\r | |
348 | \r | |
349 | EFI_DEVICE_PATH_PROTOCOL *\r | |
350 | GetNextDevicePathInstanceProtocolInterface (\r | |
351 | IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathInstance,\r | |
352 | OUT UINTN *DevicePathInstanceSize\r | |
353 | )\r | |
354 | /*++\r | |
355 | \r | |
356 | Routine Description:\r | |
357 | Creates a copy of the current device path instance and returns a pointer to the next device path instance.\r | |
358 | \r | |
359 | Arguments:\r | |
360 | DevicePathInstance - On input, this holds the pointer to the current device path\r | |
361 | instance. On output, this holds the pointer to the next\r | |
362 | device path instance or NULL if there are no more device\r | |
363 | path instances in the device path.\r | |
364 | DevicePathInstanceSize - On output, this holds the size of the device path instance,\r | |
365 | in bytes or zero, if DevicePathInstance is zero.\r | |
366 | \r | |
367 | Returns:\r | |
368 | Pointer - A pointer to the copy of the current device path instance.\r | |
369 | NULL - DevicePathInstace was NULL on entry or there was insufficient memory.\r | |
370 | \r | |
371 | --*/\r | |
372 | ;\r | |
373 | \r | |
374 | BOOLEAN\r | |
375 | IsDevicePathMultiInstanceProtocolInterface (\r | |
376 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
377 | )\r | |
378 | /*++\r | |
379 | \r | |
380 | Routine Description:\r | |
381 | Returns whether a device path is multi-instance.\r | |
382 | \r | |
383 | Arguments:\r | |
384 | DevicePath - Points to the device path. If NULL, then ignored.\r | |
385 | \r | |
386 | Returns:\r | |
387 | TRUE - The device path has more than one instance\r | |
388 | FALSE - The device path is empty or contains only a single instance.\r | |
389 | \r | |
390 | --*/\r | |
391 | ;\r | |
392 | \r | |
393 | EFI_DEVICE_PATH_PROTOCOL *\r | |
394 | CreateDeviceNodeProtocolInterface (\r | |
395 | IN UINT8 NodeType,\r | |
396 | IN UINT8 NodeSubType,\r | |
397 | IN UINT16 NodeLength\r | |
398 | )\r | |
399 | /*++\r | |
400 | \r | |
401 | Routine Description:\r | |
402 | Creates a device node\r | |
403 | \r | |
404 | Arguments:\r | |
405 | NodeType - NodeType is the device node type (EFI_DEVICE_PATH.Type) for\r | |
406 | the new device node.\r | |
407 | NodeSubType - NodeSubType is the device node sub-type\r | |
408 | EFI_DEVICE_PATH.SubType) for the new device node.\r | |
409 | NodeLength - NodeLength is the length of the device node\r | |
410 | (EFI_DEVICE_PATH.Length) for the new device node.\r | |
411 | \r | |
412 | Returns:\r | |
413 | Pointer - A pointer to the newly created device node.\r | |
414 | NULL - NodeLength is less than\r | |
415 | the size of the header or there was insufficient memory.\r | |
416 | \r | |
417 | --*/\r | |
418 | ;\r | |
419 | \r | |
420 | #endif\r |