2 Definition for Device Path Utilities driver
4 Copyright (c) 2006 - 2008, 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>
34 extern const EFI_GUID mEfiDevicePathMessagingUartFlowControlGuid
;
35 extern const EFI_GUID mEfiDevicePathMessagingSASGuid
;
39 #define MIN_ALIGNMENT_SIZE sizeof(UINTN)
40 #define ALIGN_SIZE(a) ((a % MIN_ALIGNMENT_SIZE) ? MIN_ALIGNMENT_SIZE - (a % MIN_ALIGNMENT_SIZE) : 0)
42 #define IS_COMMA(a) ((a) == L',')
43 #define IS_HYPHEN(a) ((a) == L'-')
44 #define IS_DOT(a) ((a) == L'.')
45 #define IS_LEFT_PARENTH(a) ((a) == L'(')
46 #define IS_RIGHT_PARENTH(a) ((a) == L')')
47 #define IS_SLASH(a) ((a) == L'/')
48 #define IS_NULL(a) ((a) == L'\0')
50 #define DEVICE_NODE_END 1
51 #define DEVICE_PATH_INSTANCE_END 2
52 #define DEVICE_PATH_END 3
54 #define SetDevicePathInstanceEndNode(a) { \
55 (a)->Type = END_DEVICE_PATH_TYPE; \
56 (a)->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE; \
57 (a)->Length[0] = sizeof (EFI_DEVICE_PATH_PROTOCOL); \
62 // Private Data structure
73 VOID (*Function
) (POOL_PRINT
*, VOID
*, BOOLEAN
, BOOLEAN
);
74 } DEVICE_PATH_TO_TEXT_TABLE
;
77 CHAR16
*DevicePathNodeText
;
78 EFI_DEVICE_PATH_PROTOCOL
* (*Function
) (CHAR16
*);
79 } DEVICE_PATH_FROM_TEXT_TABLE
;
84 BOOLEAN SubClassExist
;
88 #define USB_CLASS_AUDIO 1
89 #define USB_CLASS_CDCCONTROL 2
90 #define USB_CLASS_HID 3
91 #define USB_CLASS_IMAGE 6
92 #define USB_CLASS_PRINTER 7
93 #define USB_CLASS_MASS_STORAGE 8
94 #define USB_CLASS_HUB 9
95 #define USB_CLASS_CDCDATA 10
96 #define USB_CLASS_SMART_CARD 11
97 #define USB_CLASS_VIDEO 14
98 #define USB_CLASS_DIAGNOSTIC 220
99 #define USB_CLASS_WIRELESS 224
101 #define USB_CLASS_RESERVE 254
102 #define USB_SUBCLASS_FW_UPDATE 1
103 #define USB_SUBCLASS_IRDA_BRIDGE 2
104 #define USB_SUBCLASS_TEST 3
109 EFI_DEVICE_PATH_PROTOCOL Header
;
111 UINT8 VendorDefinedData
[1];
112 } VENDOR_DEFINED_HARDWARE_DEVICE_PATH
;
115 EFI_DEVICE_PATH_PROTOCOL Header
;
117 UINT8 VendorDefinedData
[1];
118 } VENDOR_DEFINED_MESSAGING_DEVICE_PATH
;
121 EFI_DEVICE_PATH_PROTOCOL Header
;
123 UINT8 VendorDefinedData
[1];
124 } VENDOR_DEFINED_MEDIA_DEVICE_PATH
;
127 EFI_DEVICE_PATH_PROTOCOL Header
;
131 CHAR8 HidUidCidStr
[3];
132 } ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR
;
135 EFI_DEVICE_PATH_PROTOCOL Header
;
136 UINT16 NetworkProtocol
;
139 UINT16 TargetPortalGroupTag
;
140 CHAR8 iSCSITargetName
[1];
141 } ISCSI_DEVICE_PATH_WITH_NAME
;
144 EFI_DEVICE_PATH_PROTOCOL Header
;
146 UINT8 VendorDefinedData
[1];
147 } VENDOR_DEVICE_PATH_WITH_DATA
;
152 ConvertDeviceNodeToText (
153 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
,
154 IN BOOLEAN DisplayOnly
,
155 IN BOOLEAN AllowShortcuts
160 Convert a device node to its text representation.
163 DeviceNode - Points to the device node to be converted.
164 DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation
165 of the display node is used, where applicable. If DisplayOnly
166 is FALSE, then the longer text representation of the display node
168 AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text
169 representation for a device node can be used, where applicable.
172 A pointer - a pointer to the allocated text representation of the device node.
173 NULL - if DeviceNode is NULL or there was insufficient memory.
179 ConvertDevicePathToText (
180 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
,
181 IN BOOLEAN DisplayOnly
,
182 IN BOOLEAN AllowShortcuts
187 Convert a device path to its text representation.
190 DeviceNode - Points to the device path to be converted.
191 DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation
192 of the display node is used, where applicable. If DisplayOnly
193 is FALSE, then the longer text representation of the display node
195 AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text
196 representation for a device node can be used, where applicable.
199 A pointer - a pointer to the allocated text representation of the device path.
200 NULL - if DeviceNode is NULL or there was insufficient memory.
205 EFI_DEVICE_PATH_PROTOCOL
*
206 ConvertTextToDeviceNode (
207 IN CONST CHAR16
*TextDeviceNode
212 Convert text to the binary representation of a device node.
215 TextDeviceNode - TextDeviceNode points to the text representation of a device
216 node. Conversion starts with the first character and continues
217 until the first non-device node character.
220 A pointer - Pointer to the EFI device node.
221 NULL - if TextDeviceNode is NULL or there was insufficient memory.
226 EFI_DEVICE_PATH_PROTOCOL
*
227 ConvertTextToDevicePath (
228 IN CONST CHAR16
*TextDevicePath
233 Convert text to the binary representation of a device path.
236 TextDevicePath - TextDevicePath points to the text representation of a device
237 path. Conversion starts with the first character and continues
238 until the first non-device node character.
241 A pointer - Pointer to the allocated device path.
242 NULL - if TextDeviceNode is NULL or there was insufficient memory.
248 GetDevicePathSizeProtocolInterface (
249 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
254 Returns the size of the device path, in bytes.
257 DevicePath - Points to the start of the EFI device path.
260 Size - Size of the specified device path, in bytes, including the end-of-path tag.
265 EFI_DEVICE_PATH_PROTOCOL
*
266 DuplicateDevicePathProtocolInterface (
267 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
272 Create a duplicate of the specified path.
275 DevicePath - Points to the source EFI device path.
278 Pointer - A pointer to the duplicate device path.
279 NULL - Insufficient memory.
284 EFI_DEVICE_PATH_PROTOCOL
*
285 AppendDevicePathProtocolInterface (
286 IN CONST EFI_DEVICE_PATH_PROTOCOL
*Src1
,
287 IN CONST EFI_DEVICE_PATH_PROTOCOL
*Src2
292 Create a new path by appending the second device path to the first.
295 Src1 - Points to the first device path. If NULL, then it is ignored.
296 Src2 - Points to the second device path. If NULL, then it is ignored.
299 Pointer - A pointer to the newly created device path.
300 NULL - Memory could not be allocated
301 or either DevicePath or DeviceNode is NULL.
306 EFI_DEVICE_PATH_PROTOCOL
*
307 AppendDeviceNodeProtocolInterface (
308 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
309 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
314 Creates a new path by appending the device node to the device path.
317 DevicePath - Points to the device path.
318 DeviceNode - Points to the device node.
321 Pointer - A pointer to the allocated device node.
322 NULL - Memory could not be allocated
323 or either DevicePath or DeviceNode is NULL.
328 EFI_DEVICE_PATH_PROTOCOL
*
329 AppendDevicePathInstanceProtocolInterface (
330 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
331 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePathInstance
336 Creates a new path by appending the specified device path instance to the specified device path.
339 DevicePath - Points to the device path. If NULL, then ignored.
340 DevicePathInstance - Points to the device path instance.
343 Pointer - A pointer to the newly created device path
344 NULL - Memory could not be allocated or DevicePathInstance is NULL.
349 EFI_DEVICE_PATH_PROTOCOL
*
350 GetNextDevicePathInstanceProtocolInterface (
351 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePathInstance
,
352 OUT UINTN
*DevicePathInstanceSize
357 Creates a copy of the current device path instance and returns a pointer to the next device path instance.
360 DevicePathInstance - On input, this holds the pointer to the current device path
361 instance. On output, this holds the pointer to the next
362 device path instance or NULL if there are no more device
363 path instances in the device path.
364 DevicePathInstanceSize - On output, this holds the size of the device path instance,
365 in bytes or zero, if DevicePathInstance is zero.
368 Pointer - A pointer to the copy of the current device path instance.
369 NULL - DevicePathInstace was NULL on entry or there was insufficient memory.
375 IsDevicePathMultiInstanceProtocolInterface (
376 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
381 Returns whether a device path is multi-instance.
384 DevicePath - Points to the device path. If NULL, then ignored.
387 TRUE - The device path has more than one instance
388 FALSE - The device path is empty or contains only a single instance.
393 EFI_DEVICE_PATH_PROTOCOL
*
394 CreateDeviceNodeProtocolInterface (
396 IN UINT8 NodeSubType
,
402 Creates a device node
405 NodeType - NodeType is the device node type (EFI_DEVICE_PATH.Type) for
407 NodeSubType - NodeSubType is the device node sub-type
408 EFI_DEVICE_PATH.SubType) for the new device node.
409 NodeLength - NodeLength is the length of the device node
410 (EFI_DEVICE_PATH.Length) for the new device node.
413 Pointer - A pointer to the newly created device node.
414 NULL - NodeLength is less than
415 the size of the header or there was insufficient memory.