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>
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
71 VOID (*Function
) (POOL_PRINT
*, VOID
*, BOOLEAN
, BOOLEAN
);
72 } DEVICE_PATH_TO_TEXT_TABLE
;
75 CHAR16
*DevicePathNodeText
;
77 } DEVICE_PATH_FROM_TEXT_TABLE
;
82 BOOLEAN SubClassExist
;
86 #define USB_CLASS_AUDIO 1
87 #define USB_CLASS_CDCCONTROL 2
88 #define USB_CLASS_HID 3
89 #define USB_CLASS_IMAGE 6
90 #define USB_CLASS_PRINTER 7
91 #define USB_CLASS_MASS_STORAGE 8
92 #define USB_CLASS_HUB 9
93 #define USB_CLASS_CDCDATA 10
94 #define USB_CLASS_SMART_CARD 11
95 #define USB_CLASS_VIDEO 14
96 #define USB_CLASS_DIAGNOSTIC 220
97 #define USB_CLASS_WIRELESS 224
99 #define USB_CLASS_RESERVE 254
100 #define USB_SUBCLASS_FW_UPDATE 1
101 #define USB_SUBCLASS_IRDA_BRIDGE 2
102 #define USB_SUBCLASS_TEST 3
107 EFI_DEVICE_PATH_PROTOCOL Header
;
109 UINT8 VendorDefinedData
[1];
110 } VENDOR_DEFINED_HARDWARE_DEVICE_PATH
;
113 EFI_DEVICE_PATH_PROTOCOL Header
;
115 UINT8 VendorDefinedData
[1];
116 } VENDOR_DEFINED_MESSAGING_DEVICE_PATH
;
119 EFI_DEVICE_PATH_PROTOCOL Header
;
121 UINT8 VendorDefinedData
[1];
122 } VENDOR_DEFINED_MEDIA_DEVICE_PATH
;
125 EFI_DEVICE_PATH_PROTOCOL Header
;
129 CHAR8 HidUidCidStr
[3];
130 } ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR
;
133 EFI_DEVICE_PATH_PROTOCOL Header
;
134 UINT16 NetworkProtocol
;
137 UINT16 TargetPortalGroupTag
;
139 } ISCSI_DEVICE_PATH_WITH_NAME
;
142 EFI_DEVICE_PATH_PROTOCOL Header
;
144 UINT8 VendorDefinedData
[1];
145 } VENDOR_DEVICE_PATH_WITH_DATA
;
150 Converts a device node to its string representation.
152 @param DeviceNode A Pointer to the device node to be converted.
153 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
154 of the display node is used, where applicable. If DisplayOnly
155 is FALSE, then the longer text representation of the display node
157 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
158 representation for a device node can be used, where applicable.
160 @return A pointer to the allocated text representation of the device node or NULL if DeviceNode
161 is NULL or there was insufficient memory.
166 ConvertDeviceNodeToText (
167 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
,
168 IN BOOLEAN DisplayOnly
,
169 IN BOOLEAN AllowShortcuts
173 Converts a device path to its text representation.
175 @param DevicePath A Pointer to the device to be converted.
176 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
177 of the display node is used, where applicable. If DisplayOnly
178 is FALSE, then the longer text representation of the display node
180 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
181 representation for a device node can be used, where applicable.
183 @return A pointer to the allocated text representation of the device path or
184 NULL if DeviceNode is NULL or there was insufficient memory.
189 ConvertDevicePathToText (
190 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
191 IN BOOLEAN DisplayOnly
,
192 IN BOOLEAN AllowShortcuts
196 Convert text to the binary representation of a device node.
198 @param TextDeviceNode TextDeviceNode points to the text representation of a device
199 node. Conversion starts with the first character and continues
200 until the first non-device node character.
202 @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was
203 insufficient memory or text unsupported.
206 EFI_DEVICE_PATH_PROTOCOL
*
208 ConvertTextToDeviceNode (
209 IN CONST CHAR16
*TextDeviceNode
213 Convert text to the binary representation of a device path.
216 @param TextDevicePath TextDevicePath points to the text representation of a device
217 path. Conversion starts with the first character and continues
218 until the first non-device node character.
220 @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or
221 there was insufficient memory.
224 EFI_DEVICE_PATH_PROTOCOL
*
226 ConvertTextToDevicePath (
227 IN CONST CHAR16
*TextDevicePath
231 Returns the size of a device path in bytes.
233 This function returns the size, in bytes, of the device path data structure specified by
234 DevicePath including the end of device path node. If DevicePath is NULL, then 0 is returned.
236 @param DevicePath A pointer to a device path data structure.
238 @return The size of a device path in bytes.
243 GetDevicePathSizeProtocolInterface (
244 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
248 Creates a new device path by appending a second device path to a first device path.
250 This function allocates space for a new copy of the device path specified by DevicePath. If
251 DevicePath is NULL, then NULL is returned. If the memory is successfully allocated, then the
252 contents of DevicePath are copied to the newly allocated buffer, and a pointer to that buffer
253 is returned. Otherwise, NULL is returned.
255 @param DevicePath A pointer to a device path data structure.
257 @return A pointer to the duplicated device path.
260 EFI_DEVICE_PATH_PROTOCOL
*
262 DuplicateDevicePathProtocolInterface (
263 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
267 Creates a new device path by appending a second device path to a first device path.
269 This function creates a new device path by appending a copy of SecondDevicePath to a copy of
270 FirstDevicePath in a newly allocated buffer. Only the end-of-device-path device node from
271 SecondDevicePath is retained. The newly created device path is returned.
272 If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned.
273 If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned.
274 If both FirstDevicePath and SecondDevicePath are NULL, then a copy of an end-of-device-path is
276 If there is not enough memory for the newly allocated buffer, then NULL is returned.
277 The memory for the new device path is allocated from EFI boot services memory. It is the
278 responsibility of the caller to free the memory allocated.
280 @param FirstDevicePath A pointer to a device path data structure.
281 @param SecondDevicePath A pointer to a device path data structure.
283 @return A pointer to the new device path.
286 EFI_DEVICE_PATH_PROTOCOL
*
288 AppendDevicePathProtocolInterface (
289 IN CONST EFI_DEVICE_PATH_PROTOCOL
*FirstDevicePath
,
290 IN CONST EFI_DEVICE_PATH_PROTOCOL
*SecondDevicePath
294 Creates a new path by appending the device node to the device path.
296 This function creates a new device path by appending a copy of the device node specified by
297 DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer.
298 The end-of-device-path device node is moved after the end of the appended device node.
299 If DevicePathNode is NULL then a copy of DevicePath is returned.
300 If DevicePath is NULL then a copy of DevicePathNode, followed by an end-of-device path device
302 If both DevicePathNode and DevicePath are NULL then a copy of an end-of-device-path device node
304 If there is not enough memory to allocate space for the new device path, then NULL is returned.
305 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
306 free the memory allocated.
308 @param DevicePath A pointer to a device path data structure.
309 @param DevicePathNode A pointer to a single device path node.
311 @return A pointer to the new device path.
314 EFI_DEVICE_PATH_PROTOCOL
*
316 AppendDeviceNodeProtocolInterface (
317 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
318 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
322 Creates a new device path by appending the specified device path instance to the specified device
325 This function creates a new device path by appending a copy of the device path instance specified
326 by DevicePathInstance to a copy of the device path specified by DevicePath in a allocated buffer.
327 The end-of-device-path device node is moved after the end of the appended device path instance
328 and a new end-of-device-path-instance node is inserted between.
329 If DevicePath is NULL, then a copy if DevicePathInstance is returned.
330 If DevicePathInstance is NULL, then NULL is returned.
331 If there is not enough memory to allocate space for the new device path, then NULL is returned.
332 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
333 free the memory allocated.
335 @param DevicePath A pointer to a device path data structure.
336 @param DevicePathInstance A pointer to a device path instance.
338 @return A pointer to the new device path.
341 EFI_DEVICE_PATH_PROTOCOL
*
343 AppendDevicePathInstanceProtocolInterface (
344 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
345 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePathInstance
349 Creates a copy of the current device path instance and returns a pointer to the next device path
352 This function creates a copy of the current device path instance. It also updates DevicePath to
353 point to the next device path instance in the device path (or NULL if no more) and updates Size
354 to hold the size of the device path instance copy.
355 If DevicePath is NULL, then NULL is returned.
356 If there is not enough memory to allocate space for the new device path, then NULL is returned.
357 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
358 free the memory allocated.
359 If Size is NULL, then ASSERT().
361 @param DevicePath On input, this holds the pointer to the current device path
362 instance. On output, this holds the pointer to the next device
363 path instance or NULL if there are no more device path
364 instances in the device path pointer to a device path data
366 @param Size On output, this holds the size of the device path instance, in
367 bytes or zero, if DevicePath is NULL.
369 @return A pointer to the current device path instance.
372 EFI_DEVICE_PATH_PROTOCOL
*
374 GetNextDevicePathInstanceProtocolInterface (
375 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
,
380 Determines if a device path is single or multi-instance.
382 This function returns TRUE if the device path specified by DevicePath is multi-instance.
383 Otherwise, FALSE is returned. If DevicePath is NULL, then FALSE is returned.
385 @param DevicePath A pointer to a device path data structure.
387 @retval TRUE DevicePath is multi-instance.
388 @retval FALSE DevicePath is not multi-instance or DevicePath is NULL.
393 IsDevicePathMultiInstanceProtocolInterface (
394 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
398 Creates a copy of the current device path instance and returns a pointer to the next device path
401 This function creates a new device node in a newly allocated buffer of size NodeLength and
402 initializes the device path node header with NodeType and NodeSubType. The new device path node
404 If NodeLength is smaller than a device path header, then NULL is returned.
405 If there is not enough memory to allocate space for the new device path, then NULL is returned.
406 The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
407 free the memory allocated.
409 @param NodeType The device node type for the new device node.
410 @param NodeSubType The device node sub-type for the new device node.
411 @param NodeLength The length of the new device node.
413 @return The new device path.
416 EFI_DEVICE_PATH_PROTOCOL
*
418 CreateDeviceNodeProtocolInterface (
420 IN UINT8 NodeSubType
,