2 Definition for Device Path Utilities driver
4 Copyright (c) 2006 - 2010, Intel Corporation. <BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef _DEVICE_PATH_DRIVER_H_
16 #define _DEVICE_PATH_DRIVER_H_
19 #include <Protocol/DevicePathUtilities.h>
20 #include <Protocol/DebugPort.h>
21 #include <Protocol/DevicePathToText.h>
22 #include <Protocol/DevicePathFromText.h>
23 #include <Guid/PcAnsi.h>
24 #include <Library/DebugLib.h>
25 #include <Library/PrintLib.h>
26 #include <Library/UefiDriverEntryPoint.h>
27 #include <Library/BaseLib.h>
28 #include <Library/BaseMemoryLib.h>
29 #include <Library/MemoryAllocationLib.h>
30 #include <Library/UefiBootServicesTableLib.h>
31 #include <Library/DevicePathLib.h>
32 #include <Library/PcdLib.h>
37 #define IS_COMMA(a) ((a) == L',')
38 #define IS_HYPHEN(a) ((a) == L'-')
39 #define IS_DOT(a) ((a) == L'.')
40 #define IS_LEFT_PARENTH(a) ((a) == L'(')
41 #define IS_RIGHT_PARENTH(a) ((a) == L')')
42 #define IS_SLASH(a) ((a) == L'/')
43 #define IS_NULL(a) ((a) == L'\0')
46 #define SET_DEVICE_PATH_INSTANCE_END_NODE(a) { \
47 (a)->Type = END_DEVICE_PATH_TYPE; \
48 (a)->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE; \
49 (a)->Length[0] = sizeof (EFI_DEVICE_PATH_PROTOCOL); \
54 // Private Data structure
63 EFI_DEVICE_PATH_PROTOCOL
*
65 IN CHAR16
*DeviceNodeStr
70 (*DEVICE_PATH_TO_TEXT_FUNC
) (
71 IN OUT POOL_PRINT
*Str
,
73 IN BOOLEAN DisplayOnly
,
74 IN BOOLEAN AllowShortcuts
80 DEVICE_PATH_TO_TEXT_FUNC Function
;
81 } DEVICE_PATH_TO_TEXT_TABLE
;
84 CHAR16
*DevicePathNodeText
;
86 } DEVICE_PATH_FROM_TEXT_TABLE
;
91 BOOLEAN SubClassExist
;
95 #define USB_CLASS_AUDIO 1
96 #define USB_CLASS_CDCCONTROL 2
97 #define USB_CLASS_HID 3
98 #define USB_CLASS_IMAGE 6
99 #define USB_CLASS_PRINTER 7
100 #define USB_CLASS_MASS_STORAGE 8
101 #define USB_CLASS_HUB 9
102 #define USB_CLASS_CDCDATA 10
103 #define USB_CLASS_SMART_CARD 11
104 #define USB_CLASS_VIDEO 14
105 #define USB_CLASS_DIAGNOSTIC 220
106 #define USB_CLASS_WIRELESS 224
108 #define USB_CLASS_RESERVE 254
109 #define USB_SUBCLASS_FW_UPDATE 1
110 #define USB_SUBCLASS_IRDA_BRIDGE 2
111 #define USB_SUBCLASS_TEST 3
116 EFI_DEVICE_PATH_PROTOCOL Header
;
118 UINT8 VendorDefinedData
[1];
119 } VENDOR_DEFINED_HARDWARE_DEVICE_PATH
;
122 EFI_DEVICE_PATH_PROTOCOL Header
;
124 UINT8 VendorDefinedData
[1];
125 } VENDOR_DEFINED_MESSAGING_DEVICE_PATH
;
128 EFI_DEVICE_PATH_PROTOCOL Header
;
130 UINT8 VendorDefinedData
[1];
131 } VENDOR_DEFINED_MEDIA_DEVICE_PATH
;
134 EFI_DEVICE_PATH_PROTOCOL Header
;
138 CHAR8 HidUidCidStr
[3];
139 } ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR
;
142 EFI_DEVICE_PATH_PROTOCOL Header
;
143 UINT16 NetworkProtocol
;
146 UINT16 TargetPortalGroupTag
;
148 } ISCSI_DEVICE_PATH_WITH_NAME
;
151 EFI_DEVICE_PATH_PROTOCOL Header
;
153 UINT8 VendorDefinedData
[1];
154 } VENDOR_DEVICE_PATH_WITH_DATA
;
159 Converts a device node to its string representation.
161 @param DeviceNode A Pointer to the device node to be converted.
162 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
163 of the display node is used, where applicable. If DisplayOnly
164 is FALSE, then the longer text representation of the display node
166 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
167 representation for a device node can be used, where applicable.
169 @return A pointer to the allocated text representation of the device node or NULL if DeviceNode
170 is NULL or there was insufficient memory.
175 ConvertDeviceNodeToText (
176 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
,
177 IN BOOLEAN DisplayOnly
,
178 IN BOOLEAN AllowShortcuts
182 Converts a device path to its text representation.
184 @param DevicePath A Pointer to the device to be converted.
185 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
186 of the display node is used, where applicable. If DisplayOnly
187 is FALSE, then the longer text representation of the display node
189 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
190 representation for a device node can be used, where applicable.
192 @return A pointer to the allocated text representation of the device path or
193 NULL if DeviceNode is NULL or there was insufficient memory.
198 ConvertDevicePathToText (
199 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
200 IN BOOLEAN DisplayOnly
,
201 IN BOOLEAN AllowShortcuts
205 Convert text to the binary representation of a device node.
207 @param TextDeviceNode TextDeviceNode points to the text representation of a device
208 node. Conversion starts with the first character and continues
209 until the first non-device node character.
211 @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was
212 insufficient memory or text unsupported.
215 EFI_DEVICE_PATH_PROTOCOL
*
217 ConvertTextToDeviceNode (
218 IN CONST CHAR16
*TextDeviceNode
222 Convert text to the binary representation of a device path.
225 @param TextDevicePath TextDevicePath points to the text representation of a device
226 path. Conversion starts with the first character and continues
227 until the first non-device node character.
229 @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or
230 there was insufficient memory.
233 EFI_DEVICE_PATH_PROTOCOL
*
235 ConvertTextToDevicePath (
236 IN CONST CHAR16
*TextDevicePath
240 Returns the size of a device path in bytes.
242 This function returns the size, in bytes, of the device path data structure specified by
243 DevicePath including the end of device path node. If DevicePath is NULL, then 0 is returned.
245 @param DevicePath A pointer to a device path data structure.
247 @return The size of a device path in bytes.
252 GetDevicePathSizeProtocolInterface (
253 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
257 Creates a new device path by appending a second device path to a first device path.
259 This function allocates space for a new copy of the device path specified by DevicePath. If
260 DevicePath is NULL, then NULL is returned. If the memory is successfully allocated, then the
261 contents of DevicePath are copied to the newly allocated buffer, and a pointer to that buffer
262 is returned. Otherwise, NULL is returned.
264 @param DevicePath A pointer to a device path data structure.
266 @return A pointer to the duplicated device path.
269 EFI_DEVICE_PATH_PROTOCOL
*
271 DuplicateDevicePathProtocolInterface (
272 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
276 Creates a new device path by appending a second device path to a first device path.
278 This function creates a new device path by appending a copy of SecondDevicePath to a copy of
279 FirstDevicePath in a newly allocated buffer. Only the end-of-device-path device node from
280 SecondDevicePath is retained. The newly created device path is returned.
281 If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned.
282 If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned.
283 If both FirstDevicePath and SecondDevicePath are NULL, then a copy of an end-of-device-path is
285 If there is not enough memory for the newly allocated buffer, then NULL is returned.
286 The memory for the new device path is allocated from EFI boot services memory. It is the
287 responsibility of the caller to free the memory allocated.
289 @param FirstDevicePath A pointer to a device path data structure.
290 @param SecondDevicePath A pointer to a device path data structure.
292 @return A pointer to the new device path.
295 EFI_DEVICE_PATH_PROTOCOL
*
297 AppendDevicePathProtocolInterface (
298 IN CONST EFI_DEVICE_PATH_PROTOCOL
*FirstDevicePath
,
299 IN CONST EFI_DEVICE_PATH_PROTOCOL
*SecondDevicePath
303 Creates a new path by appending the device node to the device path.
305 This function creates a new device path by appending a copy of the device node specified by
306 DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer.
307 The end-of-device-path device node is moved after the end of the appended device node.
308 If DevicePathNode is NULL then a copy of DevicePath is returned.
309 If DevicePath is NULL then a copy of DevicePathNode, followed by an end-of-device path device
311 If both DevicePathNode and DevicePath are NULL then a copy of an end-of-device-path device node
313 If there is not enough memory to allocate space for the new device path, then NULL is returned.
314 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
315 free the memory allocated.
317 @param DevicePath A pointer to a device path data structure.
318 @param DevicePathNode A pointer to a single device path node.
320 @return A pointer to the new device path.
323 EFI_DEVICE_PATH_PROTOCOL
*
325 AppendDeviceNodeProtocolInterface (
326 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
327 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
331 Creates a new device path by appending the specified device path instance to the specified device
334 This function creates a new device path by appending a copy of the device path instance specified
335 by DevicePathInstance to a copy of the device path specified by DevicePath in a allocated buffer.
336 The end-of-device-path device node is moved after the end of the appended device path instance
337 and a new end-of-device-path-instance node is inserted between.
338 If DevicePath is NULL, then a copy if DevicePathInstance is returned.
339 If DevicePathInstance is NULL, then NULL is returned.
340 If there is not enough memory to allocate space for the new device path, then NULL is returned.
341 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
342 free the memory allocated.
344 @param DevicePath A pointer to a device path data structure.
345 @param DevicePathInstance A pointer to a device path instance.
347 @return A pointer to the new device path.
350 EFI_DEVICE_PATH_PROTOCOL
*
352 AppendDevicePathInstanceProtocolInterface (
353 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
354 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePathInstance
358 Creates a copy of the current device path instance and returns a pointer to the next device path
361 This function creates a copy of the current device path instance. It also updates DevicePath to
362 point to the next device path instance in the device path (or NULL if no more) and updates Size
363 to hold the size of the device path instance copy.
364 If DevicePath is NULL, then NULL is returned.
365 If there is not enough memory to allocate space for the new device path, then NULL is returned.
366 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
367 free the memory allocated.
368 If Size is NULL, then ASSERT().
370 @param DevicePath On input, this holds the pointer to the current device path
371 instance. On output, this holds the pointer to the next device
372 path instance or NULL if there are no more device path
373 instances in the device path pointer to a device path data
375 @param Size On output, this holds the size of the device path instance, in
376 bytes or zero, if DevicePath is NULL.
378 @return A pointer to the current device path instance.
381 EFI_DEVICE_PATH_PROTOCOL
*
383 GetNextDevicePathInstanceProtocolInterface (
384 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
,
389 Determines if a device path is single or multi-instance.
391 This function returns TRUE if the device path specified by DevicePath is multi-instance.
392 Otherwise, FALSE is returned. If DevicePath is NULL, then FALSE is returned.
394 @param DevicePath A pointer to a device path data structure.
396 @retval TRUE DevicePath is multi-instance.
397 @retval FALSE DevicePath is not multi-instance or DevicePath is NULL.
402 IsDevicePathMultiInstanceProtocolInterface (
403 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
407 Creates a copy of the current device path instance and returns a pointer to the next device path
410 This function creates a new device node in a newly allocated buffer of size NodeLength and
411 initializes the device path node header with NodeType and NodeSubType. The new device path node
413 If NodeLength is smaller than a device path header, then NULL is returned.
414 If there is not enough memory to allocate space for the new device path, then NULL is returned.
415 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
416 free the memory allocated.
418 @param NodeType The device node type for the new device node.
419 @param NodeSubType The device node sub-type for the new device node.
420 @param NodeLength The length of the new device node.
422 @return The new device path.
425 EFI_DEVICE_PATH_PROTOCOL
*
427 CreateDeviceNodeProtocolInterface (
429 IN UINT8 NodeSubType
,