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