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
115 EFI_DEVICE_PATH_PROTOCOL Header
;
117 UINT8 VendorDefinedData
[1];
118 } VENDOR_DEFINED_HARDWARE_DEVICE_PATH
;
121 EFI_DEVICE_PATH_PROTOCOL Header
;
123 UINT8 VendorDefinedData
[1];
124 } VENDOR_DEFINED_MESSAGING_DEVICE_PATH
;
127 EFI_DEVICE_PATH_PROTOCOL Header
;
129 UINT8 VendorDefinedData
[1];
130 } VENDOR_DEFINED_MEDIA_DEVICE_PATH
;
133 EFI_DEVICE_PATH_PROTOCOL Header
;
137 CHAR8 HidUidCidStr
[3];
138 } ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR
;
141 EFI_DEVICE_PATH_PROTOCOL Header
;
142 UINT16 NetworkProtocol
;
145 UINT16 TargetPortalGroupTag
;
146 CHAR8 iSCSITargetName
[1];
147 } ISCSI_DEVICE_PATH_WITH_NAME
;
150 EFI_DEVICE_PATH_PROTOCOL Header
;
152 UINT8 VendorDefinedData
[1];
153 } VENDOR_DEVICE_PATH_WITH_DATA
;
158 ConvertDeviceNodeToText (
159 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
,
160 IN BOOLEAN DisplayOnly
,
161 IN BOOLEAN AllowShortcuts
166 Convert a device node to its text representation.
169 DeviceNode - Points to the device node to be converted.
170 DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation
171 of the display node is used, where applicable. If DisplayOnly
172 is FALSE, then the longer text representation of the display node
174 AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text
175 representation for a device node can be used, where applicable.
178 A pointer - a pointer to the allocated text representation of the device node.
179 NULL - if DeviceNode is NULL or there was insufficient memory.
185 ConvertDevicePathToText (
186 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
,
187 IN BOOLEAN DisplayOnly
,
188 IN BOOLEAN AllowShortcuts
193 Convert a device path to its text representation.
196 DeviceNode - Points to the device path to be converted.
197 DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation
198 of the display node is used, where applicable. If DisplayOnly
199 is FALSE, then the longer text representation of the display node
201 AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text
202 representation for a device node can be used, where applicable.
205 A pointer - a pointer to the allocated text representation of the device path.
206 NULL - if DeviceNode is NULL or there was insufficient memory.
211 EFI_DEVICE_PATH_PROTOCOL
*
212 ConvertTextToDeviceNode (
213 IN CONST CHAR16
*TextDeviceNode
218 Convert text to the binary representation of a device node.
221 TextDeviceNode - TextDeviceNode points to the text representation of a device
222 node. Conversion starts with the first character and continues
223 until the first non-device node character.
226 A pointer - Pointer to the EFI device node.
227 NULL - if TextDeviceNode is NULL or there was insufficient memory.
232 EFI_DEVICE_PATH_PROTOCOL
*
233 ConvertTextToDevicePath (
234 IN CONST CHAR16
*TextDevicePath
239 Convert text to the binary representation of a device path.
242 TextDevicePath - TextDevicePath points to the text representation of a device
243 path. Conversion starts with the first character and continues
244 until the first non-device node character.
247 A pointer - Pointer to the allocated device path.
248 NULL - if TextDeviceNode is NULL or there was insufficient memory.
254 GetDevicePathSizeProtocolInterface (
255 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
260 Returns the size of the device path, in bytes.
263 DevicePath - Points to the start of the EFI device path.
266 Size - Size of the specified device path, in bytes, including the end-of-path tag.
271 EFI_DEVICE_PATH_PROTOCOL
*
272 DuplicateDevicePathProtocolInterface (
273 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
278 Create a duplicate of the specified path.
281 DevicePath - Points to the source EFI device path.
284 Pointer - A pointer to the duplicate device path.
285 NULL - Insufficient memory.
290 EFI_DEVICE_PATH_PROTOCOL
*
291 AppendDevicePathProtocolInterface (
292 IN CONST EFI_DEVICE_PATH_PROTOCOL
*Src1
,
293 IN CONST EFI_DEVICE_PATH_PROTOCOL
*Src2
298 Create a new path by appending the second device path to the first.
301 Src1 - Points to the first device path. If NULL, then it is ignored.
302 Src2 - Points to the second device path. If NULL, then it is ignored.
305 Pointer - A pointer to the newly created device path.
306 NULL - Memory could not be allocated
307 or either DevicePath or DeviceNode is NULL.
312 EFI_DEVICE_PATH_PROTOCOL
*
313 AppendDeviceNodeProtocolInterface (
314 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
315 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
320 Creates a new path by appending the device node to the device path.
323 DevicePath - Points to the device path.
324 DeviceNode - Points to the device node.
327 Pointer - A pointer to the allocated device node.
328 NULL - Memory could not be allocated
329 or either DevicePath or DeviceNode is NULL.
334 EFI_DEVICE_PATH_PROTOCOL
*
335 AppendDevicePathInstanceProtocolInterface (
336 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
337 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePathInstance
342 Creates a new path by appending the specified device path instance to the specified device path.
345 DevicePath - Points to the device path. If NULL, then ignored.
346 DevicePathInstance - Points to the device path instance.
349 Pointer - A pointer to the newly created device path
350 NULL - Memory could not be allocated or DevicePathInstance is NULL.
355 EFI_DEVICE_PATH_PROTOCOL
*
356 GetNextDevicePathInstanceProtocolInterface (
357 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePathInstance
,
358 OUT UINTN
*DevicePathInstanceSize
363 Creates a copy of the current device path instance and returns a pointer to the next device path instance.
366 DevicePathInstance - On input, this holds the pointer to the current device path
367 instance. On output, this holds the pointer to the next
368 device path instance or NULL if there are no more device
369 path instances in the device path.
370 DevicePathInstanceSize - On output, this holds the size of the device path instance,
371 in bytes or zero, if DevicePathInstance is zero.
374 Pointer - A pointer to the copy of the current device path instance.
375 NULL - DevicePathInstace was NULL on entry or there was insufficient memory.
381 IsDevicePathMultiInstanceProtocolInterface (
382 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
387 Returns whether a device path is multi-instance.
390 DevicePath - Points to the device path. If NULL, then ignored.
393 TRUE - The device path has more than one instance
394 FALSE - The device path is empty or contains only a single instance.
399 EFI_DEVICE_PATH_PROTOCOL
*
400 CreateDeviceNodeProtocolInterface (
402 IN UINT8 NodeSubType
,
408 Creates a device node
411 NodeType - NodeType is the device node type (EFI_DEVICE_PATH.Type) for
413 NodeSubType - NodeSubType is the device node sub-type
414 EFI_DEVICE_PATH.SubType) for the new device node.
415 NodeLength - NodeLength is the length of the device node
416 (EFI_DEVICE_PATH.Length) for the new device node.
419 Pointer - A pointer to the newly created device node.
420 NULL - NodeLength is less than
421 the size of the header or there was insufficient memory.