2 Library instance that implement UEFI Device Path Library class based on protocol
3 gEfiDevicePathUtilitiesProtocolGuid.
5 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
13 #include <Protocol/DevicePathUtilities.h>
14 #include <Protocol/DevicePathToText.h>
15 #include <Protocol/DevicePathFromText.h>
17 #include <Library/DevicePathLib.h>
18 #include <Library/DebugLib.h>
19 #include <Library/BaseLib.h>
20 #include <Library/MemoryAllocationLib.h>
21 #include <Library/BaseMemoryLib.h>
22 #include <Library/UefiBootServicesTableLib.h>
23 #include <Library/PcdLib.h>
25 GLOBAL_REMOVE_IF_UNREFERENCED EFI_DEVICE_PATH_UTILITIES_PROTOCOL
*mDevicePathLibDevicePathUtilities
= NULL
;
26 GLOBAL_REMOVE_IF_UNREFERENCED EFI_DEVICE_PATH_TO_TEXT_PROTOCOL
*mDevicePathLibDevicePathToText
= NULL
;
27 GLOBAL_REMOVE_IF_UNREFERENCED EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL
*mDevicePathLibDevicePathFromText
= NULL
;
30 // Template for an end-of-device path node.
32 GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_DEVICE_PATH_PROTOCOL mUefiDevicePathLibEndDevicePath
= {
34 END_ENTIRE_DEVICE_PATH_SUBTYPE
,
36 END_DEVICE_PATH_LENGTH
,
42 The constructor function caches the pointer to DevicePathUtilites protocol.
44 The constructor function locates DevicePathUtilities protocol from protocol database.
45 It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.
47 @param ImageHandle The firmware allocated handle for the EFI image.
48 @param SystemTable A pointer to the EFI System Table.
50 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
55 DevicePathLibConstructor (
56 IN EFI_HANDLE ImageHandle
,
57 IN EFI_SYSTEM_TABLE
*SystemTable
62 Status
= gBS
->LocateProtocol (
63 &gEfiDevicePathUtilitiesProtocolGuid
,
65 (VOID
**) &mDevicePathLibDevicePathUtilities
67 ASSERT_EFI_ERROR (Status
);
68 ASSERT (mDevicePathLibDevicePathUtilities
!= NULL
);
73 Determine whether a given device path is valid.
74 If DevicePath is NULL, then ASSERT().
76 @param DevicePath A pointer to a device path data structure.
77 @param MaxSize The maximum size of the device path data structure.
79 @retval TRUE DevicePath is valid.
80 @retval FALSE The length of any node node in the DevicePath is less
81 than sizeof (EFI_DEVICE_PATH_PROTOCOL).
82 @retval FALSE If MaxSize is not zero, the size of the DevicePath
84 @retval FALSE If PcdMaximumDevicePathNodeCount is not zero, the node
85 count of the DevicePath exceeds PcdMaximumDevicePathNodeCount.
90 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
98 ASSERT (DevicePath
!= NULL
);
105 // Validate the input size big enough to touch the first node.
107 if (MaxSize
< sizeof (EFI_DEVICE_PATH_PROTOCOL
)) {
111 for (Count
= 0, Size
= 0; !IsDevicePathEnd (DevicePath
); DevicePath
= NextDevicePathNode (DevicePath
)) {
112 NodeLength
= DevicePathNodeLength (DevicePath
);
113 if (NodeLength
< sizeof (EFI_DEVICE_PATH_PROTOCOL
)) {
117 if (NodeLength
> MAX_UINTN
- Size
) {
123 // Validate next node before touch it.
125 if (Size
> MaxSize
- END_DEVICE_PATH_LENGTH
) {
129 if (PcdGet32 (PcdMaximumDevicePathNodeCount
) > 0) {
131 if (Count
>= PcdGet32 (PcdMaximumDevicePathNodeCount
)) {
137 // FilePath must be a NULL-terminated string.
139 if (DevicePathType (DevicePath
) == MEDIA_DEVICE_PATH
&&
140 DevicePathSubType (DevicePath
) == MEDIA_FILEPATH_DP
&&
141 *(CHAR16
*)((UINT8
*)DevicePath
+ NodeLength
- 2) != 0) {
147 // Only return TRUE when the End Device Path node is valid.
149 return (BOOLEAN
) (DevicePathNodeLength (DevicePath
) == END_DEVICE_PATH_LENGTH
);
153 Returns the Type field of a device path node.
155 Returns the Type field of the device path node specified by Node.
157 If Node is NULL, then ASSERT().
159 @param Node A pointer to a device path node data structure.
161 @return The Type field of the device path node specified by Node.
170 ASSERT (Node
!= NULL
);
171 return ((EFI_DEVICE_PATH_PROTOCOL
*)(Node
))->Type
;
175 Returns the SubType field of a device path node.
177 Returns the SubType field of the device path node specified by Node.
179 If Node is NULL, then ASSERT().
181 @param Node A pointer to a device path node data structure.
183 @return The SubType field of the device path node specified by Node.
192 ASSERT (Node
!= NULL
);
193 return ((EFI_DEVICE_PATH_PROTOCOL
*)(Node
))->SubType
;
197 Returns the 16-bit Length field of a device path node.
199 Returns the 16-bit Length field of the device path node specified by Node.
200 Node is not required to be aligned on a 16-bit boundary, so it is recommended
201 that a function such as ReadUnaligned16() be used to extract the contents of
204 If Node is NULL, then ASSERT().
206 @param Node A pointer to a device path node data structure.
208 @return The 16-bit Length field of the device path node specified by Node.
213 DevicePathNodeLength (
217 ASSERT (Node
!= NULL
);
218 return ReadUnaligned16 ((UINT16
*)&((EFI_DEVICE_PATH_PROTOCOL
*)(Node
))->Length
[0]);
222 Returns a pointer to the next node in a device path.
224 Returns a pointer to the device path node that follows the device path node
227 If Node is NULL, then ASSERT().
229 @param Node A pointer to a device path node data structure.
231 @return a pointer to the device path node that follows the device path node
235 EFI_DEVICE_PATH_PROTOCOL
*
241 ASSERT (Node
!= NULL
);
242 return (EFI_DEVICE_PATH_PROTOCOL
*)((UINT8
*)(Node
) + DevicePathNodeLength(Node
));
246 Determines if a device path node is an end node of a device path.
247 This includes nodes that are the end of a device path instance and nodes that
248 are the end of an entire device path.
250 Determines if the device path node specified by Node is an end node of a device path.
251 This includes nodes that are the end of a device path instance and nodes that are the
252 end of an entire device path. If Node represents an end node of a device path,
253 then TRUE is returned. Otherwise, FALSE is returned.
255 If Node is NULL, then ASSERT().
257 @param Node A pointer to a device path node data structure.
259 @retval TRUE The device path node specified by Node is an end node of a device path.
260 @retval FALSE The device path node specified by Node is not an end node of
266 IsDevicePathEndType (
270 ASSERT (Node
!= NULL
);
271 return (BOOLEAN
) (DevicePathType (Node
) == END_DEVICE_PATH_TYPE
);
275 Determines if a device path node is an end node of an entire device path.
277 Determines if a device path node specified by Node is an end node of an entire
279 If Node represents the end of an entire device path, then TRUE is returned.
280 Otherwise, FALSE is returned.
282 If Node is NULL, then ASSERT().
284 @param Node A pointer to a device path node data structure.
286 @retval TRUE The device path node specified by Node is the end of an entire device path.
287 @retval FALSE The device path node specified by Node is not the end of an entire device path.
296 ASSERT (Node
!= NULL
);
297 return (BOOLEAN
) (IsDevicePathEndType (Node
) && DevicePathSubType(Node
) == END_ENTIRE_DEVICE_PATH_SUBTYPE
);
301 Determines if a device path node is an end node of a device path instance.
303 Determines if a device path node specified by Node is an end node of a device
305 If Node represents the end of a device path instance, then TRUE is returned.
306 Otherwise, FALSE is returned.
308 If Node is NULL, then ASSERT().
310 @param Node A pointer to a device path node data structure.
312 @retval TRUE The device path node specified by Node is the end of a device
314 @retval FALSE The device path node specified by Node is not the end of a
315 device path instance.
320 IsDevicePathEndInstance (
324 ASSERT (Node
!= NULL
);
325 return (BOOLEAN
) (IsDevicePathEndType (Node
) && DevicePathSubType(Node
) == END_INSTANCE_DEVICE_PATH_SUBTYPE
);
329 Sets the length, in bytes, of a device path node.
331 Sets the length of the device path node specified by Node to the value specified
332 by NodeLength. NodeLength is returned. Node is not required to be aligned on
333 a 16-bit boundary, so it is recommended that a function such as WriteUnaligned16()
334 be used to set the contents of the Length field.
336 If Node is NULL, then ASSERT().
337 If NodeLength >= SIZE_64KB, then ASSERT().
338 If NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL), then ASSERT().
340 @param Node A pointer to a device path node data structure.
341 @param Length The length, in bytes, of the device path node.
348 SetDevicePathNodeLength (
353 ASSERT (Node
!= NULL
);
354 ASSERT ((Length
>= sizeof (EFI_DEVICE_PATH_PROTOCOL
)) && (Length
< SIZE_64KB
));
355 return WriteUnaligned16 ((UINT16
*)&((EFI_DEVICE_PATH_PROTOCOL
*)(Node
))->Length
[0], (UINT16
)(Length
));
359 Fills in all the fields of a device path node that is the end of an entire device path.
361 Fills in all the fields of a device path node specified by Node so Node represents
362 the end of an entire device path. The Type field of Node is set to
363 END_DEVICE_PATH_TYPE, the SubType field of Node is set to
364 END_ENTIRE_DEVICE_PATH_SUBTYPE, and the Length field of Node is set to
365 END_DEVICE_PATH_LENGTH. Node is not required to be aligned on a 16-bit boundary,
366 so it is recommended that a function such as WriteUnaligned16() be used to set
367 the contents of the Length field.
369 If Node is NULL, then ASSERT().
371 @param Node A pointer to a device path node data structure.
376 SetDevicePathEndNode (
380 ASSERT (Node
!= NULL
);
381 CopyMem (Node
, &mUefiDevicePathLibEndDevicePath
, sizeof (mUefiDevicePathLibEndDevicePath
));
385 Returns the size of a device path in bytes.
387 This function returns the size, in bytes, of the device path data structure
388 specified by DevicePath including the end of device path node.
389 If DevicePath is NULL or invalid, then 0 is returned.
391 @param DevicePath A pointer to a device path data structure.
393 @retval 0 If DevicePath is NULL or invalid.
394 @retval Others The size of a device path in bytes.
400 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
403 return mDevicePathLibDevicePathUtilities
->GetDevicePathSize (DevicePath
);
407 Creates a new copy of an existing device path.
409 This function allocates space for a new copy of the device path specified by
410 DevicePath. If DevicePath is NULL, then NULL is returned.
411 If the memory is successfully allocated, then the
412 contents of DevicePath are copied to the newly allocated buffer, and a pointer to that buffer
413 is returned. Otherwise, NULL is returned.
414 The memory for the new device path is allocated from EFI boot services memory.
415 It is the responsibility of the caller to free the memory allocated.
417 @param DevicePath A pointer to a device path data structure.
419 @retval NULL If DevicePath is NULL or invalid.
420 @retval Others A pointer to the duplicated device path.
423 EFI_DEVICE_PATH_PROTOCOL
*
425 DuplicateDevicePath (
426 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
429 return mDevicePathLibDevicePathUtilities
->DuplicateDevicePath (DevicePath
);
433 Creates a new device path by appending a second device path to a first device path.
435 This function creates a new device path by appending a copy of SecondDevicePath to a copy of
436 FirstDevicePath in a newly allocated buffer. Only the end-of-device-path device node from
437 SecondDevicePath is retained. The newly created device path is returned.
438 If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned.
439 If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned.
440 If both FirstDevicePath and SecondDevicePath are NULL, then a copy of an end-of-device-path is
442 If there is not enough memory for the newly allocated buffer, then NULL is returned.
443 The memory for the new device path is allocated from EFI boot services memory. It is the
444 responsibility of the caller to free the memory allocated.
446 @param FirstDevicePath A pointer to a device path data structure.
447 @param SecondDevicePath A pointer to a device path data structure.
449 @retval NULL If there is not enough memory for the newly allocated buffer.
450 @retval NULL If FirstDevicePath or SecondDevicePath is invalid.
451 @retval Others A pointer to the new device path if success.
452 Or a copy an end-of-device-path if both FirstDevicePath and
453 SecondDevicePath are NULL.
456 EFI_DEVICE_PATH_PROTOCOL
*
459 IN CONST EFI_DEVICE_PATH_PROTOCOL
*FirstDevicePath
, OPTIONAL
460 IN CONST EFI_DEVICE_PATH_PROTOCOL
*SecondDevicePath OPTIONAL
463 return mDevicePathLibDevicePathUtilities
->AppendDevicePath (FirstDevicePath
, SecondDevicePath
);
467 Creates a new path by appending the device node to the device path.
469 This function creates a new device path by appending a copy of the device node
470 specified by DevicePathNode to a copy of the device path specified by DevicePath
471 in an allocated buffer.
472 The end-of-device-path device node is moved after the end of the appended device node.
473 If DevicePathNode is NULL then a copy of DevicePath is returned.
474 If DevicePath is NULL then a copy of DevicePathNode, followed by an end-of-device
475 path device node is returned.
476 If both DevicePathNode and DevicePath are NULL then a copy of an end-of-device-path
477 device node is returned.
478 If there is not enough memory to allocate space for the new device path, then
480 The memory is allocated from EFI boot services memory. It is the responsibility
481 of the caller to free the memory allocated.
483 @param DevicePath A pointer to a device path data structure.
484 @param DevicePathNode A pointer to a single device path node.
486 @retval NULL If there is not enough memory for the new device path.
487 @retval Others A pointer to the new device path if success.
488 A copy of DevicePathNode followed by an end-of-device-path node
489 if both FirstDevicePath and SecondDevicePath are NULL.
490 A copy of an end-of-device-path node if both FirstDevicePath
491 and SecondDevicePath are NULL.
494 EFI_DEVICE_PATH_PROTOCOL
*
496 AppendDevicePathNode (
497 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
, OPTIONAL
498 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode OPTIONAL
501 return mDevicePathLibDevicePathUtilities
->AppendDeviceNode (DevicePath
, DevicePathNode
);
505 Creates a new device path by appending the specified device path instance to
506 the specified device path.
508 This function creates a new device path by appending a copy of the device path
509 instance specified by DevicePathInstance to a copy of the device path specified
510 by DevicePath in a allocated buffer.
511 The end-of-device-path device node is moved after the end of the appended device
512 path instance and a new end-of-device-path-instance node is inserted between.
513 If DevicePath is NULL, then a copy if DevicePathInstance is returned.
514 If DevicePathInstance is NULL, then NULL is returned.
515 If DevicePath or DevicePathInstance is invalid, then NULL is returned.
516 If there is not enough memory to allocate space for the new device path, then
518 The memory is allocated from EFI boot services memory. It is the responsibility
519 of the caller to free the memory allocated.
521 @param DevicePath A pointer to a device path data structure.
522 @param DevicePathInstance A pointer to a device path instance.
524 @return A pointer to the new device path.
527 EFI_DEVICE_PATH_PROTOCOL
*
529 AppendDevicePathInstance (
530 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
, OPTIONAL
531 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePathInstance OPTIONAL
534 return mDevicePathLibDevicePathUtilities
->AppendDevicePathInstance (DevicePath
, DevicePathInstance
);
538 Creates a copy of the current device path instance and returns a pointer to the
539 next device path instance.
541 This function creates a copy of the current device path instance. It also updates
542 DevicePath to point to the next device path instance in the device path (or NULL
543 if no more) and updates Size to hold the size of the device path instance copy.
544 If DevicePath is NULL, then NULL is returned.
545 If there is not enough memory to allocate space for the new device path, then
547 The memory is allocated from EFI boot services memory. It is the responsibility
548 of the caller to free the memory allocated.
549 If Size is NULL, then ASSERT().
551 @param DevicePath On input, this holds the pointer to the current
552 device path instance. On output, this holds
553 the pointer to the next device path instance
554 or NULL if there are no more device path
555 instances in the device path pointer to a
556 device path data structure.
557 @param Size On output, this holds the size of the device
558 path instance, in bytes or zero, if DevicePath
561 @return A pointer to the current device path instance.
564 EFI_DEVICE_PATH_PROTOCOL
*
566 GetNextDevicePathInstance (
567 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
,
571 ASSERT (Size
!= NULL
);
572 return mDevicePathLibDevicePathUtilities
->GetNextDevicePathInstance (DevicePath
, Size
);
576 Creates a device node.
578 This function creates a new device node in a newly allocated buffer of size
579 NodeLength and initializes the device path node header with NodeType and NodeSubType.
580 The new device path node is returned.
581 If NodeLength is smaller than a device path header, then NULL is returned.
582 If there is not enough memory to allocate space for the new device path, then
584 The memory is allocated from EFI boot services memory. It is the responsibility
585 of the caller to free the memory allocated.
587 @param NodeType The device node type for the new device node.
588 @param NodeSubType The device node sub-type for the new device node.
589 @param NodeLength The length of the new device node.
591 @return The new device path.
594 EFI_DEVICE_PATH_PROTOCOL
*
598 IN UINT8 NodeSubType
,
602 return mDevicePathLibDevicePathUtilities
->CreateDeviceNode (NodeType
, NodeSubType
, NodeLength
);
606 Determines if a device path is single or multi-instance.
608 This function returns TRUE if the device path specified by DevicePath is
610 Otherwise, FALSE is returned.
611 If DevicePath is NULL or invalid, then FALSE is returned.
613 @param DevicePath A pointer to a device path data structure.
615 @retval TRUE DevicePath is multi-instance.
616 @retval FALSE DevicePath is not multi-instance, or DevicePath
622 IsDevicePathMultiInstance (
623 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
626 return mDevicePathLibDevicePathUtilities
->IsDevicePathMultiInstance (DevicePath
);
630 Retrieves the device path protocol from a handle.
632 This function returns the device path protocol from the handle specified by Handle.
633 If Handle is NULL or Handle does not contain a device path protocol, then NULL
636 @param Handle The handle from which to retrieve the device
639 @return The device path protocol from the handle specified by Handle.
642 EFI_DEVICE_PATH_PROTOCOL
*
644 DevicePathFromHandle (
648 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
651 Status
= gBS
->HandleProtocol (
653 &gEfiDevicePathProtocolGuid
,
656 if (EFI_ERROR (Status
)) {
663 Allocates a device path for a file and appends it to an existing device path.
665 If Device is a valid device handle that contains a device path protocol, then
666 a device path for the file specified by FileName is allocated and appended to
667 the device path associated with the handle Device. The allocated device path
668 is returned. If Device is NULL or Device is a handle that does not support the
669 device path protocol, then a device path containing a single device path node
670 for the file specified by FileName is allocated and returned.
671 The memory for the new device path is allocated from EFI boot services memory.
672 It is the responsibility of the caller to free the memory allocated.
674 If FileName is NULL, then ASSERT().
675 If FileName is not aligned on a 16-bit boundary, then ASSERT().
677 @param Device A pointer to a device handle. This parameter
678 is optional and may be NULL.
679 @param FileName A pointer to a Null-terminated Unicode string.
681 @return The allocated device path.
684 EFI_DEVICE_PATH_PROTOCOL
*
687 IN EFI_HANDLE Device
, OPTIONAL
688 IN CONST CHAR16
*FileName
692 FILEPATH_DEVICE_PATH
*FilePath
;
693 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
694 EFI_DEVICE_PATH_PROTOCOL
*FileDevicePath
;
698 Size
= StrSize (FileName
);
699 FileDevicePath
= AllocatePool (Size
+ SIZE_OF_FILEPATH_DEVICE_PATH
+ END_DEVICE_PATH_LENGTH
);
700 if (FileDevicePath
!= NULL
) {
701 FilePath
= (FILEPATH_DEVICE_PATH
*) FileDevicePath
;
702 FilePath
->Header
.Type
= MEDIA_DEVICE_PATH
;
703 FilePath
->Header
.SubType
= MEDIA_FILEPATH_DP
;
704 CopyMem (&FilePath
->PathName
, FileName
, Size
);
705 SetDevicePathNodeLength (&FilePath
->Header
, Size
+ SIZE_OF_FILEPATH_DEVICE_PATH
);
706 SetDevicePathEndNode (NextDevicePathNode (&FilePath
->Header
));
708 if (Device
!= NULL
) {
709 DevicePath
= DevicePathFromHandle (Device
);
712 DevicePath
= AppendDevicePath (DevicePath
, FileDevicePath
);
713 FreePool (FileDevicePath
);
720 Locate and return the protocol instance identified by the ProtocolGuid.
722 @param ProtocolGuid The GUID of the protocol.
724 @return A pointer to the protocol instance or NULL when absent.
727 UefiDevicePathLibLocateProtocol (
728 EFI_GUID
*ProtocolGuid
733 Status
= gBS
->LocateProtocol (
738 if (EFI_ERROR (Status
)) {
746 Converts a device node to its string representation.
748 @param DeviceNode A Pointer to the device node to be converted.
749 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
750 of the display node is used, where applicable. If DisplayOnly
751 is FALSE, then the longer text representation of the display node
753 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
754 representation for a device node can be used, where applicable.
756 @return A pointer to the allocated text representation of the device node or NULL if DeviceNode
757 is NULL or there was insufficient memory.
762 ConvertDeviceNodeToText (
763 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DeviceNode
,
764 IN BOOLEAN DisplayOnly
,
765 IN BOOLEAN AllowShortcuts
768 if (mDevicePathLibDevicePathToText
== NULL
) {
769 mDevicePathLibDevicePathToText
= UefiDevicePathLibLocateProtocol (&gEfiDevicePathToTextProtocolGuid
);
771 if (mDevicePathLibDevicePathToText
!= NULL
) {
772 return mDevicePathLibDevicePathToText
->ConvertDeviceNodeToText (DeviceNode
, DisplayOnly
, AllowShortcuts
);
779 Converts a device path to its text representation.
781 @param DevicePath A Pointer to the device to be converted.
782 @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
783 of the display node is used, where applicable. If DisplayOnly
784 is FALSE, then the longer text representation of the display node
786 @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
787 representation for a device node can be used, where applicable.
789 @return A pointer to the allocated text representation of the device path or
790 NULL if DeviceNode is NULL or there was insufficient memory.
795 ConvertDevicePathToText (
796 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
797 IN BOOLEAN DisplayOnly
,
798 IN BOOLEAN AllowShortcuts
801 if (mDevicePathLibDevicePathToText
== NULL
) {
802 mDevicePathLibDevicePathToText
= UefiDevicePathLibLocateProtocol (&gEfiDevicePathToTextProtocolGuid
);
804 if (mDevicePathLibDevicePathToText
!= NULL
) {
805 return mDevicePathLibDevicePathToText
->ConvertDevicePathToText (DevicePath
, DisplayOnly
, AllowShortcuts
);
812 Convert text to the binary representation of a device node.
814 @param TextDeviceNode TextDeviceNode points to the text representation of a device
815 node. Conversion starts with the first character and continues
816 until the first non-device node character.
818 @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was
819 insufficient memory or text unsupported.
822 EFI_DEVICE_PATH_PROTOCOL
*
824 ConvertTextToDeviceNode (
825 IN CONST CHAR16
*TextDeviceNode
828 if (mDevicePathLibDevicePathFromText
== NULL
) {
829 mDevicePathLibDevicePathFromText
= UefiDevicePathLibLocateProtocol (&gEfiDevicePathFromTextProtocolGuid
);
831 if (mDevicePathLibDevicePathFromText
!= NULL
) {
832 return mDevicePathLibDevicePathFromText
->ConvertTextToDeviceNode (TextDeviceNode
);
839 Convert text to the binary representation of a device path.
842 @param TextDevicePath TextDevicePath points to the text representation of a device
843 path. Conversion starts with the first character and continues
844 until the first non-device node character.
846 @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or
847 there was insufficient memory.
850 EFI_DEVICE_PATH_PROTOCOL
*
852 ConvertTextToDevicePath (
853 IN CONST CHAR16
*TextDevicePath
856 if (mDevicePathLibDevicePathFromText
== NULL
) {
857 mDevicePathLibDevicePathFromText
= UefiDevicePathLibLocateProtocol (&gEfiDevicePathFromTextProtocolGuid
);
859 if (mDevicePathLibDevicePathFromText
!= NULL
) {
860 return mDevicePathLibDevicePathFromText
->ConvertTextToDevicePath (TextDevicePath
);