]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.h
MdePkg: Add UEFI2.5 bluetooth protocol/devicepath definition in MdePkg.
[mirror_edk2.git] / MdePkg / Library / UefiDevicePathLib / UefiDevicePathLib.h
CommitLineData
13d40edd 1/** @file\r
4d0a30a4 2 Definition for Device Path library.\r
95276127 3\r
5d6a5aee 4Copyright (c) 2013 - 2014, 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
4d0a30a4
RN
15#ifndef _UEFI_DEVICE_PATH_LIB_H_\r
16#define _UEFI_DEVICE_PATH_LIB_H_\r
60c93673 17#include <Uefi.h>\r
859b72fa
A
18#include <Protocol/DevicePathUtilities.h>\r
19#include <Protocol/DebugPort.h>\r
20#include <Protocol/DevicePathToText.h>\r
21#include <Protocol/DevicePathFromText.h>\r
22#include <Guid/PcAnsi.h>\r
23#include <Library/DebugLib.h>\r
24#include <Library/PrintLib.h>\r
859b72fa
A
25#include <Library/BaseLib.h>\r
26#include <Library/BaseMemoryLib.h>\r
27#include <Library/MemoryAllocationLib.h>\r
28#include <Library/UefiBootServicesTableLib.h>\r
29#include <Library/DevicePathLib.h>\r
30#include <Library/PcdLib.h>\r
95276127 31\r
95276127 32#define IS_COMMA(a) ((a) == L',')\r
33#define IS_HYPHEN(a) ((a) == L'-')\r
34#define IS_DOT(a) ((a) == L'.')\r
35#define IS_LEFT_PARENTH(a) ((a) == L'(')\r
36#define IS_RIGHT_PARENTH(a) ((a) == L')')\r
37#define IS_SLASH(a) ((a) == L'/')\r
38#define IS_NULL(a) ((a) == L'\0')\r
39\r
95276127 40\r
95276127 41//\r
42// Private Data structure\r
43//\r
44typedef struct {\r
45 CHAR16 *Str;\r
4d0a30a4 46 UINTN Count;\r
e9b3cd55 47 UINTN Capacity;\r
95276127 48} POOL_PRINT;\r
49\r
572f5d8a 50typedef\r
51EFI_DEVICE_PATH_PROTOCOL *\r
4d0a30a4
RN
52(*DEVICE_PATH_FROM_TEXT) (\r
53 IN CHAR16 *Str\r
572f5d8a 54 );\r
55\r
1ccdbf2a 56typedef\r
57VOID\r
4d0a30a4 58(*DEVICE_PATH_TO_TEXT) (\r
1ccdbf2a 59 IN OUT POOL_PRINT *Str,\r
4d0a30a4 60 IN VOID *DevicePath,\r
1ccdbf2a 61 IN BOOLEAN DisplayOnly,\r
62 IN BOOLEAN AllowShortcuts\r
63 );\r
64\r
95276127 65typedef struct {\r
4d0a30a4
RN
66 UINT8 Type;\r
67 UINT8 SubType;\r
68 DEVICE_PATH_TO_TEXT Function;\r
95276127 69} DEVICE_PATH_TO_TEXT_TABLE;\r
70\r
5d6a5aee
RN
71typedef struct {\r
72 UINT8 Type;\r
73 CHAR16 *Text;\r
74} DEVICE_PATH_TO_TEXT_GENERIC_TABLE;\r
75\r
95276127 76typedef struct {\r
77 CHAR16 *DevicePathNodeText;\r
4d0a30a4 78 DEVICE_PATH_FROM_TEXT Function;\r
95276127 79} DEVICE_PATH_FROM_TEXT_TABLE;\r
80\r
81typedef 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
052019e1 106#define RFC_1700_UDP_PROTOCOL 17\r
107#define RFC_1700_TCP_PROTOCOL 6\r
108\r
cf40f28a 109#pragma pack(1)\r
110\r
95276127 111typedef struct {\r
112 EFI_DEVICE_PATH_PROTOCOL Header;\r
113 EFI_GUID Guid;\r
114 UINT8 VendorDefinedData[1];\r
115} VENDOR_DEFINED_HARDWARE_DEVICE_PATH;\r
116\r
117typedef struct {\r
118 EFI_DEVICE_PATH_PROTOCOL Header;\r
119 EFI_GUID Guid;\r
120 UINT8 VendorDefinedData[1];\r
121} VENDOR_DEFINED_MESSAGING_DEVICE_PATH;\r
122\r
123typedef struct {\r
124 EFI_DEVICE_PATH_PROTOCOL Header;\r
125 EFI_GUID Guid;\r
126 UINT8 VendorDefinedData[1];\r
127} VENDOR_DEFINED_MEDIA_DEVICE_PATH;\r
128\r
129typedef struct {\r
130 EFI_DEVICE_PATH_PROTOCOL Header;\r
1ccdbf2a 131 UINT32 Hid;\r
132 UINT32 Uid;\r
133 UINT32 Cid;\r
95276127 134 CHAR8 HidUidCidStr[3];\r
135} ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR;\r
136\r
137typedef struct {\r
138 EFI_DEVICE_PATH_PROTOCOL Header;\r
139 UINT16 NetworkProtocol;\r
140 UINT16 LoginOption;\r
95276127 141 UINT64 Lun;\r
cf40f28a 142 UINT16 TargetPortalGroupTag;\r
184f7d83 143 CHAR8 TargetName[1];\r
95276127 144} ISCSI_DEVICE_PATH_WITH_NAME;\r
145\r
146typedef struct {\r
147 EFI_DEVICE_PATH_PROTOCOL Header;\r
148 EFI_GUID Guid;\r
149 UINT8 VendorDefinedData[1];\r
150} VENDOR_DEVICE_PATH_WITH_DATA;\r
151\r
cf40f28a 152#pragma pack()\r
153\r
572f5d8a 154/**\r
4d0a30a4 155 Returns the size of a device path in bytes.\r
572f5d8a 156\r
4d0a30a4
RN
157 This function returns the size, in bytes, of the device path data structure \r
158 specified by DevicePath including the end of device path node.\r
159 If DevicePath is NULL or invalid, then 0 is returned.\r
572f5d8a 160\r
4d0a30a4
RN
161 @param DevicePath A pointer to a device path data structure.\r
162\r
163 @retval 0 If DevicePath is NULL or invalid.\r
164 @retval Others The size of a device path in bytes.\r
572f5d8a 165\r
166**/\r
4d0a30a4 167UINTN\r
572f5d8a 168EFIAPI\r
4d0a30a4
RN
169UefiDevicePathLibGetDevicePathSize (\r
170 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
572f5d8a 171 );\r
95276127 172\r
572f5d8a 173/**\r
4d0a30a4
RN
174 Creates a new copy of an existing device path.\r
175\r
176 This function allocates space for a new copy of the device path specified by DevicePath. \r
177 If DevicePath is NULL, then NULL is returned. If the memory is successfully \r
178 allocated, then the contents of DevicePath are copied to the newly allocated \r
179 buffer, and a pointer to that buffer is returned. Otherwise, NULL is returned. \r
180 The memory for the new device path is allocated from EFI boot services memory. \r
181 It is the responsibility of the caller to free the memory allocated. \r
182 \r
183 @param DevicePath A pointer to a device path data structure.\r
184\r
185 @retval NULL DevicePath is NULL or invalid.\r
186 @retval Others A pointer to the duplicated device path.\r
187 \r
572f5d8a 188**/\r
4d0a30a4 189EFI_DEVICE_PATH_PROTOCOL *\r
572f5d8a 190EFIAPI\r
4d0a30a4
RN
191UefiDevicePathLibDuplicateDevicePath (\r
192 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
572f5d8a 193 );\r
95276127 194\r
572f5d8a 195/**\r
4d0a30a4 196 Creates a new device path by appending a second device path to a first device path.\r
95276127 197\r
4d0a30a4
RN
198 This function creates a new device path by appending a copy of SecondDevicePath \r
199 to a copy of FirstDevicePath in a newly allocated buffer. Only the end-of-device-path \r
200 device node from SecondDevicePath is retained. The newly created device path is \r
201 returned. If FirstDevicePath is NULL, then it is ignored, and a duplicate of \r
202 SecondDevicePath is returned. If SecondDevicePath is NULL, then it is ignored, \r
203 and a duplicate of FirstDevicePath is returned. If both FirstDevicePath and \r
204 SecondDevicePath are NULL, then a copy of an end-of-device-path is returned. \r
205 \r
206 If there is not enough memory for the newly allocated buffer, then NULL is returned.\r
207 The memory for the new device path is allocated from EFI boot services memory. \r
208 It is the responsibility of the caller to free the memory allocated.\r
95276127 209\r
4d0a30a4
RN
210 @param FirstDevicePath A pointer to a device path data structure.\r
211 @param SecondDevicePath A pointer to a device path data structure.\r
212 \r
213 @retval NULL If there is not enough memory for the newly allocated buffer.\r
214 @retval NULL If FirstDevicePath or SecondDevicePath is invalid.\r
215 @retval Others A pointer to the new device path if success.\r
216 Or a copy an end-of-device-path if both FirstDevicePath and SecondDevicePath are NULL.\r
95276127 217\r
572f5d8a 218**/\r
95276127 219EFI_DEVICE_PATH_PROTOCOL *\r
572f5d8a 220EFIAPI\r
4d0a30a4
RN
221UefiDevicePathLibAppendDevicePath (\r
222 IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath, OPTIONAL\r
223 IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath OPTIONAL\r
572f5d8a 224 );\r
95276127 225\r
572f5d8a 226/**\r
4d0a30a4 227 Creates a new path by appending the device node to the device path.\r
95276127 228\r
4d0a30a4
RN
229 This function creates a new device path by appending a copy of the device node \r
230 specified by DevicePathNode to a copy of the device path specified by DevicePath \r
231 in an allocated buffer. The end-of-device-path device node is moved after the \r
232 end of the appended device node.\r
233 If DevicePathNode is NULL then a copy of DevicePath is returned.\r
234 If DevicePath is NULL then a copy of DevicePathNode, followed by an end-of-device \r
235 path device node is returned.\r
236 If both DevicePathNode and DevicePath are NULL then a copy of an end-of-device-path \r
237 device node is returned.\r
238 If there is not enough memory to allocate space for the new device path, then \r
239 NULL is returned. \r
240 The memory is allocated from EFI boot services memory. It is the responsibility \r
241 of the caller to free the memory allocated.\r
95276127 242\r
4d0a30a4
RN
243 @param DevicePath A pointer to a device path data structure.\r
244 @param DevicePathNode A pointer to a single device path node.\r
95276127 245\r
4d0a30a4
RN
246 @retval NULL If there is not enough memory for the new device path.\r
247 @retval Others A pointer to the new device path if success.\r
248 A copy of DevicePathNode followed by an end-of-device-path node \r
249 if both FirstDevicePath and SecondDevicePath are NULL.\r
250 A copy of an end-of-device-path node if both FirstDevicePath \r
251 and SecondDevicePath are NULL.\r
95276127 252\r
572f5d8a 253**/\r
95276127 254EFI_DEVICE_PATH_PROTOCOL *\r
572f5d8a 255EFIAPI\r
4d0a30a4
RN
256UefiDevicePathLibAppendDevicePathNode (\r
257 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL\r
258 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL\r
572f5d8a 259 );\r
95276127 260\r
572f5d8a 261/**\r
4d0a30a4
RN
262 Creates a new device path by appending the specified device path instance to the specified device\r
263 path.\r
264 \r
265 This function creates a new device path by appending a copy of the device path \r
266 instance specified by DevicePathInstance to a copy of the device path specified \r
267 by DevicePath in a allocated buffer.\r
268 The end-of-device-path device node is moved after the end of the appended device \r
269 path instance and a new end-of-device-path-instance node is inserted between. \r
270 If DevicePath is NULL, then a copy if DevicePathInstance is returned.\r
271 If DevicePathInstance is NULL, then NULL is returned.\r
272 If DevicePath or DevicePathInstance is invalid, then NULL is returned.\r
273 If there is not enough memory to allocate space for the new device path, then \r
274 NULL is returned. \r
275 The memory is allocated from EFI boot services memory. It is the responsibility \r
276 of the caller to free the memory allocated.\r
277 \r
572f5d8a 278 @param DevicePath A pointer to a device path data structure.\r
4d0a30a4 279 @param DevicePathInstance A pointer to a device path instance.\r
95276127 280\r
4d0a30a4 281 @return A pointer to the new device path.\r
95276127 282\r
572f5d8a 283**/\r
4d0a30a4 284EFI_DEVICE_PATH_PROTOCOL *\r
572f5d8a 285EFIAPI\r
4d0a30a4
RN
286UefiDevicePathLibAppendDevicePathInstance (\r
287 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL\r
288 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance OPTIONAL\r
572f5d8a 289 );\r
95276127 290\r
572f5d8a 291/**\r
4d0a30a4
RN
292 Creates a copy of the current device path instance and returns a pointer to the next device path\r
293 instance.\r
95276127 294\r
4d0a30a4
RN
295 This function creates a copy of the current device path instance. It also updates \r
296 DevicePath to point to the next device path instance in the device path (or NULL \r
297 if no more) and updates Size to hold the size of the device path instance copy.\r
298 If DevicePath is NULL, then NULL is returned.\r
299 If DevicePath points to a invalid device path, then NULL is returned.\r
300 If there is not enough memory to allocate space for the new device path, then \r
301 NULL is returned. \r
302 The memory is allocated from EFI boot services memory. It is the responsibility \r
303 of the caller to free the memory allocated.\r
304 If Size is NULL, then ASSERT().\r
305 \r
306 @param DevicePath On input, this holds the pointer to the current \r
307 device path instance. On output, this holds \r
308 the pointer to the next device path instance \r
309 or NULL if there are no more device path\r
310 instances in the device path pointer to a \r
311 device path data structure.\r
312 @param Size On output, this holds the size of the device \r
313 path instance, in bytes or zero, if DevicePath \r
314 is NULL.\r
95276127 315\r
4d0a30a4 316 @return A pointer to the current device path instance.\r
95276127 317\r
572f5d8a 318**/\r
95276127 319EFI_DEVICE_PATH_PROTOCOL *\r
572f5d8a 320EFIAPI\r
4d0a30a4
RN
321UefiDevicePathLibGetNextDevicePathInstance (\r
322 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,\r
323 OUT UINTN *Size\r
572f5d8a 324 );\r
95276127 325\r
572f5d8a 326/**\r
4d0a30a4 327 Creates a device node.\r
95276127 328\r
4d0a30a4
RN
329 This function creates a new device node in a newly allocated buffer of size \r
330 NodeLength and initializes the device path node header with NodeType and NodeSubType. \r
331 The new device path node is returned.\r
332 If NodeLength is smaller than a device path header, then NULL is returned. \r
333 If there is not enough memory to allocate space for the new device path, then \r
334 NULL is returned. \r
335 The memory is allocated from EFI boot services memory. It is the responsibility \r
336 of the caller to free the memory allocated.\r
95276127 337\r
4d0a30a4
RN
338 @param NodeType The device node type for the new device node.\r
339 @param NodeSubType The device node sub-type for the new device node.\r
340 @param NodeLength The length of the new device node.\r
95276127 341\r
4d0a30a4 342 @return The new device path.\r
95276127 343\r
572f5d8a 344**/\r
95276127 345EFI_DEVICE_PATH_PROTOCOL *\r
572f5d8a 346EFIAPI\r
4d0a30a4
RN
347UefiDevicePathLibCreateDeviceNode (\r
348 IN UINT8 NodeType,\r
349 IN UINT8 NodeSubType,\r
350 IN UINT16 NodeLength\r
572f5d8a 351 );\r
352\r
353/**\r
4d0a30a4 354 Determines if a device path is single or multi-instance.\r
572f5d8a 355\r
4d0a30a4
RN
356 This function returns TRUE if the device path specified by DevicePath is\r
357 multi-instance.\r
358 Otherwise, FALSE is returned.\r
359 If DevicePath is NULL or invalid, then FALSE is returned.\r
572f5d8a 360\r
361 @param DevicePath A pointer to a device path data structure.\r
572f5d8a 362\r
4d0a30a4
RN
363 @retval TRUE DevicePath is multi-instance.\r
364 @retval FALSE DevicePath is not multi-instance, or DevicePath \r
365 is NULL or invalid.\r
95276127 366\r
572f5d8a 367**/\r
4d0a30a4 368BOOLEAN\r
572f5d8a 369EFIAPI\r
4d0a30a4
RN
370UefiDevicePathLibIsDevicePathMultiInstance (\r
371 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
572f5d8a 372 );\r
95276127 373\r
95276127 374\r
4d0a30a4
RN
375/**\r
376 Converts a device path to its text representation.\r
95276127 377\r
4d0a30a4
RN
378 @param DevicePath A Pointer to the device to be converted.\r
379 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
380 of the display node is used, where applicable. If DisplayOnly\r
381 is FALSE, then the longer text representation of the display node\r
382 is used.\r
383 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
384 representation for a device node can be used, where applicable.\r
95276127 385\r
4d0a30a4
RN
386 @return A pointer to the allocated text representation of the device path or\r
387 NULL if DeviceNode is NULL or there was insufficient memory.\r
95276127 388\r
572f5d8a 389**/\r
4d0a30a4 390CHAR16 *\r
572f5d8a 391EFIAPI\r
4d0a30a4
RN
392UefiDevicePathLibConvertDevicePathToText (\r
393 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
394 IN BOOLEAN DisplayOnly,\r
395 IN BOOLEAN AllowShortcuts\r
572f5d8a 396 );\r
397\r
398/**\r
4d0a30a4 399 Converts a device node to its string representation.\r
572f5d8a 400\r
4d0a30a4
RN
401 @param DeviceNode A Pointer to the device node to be converted.\r
402 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation\r
403 of the display node is used, where applicable. If DisplayOnly\r
404 is FALSE, then the longer text representation of the display node\r
405 is used.\r
406 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text\r
407 representation for a device node can be used, where applicable.\r
572f5d8a 408\r
4d0a30a4
RN
409 @return A pointer to the allocated text representation of the device node or NULL if DeviceNode\r
410 is NULL or there was insufficient memory.\r
95276127 411\r
572f5d8a 412**/\r
4d0a30a4 413CHAR16 *\r
572f5d8a 414EFIAPI\r
4d0a30a4
RN
415UefiDevicePathLibConvertDeviceNodeToText (\r
416 IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,\r
417 IN BOOLEAN DisplayOnly,\r
418 IN BOOLEAN AllowShortcuts\r
572f5d8a 419 );\r
95276127 420\r
572f5d8a 421/**\r
4d0a30a4 422 Convert text to the binary representation of a device node.\r
95276127 423\r
4d0a30a4
RN
424 @param TextDeviceNode TextDeviceNode points to the text representation of a device\r
425 node. Conversion starts with the first character and continues\r
426 until the first non-device node character.\r
95276127 427\r
4d0a30a4
RN
428 @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was\r
429 insufficient memory or text unsupported.\r
95276127 430\r
572f5d8a 431**/\r
4d0a30a4 432EFI_DEVICE_PATH_PROTOCOL *\r
572f5d8a 433EFIAPI\r
4d0a30a4
RN
434UefiDevicePathLibConvertTextToDeviceNode (\r
435 IN CONST CHAR16 *TextDeviceNode\r
572f5d8a 436 );\r
95276127 437\r
572f5d8a 438/**\r
4d0a30a4 439 Convert text to the binary representation of a device path.\r
95276127 440\r
95276127 441\r
4d0a30a4
RN
442 @param TextDevicePath TextDevicePath points to the text representation of a device\r
443 path. Conversion starts with the first character and continues\r
444 until the first non-device node character.\r
95276127 445\r
4d0a30a4
RN
446 @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or\r
447 there was insufficient memory.\r
95276127 448\r
572f5d8a 449**/\r
95276127 450EFI_DEVICE_PATH_PROTOCOL *\r
572f5d8a 451EFIAPI\r
4d0a30a4
RN
452UefiDevicePathLibConvertTextToDevicePath (\r
453 IN CONST CHAR16 *TextDevicePath\r
572f5d8a 454 );\r
95276127 455\r
456#endif\r