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