3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 Definition for Device Path Utilities driver
21 #ifndef _DEVICE_PATH_DRIVER_H
22 #define _DEVICE_PATH_DRIVER_H
25 #include <Protocol/DevicePathUtilities.h>
26 #include <Protocol/DebugPort.h>
27 #include <Protocol/DevicePathToText.h>
28 #include <Protocol/DevicePathFromText.h>
29 #include <Guid/PcAnsi.h>
30 #include <Library/DebugLib.h>
31 #include <Library/PrintLib.h>
32 #include <Library/UefiDriverEntryPoint.h>
33 #include <Library/BaseLib.h>
34 #include <Library/BaseMemoryLib.h>
35 #include <Library/MemoryAllocationLib.h>
36 #include <Library/UefiBootServicesTableLib.h>
37 #include <Library/DevicePathLib.h>
38 #include <Library/PcdLib.h>
40 extern const EFI_GUID mEfiDevicePathMessagingUartFlowControlGuid
;
41 extern const EFI_GUID mEfiDevicePathMessagingSASGuid
;
45 #define MIN_ALIGNMENT_SIZE sizeof(UINTN)
46 #define ALIGN_SIZE(a) ((a % MIN_ALIGNMENT_SIZE) ? MIN_ALIGNMENT_SIZE - (a % MIN_ALIGNMENT_SIZE) : 0)
48 #define IS_COMMA(a) ((a) == L',')
49 #define IS_HYPHEN(a) ((a) == L'-')
50 #define IS_DOT(a) ((a) == L'.')
51 #define IS_LEFT_PARENTH(a) ((a) == L'(')
52 #define IS_RIGHT_PARENTH(a) ((a) == L')')
53 #define IS_SLASH(a) ((a) == L'/')
54 #define IS_NULL(a) ((a) == L'\0')
56 #define DEVICE_NODE_END 1
57 #define DEVICE_PATH_INSTANCE_END 2
58 #define DEVICE_PATH_END 3
60 #define SetDevicePathInstanceEndNode(a) { \
61 (a)->Type = END_DEVICE_PATH_TYPE; \
62 (a)->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE; \
63 (a)->Length[0] = sizeof (EFI_DEVICE_PATH_PROTOCOL); \
68 // Private Data structure
79 VOID (*Function
) (POOL_PRINT
*, VOID
*, BOOLEAN
, BOOLEAN
);
80 } DEVICE_PATH_TO_TEXT_TABLE
;
83 CHAR16
*DevicePathNodeText
;
84 EFI_DEVICE_PATH_PROTOCOL
* (*Function
) (CHAR16
*);
85 } DEVICE_PATH_FROM_TEXT_TABLE
;
90 BOOLEAN SubClassExist
;
94 #define USB_CLASS_AUDIO 1
95 #define USB_CLASS_CDCCONTROL 2
96 #define USB_CLASS_HID 3
97 #define USB_CLASS_IMAGE 6
98 #define USB_CLASS_PRINTER 7
99 #define USB_CLASS_MASS_STORAGE 8
100 #define USB_CLASS_HUB 9
101 #define USB_CLASS_CDCDATA 10
102 #define USB_CLASS_SMART_CARD 11
103 #define USB_CLASS_VIDEO 14
104 #define USB_CLASS_DIAGNOSTIC 220
105 #define USB_CLASS_WIRELESS 224
107 #define USB_CLASS_RESERVE 254
108 #define USB_SUBCLASS_FW_UPDATE 1
109 #define USB_SUBCLASS_IRDA_BRIDGE 2
110 #define USB_SUBCLASS_TEST 3
113 EFI_DEVICE_PATH_PROTOCOL Header
;
115 UINT8 VendorDefinedData
[1];
116 } VENDOR_DEFINED_HARDWARE_DEVICE_PATH
;
119 EFI_DEVICE_PATH_PROTOCOL Header
;
121 UINT8 VendorDefinedData
[1];
122 } VENDOR_DEFINED_MESSAGING_DEVICE_PATH
;
125 EFI_DEVICE_PATH_PROTOCOL Header
;
127 UINT8 VendorDefinedData
[1];
128 } VENDOR_DEFINED_MEDIA_DEVICE_PATH
;
131 EFI_DEVICE_PATH_PROTOCOL Header
;
135 CHAR8 HidUidCidStr
[3];
136 } ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR
;
139 EFI_DEVICE_PATH_PROTOCOL Header
;
140 UINT16 NetworkProtocol
;
143 UINT16 TargetPortalGroupTag
;
145 CHAR16 iSCSITargetName
[1];
146 } ISCSI_DEVICE_PATH_WITH_NAME
;
149 EFI_DEVICE_PATH_PROTOCOL Header
;
151 UINT8 VendorDefinedData
[1];
152 } VENDOR_DEVICE_PATH_WITH_DATA
;
155 ConvertDeviceNodeToText (
156 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
,
157 IN BOOLEAN DisplayOnly
,
158 IN BOOLEAN AllowShortcuts
163 Convert a device node to its text representation.
166 DeviceNode - Points to the device node to be converted.
167 DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation
168 of the display node is used, where applicable. If DisplayOnly
169 is FALSE, then the longer text representation of the display node
171 AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text
172 representation for a device node can be used, where applicable.
175 A pointer - a pointer to the allocated text representation of the device node.
176 NULL - if DeviceNode is NULL or there was insufficient memory.
182 ConvertDevicePathToText (
183 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
,
184 IN BOOLEAN DisplayOnly
,
185 IN BOOLEAN AllowShortcuts
190 Convert a device path to its text representation.
193 DeviceNode - Points to the device path to be converted.
194 DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation
195 of the display node is used, where applicable. If DisplayOnly
196 is FALSE, then the longer text representation of the display node
198 AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text
199 representation for a device node can be used, where applicable.
202 A pointer - a pointer to the allocated text representation of the device path.
203 NULL - if DeviceNode is NULL or there was insufficient memory.
208 EFI_DEVICE_PATH_PROTOCOL
*
209 ConvertTextToDeviceNode (
210 IN CONST CHAR16
*TextDeviceNode
215 Convert text to the binary representation of a device node.
218 TextDeviceNode - TextDeviceNode points to the text representation of a device
219 node. Conversion starts with the first character and continues
220 until the first non-device node character.
223 A pointer - Pointer to the EFI device node.
224 NULL - if TextDeviceNode is NULL or there was insufficient memory.
229 EFI_DEVICE_PATH_PROTOCOL
*
230 ConvertTextToDevicePath (
231 IN CONST CHAR16
*TextDevicePath
236 Convert text to the binary representation of a device path.
239 TextDevicePath - TextDevicePath points to the text representation of a device
240 path. Conversion starts with the first character and continues
241 until the first non-device node character.
244 A pointer - Pointer to the allocated device path.
245 NULL - if TextDeviceNode is NULL or there was insufficient memory.
251 GetDevicePathSizeProtocolInterface (
252 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
257 Returns the size of the device path, in bytes.
260 DevicePath - Points to the start of the EFI device path.
263 Size - Size of the specified device path, in bytes, including the end-of-path tag.
268 EFI_DEVICE_PATH_PROTOCOL
*
269 DuplicateDevicePathProtocolInterface (
270 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
275 Create a duplicate of the specified path.
278 DevicePath - Points to the source EFI device path.
281 Pointer - A pointer to the duplicate device path.
282 NULL - Insufficient memory.
287 EFI_DEVICE_PATH_PROTOCOL
*
288 AppendDevicePathProtocolInterface (
289 IN CONST EFI_DEVICE_PATH_PROTOCOL
*Src1
,
290 IN CONST EFI_DEVICE_PATH_PROTOCOL
*Src2
295 Create a new path by appending the second device path to the first.
298 Src1 - Points to the first device path. If NULL, then it is ignored.
299 Src2 - Points to the second device path. If NULL, then it is ignored.
302 Pointer - A pointer to the newly created device path.
303 NULL - Memory could not be allocated
304 or either DevicePath or DeviceNode is NULL.
309 EFI_DEVICE_PATH_PROTOCOL
*
310 AppendDeviceNodeProtocolInterface (
311 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
312 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
317 Creates a new path by appending the device node to the device path.
320 DevicePath - Points to the device path.
321 DeviceNode - Points to the device node.
324 Pointer - A pointer to the allocated device node.
325 NULL - Memory could not be allocated
326 or either DevicePath or DeviceNode is NULL.
331 EFI_DEVICE_PATH_PROTOCOL
*
332 AppendDevicePathInstanceProtocolInterface (
333 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
334 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePathInstance
339 Creates a new path by appending the specified device path instance to the specified device path.
342 DevicePath - Points to the device path. If NULL, then ignored.
343 DevicePathInstance - Points to the device path instance.
346 Pointer - A pointer to the newly created device path
347 NULL - Memory could not be allocated or DevicePathInstance is NULL.
352 EFI_DEVICE_PATH_PROTOCOL
*
353 GetNextDevicePathInstanceProtocolInterface (
354 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePathInstance
,
355 OUT UINTN
*DevicePathInstanceSize
360 Creates a copy of the current device path instance and returns a pointer to the next device path instance.
363 DevicePathInstance - On input, this holds the pointer to the current device path
364 instance. On output, this holds the pointer to the next
365 device path instance or NULL if there are no more device
366 path instances in the device path.
367 DevicePathInstanceSize - On output, this holds the size of the device path instance,
368 in bytes or zero, if DevicePathInstance is zero.
371 Pointer - A pointer to the copy of the current device path instance.
372 NULL - DevicePathInstace was NULL on entry or there was insufficient memory.
378 IsDevicePathMultiInstanceProtocolInterface (
379 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
384 Returns whether a device path is multi-instance.
387 DevicePath - Points to the device path. If NULL, then ignored.
390 TRUE - The device path has more than one instance
391 FALSE - The device path is empty or contains only a single instance.
396 EFI_DEVICE_PATH_PROTOCOL
*
397 CreateDeviceNodeProtocolInterface (
399 IN UINT8 NodeSubType
,
405 Creates a device node
408 NodeType - NodeType is the device node type (EFI_DEVICE_PATH.Type) for
410 NodeSubType - NodeSubType is the device node sub-type
411 EFI_DEVICE_PATH.SubType) for the new device node.
412 NodeLength - NodeLength is the length of the device node
413 (EFI_DEVICE_PATH.Length) for the new device node.
416 Pointer - A pointer to the newly created device node.
417 NULL - NodeLength is less than
418 the size of the header or there was insufficient memory.