]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/DevicePathDxe/DevicePath.h
Support new format of IPv4 device path node, FibreEx and PcieRoot device path node...
[mirror_edk2.git] / MdeModulePkg / Universal / DevicePathDxe / DevicePath.h
CommitLineData
13d40edd 1/** @file\r
2 Definition for Device Path Utilities driver\r
95276127 3\r
e9b3cd55 4Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
e5eed7d3 5This program and the accompanying materials\r
13d40edd 6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
95276127 9\r
13d40edd 10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
95276127 12\r
13d40edd 13**/\r
95276127 14\r
572f5d8a 15#ifndef _DEVICE_PATH_DRIVER_H_\r
16#define _DEVICE_PATH_DRIVER_H_\r
95276127 17\r
60c93673 18#include <Uefi.h>\r
859b72fa
A
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
95276127 34#define IS_COMMA(a) ((a) == L',')\r
35#define IS_HYPHEN(a) ((a) == L'-')\r
36#define IS_DOT(a) ((a) == L'.')\r
37#define IS_LEFT_PARENTH(a) ((a) == L'(')\r
38#define IS_RIGHT_PARENTH(a) ((a) == L')')\r
39#define IS_SLASH(a) ((a) == L'/')\r
40#define IS_NULL(a) ((a) == L'\0')\r
41\r
95276127 42\r
c9325700
ED
43#define SET_DEVICE_PATH_INSTANCE_END_NODE(a) { \\r
44 (a)->Type = END_DEVICE_PATH_TYPE; \\r
45 (a)->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE; \\r
46 (a)->Length[0] = (UINT8) sizeof (EFI_DEVICE_PATH_PROTOCOL); \\r
47 (a)->Length[1] = 0; \\r
95276127 48 }\r
49\r
50//\r
51// Private Data structure\r
52//\r
53typedef struct {\r
54 CHAR16 *Str;\r
e9b3cd55
RN
55 UINTN Length;\r
56 UINTN Capacity;\r
95276127 57} POOL_PRINT;\r
58\r
572f5d8a 59typedef\r
60EFI_DEVICE_PATH_PROTOCOL *\r
61(*DUMP_NODE) (\r
62 IN CHAR16 *DeviceNodeStr\r
63 );\r
64\r
1ccdbf2a 65typedef\r
66VOID\r
67(*DEVICE_PATH_TO_TEXT_FUNC) (\r
68 IN OUT POOL_PRINT *Str,\r
69 IN VOID *DevPath,\r
70 IN BOOLEAN DisplayOnly,\r
71 IN BOOLEAN AllowShortcuts\r
72 );\r
73\r
95276127 74typedef struct {\r
1ccdbf2a 75 UINT8 Type;\r
76 UINT8 SubType;\r
77 DEVICE_PATH_TO_TEXT_FUNC Function;\r
95276127 78} DEVICE_PATH_TO_TEXT_TABLE;\r
79\r
80typedef struct {\r
81 CHAR16 *DevicePathNodeText;\r
572f5d8a 82 DUMP_NODE Function;\r
95276127 83} DEVICE_PATH_FROM_TEXT_TABLE;\r
84\r
85typedef struct {\r
86 BOOLEAN ClassExist;\r
87 UINT8 Class;\r
88 BOOLEAN SubClassExist;\r
89 UINT8 SubClass;\r
90} USB_CLASS_TEXT;\r
91\r
92#define USB_CLASS_AUDIO 1\r
93#define USB_CLASS_CDCCONTROL 2\r
94#define USB_CLASS_HID 3\r
95#define USB_CLASS_IMAGE 6\r
96#define USB_CLASS_PRINTER 7\r
97#define USB_CLASS_MASS_STORAGE 8\r
98#define USB_CLASS_HUB 9\r
99#define USB_CLASS_CDCDATA 10\r
100#define USB_CLASS_SMART_CARD 11\r
101#define USB_CLASS_VIDEO 14\r
102#define USB_CLASS_DIAGNOSTIC 220\r
103#define USB_CLASS_WIRELESS 224\r
104\r
105#define USB_CLASS_RESERVE 254\r
106#define USB_SUBCLASS_FW_UPDATE 1\r
107#define USB_SUBCLASS_IRDA_BRIDGE 2\r
108#define USB_SUBCLASS_TEST 3\r
109\r
052019e1 110#define RFC_1700_UDP_PROTOCOL 17\r
111#define RFC_1700_TCP_PROTOCOL 6\r
112\r
cf40f28a 113#pragma pack(1)\r
114\r
95276127 115typedef struct {\r
116 EFI_DEVICE_PATH_PROTOCOL Header;\r
117 EFI_GUID Guid;\r
118 UINT8 VendorDefinedData[1];\r
119} VENDOR_DEFINED_HARDWARE_DEVICE_PATH;\r
120\r
121typedef struct {\r
122 EFI_DEVICE_PATH_PROTOCOL Header;\r
123 EFI_GUID Guid;\r
124 UINT8 VendorDefinedData[1];\r
125} VENDOR_DEFINED_MESSAGING_DEVICE_PATH;\r
126\r
127typedef struct {\r
128 EFI_DEVICE_PATH_PROTOCOL Header;\r
129 EFI_GUID Guid;\r
130 UINT8 VendorDefinedData[1];\r
131} VENDOR_DEFINED_MEDIA_DEVICE_PATH;\r
132\r
133typedef struct {\r
134 EFI_DEVICE_PATH_PROTOCOL Header;\r
1ccdbf2a 135 UINT32 Hid;\r
136 UINT32 Uid;\r
137 UINT32 Cid;\r
95276127 138 CHAR8 HidUidCidStr[3];\r
139} ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR;\r
140\r
141typedef struct {\r
142 EFI_DEVICE_PATH_PROTOCOL Header;\r
143 UINT16 NetworkProtocol;\r
144 UINT16 LoginOption;\r
95276127 145 UINT64 Lun;\r
cf40f28a 146 UINT16 TargetPortalGroupTag;\r
184f7d83 147 CHAR8 TargetName[1];\r
95276127 148} ISCSI_DEVICE_PATH_WITH_NAME;\r
149\r
150typedef struct {\r
151 EFI_DEVICE_PATH_PROTOCOL Header;\r
152 EFI_GUID Guid;\r
153 UINT8 VendorDefinedData[1];\r
154} VENDOR_DEVICE_PATH_WITH_DATA;\r
155\r
cf40f28a 156#pragma pack()\r
157\r
572f5d8a 158/**\r
159 Converts a device node to its string representation.\r
160\r
161 @param DeviceNode A Pointer to the device node to be converted.\r
162 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
163 of the display node is used, where applicable. If DisplayOnly\r
164 is FALSE, then the longer text representation of the display node\r
165 is used.\r
166 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
167 representation for a device node can be used, where applicable.\r
168\r
169 @return A pointer to the allocated text representation of the device node or NULL if DeviceNode\r
170 is NULL or there was insufficient memory.\r
171\r
172**/\r
95276127 173CHAR16 *\r
572f5d8a 174EFIAPI\r
95276127 175ConvertDeviceNodeToText (\r
176 IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,\r
177 IN BOOLEAN DisplayOnly,\r
178 IN BOOLEAN AllowShortcuts\r
572f5d8a 179 );\r
95276127 180\r
572f5d8a 181/**\r
182 Converts a device path to its text representation.\r
95276127 183\r
572f5d8a 184 @param DevicePath A Pointer to the device to be converted.\r
185 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
95276127 186 of the display node is used, where applicable. If DisplayOnly\r
187 is FALSE, then the longer text representation of the display node\r
188 is used.\r
572f5d8a 189 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
95276127 190 representation for a device node can be used, where applicable.\r
191\r
572f5d8a 192 @return A pointer to the allocated text representation of the device path or\r
193 NULL if DeviceNode is NULL or there was insufficient memory.\r
95276127 194\r
572f5d8a 195**/\r
95276127 196CHAR16 *\r
572f5d8a 197EFIAPI\r
95276127 198ConvertDevicePathToText (\r
572f5d8a 199 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
200 IN BOOLEAN DisplayOnly,\r
201 IN BOOLEAN AllowShortcuts\r
202 );\r
95276127 203\r
572f5d8a 204/**\r
205 Convert text to the binary representation of a device node.\r
95276127 206\r
572f5d8a 207 @param TextDeviceNode TextDeviceNode points to the text representation of a device\r
208 node. Conversion starts with the first character and continues\r
209 until the first non-device node character.\r
95276127 210\r
572f5d8a 211 @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was\r
212 insufficient memory or text unsupported.\r
95276127 213\r
572f5d8a 214**/\r
95276127 215EFI_DEVICE_PATH_PROTOCOL *\r
572f5d8a 216EFIAPI\r
95276127 217ConvertTextToDeviceNode (\r
218 IN CONST CHAR16 *TextDeviceNode\r
572f5d8a 219 );\r
95276127 220\r
572f5d8a 221/**\r
222 Convert text to the binary representation of a device path.\r
95276127 223\r
95276127 224\r
572f5d8a 225 @param TextDevicePath TextDevicePath points to the text representation of a device\r
226 path. Conversion starts with the first character and continues\r
227 until the first non-device node character.\r
95276127 228\r
572f5d8a 229 @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or\r
230 there was insufficient memory.\r
95276127 231\r
572f5d8a 232**/\r
95276127 233EFI_DEVICE_PATH_PROTOCOL *\r
572f5d8a 234EFIAPI\r
95276127 235ConvertTextToDevicePath (\r
236 IN CONST CHAR16 *TextDevicePath\r
572f5d8a 237 );\r
95276127 238\r
572f5d8a 239/**\r
240 Returns the size of a device path in bytes.\r
95276127 241\r
572f5d8a 242 This function returns the size, in bytes, of the device path data structure specified by\r
243 DevicePath including the end of device path node. If DevicePath is NULL, then 0 is returned.\r
95276127 244\r
572f5d8a 245 @param DevicePath A pointer to a device path data structure.\r
95276127 246\r
572f5d8a 247 @return The size of a device path in bytes.\r
95276127 248\r
572f5d8a 249**/\r
95276127 250UINTN\r
572f5d8a 251EFIAPI\r
95276127 252GetDevicePathSizeProtocolInterface (\r
253 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
572f5d8a 254 );\r
95276127 255\r
572f5d8a 256/**\r
257 Creates a new device path by appending a second device path to a first device path.\r
95276127 258\r
572f5d8a 259 This function allocates space for a new copy of the device path specified by DevicePath. If\r
260 DevicePath is NULL, then NULL is returned. If the memory is successfully allocated, then the\r
261 contents of DevicePath are copied to the newly allocated buffer, and a pointer to that buffer\r
262 is returned. Otherwise, NULL is returned.\r
95276127 263\r
572f5d8a 264 @param DevicePath A pointer to a device path data structure.\r
95276127 265\r
572f5d8a 266 @return A pointer to the duplicated device path.\r
95276127 267\r
572f5d8a 268**/\r
95276127 269EFI_DEVICE_PATH_PROTOCOL *\r
572f5d8a 270EFIAPI\r
95276127 271DuplicateDevicePathProtocolInterface (\r
272 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
572f5d8a 273 );\r
95276127 274\r
572f5d8a 275/**\r
276 Creates a new device path by appending a second device path to a first device path.\r
95276127 277\r
572f5d8a 278 This function creates a new device path by appending a copy of SecondDevicePath to a copy of\r
279 FirstDevicePath in a newly allocated buffer. Only the end-of-device-path device node from\r
280 SecondDevicePath is retained. The newly created device path is returned.\r
281 If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned.\r
282 If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned.\r
283 If both FirstDevicePath and SecondDevicePath are NULL, then a copy of an end-of-device-path is\r
284 returned.\r
285 If there is not enough memory for the newly allocated buffer, then NULL is returned.\r
286 The memory for the new device path is allocated from EFI boot services memory. It is the\r
287 responsibility of the caller to free the memory allocated.\r
95276127 288\r
572f5d8a 289 @param FirstDevicePath A pointer to a device path data structure.\r
290 @param SecondDevicePath A pointer to a device path data structure.\r
95276127 291\r
572f5d8a 292 @return A pointer to the new device path.\r
95276127 293\r
572f5d8a 294**/\r
95276127 295EFI_DEVICE_PATH_PROTOCOL *\r
572f5d8a 296EFIAPI\r
95276127 297AppendDevicePathProtocolInterface (\r
572f5d8a 298 IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath,\r
299 IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath\r
300 );\r
301\r
302/**\r
303 Creates a new path by appending the device node to the device path.\r
304\r
305 This function creates a new device path by appending a copy of the device node specified by\r
306 DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer.\r
307 The end-of-device-path device node is moved after the end of the appended device node.\r
308 If DevicePathNode is NULL then a copy of DevicePath is returned.\r
309 If DevicePath is NULL then a copy of DevicePathNode, followed by an end-of-device path device\r
310 node is returned.\r
311 If both DevicePathNode and DevicePath are NULL then a copy of an end-of-device-path device node\r
312 is returned.\r
313 If there is not enough memory to allocate space for the new device path, then NULL is returned.\r
314 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
315 free the memory allocated.\r
316\r
317 @param DevicePath A pointer to a device path data structure.\r
318 @param DevicePathNode A pointer to a single device path node.\r
319\r
320 @return A pointer to the new device path.\r
95276127 321\r
572f5d8a 322**/\r
95276127 323EFI_DEVICE_PATH_PROTOCOL *\r
572f5d8a 324EFIAPI\r
95276127 325AppendDeviceNodeProtocolInterface (\r
326 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
572f5d8a 327 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode\r
328 );\r
95276127 329\r
572f5d8a 330/**\r
331 Creates a new device path by appending the specified device path instance to the specified device\r
332 path.\r
95276127 333\r
572f5d8a 334 This function creates a new device path by appending a copy of the device path instance specified\r
5755841f 335 by DevicePathInstance to a copy of the device path specified by DevicePath in a allocated buffer.\r
572f5d8a 336 The end-of-device-path device node is moved after the end of the appended device path instance\r
337 and a new end-of-device-path-instance node is inserted between.\r
338 If DevicePath is NULL, then a copy if DevicePathInstance is returned.\r
339 If DevicePathInstance is NULL, then NULL is returned.\r
340 If there is not enough memory to allocate space for the new device path, then NULL is returned.\r
341 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
342 free the memory allocated.\r
95276127 343\r
572f5d8a 344 @param DevicePath A pointer to a device path data structure.\r
345 @param DevicePathInstance A pointer to a device path instance.\r
95276127 346\r
572f5d8a 347 @return A pointer to the new device path.\r
95276127 348\r
572f5d8a 349**/\r
95276127 350EFI_DEVICE_PATH_PROTOCOL *\r
572f5d8a 351EFIAPI\r
95276127 352AppendDevicePathInstanceProtocolInterface (\r
353 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
354 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance\r
572f5d8a 355 );\r
356\r
357/**\r
358 Creates a copy of the current device path instance and returns a pointer to the next device path\r
359 instance.\r
360\r
361 This function creates a copy of the current device path instance. It also updates DevicePath to\r
362 point to the next device path instance in the device path (or NULL if no more) and updates Size\r
363 to hold the size of the device path instance copy.\r
364 If DevicePath is NULL, then NULL is returned.\r
365 If there is not enough memory to allocate space for the new device path, then NULL is returned.\r
366 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
367 free the memory allocated.\r
368 If Size is NULL, then ASSERT().\r
369\r
370 @param DevicePath On input, this holds the pointer to the current device path\r
371 instance. On output, this holds the pointer to the next device\r
372 path instance or NULL if there are no more device path\r
373 instances in the device path pointer to a device path data\r
374 structure.\r
375 @param Size On output, this holds the size of the device path instance, in\r
376 bytes or zero, if DevicePath is NULL.\r
377\r
378 @return A pointer to the current device path instance.\r
95276127 379\r
572f5d8a 380**/\r
95276127 381EFI_DEVICE_PATH_PROTOCOL *\r
572f5d8a 382EFIAPI\r
95276127 383GetNextDevicePathInstanceProtocolInterface (\r
572f5d8a 384 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,\r
385 OUT UINTN *Size\r
386 );\r
95276127 387\r
572f5d8a 388/**\r
389 Determines if a device path is single or multi-instance.\r
95276127 390\r
572f5d8a 391 This function returns TRUE if the device path specified by DevicePath is multi-instance.\r
392 Otherwise, FALSE is returned. If DevicePath is NULL, then FALSE is returned.\r
95276127 393\r
572f5d8a 394 @param DevicePath A pointer to a device path data structure.\r
95276127 395\r
572f5d8a 396 @retval TRUE DevicePath is multi-instance.\r
397 @retval FALSE DevicePath is not multi-instance or DevicePath is NULL.\r
95276127 398\r
572f5d8a 399**/\r
95276127 400BOOLEAN\r
572f5d8a 401EFIAPI\r
95276127 402IsDevicePathMultiInstanceProtocolInterface (\r
403 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
572f5d8a 404 );\r
95276127 405\r
572f5d8a 406/**\r
407 Creates a copy of the current device path instance and returns a pointer to the next device path\r
408 instance.\r
95276127 409\r
572f5d8a 410 This function creates a new device node in a newly allocated buffer of size NodeLength and\r
411 initializes the device path node header with NodeType and NodeSubType. The new device path node\r
412 is returned.\r
413 If NodeLength is smaller than a device path header, then NULL is returned.\r
414 If there is not enough memory to allocate space for the new device path, then NULL is returned.\r
415 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
416 free the memory allocated.\r
95276127 417\r
572f5d8a 418 @param NodeType The device node type for the new device node.\r
419 @param NodeSubType The device node sub-type for the new device node.\r
420 @param NodeLength The length of the new device node.\r
95276127 421\r
572f5d8a 422 @return The new device path.\r
95276127 423\r
572f5d8a 424**/\r
95276127 425EFI_DEVICE_PATH_PROTOCOL *\r
572f5d8a 426EFIAPI\r
95276127 427CreateDeviceNodeProtocolInterface (\r
428 IN UINT8 NodeType,\r
429 IN UINT8 NodeSubType,\r
430 IN UINT16 NodeLength\r
572f5d8a 431 );\r
95276127 432\r
433#endif\r