]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add 4 APIs to DevicePathLib: ConvertDeviceNodeToText, ConvertDevicePathToText, Conver...
authorRuiyu Ni <ruiyu.ni@intel.com>
Fri, 26 Jul 2013 03:00:21 +0000 (03:00 +0000)
committerniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 26 Jul 2013 03:00:21 +0000 (03:00 +0000)
Add a new instance of DevicePathLib which tries to locate the protocol and if it's not found, it uses the internal functions.

Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14504 6f19259b-4bc3-4df7-8a09-765794883524

18 files changed:
MdeModulePkg/Universal/DevicePathDxe/DevicePath.c
MdeModulePkg/Universal/DevicePathDxe/DevicePath.h [deleted file]
MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c [deleted file]
MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c [deleted file]
MdeModulePkg/Universal/DevicePathDxe/DevicePathUtilities.c [deleted file]
MdePkg/Include/Library/DevicePathLib.h
MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c [new file with mode: 0644]
MdePkg/Library/UefiDevicePathLib/DevicePathToText.c [new file with mode: 0644]
MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c [new file with mode: 0644]
MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c
MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.h [new file with mode: 0644]
MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibOptionalDevicePathProtocol.c [new file with mode: 0644]
MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibOptionalDevicePathProtocol.inf [new file with mode: 0644]
MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLib.c
MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLibDevicePathProtocol.inf
MdePkg/MdePkg.dsc

index 716aa605c8564f5c754e1593175e4e5973864782..70f03bd27aa0e2cabd1df9b0ae9a743c214d98c6 100644 (file)
@@ -2,7 +2,7 @@
   Device Path Driver to produce DevPathUtilities Protocol, DevPathFromText Protocol\r
   and DevPathToText Protocol.\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -13,19 +13,24 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
-#include "DevicePath.h"\r
-\r
-EFI_HANDLE  mDevicePathHandle = NULL;\r
+#include <Uefi.h>\r
+#include <Protocol/DevicePathUtilities.h>\r
+#include <Protocol/DevicePathToText.h>\r
+#include <Protocol/DevicePathFromText.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/DevicePathLib.h>\r
+#include <Library/PcdLib.h>\r
 \r
 GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_DEVICE_PATH_UTILITIES_PROTOCOL mDevicePathUtilities = {\r
-  GetDevicePathSizeProtocolInterface,\r
-  DuplicateDevicePathProtocolInterface,\r
-  AppendDevicePathProtocolInterface,\r
-  AppendDeviceNodeProtocolInterface,\r
-  AppendDevicePathInstanceProtocolInterface,\r
-  GetNextDevicePathInstanceProtocolInterface,\r
-  IsDevicePathMultiInstanceProtocolInterface,\r
-  CreateDeviceNodeProtocolInterface\r
+  GetDevicePathSize,\r
+  DuplicateDevicePath,\r
+  AppendDevicePath,\r
+  AppendDevicePathNode,\r
+  AppendDevicePathInstance,\r
+  GetNextDevicePathInstance,\r
+  IsDevicePathMultiInstance,\r
+  CreateDeviceNode\r
 };\r
 \r
 GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_DEVICE_PATH_TO_TEXT_PROTOCOL   mDevicePathToText = {\r
@@ -38,11 +43,6 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL mDevicePa
   ConvertTextToDevicePath\r
 };\r
 \r
-GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_GUID mEfiDevicePathMessagingUartFlowControlGuid = DEVICE_PATH_MESSAGING_UART_FLOW_CONTROL;\r
-GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_GUID mEfiDevicePathMessagingSASGuid             = DEVICE_PATH_MESSAGING_SAS;\r
-\r
-\r
-\r
 /**\r
   The user Entry Point for DevicePath module.\r
 \r
@@ -64,12 +64,14 @@ DevicePathEntryPoint (
   )\r
 {\r
   EFI_STATUS  Status;\r
+  EFI_HANDLE  Handle;\r
 \r
+  Handle = NULL;\r
   Status = EFI_UNSUPPORTED;\r
   if (FeaturePcdGet (PcdDevicePathSupportDevicePathToText)) {\r
     if (FeaturePcdGet (PcdDevicePathSupportDevicePathFromText)) {\r
       Status = gBS->InstallMultipleProtocolInterfaces (\r
-                      &mDevicePathHandle,\r
+                      &Handle,\r
                       &gEfiDevicePathUtilitiesProtocolGuid, &mDevicePathUtilities,\r
                       &gEfiDevicePathToTextProtocolGuid,    &mDevicePathToText,\r
                       &gEfiDevicePathFromTextProtocolGuid,  &mDevicePathFromText,\r
@@ -77,7 +79,7 @@ DevicePathEntryPoint (
                       );\r
     } else {\r
       Status = gBS->InstallMultipleProtocolInterfaces (\r
-                      &mDevicePathHandle,\r
+                      &Handle,\r
                       &gEfiDevicePathUtilitiesProtocolGuid, &mDevicePathUtilities,\r
                       &gEfiDevicePathToTextProtocolGuid,    &mDevicePathToText,\r
                       NULL\r
@@ -86,14 +88,14 @@ DevicePathEntryPoint (
   } else {\r
     if (FeaturePcdGet (PcdDevicePathSupportDevicePathFromText)) {\r
       Status = gBS->InstallMultipleProtocolInterfaces (\r
-                      &mDevicePathHandle,\r
+                      &Handle,\r
                       &gEfiDevicePathUtilitiesProtocolGuid, &mDevicePathUtilities,\r
                       &gEfiDevicePathFromTextProtocolGuid,  &mDevicePathFromText,\r
                       NULL\r
                       );\r
     } else {\r
       Status = gBS->InstallMultipleProtocolInterfaces (\r
-                      &mDevicePathHandle,\r
+                      &Handle,\r
                       &gEfiDevicePathUtilitiesProtocolGuid, &mDevicePathUtilities,\r
                       NULL\r
                       );\r
diff --git a/MdeModulePkg/Universal/DevicePathDxe/DevicePath.h b/MdeModulePkg/Universal/DevicePathDxe/DevicePath.h
deleted file mode 100644 (file)
index 8beb68c..0000000
+++ /dev/null
@@ -1,433 +0,0 @@
-/** @file\r
-  Definition for Device Path Utilities driver\r
-\r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef _DEVICE_PATH_DRIVER_H_\r
-#define _DEVICE_PATH_DRIVER_H_\r
-\r
-#include <Uefi.h>\r
-#include <Protocol/DevicePathUtilities.h>\r
-#include <Protocol/DebugPort.h>\r
-#include <Protocol/DevicePathToText.h>\r
-#include <Protocol/DevicePathFromText.h>\r
-#include <Guid/PcAnsi.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/PrintLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/PcdLib.h>\r
-\r
-#define IS_COMMA(a)                ((a) == L',')\r
-#define IS_HYPHEN(a)               ((a) == L'-')\r
-#define IS_DOT(a)                  ((a) == L'.')\r
-#define IS_LEFT_PARENTH(a)         ((a) == L'(')\r
-#define IS_RIGHT_PARENTH(a)        ((a) == L')')\r
-#define IS_SLASH(a)                ((a) == L'/')\r
-#define IS_NULL(a)                 ((a) == L'\0')\r
-\r
-\r
-#define SET_DEVICE_PATH_INSTANCE_END_NODE(a) {                   \\r
-    (a)->Type       = END_DEVICE_PATH_TYPE;                      \\r
-    (a)->SubType    = END_INSTANCE_DEVICE_PATH_SUBTYPE;          \\r
-    (a)->Length[0]  = (UINT8) sizeof (EFI_DEVICE_PATH_PROTOCOL); \\r
-    (a)->Length[1]  = 0;                                         \\r
-  }\r
-\r
-//\r
-// Private Data structure\r
-//\r
-typedef struct {\r
-  CHAR16  *Str;\r
-  UINTN   Length;\r
-  UINTN   Capacity;\r
-} POOL_PRINT;\r
-\r
-typedef\r
-EFI_DEVICE_PATH_PROTOCOL  *\r
-(*DUMP_NODE) (\r
-  IN  CHAR16 *DeviceNodeStr\r
-  );\r
-\r
-typedef\r
-VOID\r
-(*DEVICE_PATH_TO_TEXT_FUNC) (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  );\r
-\r
-typedef struct {\r
-  UINT8                     Type;\r
-  UINT8                     SubType;\r
-  DEVICE_PATH_TO_TEXT_FUNC  Function;\r
-} DEVICE_PATH_TO_TEXT_TABLE;\r
-\r
-typedef struct {\r
-  CHAR16                    *DevicePathNodeText;\r
-  DUMP_NODE                 Function;\r
-} DEVICE_PATH_FROM_TEXT_TABLE;\r
-\r
-typedef struct {\r
-  BOOLEAN ClassExist;\r
-  UINT8   Class;\r
-  BOOLEAN SubClassExist;\r
-  UINT8   SubClass;\r
-} USB_CLASS_TEXT;\r
-\r
-#define USB_CLASS_AUDIO            1\r
-#define USB_CLASS_CDCCONTROL       2\r
-#define USB_CLASS_HID              3\r
-#define USB_CLASS_IMAGE            6\r
-#define USB_CLASS_PRINTER          7\r
-#define USB_CLASS_MASS_STORAGE     8\r
-#define USB_CLASS_HUB              9\r
-#define USB_CLASS_CDCDATA          10\r
-#define USB_CLASS_SMART_CARD       11\r
-#define USB_CLASS_VIDEO            14\r
-#define USB_CLASS_DIAGNOSTIC       220\r
-#define USB_CLASS_WIRELESS         224\r
-\r
-#define USB_CLASS_RESERVE          254\r
-#define USB_SUBCLASS_FW_UPDATE     1\r
-#define USB_SUBCLASS_IRDA_BRIDGE   2\r
-#define USB_SUBCLASS_TEST          3\r
-\r
-#define RFC_1700_UDP_PROTOCOL      17\r
-#define RFC_1700_TCP_PROTOCOL      6\r
-\r
-#pragma pack(1)\r
-\r
-typedef struct {\r
-  EFI_DEVICE_PATH_PROTOCOL  Header;\r
-  EFI_GUID                  Guid;\r
-  UINT8                     VendorDefinedData[1];\r
-} VENDOR_DEFINED_HARDWARE_DEVICE_PATH;\r
-\r
-typedef struct {\r
-  EFI_DEVICE_PATH_PROTOCOL  Header;\r
-  EFI_GUID                  Guid;\r
-  UINT8                     VendorDefinedData[1];\r
-} VENDOR_DEFINED_MESSAGING_DEVICE_PATH;\r
-\r
-typedef struct {\r
-  EFI_DEVICE_PATH_PROTOCOL  Header;\r
-  EFI_GUID                  Guid;\r
-  UINT8                     VendorDefinedData[1];\r
-} VENDOR_DEFINED_MEDIA_DEVICE_PATH;\r
-\r
-typedef struct {\r
-  EFI_DEVICE_PATH_PROTOCOL  Header;\r
-  UINT32                    Hid;\r
-  UINT32                    Uid;\r
-  UINT32                    Cid;\r
-  CHAR8                     HidUidCidStr[3];\r
-} ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR;\r
-\r
-typedef struct {\r
-  EFI_DEVICE_PATH_PROTOCOL  Header;\r
-  UINT16                    NetworkProtocol;\r
-  UINT16                    LoginOption;\r
-  UINT64                    Lun;\r
-  UINT16                    TargetPortalGroupTag;\r
-  CHAR8                     TargetName[1];\r
-} ISCSI_DEVICE_PATH_WITH_NAME;\r
-\r
-typedef struct {\r
-  EFI_DEVICE_PATH_PROTOCOL  Header;\r
-  EFI_GUID                  Guid;\r
-  UINT8                     VendorDefinedData[1];\r
-} VENDOR_DEVICE_PATH_WITH_DATA;\r
-\r
-#pragma pack()\r
-\r
-/**\r
-  Converts a device node to its string representation.\r
-\r
-  @param DeviceNode        A Pointer to the device node to be converted.\r
-  @param DisplayOnly       If DisplayOnly is TRUE, then the shorter text representation\r
-                           of the display node is used, where applicable. If DisplayOnly\r
-                           is FALSE, then the longer text representation of the display node\r
-                           is used.\r
-  @param AllowShortcuts    If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                           representation for a device node can be used, where applicable.\r
-\r
-  @return A pointer to the allocated text representation of the device node or NULL if DeviceNode\r
-          is NULL or there was insufficient memory.\r
-\r
-**/\r
-CHAR16 *\r
-EFIAPI\r
-ConvertDeviceNodeToText (\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DeviceNode,\r
-  IN BOOLEAN                         DisplayOnly,\r
-  IN BOOLEAN                         AllowShortcuts\r
-  );\r
-\r
-/**\r
-  Converts a device path to its text representation.\r
-\r
-  @param DevicePath      A Pointer to the device to be converted.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-  @return A pointer to the allocated text representation of the device path or\r
-          NULL if DeviceNode is NULL or there was insufficient memory.\r
-\r
-**/\r
-CHAR16 *\r
-EFIAPI\r
-ConvertDevicePathToText (\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL   *DevicePath,\r
-  IN BOOLEAN                          DisplayOnly,\r
-  IN BOOLEAN                          AllowShortcuts\r
-  );\r
-\r
-/**\r
-  Convert text to the binary representation of a device node.\r
-\r
-  @param TextDeviceNode  TextDeviceNode points to the text representation of a device\r
-                         node. Conversion starts with the first character and continues\r
-                         until the first non-device node character.\r
-\r
-  @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was\r
-          insufficient memory or text unsupported.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-EFIAPI\r
-ConvertTextToDeviceNode (\r
-  IN CONST CHAR16 *TextDeviceNode\r
-  );\r
-\r
-/**\r
-  Convert text to the binary representation of a device path.\r
-\r
-\r
-  @param TextDevicePath  TextDevicePath points to the text representation of a device\r
-                         path. Conversion starts with the first character and continues\r
-                         until the first non-device node character.\r
-\r
-  @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or\r
-          there was insufficient memory.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-EFIAPI\r
-ConvertTextToDevicePath (\r
-  IN CONST CHAR16 *TextDevicePath\r
-  );\r
-\r
-/**\r
-  Returns the size of a device path in bytes.\r
-\r
-  This function returns the size, in bytes, of the device path data structure specified by\r
-  DevicePath including the end of device path node.  If DevicePath is NULL, then 0 is returned.\r
-\r
-  @param  DevicePath                 A pointer to a device path data structure.\r
-\r
-  @return The size of a device path in bytes.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-GetDevicePathSizeProtocolInterface (\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
-  );\r
-\r
-/**\r
-  Creates a new device path by appending a second device path to a first device path.\r
-\r
-  This function allocates space for a new copy of the device path specified by DevicePath.  If\r
-  DevicePath is NULL, then NULL is returned.  If the memory is successfully allocated, then the\r
-  contents of DevicePath are copied to the newly allocated buffer, and a pointer to that buffer\r
-  is returned.  Otherwise, NULL is returned.\r
-\r
-  @param  DevicePath                 A pointer to a device path data structure.\r
-\r
-  @return A pointer to the duplicated device path.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-EFIAPI\r
-DuplicateDevicePathProtocolInterface (\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
-  );\r
-\r
-/**\r
-  Creates a new device path by appending a second device path to a first device path.\r
-\r
-  This function creates a new device path by appending a copy of SecondDevicePath to a copy of\r
-  FirstDevicePath in a newly allocated buffer.  Only the end-of-device-path device node from\r
-  SecondDevicePath is retained. The newly created device path is returned.\r
-  If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned.\r
-  If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned.\r
-  If both FirstDevicePath and SecondDevicePath are NULL, then a copy of an end-of-device-path is\r
-  returned.\r
-  If there is not enough memory for the newly allocated buffer, then NULL is returned.\r
-  The memory for the new device path is allocated from EFI boot services memory. It is the\r
-  responsibility of the caller to free the memory allocated.\r
-\r
-  @param  FirstDevicePath            A pointer to a device path data structure.\r
-  @param  SecondDevicePath           A pointer to a device path data structure.\r
-\r
-  @return A pointer to the new device path.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-EFIAPI\r
-AppendDevicePathProtocolInterface (\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath,\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath\r
-  );\r
-\r
-/**\r
-  Creates a new path by appending the device node to the device path.\r
-\r
-  This function creates a new device path by appending a copy of the device node specified by\r
-  DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer.\r
-  The end-of-device-path device node is moved after the end of the appended device node.\r
-  If DevicePathNode is NULL then a copy of DevicePath is returned.\r
-  If DevicePath is NULL then a copy of DevicePathNode, followed by an end-of-device path device\r
-  node is returned.\r
-  If both DevicePathNode and DevicePath are NULL then a copy of an end-of-device-path device node\r
-  is returned.\r
-  If there is not enough memory to allocate space for the new device path, then NULL is returned.\r
-  The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
-  free the memory allocated.\r
-\r
-  @param  DevicePath                 A pointer to a device path data structure.\r
-  @param  DevicePathNode             A pointer to a single device path node.\r
-\r
-  @return A pointer to the new device path.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-EFIAPI\r
-AppendDeviceNodeProtocolInterface (\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode\r
-  );\r
-\r
-/**\r
-  Creates a new device path by appending the specified device path instance to the specified device\r
-  path.\r
-\r
-  This function creates a new device path by appending a copy of the device path instance specified\r
-  by DevicePathInstance to a copy of the device path specified by DevicePath in a allocated buffer.\r
-  The end-of-device-path device node is moved after the end of the appended device path instance\r
-  and a new end-of-device-path-instance node is inserted between.\r
-  If DevicePath is NULL, then a copy if DevicePathInstance is returned.\r
-  If DevicePathInstance is NULL, then NULL is returned.\r
-  If there is not enough memory to allocate space for the new device path, then NULL is returned.\r
-  The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
-  free the memory allocated.\r
-\r
-  @param  DevicePath                 A pointer to a device path data structure.\r
-  @param  DevicePathInstance         A pointer to a device path instance.\r
-\r
-  @return A pointer to the new device path.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-EFIAPI\r
-AppendDevicePathInstanceProtocolInterface (\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance\r
-  );\r
-\r
-/**\r
-  Creates a copy of the current device path instance and returns a pointer to the next device path\r
-  instance.\r
-\r
-  This function creates a copy of the current device path instance. It also updates DevicePath to\r
-  point to the next device path instance in the device path (or NULL if no more) and updates Size\r
-  to hold the size of the device path instance copy.\r
-  If DevicePath is NULL, then NULL is returned.\r
-  If there is not enough memory to allocate space for the new device path, then NULL is returned.\r
-  The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
-  free the memory allocated.\r
-  If Size is NULL, then ASSERT().\r
-\r
-  @param  DevicePath                 On input, this holds the pointer to the current device path\r
-                                     instance. On output, this holds the pointer to the next device\r
-                                     path instance or NULL if there are no more device path\r
-                                     instances in the device path pointer to a device path data\r
-                                     structure.\r
-  @param  Size                       On output, this holds the size of the device path instance, in\r
-                                     bytes or zero, if DevicePath is NULL.\r
-\r
-  @return A pointer to the current device path instance.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-EFIAPI\r
-GetNextDevicePathInstanceProtocolInterface (\r
-  IN OUT EFI_DEVICE_PATH_PROTOCOL   **DevicePath,\r
-  OUT UINTN                         *Size\r
-  );\r
-\r
-/**\r
-  Determines if a device path is single or multi-instance.\r
-\r
-  This function returns TRUE if the device path specified by DevicePath is multi-instance.\r
-  Otherwise, FALSE is returned.  If DevicePath is NULL, then FALSE is returned.\r
-\r
-  @param  DevicePath                 A pointer to a device path data structure.\r
-\r
-  @retval  TRUE                      DevicePath is multi-instance.\r
-  @retval  FALSE                     DevicePath is not multi-instance or DevicePath is NULL.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-IsDevicePathMultiInstanceProtocolInterface (\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
-  );\r
-\r
-/**\r
-  Creates a copy of the current device path instance and returns a pointer to the next device path\r
-  instance.\r
-\r
-  This function creates a new device node in a newly allocated buffer of size NodeLength and\r
-  initializes the device path node header with NodeType and NodeSubType.  The new device path node\r
-  is returned.\r
-  If NodeLength is smaller than a device path header, then NULL is returned.\r
-  If there is not enough memory to allocate space for the new device path, then NULL is returned.\r
-  The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
-  free the memory allocated.\r
-\r
-  @param  NodeType                   The device node type for the new device node.\r
-  @param  NodeSubType                The device node sub-type for the new device node.\r
-  @param  NodeLength                 The length of the new device node.\r
-\r
-  @return The new device path.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-EFIAPI\r
-CreateDeviceNodeProtocolInterface (\r
-  IN UINT8  NodeType,\r
-  IN UINT8  NodeSubType,\r
-  IN UINT16 NodeLength\r
-  );\r
-\r
-#endif\r
index d315fe6f52350280c559443f2b4e79c791377bb4..29017bad074e00d77e81afd94e446a8c600997c8 100644 (file)
@@ -6,7 +6,7 @@
 #  PcdDevicePathSupportDevicePathToText & PcdDevicePathSupportDevicePathFromText\r
 #  respectively.\r
 #\r
-#  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
 #  which accompanies this distribution.  The full text of the license may be found at\r
 #\r
 \r
 [Sources]\r
-  DevicePathUtilities.c\r
-  DevicePathToText.c   ||||gEfiMdeModulePkgTokenSpaceGuid.PcdDevicePathSupportDevicePathToText\r
-  DevicePathFromText.c ||||gEfiMdeModulePkgTokenSpaceGuid.PcdDevicePathSupportDevicePathFromText\r
-  DevicePath.h\r
   DevicePath.c\r
 \r
 [Packages]\r
-  MdeModulePkg/MdeModulePkg.dec\r
   MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
 \r
 [LibraryClasses]\r
-  PcdLib\r
   DevicePathLib\r
   UefiBootServicesTableLib\r
-  MemoryAllocationLib\r
-  BaseMemoryLib\r
-  BaseLib\r
   UefiDriverEntryPoint\r
-  PrintLib\r
-  DebugLib\r
-\r
-[Guids]\r
-  gEfiVTUTF8Guid         | gEfiMdeModulePkgTokenSpaceGuid.PcdDevicePathSupportDevicePathFromText OR gEfiMdeModulePkgTokenSpaceGuid.PcdDevicePathSupportDevicePathToText ## SOMETIMES_CONSUMES ## GUID\r
-  gEfiVT100Guid          | gEfiMdeModulePkgTokenSpaceGuid.PcdDevicePathSupportDevicePathFromText OR gEfiMdeModulePkgTokenSpaceGuid.PcdDevicePathSupportDevicePathToText ## SOMETIMES_CONSUMES ## GUID\r
-  gEfiVT100PlusGuid      | gEfiMdeModulePkgTokenSpaceGuid.PcdDevicePathSupportDevicePathFromText OR gEfiMdeModulePkgTokenSpaceGuid.PcdDevicePathSupportDevicePathToText ## SOMETIMES_CONSUMES ## GUID\r
-  gEfiPcAnsiGuid         | gEfiMdeModulePkgTokenSpaceGuid.PcdDevicePathSupportDevicePathFromText OR gEfiMdeModulePkgTokenSpaceGuid.PcdDevicePathSupportDevicePathToText ## SOMETIMES_CONSUMES ## GUID\r
-  gEfiUartDevicePathGuid | gEfiMdeModulePkgTokenSpaceGuid.PcdDevicePathSupportDevicePathFromText OR gEfiMdeModulePkgTokenSpaceGuid.PcdDevicePathSupportDevicePathToText ## SOMETIMES_CONSUMES ## GUID\r
-  gEfiSasDevicePathGuid  | gEfiMdeModulePkgTokenSpaceGuid.PcdDevicePathSupportDevicePathFromText OR gEfiMdeModulePkgTokenSpaceGuid.PcdDevicePathSupportDevicePathToText ## SOMETIMES_CONSUMES ## GUID\r
   \r
 [Protocols]\r
   gEfiDevicePathToTextProtocolGuid   | gEfiMdeModulePkgTokenSpaceGuid.PcdDevicePathSupportDevicePathFromText ## PRODUCES\r
   gEfiDevicePathFromTextProtocolGuid | gEfiMdeModulePkgTokenSpaceGuid.PcdDevicePathSupportDevicePathToText ## PRODUCES\r
   gEfiDevicePathUtilitiesProtocolGuid ## PRODUCES\r
-  gEfiDebugPortProtocolGuid          | gEfiMdeModulePkgTokenSpaceGuid.PcdDevicePathSupportDevicePathFromText OR gEfiMdeModulePkgTokenSpaceGuid.PcdDevicePathSupportDevicePathToText ## SOMETIMES_CONSUMES ## GUID\r
 \r
 [FeaturePcd]\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdDevicePathSupportDevicePathFromText\r
diff --git a/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c b/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c
deleted file mode 100644 (file)
index f96bea1..0000000
+++ /dev/null
@@ -1,3210 +0,0 @@
-/** @file\r
-  DevicePathFromText protocol as defined in the UEFI 2.0 specification.\r
-\r
-Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "DevicePath.h"\r
-\r
-\r
-/**\r
-\r
-  Duplicates a string.\r
-\r
-  @param  Src  Source string.\r
-\r
-  @return The duplicated string.\r
-\r
-**/\r
-CHAR16 *\r
-StrDuplicate (\r
-  IN CONST CHAR16  *Src\r
-  )\r
-{\r
-  return AllocateCopyPool (StrSize (Src), Src);\r
-}\r
-\r
-/**\r
-\r
-  Get parameter in a pair of parentheses follow the given node name.\r
-  For example, given the "Pci(0,1)" and NodeName "Pci", it returns "0,1".\r
-\r
-  @param  Str      Device Path Text.\r
-  @param  NodeName Name of the node.\r
-\r
-  @return Parameter text for the node.\r
-\r
-**/\r
-CHAR16 *\r
-GetParamByNodeName (\r
-  IN CHAR16 *Str,\r
-  IN CHAR16 *NodeName\r
-  )\r
-{\r
-  CHAR16  *ParamStr;\r
-  CHAR16  *StrPointer;\r
-  UINTN   NodeNameLength;\r
-  UINTN   ParameterLength;\r
-\r
-  //\r
-  // Check whether the node name matchs\r
-  //\r
-  NodeNameLength = StrLen (NodeName);\r
-  if (CompareMem (Str, NodeName, NodeNameLength * sizeof (CHAR16)) != 0) {\r
-    return NULL;\r
-  }\r
-\r
-  ParamStr = Str + NodeNameLength;\r
-  if (!IS_LEFT_PARENTH (*ParamStr)) {\r
-    return NULL;\r
-  }\r
-\r
-  //\r
-  // Skip the found '(' and find first occurrence of ')'\r
-  //\r
-  ParamStr++;\r
-  ParameterLength = 0;\r
-  StrPointer = ParamStr;\r
-  while (!IS_NULL (*StrPointer)) {\r
-    if (IS_RIGHT_PARENTH (*StrPointer)) {\r
-      break;\r
-    }\r
-    StrPointer++;\r
-    ParameterLength++;\r
-  }\r
-  if (IS_NULL (*StrPointer)) {\r
-    //\r
-    // ')' not found\r
-    //\r
-    return NULL;\r
-  }\r
-\r
-  ParamStr = AllocateCopyPool ((ParameterLength + 1) * sizeof (CHAR16), ParamStr);\r
-  if (ParamStr == NULL) {\r
-    return NULL;\r
-  }\r
-  //\r
-  // Terminate the parameter string\r
-  //\r
-  ParamStr[ParameterLength] = L'\0';\r
-\r
-  return ParamStr;\r
-}\r
-\r
-/**\r
-  Gets current sub-string from a string list, before return\r
-  the list header is moved to next sub-string. The sub-string is separated\r
-  by the specified character. For example, the separator is ',', the string\r
-  list is "2,0,3", it returns "2", the remain list move to "0,3"\r
-\r
-  @param  List        A string list separated by the specified separator\r
-  @param  Separator   The separator character\r
-\r
-  @return A pointer to the current sub-string\r
-\r
-**/\r
-CHAR16 *\r
-SplitStr (\r
-  IN OUT CHAR16 **List,\r
-  IN     CHAR16 Separator\r
-  )\r
-{\r
-  CHAR16  *Str;\r
-  CHAR16  *ReturnStr;\r
-\r
-  Str = *List;\r
-  ReturnStr = Str;\r
-\r
-  if (IS_NULL (*Str)) {\r
-    return ReturnStr;\r
-  }\r
-\r
-  //\r
-  // Find first occurrence of the separator\r
-  //\r
-  while (!IS_NULL (*Str)) {\r
-    if (*Str == Separator) {\r
-      break;\r
-    }\r
-    Str++;\r
-  }\r
-\r
-  if (*Str == Separator) {\r
-    //\r
-    // Find a sub-string, terminate it\r
-    //\r
-    *Str = L'\0';\r
-    Str++;\r
-  }\r
-\r
-  //\r
-  // Move to next sub-string\r
-  //\r
-  *List = Str;\r
-\r
-  return ReturnStr;\r
-}\r
-\r
-/**\r
-  Gets the next parameter string from the list.\r
-\r
-  @param List            A string list separated by the specified separator\r
-\r
-  @return A pointer to the current sub-string\r
-\r
-**/\r
-CHAR16 *\r
-GetNextParamStr (\r
-  IN OUT CHAR16 **List\r
-  )\r
-{\r
-  //\r
-  // The separator is comma\r
-  //\r
-  return SplitStr (List, L',');\r
-}\r
-\r
-/**\r
-  Get one device node from entire device path text.\r
-\r
-  @param DevicePath      On input, the current Device Path node; on output, the next device path node\r
-  @param IsInstanceEnd   This node is the end of a device path instance\r
-\r
-  @return A device node text or NULL if no more device node available\r
-\r
-**/\r
-CHAR16 *\r
-GetNextDeviceNodeStr (\r
-  IN OUT CHAR16   **DevicePath,\r
-  OUT    BOOLEAN  *IsInstanceEnd\r
-  )\r
-{\r
-  CHAR16  *Str;\r
-  CHAR16  *ReturnStr;\r
-  UINTN   ParenthesesStack;\r
-\r
-  Str = *DevicePath;\r
-  if (IS_NULL (*Str)) {\r
-    return NULL;\r
-  }\r
-\r
-  //\r
-  // Skip the leading '/', '(', ')' and ','\r
-  //\r
-  while (!IS_NULL (*Str)) {\r
-    if (!IS_SLASH (*Str) &&\r
-        !IS_COMMA (*Str) &&\r
-        !IS_LEFT_PARENTH (*Str) &&\r
-        !IS_RIGHT_PARENTH (*Str)) {\r
-      break;\r
-    }\r
-    Str++;\r
-  }\r
-\r
-  ReturnStr = Str;\r
-\r
-  //\r
-  // Scan for the separator of this device node, '/' or ','\r
-  //\r
-  ParenthesesStack = 0;\r
-  while (!IS_NULL (*Str)) {\r
-    if ((IS_COMMA (*Str) || IS_SLASH (*Str)) && (ParenthesesStack == 0)) {\r
-      break;\r
-    }\r
-\r
-    if (IS_LEFT_PARENTH (*Str)) {\r
-      ParenthesesStack++;\r
-    } else if (IS_RIGHT_PARENTH (*Str)) {\r
-      ParenthesesStack--;\r
-    }\r
-\r
-    Str++;\r
-  }\r
-\r
-  if (ParenthesesStack != 0) {\r
-    //\r
-    // The '(' doesn't pair with ')', invalid device path text\r
-    //\r
-    return NULL;\r
-  }\r
-\r
-  if (IS_COMMA (*Str)) {\r
-    *IsInstanceEnd = TRUE;\r
-    *Str = L'\0';\r
-    Str++;\r
-  } else {\r
-    *IsInstanceEnd = FALSE;\r
-    if (!IS_NULL (*Str)) {\r
-      *Str = L'\0';\r
-      Str++;\r
-    }\r
-  }\r
-\r
-  *DevicePath = Str;\r
-\r
-  return ReturnStr;\r
-}\r
-\r
-\r
-/**\r
-  Skip the leading white space and '0x' or '0X' of a integer string\r
-\r
-  @param Str             The integer string\r
-  @param IsHex           TRUE: Hex string, FALSE: Decimal string\r
-\r
-  @return The trimmed Hex string.\r
-\r
-**/\r
-CHAR16 *\r
-TrimHexStr (\r
-  IN CHAR16   *Str,\r
-  OUT BOOLEAN *IsHex\r
-  )\r
-{\r
-  *IsHex = FALSE;\r
-\r
-  //\r
-  // skip preceeding white space\r
-  //\r
-  while ((*Str != 0) && *Str == ' ') {\r
-    Str += 1;\r
-  }\r
-  //\r
-  // skip preceeding zeros\r
-  //\r
-  while ((*Str != 0) && *Str == '0') {\r
-    Str += 1;\r
-  }\r
-  //\r
-  // skip preceeding character 'x' or 'X'\r
-  //\r
-  if ((*Str != 0) && (*Str == 'x' || *Str == 'X')) {\r
-    Str += 1;\r
-    *IsHex = TRUE;\r
-  }\r
-\r
-  return Str;\r
-}\r
-\r
-/**\r
-\r
-  Convert hex string to uint.\r
-\r
-  @param Str             The hex string\r
-\r
-  @return A UINTN value represented by Str\r
-\r
-**/\r
-UINTN\r
-Xtoi (\r
-  IN CHAR16  *Str\r
-  )\r
-{\r
-  return StrHexToUintn (Str);\r
-}\r
-\r
-/**\r
-\r
-  Convert hex string to 64 bit data.\r
-\r
-  @param Str             The hex string\r
-  @param Data            A pointer to the UINT64 value represented by Str\r
-\r
-**/\r
-VOID\r
-Xtoi64 (\r
-  IN  CHAR16  *Str,\r
-  OUT UINT64  *Data\r
-  )\r
-{\r
-  *Data = StrHexToUint64 (Str);\r
-}\r
-\r
-/**\r
-\r
-  Convert decimal string to uint.\r
-\r
-  @param Str             The decimal string\r
-\r
-  @return A UINTN value represented by Str\r
-\r
-**/\r
-UINTN\r
-Dtoi (\r
-  IN CHAR16  *Str\r
-  )\r
-{\r
-  UINTN   Rvalue;\r
-  CHAR16  Char;\r
-  UINTN   High;\r
-  UINTN   Low;\r
-\r
-  ASSERT (Str != NULL);\r
-\r
-  High = (UINTN) -1 / 10;\r
-  Low  = (UINTN) -1 % 10;\r
-  //\r
-  // skip preceeding white space\r
-  //\r
-  while ((*Str != 0) && *Str == ' ') {\r
-    Str += 1;\r
-  }\r
-  //\r
-  // convert digits\r
-  //\r
-  Rvalue = 0;\r
-  Char = *(Str++);\r
-  while (Char != 0) {\r
-    if (Char >= '0' && Char <= '9') {\r
-      if ((Rvalue > High || Rvalue == High) && (Char - '0' > (INTN) Low)) {\r
-        return (UINTN) -1;\r
-      }\r
-\r
-      Rvalue = (Rvalue * 10) + Char - '0';\r
-    } else {\r
-      break;\r
-    }\r
-\r
-    Char = *(Str++);\r
-  }\r
-\r
-  return Rvalue;\r
-}\r
-\r
-/**\r
-\r
-  Convert decimal string to uint.\r
-\r
-  @param Str             The decimal string\r
-  @param Data            A pointer to the UINT64 value represented by Str\r
-\r
-**/\r
-VOID\r
-Dtoi64 (\r
-  IN CHAR16  *Str,\r
-  OUT UINT64 *Data\r
-  )\r
-{\r
-  UINT64   Rvalue;\r
-  CHAR16   Char;\r
-  UINT64   High;\r
-  UINT64   Low;\r
-\r
-  ASSERT (Str != NULL);\r
-  ASSERT (Data != NULL);\r
-\r
-  //\r
-  // skip preceeding white space\r
-  //\r
-  while ((*Str != 0) && *Str == ' ') {\r
-    Str += 1;\r
-  }\r
-  //\r
-  // convert digits\r
-  //\r
-  Rvalue = 0;\r
-  Char = *(Str++);\r
-  while (Char != 0) {\r
-    if (Char >= '0' && Char <= '9') {\r
-      High = LShiftU64 (Rvalue, 3);\r
-      Low = LShiftU64 (Rvalue, 1);\r
-      Rvalue = High + Low + Char - '0';\r
-    } else {\r
-      break;\r
-    }\r
-\r
-    Char = *(Str++);\r
-  }\r
-\r
-  *Data = Rvalue;\r
-}\r
-\r
-/**\r
-\r
-  Convert integer string to uint.\r
-\r
-  @param Str             The integer string. If leading with "0x" or "0X", it's hexadecimal.\r
-\r
-  @return A UINTN value represented by Str\r
-\r
-**/\r
-UINTN\r
-Strtoi (\r
-  IN CHAR16  *Str\r
-  )\r
-{\r
-  BOOLEAN IsHex;\r
-\r
-  Str = TrimHexStr (Str, &IsHex);\r
-\r
-  if (IsHex) {\r
-    return Xtoi (Str);\r
-  } else {\r
-    return Dtoi (Str);\r
-  }\r
-}\r
-\r
-/**\r
-\r
-  Convert integer string to 64 bit data.\r
-\r
-  @param Str             The integer string. If leading with "0x" or "0X", it's hexadecimal.\r
-  @param Data            A pointer to the UINT64 value represented by Str\r
-\r
-**/\r
-VOID\r
-Strtoi64 (\r
-  IN  CHAR16  *Str,\r
-  OUT UINT64  *Data\r
-  )\r
-{\r
-  BOOLEAN IsHex;\r
-\r
-  Str = TrimHexStr (Str, &IsHex);\r
-\r
-  if (IsHex) {\r
-    Xtoi64 (Str, Data);\r
-  } else {\r
-    Dtoi64 (Str, Data);\r
-  }\r
-}\r
-\r
-/**\r
-  Converts a list of string to a specified buffer.\r
-\r
-  @param Buf             The output buffer that contains the string.\r
-  @param BufferLength    The length of the buffer\r
-  @param Str             The input string that contains the hex number\r
-\r
-  @retval EFI_SUCCESS    The string was successfully converted to the buffer.\r
-\r
-**/\r
-EFI_STATUS\r
-StrToBuf (\r
-  OUT UINT8    *Buf,\r
-  IN  UINTN    BufferLength,\r
-  IN  CHAR16   *Str\r
-  )\r
-{\r
-  UINTN       Index;\r
-  UINTN       StrLength;\r
-  UINT8       Digit;\r
-  UINT8       Byte;\r
-\r
-  Digit = 0;\r
-\r
-  //\r
-  // Two hex char make up one byte\r
-  //\r
-  StrLength = BufferLength * sizeof (CHAR16);\r
-\r
-  for(Index = 0; Index < StrLength; Index++, Str++) {\r
-\r
-    if ((*Str >= L'a') && (*Str <= L'f')) {\r
-      Digit = (UINT8) (*Str - L'a' + 0x0A);\r
-    } else if ((*Str >= L'A') && (*Str <= L'F')) {\r
-      Digit = (UINT8) (*Str - L'A' + 0x0A);\r
-    } else if ((*Str >= L'0') && (*Str <= L'9')) {\r
-      Digit = (UINT8) (*Str - L'0');\r
-    } else {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    //\r
-    // For odd characters, write the upper nibble for each buffer byte,\r
-    // and for even characters, the lower nibble.\r
-    //\r
-    if ((Index & 1) == 0) {\r
-      Byte = (UINT8) (Digit << 4);\r
-    } else {\r
-      Byte = Buf[Index / 2];\r
-      Byte &= 0xF0;\r
-      Byte = (UINT8) (Byte | Digit);\r
-    }\r
-\r
-    Buf[Index / 2] = Byte;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Converts a string to GUID value.\r
-  Guid Format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\r
-\r
-  @param Str              The registry format GUID string that contains the GUID value.\r
-  @param Guid             A pointer to the converted GUID value.\r
-\r
-  @retval EFI_SUCCESS     The GUID string was successfully converted to the GUID value.\r
-  @retval EFI_UNSUPPORTED The input string is not in registry format.\r
-  @return others          Some error occurred when converting part of GUID value.\r
-\r
-**/\r
-EFI_STATUS\r
-StrToGuid (\r
-  IN  CHAR16   *Str,\r
-  OUT EFI_GUID *Guid\r
-  )\r
-{\r
-  //\r
-  // Get the first UINT32 data\r
-  //\r
-  Guid->Data1 = (UINT32) StrHexToUint64  (Str);\r
-  while (!IS_HYPHEN (*Str) && !IS_NULL (*Str)) {\r
-    Str ++;\r
-  }\r
-  \r
-  if (IS_HYPHEN (*Str)) {\r
-    Str++;\r
-  } else {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  \r
-  //\r
-  // Get the second UINT16 data\r
-  //\r
-  Guid->Data2 = (UINT16) StrHexToUint64  (Str);\r
-  while (!IS_HYPHEN (*Str) && !IS_NULL (*Str)) {\r
-    Str ++;\r
-  }\r
-\r
-  if (IS_HYPHEN (*Str)) {\r
-    Str++;\r
-  } else {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  \r
-  //\r
-  // Get the third UINT16 data\r
-  //\r
-  Guid->Data3 = (UINT16) StrHexToUint64  (Str);\r
-  while (!IS_HYPHEN (*Str) && !IS_NULL (*Str)) {\r
-    Str ++;\r
-  }\r
-\r
-  if (IS_HYPHEN (*Str)) {\r
-    Str++;\r
-  } else {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Get the following 8 bytes data\r
-  //  \r
-  StrToBuf (&Guid->Data4[0], 2, Str);\r
-  //\r
-  // Skip 2 byte hex chars\r
-  //\r
-  Str += 2 * 2;\r
-\r
-  if (IS_HYPHEN (*Str)) {\r
-    Str++;\r
-  } else {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  StrToBuf (&Guid->Data4[2], 6, Str);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Converts a string to IPv4 address\r
-\r
-  @param Str             A string representation of IPv4 address.\r
-  @param IPv4Addr        A pointer to the converted IPv4 address.\r
-\r
-**/\r
-VOID\r
-StrToIPv4Addr (\r
-  IN OUT CHAR16           **Str,\r
-  OUT    EFI_IPv4_ADDRESS *IPv4Addr\r
-  )\r
-{\r
-  UINTN  Index;\r
-\r
-  for (Index = 0; Index < 4; Index++) {\r
-    IPv4Addr->Addr[Index] = (UINT8) Dtoi (SplitStr (Str, L'.'));\r
-  }\r
-}\r
-\r
-/**\r
-  Converts a string to IPv4 address\r
-\r
-  @param Str             A string representation of IPv6 address.\r
-  @param IPv6Addr        A pointer to the converted IPv6 address.\r
-\r
-**/\r
-VOID\r
-StrToIPv6Addr (\r
-  IN OUT CHAR16           **Str,\r
-  OUT    EFI_IPv6_ADDRESS *IPv6Addr\r
-  )\r
-{\r
-  UINTN  Index;\r
-  UINT16 Data;\r
-\r
-  for (Index = 0; Index < 8; Index++) {\r
-    Data = (UINT16) Xtoi (SplitStr (Str, L':'));\r
-    IPv6Addr->Addr[Index * 2] = (UINT8) (Data >> 8);\r
-    IPv6Addr->Addr[Index * 2 + 1] = (UINT8) (Data & 0xff);\r
-  }\r
-}\r
-\r
-/**\r
-  Converts a Unicode string to ASCII string.\r
-\r
-  @param Str             The equivalent Unicode string\r
-  @param AsciiStr        On input, it points to destination ASCII string buffer; on output, it points\r
-                         to the next ASCII string next to it\r
-\r
-**/\r
-VOID\r
-StrToAscii (\r
-  IN     CHAR16 *Str,\r
-  IN OUT CHAR8  **AsciiStr\r
-  )\r
-{\r
-  CHAR8 *Dest;\r
-\r
-  Dest = *AsciiStr;\r
-  while (!IS_NULL (*Str)) {\r
-    *(Dest++) = (CHAR8) *(Str++);\r
-  }\r
-  *Dest = 0;\r
-\r
-  //\r
-  // Return the string next to it\r
-  //\r
-  *AsciiStr = Dest + 1;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to Hardware PCI device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to Hardware PCI device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextPci (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16          *FunctionStr;\r
-  CHAR16          *DeviceStr;\r
-  PCI_DEVICE_PATH *Pci;\r
-\r
-  DeviceStr   = GetNextParamStr (&TextDeviceNode);\r
-  FunctionStr = GetNextParamStr (&TextDeviceNode);\r
-  Pci         = (PCI_DEVICE_PATH *) CreateDeviceNode (\r
-                                      HARDWARE_DEVICE_PATH,\r
-                                      HW_PCI_DP,\r
-                                      (UINT16) sizeof (PCI_DEVICE_PATH)\r
-                                      );\r
-\r
-  Pci->Function = (UINT8) Strtoi (FunctionStr);\r
-  Pci->Device   = (UINT8) Strtoi (DeviceStr);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) Pci;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to Hardware PC card device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to Hardware PC card device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextPcCard (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16              *FunctionNumberStr;\r
-  PCCARD_DEVICE_PATH  *Pccard;\r
-\r
-  FunctionNumberStr = GetNextParamStr (&TextDeviceNode);\r
-  Pccard            = (PCCARD_DEVICE_PATH *) CreateDeviceNode (\r
-                                               HARDWARE_DEVICE_PATH,\r
-                                               HW_PCCARD_DP,\r
-                                               (UINT16) sizeof (PCCARD_DEVICE_PATH)\r
-                                               );\r
-\r
-  Pccard->FunctionNumber  = (UINT8) Strtoi (FunctionNumberStr);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) Pccard;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to Hardware memory map device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to Hardware memory map device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextMemoryMapped (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16              *MemoryTypeStr;\r
-  CHAR16              *StartingAddressStr;\r
-  CHAR16              *EndingAddressStr;\r
-  MEMMAP_DEVICE_PATH  *MemMap;\r
-\r
-  MemoryTypeStr      = GetNextParamStr (&TextDeviceNode);\r
-  StartingAddressStr = GetNextParamStr (&TextDeviceNode);\r
-  EndingAddressStr   = GetNextParamStr (&TextDeviceNode);\r
-  MemMap             = (MEMMAP_DEVICE_PATH *) CreateDeviceNode (\r
-                                               HARDWARE_DEVICE_PATH,\r
-                                               HW_MEMMAP_DP,\r
-                                               (UINT16) sizeof (MEMMAP_DEVICE_PATH)\r
-                                               );\r
-\r
-  MemMap->MemoryType = (UINT32) Strtoi (MemoryTypeStr);\r
-  Strtoi64 (StartingAddressStr, &MemMap->StartingAddress);\r
-  Strtoi64 (EndingAddressStr, &MemMap->EndingAddress);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) MemMap;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to Vendor device path structure based on the input Type\r
-  and SubType.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-  @param Type            The type of device path node.\r
-  @param SubType         The subtype of device path node.\r
-\r
-  @return A pointer to the newly-created Vendor device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-ConvertFromTextVendor (\r
-  IN CHAR16 *TextDeviceNode,\r
-  IN UINT8  Type,\r
-  IN UINT8  SubType\r
-  )\r
-{\r
-  CHAR16              *GuidStr;\r
-  CHAR16              *DataStr;\r
-  UINTN               Length;\r
-  VENDOR_DEVICE_PATH  *Vendor;\r
-\r
-  GuidStr = GetNextParamStr (&TextDeviceNode);\r
-\r
-  DataStr = GetNextParamStr (&TextDeviceNode);\r
-  Length  = StrLen (DataStr);\r
-  //\r
-  // Two hex characters make up 1 buffer byte\r
-  //\r
-  Length  = (Length + 1) / 2;\r
-\r
-  Vendor  = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
-                                     Type,\r
-                                     SubType,\r
-                                     (UINT16) (sizeof (VENDOR_DEVICE_PATH) + Length)\r
-                                     );\r
-\r
-  StrToGuid (GuidStr, &Vendor->Guid);\r
-  StrToBuf (((UINT8 *) Vendor) + sizeof (VENDOR_DEVICE_PATH), Length, DataStr);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to Vendor Hardware device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created Vendor Hardware device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextVenHw (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  return ConvertFromTextVendor (\r
-           TextDeviceNode,\r
-           HARDWARE_DEVICE_PATH,\r
-           HW_VENDOR_DP\r
-           );\r
-}\r
-\r
-/**\r
-  Converts a text device path node to Hardware Controller device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created Hardware Controller device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextCtrl (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16                  *ControllerStr;\r
-  CONTROLLER_DEVICE_PATH  *Controller;\r
-\r
-  ControllerStr = GetNextParamStr (&TextDeviceNode);\r
-  Controller    = (CONTROLLER_DEVICE_PATH *) CreateDeviceNode (\r
-                                               HARDWARE_DEVICE_PATH,\r
-                                               HW_CONTROLLER_DP,\r
-                                               (UINT16) sizeof (CONTROLLER_DEVICE_PATH)\r
-                                               );\r
-  Controller->ControllerNumber = (UINT32) Strtoi (ControllerStr);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) Controller;\r
-}\r
-\r
-/**\r
-  Converts a string to EisaId.\r
-\r
-  @param Text   The input string.\r
-  @param EisaId A pointer to the output EisaId.\r
-\r
-**/\r
-VOID\r
-EisaIdFromText (\r
-  IN CHAR16 *Text,\r
-  OUT UINT32 *EisaId\r
-  )\r
-{\r
-  UINTN PnpId;\r
-\r
-  PnpId = Xtoi (Text + 3);\r
-  *EisaId = (((Text[0] - '@') & 0x1f) << 10) +\r
-            (((Text[1] - '@') & 0x1f) << 5) +\r
-            ((Text[2] - '@') & 0x1f) +\r
-            (UINT32) (PnpId << 16);\r
-}\r
-\r
-/**\r
-  Converts a text device path node to ACPI HID device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created ACPI HID device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextAcpi (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16                *HIDStr;\r
-  CHAR16                *UIDStr;\r
-  ACPI_HID_DEVICE_PATH  *Acpi;\r
-\r
-  HIDStr = GetNextParamStr (&TextDeviceNode);\r
-  UIDStr = GetNextParamStr (&TextDeviceNode);\r
-  Acpi   = (ACPI_HID_DEVICE_PATH *) CreateDeviceNode (\r
-                                      ACPI_DEVICE_PATH,\r
-                                      ACPI_DP,\r
-                                      (UINT16) sizeof (ACPI_HID_DEVICE_PATH)\r
-                                      );\r
-\r
-  EisaIdFromText (HIDStr, &Acpi->HID);\r
-  Acpi->UID = (UINT32) Strtoi (UIDStr);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) Acpi;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to ACPI HID device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-  @param PnPId           The input plug and play identification.\r
-\r
-  @return A pointer to the newly-created ACPI HID device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-ConvertFromTextAcpi (\r
-  IN CHAR16 *TextDeviceNode,\r
-  IN UINT32  PnPId\r
-  )\r
-{\r
-  CHAR16                *UIDStr;\r
-  ACPI_HID_DEVICE_PATH  *Acpi;\r
-\r
-  UIDStr = GetNextParamStr (&TextDeviceNode);\r
-  Acpi   = (ACPI_HID_DEVICE_PATH *) CreateDeviceNode (\r
-                                      ACPI_DEVICE_PATH,\r
-                                      ACPI_DP,\r
-                                      (UINT16) sizeof (ACPI_HID_DEVICE_PATH)\r
-                                      );\r
-\r
-  Acpi->HID = EFI_PNP_ID (PnPId);\r
-  Acpi->UID = (UINT32) Strtoi (UIDStr);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) Acpi;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to PCI root device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created PCI root device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextPciRoot (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  return ConvertFromTextAcpi (TextDeviceNode, 0x0a03);\r
-}\r
-\r
-/**\r
-  Converts a text device path node to PCIE root device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created PCIE root device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextPcieRoot (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  return ConvertFromTextAcpi (TextDeviceNode, 0x0a08);\r
-}\r
-\r
-/**\r
-  Converts a text device path node to Floppy device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created Floppy device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextFloppy (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  return ConvertFromTextAcpi (TextDeviceNode, 0x0604);\r
-}\r
-\r
-/**\r
-  Converts a text device path node to Keyboard device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created  Keyboard device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextKeyboard (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  return ConvertFromTextAcpi (TextDeviceNode, 0x0301);\r
-}\r
-\r
-/**\r
-  Converts a text device path node to Serial device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created Serial device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextSerial (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  return ConvertFromTextAcpi (TextDeviceNode, 0x0501);\r
-}\r
-\r
-/**\r
-  Converts a text device path node to Parallel Port device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created Parallel Port device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextParallelPort (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  return ConvertFromTextAcpi (TextDeviceNode, 0x0401);\r
-}\r
-\r
-/**\r
-  Converts a text device path node to ACPI extension device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created ACPI extension device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextAcpiEx (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16                         *HIDStr;\r
-  CHAR16                         *CIDStr;\r
-  CHAR16                         *UIDStr;\r
-  CHAR16                         *HIDSTRStr;\r
-  CHAR16                         *CIDSTRStr;\r
-  CHAR16                         *UIDSTRStr;\r
-  CHAR8                          *AsciiStr;\r
-  UINT16                         Length;\r
-  ACPI_EXTENDED_HID_DEVICE_PATH  *AcpiEx;\r
-\r
-  HIDStr    = GetNextParamStr (&TextDeviceNode);\r
-  CIDStr    = GetNextParamStr (&TextDeviceNode);\r
-  UIDStr    = GetNextParamStr (&TextDeviceNode);\r
-  HIDSTRStr = GetNextParamStr (&TextDeviceNode);\r
-  CIDSTRStr = GetNextParamStr (&TextDeviceNode);\r
-  UIDSTRStr = GetNextParamStr (&TextDeviceNode);\r
-\r
-  Length    = (UINT16) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH) + StrLen (HIDSTRStr) + 1);\r
-  Length    = (UINT16) (Length + StrLen (UIDSTRStr) + 1);\r
-  Length    = (UINT16) (Length + StrLen (CIDSTRStr) + 1);\r
-  AcpiEx = (ACPI_EXTENDED_HID_DEVICE_PATH *) CreateDeviceNode (\r
-                                               ACPI_DEVICE_PATH,\r
-                                               ACPI_EXTENDED_DP,\r
-                                               Length\r
-                                               );\r
-\r
-  EisaIdFromText (HIDStr, &AcpiEx->HID);\r
-  EisaIdFromText (CIDStr, &AcpiEx->CID);\r
-  AcpiEx->UID = (UINT32) Strtoi (UIDStr);\r
-\r
-  AsciiStr = (CHAR8 *) ((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));\r
-  StrToAscii (HIDSTRStr, &AsciiStr);\r
-  StrToAscii (UIDSTRStr, &AsciiStr);\r
-  StrToAscii (CIDSTRStr, &AsciiStr);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) AcpiEx;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to ACPI extension device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created ACPI extension device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextAcpiExp (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16                         *HIDStr;\r
-  CHAR16                         *CIDStr;\r
-  CHAR16                         *UIDSTRStr;\r
-  CHAR8                          *AsciiStr;\r
-  UINT16                         Length;\r
-  ACPI_EXTENDED_HID_DEVICE_PATH  *AcpiEx;\r
-\r
-  HIDStr    = GetNextParamStr (&TextDeviceNode);\r
-  CIDStr    = GetNextParamStr (&TextDeviceNode);\r
-  UIDSTRStr = GetNextParamStr (&TextDeviceNode);\r
-  Length    = (UINT16) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH) + StrLen (UIDSTRStr) + 3);\r
-  AcpiEx    = (ACPI_EXTENDED_HID_DEVICE_PATH *) CreateDeviceNode (\r
-                                                  ACPI_DEVICE_PATH,\r
-                                                  ACPI_EXTENDED_DP,\r
-                                                  Length\r
-                                                  );\r
-\r
-  EisaIdFromText (HIDStr, &AcpiEx->HID);\r
-  EisaIdFromText (CIDStr, &AcpiEx->CID);\r
-  AcpiEx->UID = 0;\r
-\r
-  AsciiStr = (CHAR8 *) ((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));\r
-  //\r
-  // HID string is NULL\r
-  //\r
-  *AsciiStr = '\0';\r
-  //\r
-  // Convert UID string\r
-  //\r
-  AsciiStr++;\r
-  StrToAscii (UIDSTRStr, &AsciiStr);\r
-  //\r
-  // CID string is NULL\r
-  //\r
-  *AsciiStr = '\0';\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) AcpiEx;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to ACPI _ADR device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created ACPI _ADR device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextAcpiAdr (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16                *DisplayDeviceStr;\r
-  ACPI_ADR_DEVICE_PATH  *AcpiAdr;\r
-  UINTN                 Index;\r
-  UINTN                 Length;\r
-\r
-  AcpiAdr = (ACPI_ADR_DEVICE_PATH *) CreateDeviceNode (\r
-                                       ACPI_DEVICE_PATH,\r
-                                       ACPI_ADR_DP,\r
-                                       (UINT16) sizeof (ACPI_ADR_DEVICE_PATH)\r
-                                       );\r
-  ASSERT (AcpiAdr != NULL);\r
-\r
-  for (Index = 0; ; Index++) {\r
-    DisplayDeviceStr = GetNextParamStr (&TextDeviceNode);\r
-    if (IS_NULL (*DisplayDeviceStr)) {\r
-      break;\r
-    }\r
-    if (Index > 0) {\r
-      Length  = DevicePathNodeLength (AcpiAdr);\r
-      AcpiAdr = ReallocatePool (\r
-                  Length,\r
-                  Length + sizeof (UINT32),\r
-                  AcpiAdr\r
-                  );\r
-      ASSERT (AcpiAdr != NULL);\r
-      SetDevicePathNodeLength (AcpiAdr, Length + sizeof (UINT32));\r
-    }\r
-    \r
-    (&AcpiAdr->ADR)[Index] = (UINT32) Strtoi (DisplayDeviceStr);\r
-  }\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) AcpiAdr;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to Parallel Port device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created Parallel Port device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextAta (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16            *PrimarySecondaryStr;\r
-  CHAR16            *SlaveMasterStr;\r
-  CHAR16            *LunStr;\r
-  ATAPI_DEVICE_PATH *Atapi;\r
-\r
-  Atapi = (ATAPI_DEVICE_PATH *) CreateDeviceNode (\r
-                                  MESSAGING_DEVICE_PATH,\r
-                                  MSG_ATAPI_DP,\r
-                                  (UINT16) sizeof (ATAPI_DEVICE_PATH)\r
-                                  );\r
-\r
-  PrimarySecondaryStr     = GetNextParamStr (&TextDeviceNode);\r
-  SlaveMasterStr          = GetNextParamStr (&TextDeviceNode);\r
-  LunStr                  = GetNextParamStr (&TextDeviceNode);\r
-\r
-  Atapi->PrimarySecondary = (UINT8) ((StrCmp (PrimarySecondaryStr, L"Primary") == 0) ? 0 : 1);\r
-  Atapi->SlaveMaster      = (UINT8) ((StrCmp (SlaveMasterStr, L"Master") == 0) ? 0 : 1);\r
-  Atapi->Lun              = (UINT16) Strtoi (LunStr);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) Atapi;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to SCSI device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created SCSI device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextScsi (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16            *PunStr;\r
-  CHAR16            *LunStr;\r
-  SCSI_DEVICE_PATH  *Scsi;\r
-\r
-  PunStr = GetNextParamStr (&TextDeviceNode);\r
-  LunStr = GetNextParamStr (&TextDeviceNode);\r
-  Scsi   = (SCSI_DEVICE_PATH *) CreateDeviceNode (\r
-                                   MESSAGING_DEVICE_PATH,\r
-                                   MSG_SCSI_DP,\r
-                                   (UINT16) sizeof (SCSI_DEVICE_PATH)\r
-                                   );\r
-\r
-  Scsi->Pun = (UINT16) Strtoi (PunStr);\r
-  Scsi->Lun = (UINT16) Strtoi (LunStr);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) Scsi;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to Fibre device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created Fibre device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextFibre (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16                    *WWNStr;\r
-  CHAR16                    *LunStr;\r
-  FIBRECHANNEL_DEVICE_PATH  *Fibre;\r
-\r
-  WWNStr = GetNextParamStr (&TextDeviceNode);\r
-  LunStr = GetNextParamStr (&TextDeviceNode);\r
-  Fibre  = (FIBRECHANNEL_DEVICE_PATH *) CreateDeviceNode (\r
-                                          MESSAGING_DEVICE_PATH,\r
-                                          MSG_FIBRECHANNEL_DP,\r
-                                          (UINT16) sizeof (FIBRECHANNEL_DEVICE_PATH)\r
-                                          );\r
-\r
-  Fibre->Reserved = 0;\r
-  Strtoi64 (WWNStr, &Fibre->WWN);\r
-  Strtoi64 (LunStr, &Fibre->Lun);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) Fibre;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to FibreEx device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created FibreEx device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextFibreEx (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16                      *WWNStr;\r
-  CHAR16                      *LunStr;\r
-  FIBRECHANNELEX_DEVICE_PATH  *FibreEx;\r
-\r
-  WWNStr  = GetNextParamStr (&TextDeviceNode);\r
-  LunStr  = GetNextParamStr (&TextDeviceNode);\r
-  FibreEx = (FIBRECHANNELEX_DEVICE_PATH *) CreateDeviceNode (\r
-                                             MESSAGING_DEVICE_PATH,\r
-                                             MSG_FIBRECHANNELEX_DP,\r
-                                             (UINT16) sizeof (FIBRECHANNELEX_DEVICE_PATH)\r
-                                             );\r
-\r
-  FibreEx->Reserved = 0;\r
-  Strtoi64 (WWNStr, (UINT64 *) (&FibreEx->WWN));\r
-  Strtoi64 (LunStr, (UINT64 *) (&FibreEx->Lun));\r
-\r
-  *(UINT64 *) (&FibreEx->WWN) = SwapBytes64 (*(UINT64 *) (&FibreEx->WWN));\r
-  *(UINT64 *) (&FibreEx->Lun) = SwapBytes64 (*(UINT64 *) (&FibreEx->Lun));\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) FibreEx;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to 1394 device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created 1394 device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromText1394 (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16            *GuidStr;\r
-  F1394_DEVICE_PATH *F1394DevPath;\r
-\r
-  GuidStr = GetNextParamStr (&TextDeviceNode);\r
-  F1394DevPath  = (F1394_DEVICE_PATH *) CreateDeviceNode (\r
-                                          MESSAGING_DEVICE_PATH,\r
-                                          MSG_1394_DP,\r
-                                          (UINT16) sizeof (F1394_DEVICE_PATH)\r
-                                          );\r
-\r
-  F1394DevPath->Reserved = 0;\r
-  Xtoi64 (GuidStr, &F1394DevPath->Guid);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) F1394DevPath;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to USB device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created USB device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextUsb (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16          *PortStr;\r
-  CHAR16          *InterfaceStr;\r
-  USB_DEVICE_PATH *Usb;\r
-\r
-  PortStr               = GetNextParamStr (&TextDeviceNode);\r
-  InterfaceStr          = GetNextParamStr (&TextDeviceNode);\r
-  Usb                   = (USB_DEVICE_PATH *) CreateDeviceNode (\r
-                                                MESSAGING_DEVICE_PATH,\r
-                                                MSG_USB_DP,\r
-                                                (UINT16) sizeof (USB_DEVICE_PATH)\r
-                                                );\r
-\r
-  Usb->ParentPortNumber = (UINT8) Strtoi (PortStr);\r
-  Usb->InterfaceNumber  = (UINT8) Strtoi (InterfaceStr);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) Usb;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to I20 device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created I20 device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextI2O (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16          *TIDStr;\r
-  I2O_DEVICE_PATH *I2ODevPath;\r
-\r
-  TIDStr     = GetNextParamStr (&TextDeviceNode);\r
-  I2ODevPath = (I2O_DEVICE_PATH *) CreateDeviceNode (\r
-                                    MESSAGING_DEVICE_PATH,\r
-                                    MSG_I2O_DP,\r
-                                    (UINT16) sizeof (I2O_DEVICE_PATH)\r
-                                    );\r
-\r
-  I2ODevPath->Tid  = (UINT32) Strtoi (TIDStr);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) I2ODevPath;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to Infini Band device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created Infini Band device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextInfiniband (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16                  *FlagsStr;\r
-  CHAR16                  *GuidStr;\r
-  CHAR16                  *SidStr;\r
-  CHAR16                  *TidStr;\r
-  CHAR16                  *DidStr;\r
-  EFI_GUID                PortGid;\r
-  INFINIBAND_DEVICE_PATH  *InfiniBand;\r
-\r
-  FlagsStr   = GetNextParamStr (&TextDeviceNode);\r
-  GuidStr    = GetNextParamStr (&TextDeviceNode);\r
-  SidStr     = GetNextParamStr (&TextDeviceNode);\r
-  TidStr     = GetNextParamStr (&TextDeviceNode);\r
-  DidStr     = GetNextParamStr (&TextDeviceNode);\r
-  InfiniBand = (INFINIBAND_DEVICE_PATH *) CreateDeviceNode (\r
-                                            MESSAGING_DEVICE_PATH,\r
-                                            MSG_INFINIBAND_DP,\r
-                                            (UINT16) sizeof (INFINIBAND_DEVICE_PATH)\r
-                                            );\r
-\r
-  InfiniBand->ResourceFlags = (UINT32) Strtoi (FlagsStr);\r
-  StrToGuid (GuidStr, &PortGid);\r
-  CopyMem (InfiniBand->PortGid, &PortGid, sizeof (EFI_GUID));\r
-  Strtoi64 (SidStr, &InfiniBand->ServiceId);\r
-  Strtoi64 (TidStr, &InfiniBand->TargetPortId);\r
-  Strtoi64 (DidStr, &InfiniBand->DeviceId);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) InfiniBand;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to Vendor-Defined Messaging device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created Vendor-Defined Messaging device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextVenMsg (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  return ConvertFromTextVendor (\r
-            TextDeviceNode,\r
-            MESSAGING_DEVICE_PATH,\r
-            MSG_VENDOR_DP\r
-            );\r
-}\r
-\r
-/**\r
-  Converts a text device path node to Vendor defined PC-ANSI device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created Vendor defined PC-ANSI device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextVenPcAnsi (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  VENDOR_DEVICE_PATH  *Vendor;\r
-\r
-  Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
-                                    MESSAGING_DEVICE_PATH,\r
-                                    MSG_VENDOR_DP,\r
-                                    (UINT16) sizeof (VENDOR_DEVICE_PATH));\r
-  CopyGuid (&Vendor->Guid, &gEfiPcAnsiGuid);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to Vendor defined VT100 device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created Vendor defined VT100 device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextVenVt100 (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  VENDOR_DEVICE_PATH  *Vendor;\r
-\r
-  Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
-                                    MESSAGING_DEVICE_PATH,\r
-                                    MSG_VENDOR_DP,\r
-                                    (UINT16) sizeof (VENDOR_DEVICE_PATH));\r
-  CopyGuid (&Vendor->Guid, &gEfiVT100Guid);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to Vendor defined VT100 Plus device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created Vendor defined VT100 Plus device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextVenVt100Plus (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  VENDOR_DEVICE_PATH  *Vendor;\r
-\r
-  Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
-                                    MESSAGING_DEVICE_PATH,\r
-                                    MSG_VENDOR_DP,\r
-                                    (UINT16) sizeof (VENDOR_DEVICE_PATH));\r
-  CopyGuid (&Vendor->Guid, &gEfiVT100PlusGuid);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to Vendor defined UTF8 device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created Vendor defined UTF8 device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextVenUtf8 (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  VENDOR_DEVICE_PATH  *Vendor;\r
-\r
-  Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
-                                    MESSAGING_DEVICE_PATH,\r
-                                    MSG_VENDOR_DP,\r
-                                    (UINT16) sizeof (VENDOR_DEVICE_PATH));\r
-  CopyGuid (&Vendor->Guid, &gEfiVTUTF8Guid);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to UART Flow Control device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created UART Flow Control device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextUartFlowCtrl (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16                        *ValueStr;\r
-  UART_FLOW_CONTROL_DEVICE_PATH *UartFlowControl;\r
-\r
-  ValueStr        = GetNextParamStr (&TextDeviceNode);\r
-  UartFlowControl = (UART_FLOW_CONTROL_DEVICE_PATH *) CreateDeviceNode (\r
-                                                        MESSAGING_DEVICE_PATH,\r
-                                                        MSG_VENDOR_DP,\r
-                                                        (UINT16) sizeof (UART_FLOW_CONTROL_DEVICE_PATH)\r
-                                                        );\r
-\r
-  CopyGuid (&UartFlowControl->Guid, &gEfiUartDevicePathGuid);\r
-  if (StrCmp (ValueStr, L"XonXoff") == 0) {\r
-    UartFlowControl->FlowControlMap = 2;\r
-  } else if (StrCmp (ValueStr, L"Hardware") == 0) {\r
-    UartFlowControl->FlowControlMap = 1;\r
-  } else {\r
-    UartFlowControl->FlowControlMap = 0;\r
-  }\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) UartFlowControl;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to Serial Attached SCSI device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created Serial Attached SCSI device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextSAS (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16          *AddressStr;\r
-  CHAR16          *LunStr;\r
-  CHAR16          *RTPStr;\r
-  CHAR16          *SASSATAStr;\r
-  CHAR16          *LocationStr;\r
-  CHAR16          *ConnectStr;\r
-  CHAR16          *DriveBayStr;\r
-  CHAR16          *ReservedStr;\r
-  UINT16          Info;\r
-  UINT16          Uint16;\r
-  SAS_DEVICE_PATH *Sas;\r
-\r
-  AddressStr  = GetNextParamStr (&TextDeviceNode);\r
-  LunStr      = GetNextParamStr (&TextDeviceNode);\r
-  RTPStr      = GetNextParamStr (&TextDeviceNode);\r
-  SASSATAStr  = GetNextParamStr (&TextDeviceNode);\r
-  LocationStr = GetNextParamStr (&TextDeviceNode);\r
-  ConnectStr  = GetNextParamStr (&TextDeviceNode);\r
-  DriveBayStr = GetNextParamStr (&TextDeviceNode);\r
-  ReservedStr = GetNextParamStr (&TextDeviceNode);\r
-  Sas         = (SAS_DEVICE_PATH *) CreateDeviceNode (\r
-                                       MESSAGING_DEVICE_PATH,\r
-                                       MSG_VENDOR_DP,\r
-                                       (UINT16) sizeof (SAS_DEVICE_PATH)\r
-                                       );\r
-\r
-  CopyGuid (&Sas->Guid, &gEfiSasDevicePathGuid);\r
-  Strtoi64 (AddressStr, &Sas->SasAddress);\r
-  Strtoi64 (LunStr, &Sas->Lun);\r
-  Sas->RelativeTargetPort = (UINT16) Strtoi (RTPStr);\r
-\r
-  if (StrCmp (SASSATAStr, L"NoTopology") == 0) {\r
-    Info = 0x0;\r
-\r
-  } else if ((StrCmp (SASSATAStr, L"SATA") == 0) || (StrCmp (SASSATAStr, L"SAS") == 0)) {\r
-\r
-    Uint16 = (UINT16) Strtoi (DriveBayStr);\r
-    if (Uint16 == 0) {\r
-      Info = 0x1;\r
-    } else {\r
-      Info = (UINT16) (0x2 | ((Uint16 - 1) << 8));\r
-    }\r
-\r
-    if (StrCmp (SASSATAStr, L"SATA") == 0) {\r
-      Info |= BIT4;\r
-    }\r
-\r
-    //\r
-    // Location is an integer between 0 and 1 or else\r
-    // the keyword Internal (0) or External (1).\r
-    //\r
-    if (StrCmp (LocationStr, L"External") == 0) {\r
-      Uint16 = 1;\r
-    } else if (StrCmp (LocationStr, L"Internal") == 0) {\r
-      Uint16 = 0;\r
-    } else {\r
-      Uint16 = ((UINT16) Strtoi (LocationStr) & BIT0);\r
-    }\r
-    Info |= (Uint16 << 5);\r
-\r
-    //\r
-    // Connect is an integer between 0 and 3 or else\r
-    // the keyword Direct (0) or Expanded (1).\r
-    //\r
-    if (StrCmp (ConnectStr, L"Expanded") == 0) {\r
-      Uint16 = 1;\r
-    } else if (StrCmp (ConnectStr, L"Direct") == 0) {\r
-      Uint16 = 0;\r
-    } else {\r
-      Uint16 = ((UINT16) Strtoi (ConnectStr) & (BIT0 | BIT1));\r
-    }\r
-    Info |= (Uint16 << 6);\r
-\r
-  } else {\r
-    Info = (UINT16) Strtoi (SASSATAStr);\r
-  }\r
-\r
-  Sas->DeviceTopology = Info;\r
-  Sas->Reserved       = (UINT32) Strtoi (ReservedStr);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) Sas;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to Serial Attached SCSI Ex device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created Serial Attached SCSI Ex device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextSasEx (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16            *AddressStr;\r
-  CHAR16            *LunStr;\r
-  CHAR16            *RTPStr;\r
-  CHAR16            *SASSATAStr;\r
-  CHAR16            *LocationStr;\r
-  CHAR16            *ConnectStr;\r
-  CHAR16            *DriveBayStr;\r
-  UINT16            Info;\r
-  UINT16            Uint16;\r
-  UINT64            SasAddress;\r
-  UINT64            Lun;\r
-  SASEX_DEVICE_PATH *SasEx;\r
-\r
-  AddressStr  = GetNextParamStr (&TextDeviceNode);\r
-  LunStr      = GetNextParamStr (&TextDeviceNode);\r
-  RTPStr      = GetNextParamStr (&TextDeviceNode);\r
-  SASSATAStr  = GetNextParamStr (&TextDeviceNode);\r
-  LocationStr = GetNextParamStr (&TextDeviceNode);\r
-  ConnectStr  = GetNextParamStr (&TextDeviceNode);\r
-  DriveBayStr = GetNextParamStr (&TextDeviceNode);\r
-  SasEx       = (SASEX_DEVICE_PATH *) CreateDeviceNode (\r
-                                        MESSAGING_DEVICE_PATH,\r
-                                        MSG_SASEX_DP,\r
-                                        (UINT16) sizeof (SASEX_DEVICE_PATH)\r
-                                        );\r
-\r
-  Strtoi64 (AddressStr, &SasAddress);\r
-  Strtoi64 (LunStr,     &Lun);\r
-  WriteUnaligned64 ((UINT64 *) &SasEx->SasAddress, SwapBytes64 (SasAddress));\r
-  WriteUnaligned64 ((UINT64 *) &SasEx->Lun,        SwapBytes64 (Lun));\r
-  SasEx->RelativeTargetPort      = (UINT16) Strtoi (RTPStr);\r
-\r
-  if (StrCmp (SASSATAStr, L"NoTopology") == 0) {\r
-    Info = 0x0;\r
-\r
-  } else if ((StrCmp (SASSATAStr, L"SATA") == 0) || (StrCmp (SASSATAStr, L"SAS") == 0)) {\r
-\r
-    Uint16 = (UINT16) Strtoi (DriveBayStr);\r
-    if (Uint16 == 0) {\r
-      Info = 0x1;\r
-    } else {\r
-      Info = (UINT16) (0x2 | ((Uint16 - 1) << 8));\r
-    }\r
-\r
-    if (StrCmp (SASSATAStr, L"SATA") == 0) {\r
-      Info |= BIT4;\r
-    }\r
-\r
-    //\r
-    // Location is an integer between 0 and 1 or else\r
-    // the keyword Internal (0) or External (1).\r
-    //\r
-    if (StrCmp (LocationStr, L"External") == 0) {\r
-      Uint16 = 1;\r
-    } else if (StrCmp (LocationStr, L"Internal") == 0) {\r
-      Uint16 = 0;\r
-    } else {\r
-      Uint16 = ((UINT16) Strtoi (LocationStr) & BIT0);\r
-    }\r
-    Info |= (Uint16 << 5);\r
-\r
-    //\r
-    // Connect is an integer between 0 and 3 or else\r
-    // the keyword Direct (0) or Expanded (1).\r
-    //\r
-    if (StrCmp (ConnectStr, L"Expanded") == 0) {\r
-      Uint16 = 1;\r
-    } else if (StrCmp (ConnectStr, L"Direct") == 0) {\r
-      Uint16 = 0;\r
-    } else {\r
-      Uint16 = ((UINT16) Strtoi (ConnectStr) & (BIT0 | BIT1));\r
-    }\r
-    Info |= (Uint16 << 6);\r
-\r
-  } else {\r
-    Info = (UINT16) Strtoi (SASSATAStr);\r
-  }\r
-\r
-  SasEx->DeviceTopology = Info;\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) SasEx;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to Debug Port device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created Debug Port device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextDebugPort (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  VENDOR_DEFINED_MESSAGING_DEVICE_PATH  *Vend;\r
-\r
-  Vend = (VENDOR_DEFINED_MESSAGING_DEVICE_PATH *) CreateDeviceNode (\r
-                                                    MESSAGING_DEVICE_PATH,\r
-                                                    MSG_VENDOR_DP,\r
-                                                    (UINT16) sizeof (VENDOR_DEFINED_MESSAGING_DEVICE_PATH)\r
-                                                    );\r
-\r
-  CopyGuid (&Vend->Guid, &gEfiDebugPortProtocolGuid);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) Vend;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to MAC device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created MAC device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextMAC (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16                *AddressStr;\r
-  CHAR16                *IfTypeStr;\r
-  UINTN                 Length;\r
-  MAC_ADDR_DEVICE_PATH  *MACDevPath;\r
-\r
-  AddressStr    = GetNextParamStr (&TextDeviceNode);\r
-  IfTypeStr     = GetNextParamStr (&TextDeviceNode);\r
-  MACDevPath    = (MAC_ADDR_DEVICE_PATH *) CreateDeviceNode (\r
-                                              MESSAGING_DEVICE_PATH,\r
-                                              MSG_MAC_ADDR_DP,\r
-                                              (UINT16) sizeof (MAC_ADDR_DEVICE_PATH)\r
-                                              );\r
-\r
-  MACDevPath->IfType   = (UINT8) Strtoi (IfTypeStr);\r
-\r
-  Length = sizeof (EFI_MAC_ADDRESS);\r
-  StrToBuf (&MACDevPath->MacAddress.Addr[0], Length, AddressStr);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) MACDevPath;\r
-}\r
-\r
-\r
-/**\r
-  Converts a text format to the network protocol ID.\r
-\r
-  @param Text  String of protocol field.\r
-\r
-  @return Network protocol ID .\r
-\r
-**/\r
-UINTN\r
-NetworkProtocolFromText (\r
-  IN CHAR16 *Text\r
-  )\r
-{\r
-  if (StrCmp (Text, L"UDP") == 0) {\r
-    return RFC_1700_UDP_PROTOCOL;\r
-  }\r
-\r
-  if (StrCmp (Text, L"TCP") == 0) {\r
-    return RFC_1700_TCP_PROTOCOL;\r
-  }\r
-\r
-  return Strtoi (Text);\r
-}\r
-\r
-\r
-/**\r
-  Converts a text device path node to IPV4 device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created IPV4 device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextIPv4 (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16            *RemoteIPStr;\r
-  CHAR16            *ProtocolStr;\r
-  CHAR16            *TypeStr;\r
-  CHAR16            *LocalIPStr;\r
-  CHAR16            *GatewayIPStr;\r
-  CHAR16            *SubnetMaskStr;\r
-  IPv4_DEVICE_PATH  *IPv4;\r
-\r
-  RemoteIPStr           = GetNextParamStr (&TextDeviceNode);\r
-  ProtocolStr           = GetNextParamStr (&TextDeviceNode);\r
-  TypeStr               = GetNextParamStr (&TextDeviceNode);\r
-  LocalIPStr            = GetNextParamStr (&TextDeviceNode);\r
-  GatewayIPStr          = GetNextParamStr (&TextDeviceNode);\r
-  SubnetMaskStr         = GetNextParamStr (&TextDeviceNode);\r
-  IPv4                  = (IPv4_DEVICE_PATH *) CreateDeviceNode (\r
-                                                 MESSAGING_DEVICE_PATH,\r
-                                                 MSG_IPv4_DP,\r
-                                                 (UINT16) sizeof (IPv4_DEVICE_PATH)\r
-                                                 );\r
-\r
-  StrToIPv4Addr (&RemoteIPStr, &IPv4->RemoteIpAddress);\r
-  IPv4->Protocol = (UINT16) NetworkProtocolFromText (ProtocolStr);\r
-  if (StrCmp (TypeStr, L"Static") == 0) {\r
-    IPv4->StaticIpAddress = TRUE;\r
-  } else {\r
-    IPv4->StaticIpAddress = FALSE;\r
-  }\r
-\r
-  StrToIPv4Addr (&LocalIPStr, &IPv4->LocalIpAddress);\r
-  if (!IS_NULL (*GatewayIPStr) && !IS_NULL (*SubnetMaskStr)) {\r
-    StrToIPv4Addr (&GatewayIPStr,  &IPv4->GatewayIpAddress);\r
-    StrToIPv4Addr (&SubnetMaskStr, &IPv4->SubnetMask);\r
-  } else {\r
-    ZeroMem (&IPv4->GatewayIpAddress, sizeof (IPv4->GatewayIpAddress));\r
-    ZeroMem (&IPv4->SubnetMask,    sizeof (IPv4->SubnetMask));\r
-  }\r
-\r
-  IPv4->LocalPort       = 0;\r
-  IPv4->RemotePort      = 0;\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) IPv4;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to IPV6 device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created IPV6 device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextIPv6 (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16            *RemoteIPStr;\r
-  CHAR16            *ProtocolStr;\r
-  CHAR16            *TypeStr;\r
-  CHAR16            *LocalIPStr;\r
-  CHAR16            *GatewayIPStr;\r
-  CHAR16            *PrefixLengthStr;\r
-  IPv6_DEVICE_PATH  *IPv6;\r
-\r
-  RemoteIPStr           = GetNextParamStr (&TextDeviceNode);\r
-  ProtocolStr           = GetNextParamStr (&TextDeviceNode);\r
-  TypeStr               = GetNextParamStr (&TextDeviceNode);\r
-  LocalIPStr            = GetNextParamStr (&TextDeviceNode);\r
-  PrefixLengthStr       = GetNextParamStr (&TextDeviceNode);\r
-  GatewayIPStr          = GetNextParamStr (&TextDeviceNode);\r
-  IPv6                  = (IPv6_DEVICE_PATH *) CreateDeviceNode (\r
-                                                 MESSAGING_DEVICE_PATH,\r
-                                                 MSG_IPv6_DP,\r
-                                                 (UINT16) sizeof (IPv6_DEVICE_PATH)\r
-                                                 );\r
-\r
-  StrToIPv6Addr (&RemoteIPStr, &IPv6->RemoteIpAddress);\r
-  IPv6->Protocol        = (UINT16) NetworkProtocolFromText (ProtocolStr);\r
-  if (StrCmp (TypeStr, L"Static") == 0) {\r
-    IPv6->IpAddressOrigin = 0;\r
-  } else if (StrCmp (TypeStr, L"StatelessAutoConfigure") == 0) {\r
-    IPv6->IpAddressOrigin = 1;\r
-  } else {\r
-    IPv6->IpAddressOrigin = 2;\r
-  }\r
-\r
-  StrToIPv6Addr (&LocalIPStr, &IPv6->LocalIpAddress);\r
-  if (!IS_NULL (*GatewayIPStr) && !IS_NULL (*PrefixLengthStr)) {\r
-    StrToIPv6Addr (&GatewayIPStr, &IPv6->GatewayIpAddress);\r
-    IPv6->PrefixLength = (UINT8) Strtoi (PrefixLengthStr);\r
-  } else {\r
-    ZeroMem (&IPv6->GatewayIpAddress, sizeof (IPv6->GatewayIpAddress));\r
-    IPv6->PrefixLength = 0;\r
-  }\r
-\r
-  IPv6->LocalPort       = 0;\r
-  IPv6->RemotePort      = 0;\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) IPv6;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to UART device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created UART device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextUart (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16            *BaudStr;\r
-  CHAR16            *DataBitsStr;\r
-  CHAR16            *ParityStr;\r
-  CHAR16            *StopBitsStr;\r
-  UART_DEVICE_PATH  *Uart;\r
-\r
-  BaudStr         = GetNextParamStr (&TextDeviceNode);\r
-  DataBitsStr     = GetNextParamStr (&TextDeviceNode);\r
-  ParityStr       = GetNextParamStr (&TextDeviceNode);\r
-  StopBitsStr     = GetNextParamStr (&TextDeviceNode);\r
-  Uart            = (UART_DEVICE_PATH *) CreateDeviceNode (\r
-                                           MESSAGING_DEVICE_PATH,\r
-                                           MSG_UART_DP,\r
-                                           (UINT16) sizeof (UART_DEVICE_PATH)\r
-                                           );\r
-\r
-  Uart->BaudRate  = (StrCmp (BaudStr, L"DEFAULT") == 0) ? 115200 : Dtoi (BaudStr);\r
-  Uart->DataBits  = (UINT8) ((StrCmp (DataBitsStr, L"DEFAULT") == 0) ? 8 : Dtoi (DataBitsStr));\r
-  switch (*ParityStr) {\r
-  case L'D':\r
-    Uart->Parity = 0;\r
-    break;\r
-\r
-  case L'N':\r
-    Uart->Parity = 1;\r
-    break;\r
-\r
-  case L'E':\r
-    Uart->Parity = 2;\r
-    break;\r
-\r
-  case L'O':\r
-    Uart->Parity = 3;\r
-    break;\r
-\r
-  case L'M':\r
-    Uart->Parity = 4;\r
-    break;\r
-\r
-  case L'S':\r
-    Uart->Parity = 5;\r
-    break;\r
-\r
-  default:\r
-    Uart->Parity = 0xff;\r
-  }\r
-\r
-  if (StrCmp (StopBitsStr, L"D") == 0) {\r
-    Uart->StopBits = (UINT8) 0;\r
-  } else if (StrCmp (StopBitsStr, L"1") == 0) {\r
-    Uart->StopBits = (UINT8) 1;\r
-  } else if (StrCmp (StopBitsStr, L"1.5") == 0) {\r
-    Uart->StopBits = (UINT8) 2;\r
-  } else if (StrCmp (StopBitsStr, L"2") == 0) {\r
-    Uart->StopBits = (UINT8) 3;\r
-  } else {\r
-    Uart->StopBits = 0xff;\r
-  }\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) Uart;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to USB class device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-  @param UsbClassText    A pointer to USB_CLASS_TEXT structure to be integrated to USB Class Text.\r
-\r
-  @return A pointer to the newly-created USB class device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-ConvertFromTextUsbClass (\r
-  IN CHAR16         *TextDeviceNode,\r
-  IN USB_CLASS_TEXT *UsbClassText\r
-  )\r
-{\r
-  CHAR16                *VIDStr;\r
-  CHAR16                *PIDStr;\r
-  CHAR16                *ClassStr;\r
-  CHAR16                *SubClassStr;\r
-  CHAR16                *ProtocolStr;\r
-  USB_CLASS_DEVICE_PATH *UsbClass;\r
-\r
-  UsbClass    = (USB_CLASS_DEVICE_PATH *) CreateDeviceNode (\r
-                                            MESSAGING_DEVICE_PATH,\r
-                                            MSG_USB_CLASS_DP,\r
-                                            (UINT16) sizeof (USB_CLASS_DEVICE_PATH)\r
-                                            );\r
-\r
-  VIDStr      = GetNextParamStr (&TextDeviceNode);\r
-  PIDStr      = GetNextParamStr (&TextDeviceNode);\r
-  if (UsbClassText->ClassExist) {\r
-    ClassStr = GetNextParamStr (&TextDeviceNode);\r
-    UsbClass->DeviceClass = (UINT8) Strtoi (ClassStr);\r
-  } else {\r
-    UsbClass->DeviceClass = UsbClassText->Class;\r
-  }\r
-  if (UsbClassText->SubClassExist) {\r
-    SubClassStr = GetNextParamStr (&TextDeviceNode);\r
-    UsbClass->DeviceSubClass = (UINT8) Strtoi (SubClassStr);\r
-  } else {\r
-    UsbClass->DeviceSubClass = UsbClassText->SubClass;\r
-  }\r
-\r
-  ProtocolStr = GetNextParamStr (&TextDeviceNode);\r
-\r
-  UsbClass->VendorId        = (UINT16) Strtoi (VIDStr);\r
-  UsbClass->ProductId       = (UINT16) Strtoi (PIDStr);\r
-  UsbClass->DeviceProtocol  = (UINT8) Strtoi (ProtocolStr);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) UsbClass;\r
-}\r
-\r
-\r
-/**\r
-  Converts a text device path node to USB class device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created USB class device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextUsbClass (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  USB_CLASS_TEXT  UsbClassText;\r
-\r
-  UsbClassText.ClassExist    = TRUE;\r
-  UsbClassText.SubClassExist = TRUE;\r
-\r
-  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
-}\r
-\r
-/**\r
-  Converts a text device path node to USB audio device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created USB audio device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextUsbAudio (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  USB_CLASS_TEXT  UsbClassText;\r
-\r
-  UsbClassText.ClassExist    = FALSE;\r
-  UsbClassText.Class         = USB_CLASS_AUDIO;\r
-  UsbClassText.SubClassExist = TRUE;\r
-\r
-  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
-}\r
-\r
-/**\r
-  Converts a text device path node to USB CDC Control device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created USB CDC Control device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextUsbCDCControl (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  USB_CLASS_TEXT  UsbClassText;\r
-\r
-  UsbClassText.ClassExist    = FALSE;\r
-  UsbClassText.Class         = USB_CLASS_CDCCONTROL;\r
-  UsbClassText.SubClassExist = TRUE;\r
-\r
-  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
-}\r
-\r
-/**\r
-  Converts a text device path node to USB HID device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created USB HID device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextUsbHID (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  USB_CLASS_TEXT  UsbClassText;\r
-\r
-  UsbClassText.ClassExist    = FALSE;\r
-  UsbClassText.Class         = USB_CLASS_HID;\r
-  UsbClassText.SubClassExist = TRUE;\r
-\r
-  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
-}\r
-\r
-/**\r
-  Converts a text device path node to USB Image device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created USB Image device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextUsbImage (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  USB_CLASS_TEXT  UsbClassText;\r
-\r
-  UsbClassText.ClassExist    = FALSE;\r
-  UsbClassText.Class         = USB_CLASS_IMAGE;\r
-  UsbClassText.SubClassExist = TRUE;\r
-\r
-  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
-}\r
-\r
-/**\r
-  Converts a text device path node to USB Print device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created USB Print device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextUsbPrinter (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  USB_CLASS_TEXT  UsbClassText;\r
-\r
-  UsbClassText.ClassExist    = FALSE;\r
-  UsbClassText.Class         = USB_CLASS_PRINTER;\r
-  UsbClassText.SubClassExist = TRUE;\r
-\r
-  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
-}\r
-\r
-/**\r
-  Converts a text device path node to USB mass storage device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created USB mass storage device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextUsbMassStorage (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  USB_CLASS_TEXT  UsbClassText;\r
-\r
-  UsbClassText.ClassExist    = FALSE;\r
-  UsbClassText.Class         = USB_CLASS_MASS_STORAGE;\r
-  UsbClassText.SubClassExist = TRUE;\r
-\r
-  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
-}\r
-\r
-/**\r
-  Converts a text device path node to USB HUB device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created USB HUB device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextUsbHub (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  USB_CLASS_TEXT  UsbClassText;\r
-\r
-  UsbClassText.ClassExist    = FALSE;\r
-  UsbClassText.Class         = USB_CLASS_HUB;\r
-  UsbClassText.SubClassExist = TRUE;\r
-\r
-  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
-}\r
-\r
-/**\r
-  Converts a text device path node to USB CDC data device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created USB CDC data device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextUsbCDCData (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  USB_CLASS_TEXT  UsbClassText;\r
-\r
-  UsbClassText.ClassExist    = FALSE;\r
-  UsbClassText.Class         = USB_CLASS_CDCDATA;\r
-  UsbClassText.SubClassExist = TRUE;\r
-\r
-  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
-}\r
-\r
-/**\r
-  Converts a text device path node to USB smart card device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created USB smart card device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextUsbSmartCard (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  USB_CLASS_TEXT  UsbClassText;\r
-\r
-  UsbClassText.ClassExist    = FALSE;\r
-  UsbClassText.Class         = USB_CLASS_SMART_CARD;\r
-  UsbClassText.SubClassExist = TRUE;\r
-\r
-  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
-}\r
-\r
-/**\r
-  Converts a text device path node to USB video device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created USB video device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextUsbVideo (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  USB_CLASS_TEXT  UsbClassText;\r
-\r
-  UsbClassText.ClassExist    = FALSE;\r
-  UsbClassText.Class         = USB_CLASS_VIDEO;\r
-  UsbClassText.SubClassExist = TRUE;\r
-\r
-  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
-}\r
-\r
-/**\r
-  Converts a text device path node to USB diagnostic device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created USB diagnostic device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextUsbDiagnostic (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  USB_CLASS_TEXT  UsbClassText;\r
-\r
-  UsbClassText.ClassExist    = FALSE;\r
-  UsbClassText.Class         = USB_CLASS_DIAGNOSTIC;\r
-  UsbClassText.SubClassExist = TRUE;\r
-\r
-  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
-}\r
-\r
-/**\r
-  Converts a text device path node to USB wireless device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created USB wireless device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextUsbWireless (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  USB_CLASS_TEXT  UsbClassText;\r
-\r
-  UsbClassText.ClassExist    = FALSE;\r
-  UsbClassText.Class         = USB_CLASS_WIRELESS;\r
-  UsbClassText.SubClassExist = TRUE;\r
-\r
-  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
-}\r
-\r
-/**\r
-  Converts a text device path node to USB device firmware update device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created USB device firmware update device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextUsbDeviceFirmwareUpdate (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  USB_CLASS_TEXT  UsbClassText;\r
-\r
-  UsbClassText.ClassExist    = FALSE;\r
-  UsbClassText.Class         = USB_CLASS_RESERVE;\r
-  UsbClassText.SubClassExist = FALSE;\r
-  UsbClassText.SubClass      = USB_SUBCLASS_FW_UPDATE;\r
-\r
-  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
-}\r
-\r
-/**\r
-  Converts a text device path node to USB IRDA bridge device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created USB IRDA bridge device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextUsbIrdaBridge (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  USB_CLASS_TEXT  UsbClassText;\r
-\r
-  UsbClassText.ClassExist    = FALSE;\r
-  UsbClassText.Class         = USB_CLASS_RESERVE;\r
-  UsbClassText.SubClassExist = FALSE;\r
-  UsbClassText.SubClass      = USB_SUBCLASS_IRDA_BRIDGE;\r
-\r
-  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
-}\r
-\r
-/**\r
-  Converts a text device path node to USB text and measurement device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created USB text and measurement device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextUsbTestAndMeasurement (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  USB_CLASS_TEXT  UsbClassText;\r
-\r
-  UsbClassText.ClassExist    = FALSE;\r
-  UsbClassText.Class         = USB_CLASS_RESERVE;\r
-  UsbClassText.SubClassExist = FALSE;\r
-  UsbClassText.SubClass      = USB_SUBCLASS_TEST;\r
-\r
-  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
-}\r
-\r
-/**\r
-  Converts a text device path node to USB WWID device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created USB WWID device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextUsbWwid (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16                *VIDStr;\r
-  CHAR16                *PIDStr;\r
-  CHAR16                *InterfaceNumStr;\r
-  CHAR16                *SerialNumberStr;\r
-  USB_WWID_DEVICE_PATH  *UsbWwid;\r
-\r
-  VIDStr                    = GetNextParamStr (&TextDeviceNode);\r
-  PIDStr                    = GetNextParamStr (&TextDeviceNode);\r
-  InterfaceNumStr           = GetNextParamStr (&TextDeviceNode);\r
-  SerialNumberStr           = GetNextParamStr (&TextDeviceNode);\r
-  UsbWwid                   = (USB_WWID_DEVICE_PATH *) CreateDeviceNode (\r
-                                                         MESSAGING_DEVICE_PATH,\r
-                                                         MSG_USB_WWID_DP,\r
-                                                         (UINT16) (sizeof (USB_WWID_DEVICE_PATH) + StrSize (SerialNumberStr))\r
-                                                         );\r
-\r
-  UsbWwid->VendorId         = (UINT16) Strtoi (VIDStr);\r
-  UsbWwid->ProductId        = (UINT16) Strtoi (PIDStr);\r
-  UsbWwid->InterfaceNumber  = (UINT16) Strtoi (InterfaceNumStr);\r
-  StrCpy ((CHAR16 *) ((UINT8 *) UsbWwid + sizeof (USB_WWID_DEVICE_PATH)), SerialNumberStr);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) UsbWwid;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to Logic Unit device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created Logic Unit device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextUnit (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16                          *LunStr;\r
-  DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;\r
-\r
-  LunStr      = GetNextParamStr (&TextDeviceNode);\r
-  LogicalUnit = (DEVICE_LOGICAL_UNIT_DEVICE_PATH *) CreateDeviceNode (\r
-                                                      MESSAGING_DEVICE_PATH,\r
-                                                      MSG_DEVICE_LOGICAL_UNIT_DP,\r
-                                                      (UINT16) sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH)\r
-                                                      );\r
-\r
-  LogicalUnit->Lun  = (UINT8) Strtoi (LunStr);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) LogicalUnit;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to iSCSI device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created iSCSI device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextiSCSI (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  UINT16                      Options;\r
-  CHAR16                      *NameStr;\r
-  CHAR16                      *PortalGroupStr;\r
-  CHAR16                      *LunStr;\r
-  CHAR16                      *HeaderDigestStr;\r
-  CHAR16                      *DataDigestStr;\r
-  CHAR16                      *AuthenticationStr;\r
-  CHAR16                      *ProtocolStr;\r
-  CHAR8                       *AsciiStr;\r
-  ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;\r
-\r
-  NameStr           = GetNextParamStr (&TextDeviceNode);\r
-  PortalGroupStr    = GetNextParamStr (&TextDeviceNode);\r
-  LunStr            = GetNextParamStr (&TextDeviceNode);\r
-  HeaderDigestStr   = GetNextParamStr (&TextDeviceNode);\r
-  DataDigestStr     = GetNextParamStr (&TextDeviceNode);\r
-  AuthenticationStr = GetNextParamStr (&TextDeviceNode);\r
-  ProtocolStr       = GetNextParamStr (&TextDeviceNode);\r
-  ISCSIDevPath      = (ISCSI_DEVICE_PATH_WITH_NAME *) CreateDeviceNode (\r
-                                                        MESSAGING_DEVICE_PATH,\r
-                                                        MSG_ISCSI_DP,\r
-                                                        (UINT16) (sizeof (ISCSI_DEVICE_PATH_WITH_NAME) + StrLen (NameStr))\r
-                                                        );\r
-\r
-  AsciiStr = ISCSIDevPath->TargetName;\r
-  StrToAscii (NameStr, &AsciiStr);\r
-\r
-  ISCSIDevPath->TargetPortalGroupTag = (UINT16) Strtoi (PortalGroupStr);\r
-  Strtoi64 (LunStr, &ISCSIDevPath->Lun);\r
-\r
-  Options = 0x0000;\r
-  if (StrCmp (HeaderDigestStr, L"CRC32C") == 0) {\r
-    Options |= 0x0002;\r
-  }\r
-\r
-  if (StrCmp (DataDigestStr, L"CRC32C") == 0) {\r
-    Options |= 0x0008;\r
-  }\r
-\r
-  if (StrCmp (AuthenticationStr, L"None") == 0) {\r
-    Options |= 0x0800;\r
-  }\r
-\r
-  if (StrCmp (AuthenticationStr, L"CHAP_UNI") == 0) {\r
-    Options |= 0x1000;\r
-  }\r
-\r
-  ISCSIDevPath->LoginOption      = (UINT16) Options;\r
-\r
-  ISCSIDevPath->NetworkProtocol  = (UINT16) StrCmp (ProtocolStr, L"TCP");\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) ISCSIDevPath;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to VLAN device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created VLAN device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextVlan (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16            *VlanStr;\r
-  VLAN_DEVICE_PATH  *Vlan;\r
-\r
-  VlanStr = GetNextParamStr (&TextDeviceNode);\r
-  Vlan    = (VLAN_DEVICE_PATH *) CreateDeviceNode (\r
-                                   MESSAGING_DEVICE_PATH,\r
-                                   MSG_VLAN_DP,\r
-                                   (UINT16) sizeof (VLAN_DEVICE_PATH)\r
-                                   );\r
-\r
-  Vlan->VlanId = (UINT16) Strtoi (VlanStr);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) Vlan;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to HD device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created HD device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextHD (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16                *PartitionStr;\r
-  CHAR16                *TypeStr;\r
-  CHAR16                *SignatureStr;\r
-  CHAR16                *StartStr;\r
-  CHAR16                *SizeStr;\r
-  UINT32                Signature32;\r
-  EFI_GUID              SignatureGuid;\r
-  HARDDRIVE_DEVICE_PATH *Hd;\r
-\r
-  PartitionStr        = GetNextParamStr (&TextDeviceNode);\r
-  TypeStr             = GetNextParamStr (&TextDeviceNode);\r
-  SignatureStr        = GetNextParamStr (&TextDeviceNode);\r
-  StartStr            = GetNextParamStr (&TextDeviceNode);\r
-  SizeStr             = GetNextParamStr (&TextDeviceNode);\r
-  Hd                  = (HARDDRIVE_DEVICE_PATH *) CreateDeviceNode (\r
-                                                    MEDIA_DEVICE_PATH,\r
-                                                    MEDIA_HARDDRIVE_DP,\r
-                                                    (UINT16) sizeof (HARDDRIVE_DEVICE_PATH)\r
-                                                    );\r
-\r
-  Hd->PartitionNumber = (UINT32) Dtoi (PartitionStr);\r
-\r
-  ZeroMem (Hd->Signature, 16);\r
-  Hd->MBRType = (UINT8) 0;\r
-\r
-  if (StrCmp (TypeStr, L"MBR") == 0) {\r
-    Hd->SignatureType = SIGNATURE_TYPE_MBR;\r
-    Hd->MBRType       = 0x01;\r
-\r
-    Signature32       = (UINT32) Strtoi (SignatureStr);\r
-    CopyMem (Hd->Signature, &Signature32, sizeof (UINT32));\r
-  } else if (StrCmp (TypeStr, L"GPT") == 0) {\r
-    Hd->SignatureType = SIGNATURE_TYPE_GUID;\r
-    Hd->MBRType       = 0x02;\r
-\r
-    StrToGuid (SignatureStr, &SignatureGuid);\r
-    CopyMem (Hd->Signature, &SignatureGuid, sizeof (EFI_GUID));\r
-  } else {\r
-    Hd->SignatureType = (UINT8) Strtoi (TypeStr);\r
-  }\r
-\r
-  Strtoi64 (StartStr, &Hd->PartitionStart);\r
-  Strtoi64 (SizeStr, &Hd->PartitionSize);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) Hd;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to CDROM device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created CDROM device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextCDROM (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16            *EntryStr;\r
-  CHAR16            *StartStr;\r
-  CHAR16            *SizeStr;\r
-  CDROM_DEVICE_PATH *CDROMDevPath;\r
-\r
-  EntryStr              = GetNextParamStr (&TextDeviceNode);\r
-  StartStr              = GetNextParamStr (&TextDeviceNode);\r
-  SizeStr               = GetNextParamStr (&TextDeviceNode);\r
-  CDROMDevPath          = (CDROM_DEVICE_PATH *) CreateDeviceNode (\r
-                                                  MEDIA_DEVICE_PATH,\r
-                                                  MEDIA_CDROM_DP,\r
-                                                  (UINT16) sizeof (CDROM_DEVICE_PATH)\r
-                                                  );\r
-\r
-  CDROMDevPath->BootEntry = (UINT32) Strtoi (EntryStr);\r
-  Strtoi64 (StartStr, &CDROMDevPath->PartitionStart);\r
-  Strtoi64 (SizeStr, &CDROMDevPath->PartitionSize);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) CDROMDevPath;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to Vendor-defined media device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created Vendor-defined media device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextVenMEDIA (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  return ConvertFromTextVendor (\r
-           TextDeviceNode,\r
-           MEDIA_DEVICE_PATH,\r
-           MEDIA_VENDOR_DP\r
-           );\r
-}\r
-\r
-/**\r
-  Converts a text device path node to File device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created File device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextFilePath (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  FILEPATH_DEVICE_PATH  *File;\r
-\r
-  File = (FILEPATH_DEVICE_PATH *) CreateDeviceNode (\r
-                                    MEDIA_DEVICE_PATH,\r
-                                    MEDIA_FILEPATH_DP,\r
-                                    (UINT16) (sizeof (FILEPATH_DEVICE_PATH) + StrLen (TextDeviceNode) * 2)\r
-                                    );\r
-\r
-  StrCpy (File->PathName, TextDeviceNode);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) File;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to Media protocol device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created Media protocol device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextMedia (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16                      *GuidStr;\r
-  MEDIA_PROTOCOL_DEVICE_PATH  *Media;\r
-\r
-  GuidStr = GetNextParamStr (&TextDeviceNode);\r
-  Media   = (MEDIA_PROTOCOL_DEVICE_PATH *) CreateDeviceNode (\r
-                                             MEDIA_DEVICE_PATH,\r
-                                             MEDIA_PROTOCOL_DP,\r
-                                             (UINT16) sizeof (MEDIA_PROTOCOL_DEVICE_PATH)\r
-                                             );\r
-\r
-  StrToGuid (GuidStr, &Media->Protocol);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) Media;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to firmware volume device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created firmware volume device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextFv (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16                    *GuidStr;\r
-  MEDIA_FW_VOL_DEVICE_PATH  *Fv;\r
-\r
-  GuidStr = GetNextParamStr (&TextDeviceNode);\r
-  Fv      = (MEDIA_FW_VOL_DEVICE_PATH *) CreateDeviceNode (\r
-                                           MEDIA_DEVICE_PATH,\r
-                                           MEDIA_PIWG_FW_VOL_DP,\r
-                                           (UINT16) sizeof (MEDIA_FW_VOL_DEVICE_PATH)\r
-                                           );\r
-\r
-  StrToGuid (GuidStr, &Fv->FvName);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) Fv;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to firmware file device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created firmware file device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextFvFile (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16                             *GuidStr;\r
-  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH  *FvFile;\r
-\r
-  GuidStr = GetNextParamStr (&TextDeviceNode);\r
-  FvFile  = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) CreateDeviceNode (\r
-                                                    MEDIA_DEVICE_PATH,\r
-                                                    MEDIA_PIWG_FW_FILE_DP,\r
-                                                    (UINT16) sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH)\r
-                                                    );\r
-\r
-  StrToGuid (GuidStr, &FvFile->FvFileName);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) FvFile;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to text relative offset device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created Text device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextRelativeOffsetRange (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16                                  *StartingOffsetStr;\r
-  CHAR16                                  *EndingOffsetStr;\r
-  MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset;\r
-\r
-  StartingOffsetStr = GetNextParamStr (&TextDeviceNode);\r
-  EndingOffsetStr   = GetNextParamStr (&TextDeviceNode);\r
-  Offset            = (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *) CreateDeviceNode (\r
-                                                                    MEDIA_DEVICE_PATH,\r
-                                                                    MEDIA_RELATIVE_OFFSET_RANGE_DP,\r
-                                                                    (UINT16) sizeof (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH)\r
-                                                                    );\r
-\r
-  Strtoi64 (StartingOffsetStr, &Offset->StartingOffset);\r
-  Strtoi64 (EndingOffsetStr, &Offset->EndingOffset);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) Offset;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to BIOS Boot Specification device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created BIOS Boot Specification device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextBBS (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  CHAR16              *TypeStr;\r
-  CHAR16              *IdStr;\r
-  CHAR16              *FlagsStr;\r
-  CHAR8               *AsciiStr;\r
-  BBS_BBS_DEVICE_PATH *Bbs;\r
-\r
-  TypeStr   = GetNextParamStr (&TextDeviceNode);\r
-  IdStr     = GetNextParamStr (&TextDeviceNode);\r
-  FlagsStr  = GetNextParamStr (&TextDeviceNode);\r
-  Bbs       = (BBS_BBS_DEVICE_PATH *) CreateDeviceNode (\r
-                                        BBS_DEVICE_PATH,\r
-                                        BBS_BBS_DP,\r
-                                        (UINT16) (sizeof (BBS_BBS_DEVICE_PATH) + StrLen (IdStr))\r
-                                        );\r
-\r
-  if (StrCmp (TypeStr, L"Floppy") == 0) {\r
-    Bbs->DeviceType = BBS_TYPE_FLOPPY;\r
-  } else if (StrCmp (TypeStr, L"HD") == 0) {\r
-    Bbs->DeviceType = BBS_TYPE_HARDDRIVE;\r
-  } else if (StrCmp (TypeStr, L"CDROM") == 0) {\r
-    Bbs->DeviceType = BBS_TYPE_CDROM;\r
-  } else if (StrCmp (TypeStr, L"PCMCIA") == 0) {\r
-    Bbs->DeviceType = BBS_TYPE_PCMCIA;\r
-  } else if (StrCmp (TypeStr, L"USB") == 0) {\r
-    Bbs->DeviceType = BBS_TYPE_USB;\r
-  } else if (StrCmp (TypeStr, L"Network") == 0) {\r
-    Bbs->DeviceType = BBS_TYPE_EMBEDDED_NETWORK;\r
-  } else {\r
-    Bbs->DeviceType = (UINT16) Strtoi (TypeStr);\r
-  }\r
-\r
-  AsciiStr = Bbs->String;\r
-  StrToAscii (IdStr, &AsciiStr);\r
-\r
-  Bbs->StatusFlag = (UINT16) Strtoi (FlagsStr);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) Bbs;\r
-}\r
-\r
-/**\r
-  Converts a text device path node to SATA device path structure.\r
-\r
-  @param TextDeviceNode  The input Text device path node.\r
-\r
-  @return A pointer to the newly-created SATA device path structure.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-DevPathFromTextSata (\r
-  IN CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  SATA_DEVICE_PATH *Sata;\r
-  CHAR16           *Param1;\r
-  CHAR16           *Param2;\r
-  CHAR16           *Param3;\r
-\r
-  //\r
-  // The PMPN is optional.\r
-  //\r
-  Param1 = GetNextParamStr (&TextDeviceNode);\r
-  Param2 = GetNextParamStr (&TextDeviceNode);\r
-  Param3 = NULL;\r
-  if (!IS_NULL (TextDeviceNode)) {\r
-    Param3 = GetNextParamStr (&TextDeviceNode);\r
-  }\r
-\r
-  Sata = (SATA_DEVICE_PATH *) CreateDeviceNode (\r
-                                MESSAGING_DEVICE_PATH,\r
-                                MSG_SATA_DP,\r
-                                (UINT16) sizeof (SATA_DEVICE_PATH)\r
-                                );\r
-  Sata->HBAPortNumber = (UINT16) Xtoi (Param1);\r
-  if (Param3 != NULL) {\r
-    Sata->PortMultiplierPortNumber = (UINT16) Xtoi (Param2);\r
-    Param2                   = Param3;\r
-  } else {\r
-    Sata->PortMultiplierPortNumber = SATA_HBA_DIRECT_CONNECT_FLAG;\r
-  }\r
-  Sata->Lun = (UINT16) Xtoi (Param2);\r
-\r
-  return (EFI_DEVICE_PATH_PROTOCOL *) Sata;\r
-}\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE DevPathFromTextTable[] = {\r
-  {L"Pci", DevPathFromTextPci},\r
-  {L"PcCard", DevPathFromTextPcCard},\r
-  {L"MemoryMapped", DevPathFromTextMemoryMapped},\r
-  {L"VenHw", DevPathFromTextVenHw},\r
-  {L"Ctrl", DevPathFromTextCtrl},\r
-  {L"Acpi", DevPathFromTextAcpi},\r
-  {L"PciRoot", DevPathFromTextPciRoot},\r
-  {L"PcieRoot", DevPathFromTextPcieRoot},\r
-  {L"Floppy", DevPathFromTextFloppy},\r
-  {L"Keyboard", DevPathFromTextKeyboard},\r
-  {L"Serial", DevPathFromTextSerial},\r
-  {L"ParallelPort", DevPathFromTextParallelPort},\r
-  {L"AcpiEx", DevPathFromTextAcpiEx},\r
-  {L"AcpiExp", DevPathFromTextAcpiExp},\r
-  {L"AcpiAdr", DevPathFromTextAcpiAdr},\r
-  {L"Ata", DevPathFromTextAta},\r
-  {L"Scsi", DevPathFromTextScsi},\r
-  {L"Fibre", DevPathFromTextFibre},\r
-  {L"FibreEx", DevPathFromTextFibreEx},\r
-  {L"I1394", DevPathFromText1394},\r
-  {L"USB", DevPathFromTextUsb},\r
-  {L"I2O", DevPathFromTextI2O},\r
-  {L"Infiniband", DevPathFromTextInfiniband},\r
-  {L"VenMsg", DevPathFromTextVenMsg},\r
-  {L"VenPcAnsi", DevPathFromTextVenPcAnsi},\r
-  {L"VenVt100", DevPathFromTextVenVt100},\r
-  {L"VenVt100Plus", DevPathFromTextVenVt100Plus},\r
-  {L"VenUtf8", DevPathFromTextVenUtf8},\r
-  {L"UartFlowCtrl", DevPathFromTextUartFlowCtrl},\r
-  {L"SAS", DevPathFromTextSAS},\r
-  {L"SasEx", DevPathFromTextSasEx},\r
-  {L"DebugPort", DevPathFromTextDebugPort},\r
-  {L"MAC", DevPathFromTextMAC},\r
-  {L"IPv4", DevPathFromTextIPv4},\r
-  {L"IPv6", DevPathFromTextIPv6},\r
-  {L"Uart", DevPathFromTextUart},\r
-  {L"UsbClass", DevPathFromTextUsbClass},\r
-  {L"UsbAudio", DevPathFromTextUsbAudio},\r
-  {L"UsbCDCControl", DevPathFromTextUsbCDCControl},\r
-  {L"UsbHID", DevPathFromTextUsbHID},\r
-  {L"UsbImage", DevPathFromTextUsbImage},\r
-  {L"UsbPrinter", DevPathFromTextUsbPrinter},\r
-  {L"UsbMassStorage", DevPathFromTextUsbMassStorage},\r
-  {L"UsbHub", DevPathFromTextUsbHub},\r
-  {L"UsbCDCData", DevPathFromTextUsbCDCData},\r
-  {L"UsbSmartCard", DevPathFromTextUsbSmartCard},\r
-  {L"UsbVideo", DevPathFromTextUsbVideo},\r
-  {L"UsbDiagnostic", DevPathFromTextUsbDiagnostic},\r
-  {L"UsbWireless", DevPathFromTextUsbWireless},\r
-  {L"UsbDeviceFirmwareUpdate", DevPathFromTextUsbDeviceFirmwareUpdate},\r
-  {L"UsbIrdaBridge", DevPathFromTextUsbIrdaBridge},\r
-  {L"UsbTestAndMeasurement", DevPathFromTextUsbTestAndMeasurement},\r
-  {L"UsbWwid", DevPathFromTextUsbWwid},\r
-  {L"Unit", DevPathFromTextUnit},\r
-  {L"iSCSI", DevPathFromTextiSCSI},\r
-  {L"Vlan", DevPathFromTextVlan},\r
-  {L"HD", DevPathFromTextHD},\r
-  {L"CDROM", DevPathFromTextCDROM},\r
-  {L"VenMEDIA", DevPathFromTextVenMEDIA},\r
-  {L"Media", DevPathFromTextMedia},\r
-  {L"Fv", DevPathFromTextFv},\r
-  {L"FvFile", DevPathFromTextFvFile},\r
-  {L"Offset", DevPathFromTextRelativeOffsetRange},\r
-  {L"BBS", DevPathFromTextBBS},\r
-  {L"Sata", DevPathFromTextSata},\r
-  {NULL, NULL}\r
-};\r
-\r
-/**\r
-  Convert text to the binary representation of a device node.\r
-\r
-  @param TextDeviceNode  TextDeviceNode points to the text representation of a device\r
-                         node. Conversion starts with the first character and continues\r
-                         until the first non-device node character.\r
-\r
-  @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was\r
-          insufficient memory or text unsupported.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-EFIAPI\r
-ConvertTextToDeviceNode (\r
-  IN CONST CHAR16 *TextDeviceNode\r
-  )\r
-{\r
-  DUMP_NODE                DumpNode;\r
-  CHAR16                   *ParamStr;\r
-  EFI_DEVICE_PATH_PROTOCOL *DeviceNode;\r
-  CHAR16                   *DeviceNodeStr;\r
-  UINTN                    Index;\r
-\r
-  if ((TextDeviceNode == NULL) || (IS_NULL (*TextDeviceNode))) {\r
-    return NULL;\r
-  }\r
-\r
-  ParamStr      = NULL;\r
-  DumpNode      = NULL;\r
-  DeviceNodeStr = StrDuplicate (TextDeviceNode);\r
-  ASSERT (DeviceNodeStr != NULL);\r
-\r
-  for (Index = 0; DevPathFromTextTable[Index].Function != NULL; Index++) {\r
-    ParamStr = GetParamByNodeName (DeviceNodeStr, DevPathFromTextTable[Index].DevicePathNodeText);\r
-    if (ParamStr != NULL) {\r
-      DumpNode = DevPathFromTextTable[Index].Function;\r
-      break;\r
-    }\r
-  }\r
-\r
-  if (DumpNode == NULL) {\r
-    //\r
-    // A file path\r
-    //\r
-    DumpNode = DevPathFromTextFilePath;\r
-    DeviceNode = DumpNode (DeviceNodeStr);\r
-  } else {\r
-    DeviceNode = DumpNode (ParamStr);\r
-    FreePool (ParamStr);\r
-  }\r
-\r
-  FreePool (DeviceNodeStr);\r
-\r
-  return DeviceNode;\r
-}\r
-\r
-/**\r
-  Convert text to the binary representation of a device path.\r
-\r
-\r
-  @param TextDevicePath  TextDevicePath points to the text representation of a device\r
-                         path. Conversion starts with the first character and continues\r
-                         until the first non-device node character.\r
-\r
-  @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or\r
-          there was insufficient memory.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-EFIAPI\r
-ConvertTextToDevicePath (\r
-  IN CONST CHAR16 *TextDevicePath\r
-  )\r
-{\r
-  DUMP_NODE                DumpNode;\r
-  CHAR16                   *ParamStr;\r
-  EFI_DEVICE_PATH_PROTOCOL *DeviceNode;\r
-  UINTN                    Index;\r
-  EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;\r
-  CHAR16                   *DevicePathStr;\r
-  CHAR16                   *Str;\r
-  CHAR16                   *DeviceNodeStr;\r
-  UINT8                    IsInstanceEnd;\r
-  EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
-\r
-  if ((TextDevicePath == NULL) || (IS_NULL (*TextDevicePath))) {\r
-    return NULL;\r
-  }\r
-\r
-  DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);\r
-  ASSERT (DevicePath != NULL);\r
-  SetDevicePathEndNode (DevicePath);\r
-\r
-  ParamStr            = NULL;\r
-  DeviceNodeStr       = NULL;\r
-  DevicePathStr       = StrDuplicate (TextDevicePath);\r
-\r
-  Str                 = DevicePathStr;\r
-  while ((DeviceNodeStr = GetNextDeviceNodeStr (&Str, &IsInstanceEnd)) != NULL) {\r
-    DumpNode = NULL;\r
-    for (Index = 0; DevPathFromTextTable[Index].Function != NULL; Index++) {\r
-      ParamStr = GetParamByNodeName (DeviceNodeStr, DevPathFromTextTable[Index].DevicePathNodeText);\r
-      if (ParamStr != NULL) {\r
-        DumpNode = DevPathFromTextTable[Index].Function;\r
-        break;\r
-      }\r
-    }\r
-\r
-    if (DumpNode == NULL) {\r
-      //\r
-      // A file path\r
-      //\r
-      DumpNode  = DevPathFromTextFilePath;\r
-      DeviceNode = DumpNode (DeviceNodeStr);\r
-    } else {\r
-      DeviceNode = DumpNode (ParamStr);\r
-      FreePool (ParamStr);\r
-    }\r
-\r
-    NewDevicePath = AppendDeviceNodeProtocolInterface (DevicePath, DeviceNode);\r
-    FreePool (DevicePath);\r
-    FreePool (DeviceNode);\r
-    DevicePath = NewDevicePath;\r
-\r
-    if (IsInstanceEnd != 0) {\r
-      DeviceNode = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);\r
-      ASSERT (DeviceNode != NULL);\r
-      SET_DEVICE_PATH_INSTANCE_END_NODE (DeviceNode);\r
-\r
-      NewDevicePath = AppendDeviceNodeProtocolInterface (DevicePath, DeviceNode);\r
-      FreePool (DevicePath);\r
-      FreePool (DeviceNode);\r
-      DevicePath = NewDevicePath;\r
-    }\r
-  }\r
-\r
-  FreePool (DevicePathStr);\r
-  return DevicePath;\r
-}\r
diff --git a/MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c b/MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c
deleted file mode 100644 (file)
index 3d9d7c7..0000000
+++ /dev/null
@@ -1,2071 +0,0 @@
-/** @file\r
-  DevicePathToText protocol as defined in the UEFI 2.0 specification.\r
-\r
-Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "DevicePath.h"\r
-\r
-/**\r
-  Concatenates a formatted unicode string to allocated pool. The caller must\r
-  free the resulting buffer.\r
-\r
-  @param Str             Tracks the allocated pool, size in use, and\r
-                         amount of pool allocated.\r
-  @param Fmt             The format string\r
-  @param ...             Variable arguments based on the format string.\r
-\r
-  @return Allocated buffer with the formatted string printed in it.\r
-          The caller must free the allocated buffer. The buffer\r
-          allocation is not packed.\r
-\r
-**/\r
-CHAR16 *\r
-EFIAPI\r
-CatPrint (\r
-  IN OUT POOL_PRINT   *Str,\r
-  IN CHAR16           *Fmt,\r
-  ...\r
-  )\r
-{\r
-  UINT16  *AppendStr;\r
-  UINTN   AppendCount;\r
-  VA_LIST Args;\r
-\r
-  AppendStr = AllocateZeroPool (0x1000);\r
-  ASSERT (AppendStr != NULL);\r
-\r
-  VA_START (Args, Fmt);\r
-  AppendCount = UnicodeVSPrint (AppendStr, 0x1000, Fmt, Args);\r
-  VA_END (Args);\r
-\r
-  if (Str->Length + AppendCount * sizeof (CHAR16) > Str->Capacity) {\r
-    Str->Capacity = Str->Length + (AppendCount + 1) * sizeof (CHAR16) * 2;\r
-    Str->Str = ReallocatePool (\r
-                 Str->Length,\r
-                 Str->Capacity,\r
-                 Str->Str\r
-                 );\r
-    ASSERT (Str->Str != NULL);\r
-  }\r
-\r
-  if (Str->Length == 0) {\r
-    StrCpy (Str->Str, AppendStr);\r
-    Str->Length = (AppendCount + 1) * sizeof (CHAR16);\r
-  } else {\r
-    StrCat (Str->Str, AppendStr);\r
-    Str->Length += AppendCount * sizeof (CHAR16);\r
-  }\r
-\r
-  FreePool (AppendStr);\r
-  return Str->Str;\r
-}\r
-\r
-/**\r
-  Converts a PCI device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextPci (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  PCI_DEVICE_PATH *Pci;\r
-\r
-  Pci = DevPath;\r
-  CatPrint (Str, L"Pci(0x%x,0x%x)", Pci->Device, Pci->Function);\r
-}\r
-\r
-/**\r
-  Converts a PC Card device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextPccard (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  PCCARD_DEVICE_PATH  *Pccard;\r
-\r
-  Pccard = DevPath;\r
-  CatPrint (Str, L"PcCard(0x%x)", Pccard->FunctionNumber);\r
-}\r
-\r
-/**\r
-  Converts a Memory Map device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextMemMap (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  MEMMAP_DEVICE_PATH  *MemMap;\r
-\r
-  MemMap = DevPath;\r
-  CatPrint (\r
-    Str,\r
-    L"MemoryMapped(0x%x,0x%lx,0x%lx)",\r
-    MemMap->MemoryType,\r
-    MemMap->StartingAddress,\r
-    MemMap->EndingAddress\r
-    );\r
-}\r
-\r
-/**\r
-  Converts a Vendor device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextVendor (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  VENDOR_DEVICE_PATH  *Vendor;\r
-  CHAR16              *Type;\r
-  UINTN               Index;\r
-  UINTN               DataLength;\r
-  UINT32              FlowControlMap;\r
-  UINT16              Info;\r
-\r
-  Vendor = (VENDOR_DEVICE_PATH *) DevPath;\r
-  switch (DevicePathType (&Vendor->Header)) {\r
-  case HARDWARE_DEVICE_PATH:\r
-    Type = L"Hw";\r
-    break;\r
-\r
-  case MESSAGING_DEVICE_PATH:\r
-    Type = L"Msg";\r
-    if (AllowShortcuts) {\r
-      if (CompareGuid (&Vendor->Guid, &gEfiPcAnsiGuid)) {\r
-        CatPrint (Str, L"VenPcAnsi()");\r
-        return ;\r
-      } else if (CompareGuid (&Vendor->Guid, &gEfiVT100Guid)) {\r
-        CatPrint (Str, L"VenVt100()");\r
-        return ;\r
-      } else if (CompareGuid (&Vendor->Guid, &gEfiVT100PlusGuid)) {\r
-        CatPrint (Str, L"VenVt100Plus()");\r
-        return ;\r
-      } else if (CompareGuid (&Vendor->Guid, &gEfiVTUTF8Guid)) {\r
-        CatPrint (Str, L"VenUft8()");\r
-        return ;\r
-      } else if (CompareGuid (&Vendor->Guid, &gEfiUartDevicePathGuid)) {\r
-        FlowControlMap = (((UART_FLOW_CONTROL_DEVICE_PATH *) Vendor)->FlowControlMap);\r
-        switch (FlowControlMap & 0x00000003) {\r
-        case 0:\r
-          CatPrint (Str, L"UartFlowCtrl(%s)", L"None");\r
-          break;\r
-\r
-        case 1:\r
-          CatPrint (Str, L"UartFlowCtrl(%s)", L"Hardware");\r
-          break;\r
-\r
-        case 2:\r
-          CatPrint (Str, L"UartFlowCtrl(%s)", L"XonXoff");\r
-          break;\r
-\r
-        default:\r
-          break;\r
-        }\r
-\r
-        return ;\r
-      } else if (CompareGuid (&Vendor->Guid, &gEfiSasDevicePathGuid)) {\r
-        CatPrint (\r
-          Str,\r
-          L"SAS(0x%lx,0x%lx,0x%x,",\r
-          ((SAS_DEVICE_PATH *) Vendor)->SasAddress,\r
-          ((SAS_DEVICE_PATH *) Vendor)->Lun,\r
-          ((SAS_DEVICE_PATH *) Vendor)->RelativeTargetPort\r
-          );\r
-        Info = (((SAS_DEVICE_PATH *) Vendor)->DeviceTopology);\r
-        if (((Info & 0x0f) == 0) && ((Info & BIT7) == 0)) {\r
-          CatPrint (Str, L"NoTopology,0,0,0,");\r
-        } else if (((Info & 0x0f) <= 2) && ((Info & BIT7) == 0)) {\r
-          CatPrint (\r
-            Str,\r
-            L"%s,%s,%s,",\r
-            ((Info & BIT4) != 0) ? L"SATA" : L"SAS",\r
-            ((Info & BIT5) != 0) ? L"External" : L"Internal",\r
-            ((Info & BIT6) != 0) ? L"Expanded" : L"Direct"\r
-            );\r
-          if ((Info & 0x0f) == 1) {\r
-            CatPrint (Str, L"0,");\r
-          } else {\r
-            //\r
-            // Value 0x0 thru 0xFF -> Drive 1 thru Drive 256\r
-            //\r
-            CatPrint (Str, L"0x%x,", ((Info >> 8) & 0xff) + 1);\r
-          }\r
-        } else {\r
-          CatPrint (Str, L"0x%x,0,0,0,", Info);\r
-        }\r
-\r
-        CatPrint (Str, L"0x%x)", ((SAS_DEVICE_PATH *) Vendor)->Reserved);\r
-        return ;\r
-      } else if (CompareGuid (&Vendor->Guid, &gEfiDebugPortProtocolGuid)) {\r
-        CatPrint (Str, L"DebugPort()");\r
-        return ;\r
-      }\r
-    }\r
-    break;\r
-\r
-  case MEDIA_DEVICE_PATH:\r
-    Type = L"Media";\r
-    break;\r
-\r
-  default:\r
-    Type = L"?";\r
-    break;\r
-  }\r
-\r
-  DataLength = DevicePathNodeLength (&Vendor->Header) - sizeof (VENDOR_DEVICE_PATH);\r
-  CatPrint (Str, L"Ven%s(%g", Type, &Vendor->Guid);\r
-  if (DataLength != 0) {\r
-    CatPrint (Str, L",");\r
-    for (Index = 0; Index < DataLength; Index++) {\r
-      CatPrint (Str, L"%02x", ((VENDOR_DEVICE_PATH_WITH_DATA *) Vendor)->VendorDefinedData[Index]);\r
-    }\r
-  }\r
-\r
-  CatPrint (Str, L")");\r
-}\r
-\r
-/**\r
-  Converts a Controller device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextController (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  CONTROLLER_DEVICE_PATH  *Controller;\r
-\r
-  Controller = DevPath;\r
-  CatPrint (\r
-    Str,\r
-    L"Ctrl(0x%x)",\r
-    Controller->ControllerNumber\r
-    );\r
-}\r
-\r
-/**\r
-  Converts a ACPI device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextAcpi (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  ACPI_HID_DEVICE_PATH  *Acpi;\r
-\r
-  Acpi = DevPath;\r
-  if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
-    switch (EISA_ID_TO_NUM (Acpi->HID)) {\r
-    case 0x0a03:\r
-      CatPrint (Str, L"PciRoot(0x%x)", Acpi->UID);\r
-      break;\r
-\r
-    case 0x0a08:\r
-      CatPrint (Str, L"PcieRoot(0x%x)", Acpi->UID);\r
-      break;\r
-\r
-    case 0x0604:\r
-      CatPrint (Str, L"Floppy(0x%x)", Acpi->UID);\r
-      break;\r
-\r
-    case 0x0301:\r
-      CatPrint (Str, L"Keyboard(0x%x)", Acpi->UID);\r
-      break;\r
-\r
-    case 0x0501:\r
-      CatPrint (Str, L"Serial(0x%x)", Acpi->UID);\r
-      break;\r
-\r
-    case 0x0401:\r
-      CatPrint (Str, L"ParallelPort(0x%x)", Acpi->UID);\r
-      break;\r
-\r
-    default:\r
-      CatPrint (Str, L"Acpi(PNP%04x,0x%x)", EISA_ID_TO_NUM (Acpi->HID), Acpi->UID);\r
-      break;\r
-    }\r
-  } else {\r
-    CatPrint (Str, L"Acpi(0x%08x,0x%x)", Acpi->HID, Acpi->UID);\r
-  }\r
-}\r
-\r
-/**\r
-  Converts EISA identification to string.\r
-\r
-  @param EisaId        The input EISA identification.\r
-  @param Text          A pointer to the output string.\r
-\r
-**/\r
-VOID\r
-EisaIdToText (\r
-  IN UINT32         EisaId,\r
-  IN OUT CHAR16     *Text\r
-  )\r
-{\r
-  CHAR16 PnpIdStr[17];\r
-\r
-  //\r
-  //UnicodeSPrint ("%X", 0x0a03) => "0000000000000A03"\r
-  //\r
-  UnicodeSPrint (PnpIdStr, 17 * 2, L"%16X", EisaId >> 16);\r
-\r
-  UnicodeSPrint (\r
-    Text,\r
-    sizeof (CHAR16) + sizeof (CHAR16) + sizeof (CHAR16) + sizeof (PnpIdStr),\r
-    L"%c%c%c%s",\r
-    '@' + ((EisaId >> 10) & 0x1f),\r
-    '@' + ((EisaId >>  5) & 0x1f),\r
-    '@' + ((EisaId >>  0) & 0x1f),\r
-    PnpIdStr + (16 - 4)\r
-    );\r
-}\r
-\r
-/**\r
-  Converts a ACPI extended HID device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextAcpiEx (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  ACPI_EXTENDED_HID_DEVICE_PATH  *AcpiEx;\r
-  CHAR8                          *HIDStr;\r
-  CHAR8                          *UIDStr;\r
-  CHAR8                          *CIDStr;\r
-  CHAR16                         HIDText[11];\r
-  CHAR16                         CIDText[11];\r
-\r
-  AcpiEx = DevPath;\r
-  HIDStr = (CHAR8 *) (((UINT8 *) AcpiEx) + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));\r
-  UIDStr = HIDStr + AsciiStrLen (HIDStr) + 1;\r
-  CIDStr = UIDStr + AsciiStrLen (UIDStr) + 1;\r
-\r
-  EisaIdToText (AcpiEx->HID, HIDText);\r
-  EisaIdToText (AcpiEx->CID, CIDText);\r
-\r
-  if ((*HIDStr == '\0') && (*CIDStr == '\0') && (AcpiEx->UID == 0)) {\r
-    //\r
-    // use AcpiExp()\r
-    //\r
-    CatPrint (\r
-      Str,\r
-      L"AcpiExp(%s,%s,%a)",\r
-      HIDText,\r
-      CIDText,\r
-      UIDStr\r
-      );\r
-  } else {\r
-    if (AllowShortcuts) {\r
-      //\r
-      // display only\r
-      //\r
-      if (AcpiEx->HID == 0) {\r
-        CatPrint (Str, L"AcpiEx(%a,", HIDStr);\r
-      } else {\r
-        CatPrint (Str, L"AcpiEx(%s,", HIDText);\r
-      }\r
-\r
-      if (AcpiEx->UID == 0) {\r
-        CatPrint (Str, L"%a,", UIDStr);\r
-      } else {\r
-        CatPrint (Str, L"0x%x,", AcpiEx->UID);\r
-      }\r
-\r
-      if (AcpiEx->CID == 0) {\r
-        CatPrint (Str, L"%a)", CIDStr);\r
-      } else {\r
-        CatPrint (Str, L"%s)", CIDText);\r
-      }\r
-    } else {\r
-      CatPrint (\r
-        Str,\r
-        L"AcpiEx(%s,%s,0x%x,%a,%a,%a)",\r
-        HIDText,\r
-        CIDText,\r
-        AcpiEx->UID,\r
-        HIDStr,\r
-        CIDStr,\r
-        UIDStr\r
-        );\r
-    }\r
-  }\r
-}\r
-\r
-/**\r
-  Converts a ACPI address device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextAcpiAdr (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  ACPI_ADR_DEVICE_PATH    *AcpiAdr;\r
-  UINT16                  Index;\r
-  UINT16                  Length;\r
-  UINT16                  AdditionalAdrCount;\r
-\r
-  AcpiAdr            = DevPath;\r
-  Length             = (UINT16) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) AcpiAdr);\r
-  AdditionalAdrCount = (UINT16) ((Length - 8) / 4);\r
-\r
-  CatPrint (Str, L"AcpiAdr(0x%x", AcpiAdr->ADR);\r
-  for (Index = 0; Index < AdditionalAdrCount; Index++) {\r
-    CatPrint (Str, L",0x%x", *(UINT32 *) ((UINT8 *) AcpiAdr + 8 + Index * 4));\r
-  }\r
-  CatPrint (Str, L")");\r
-}\r
-\r
-/**\r
-  Converts a ATAPI device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextAtapi (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  ATAPI_DEVICE_PATH *Atapi;\r
-\r
-  Atapi = DevPath;\r
-\r
-  if (DisplayOnly) {\r
-    CatPrint (Str, L"Ata(0x%x)", Atapi->Lun);\r
-  } else {\r
-    CatPrint (\r
-      Str,\r
-      L"Ata(%s,%s,0x%x)",\r
-      (Atapi->PrimarySecondary == 1) ? L"Secondary" : L"Primary",\r
-      (Atapi->SlaveMaster == 1) ? L"Slave" : L"Master",\r
-      Atapi->Lun\r
-      );\r
-  }\r
-}\r
-\r
-/**\r
-  Converts a SCSI device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextScsi (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  SCSI_DEVICE_PATH  *Scsi;\r
-\r
-  Scsi = DevPath;\r
-  CatPrint (Str, L"Scsi(0x%x,0x%x)", Scsi->Pun, Scsi->Lun);\r
-}\r
-\r
-/**\r
-  Converts a Fibre device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextFibre (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  FIBRECHANNEL_DEVICE_PATH  *Fibre;\r
-\r
-  Fibre = DevPath;\r
-  CatPrint (Str, L"Fibre(0x%lx,0x%lx)", Fibre->WWN, Fibre->Lun);\r
-}\r
-\r
-/**\r
-  Converts a FibreEx device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextFibreEx (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  FIBRECHANNELEX_DEVICE_PATH  *FibreEx;\r
-  UINTN                       Index;\r
-\r
-  FibreEx = DevPath;\r
-  CatPrint (Str, L"FibreEx(0x");\r
-  for (Index = 0; Index < sizeof (FibreEx->WWN) / sizeof (FibreEx->WWN[0]); Index++) {\r
-    CatPrint (Str, L"%02x", FibreEx->WWN[Index]);\r
-  }\r
-  CatPrint (Str, L",0x");\r
-  for (Index = 0; Index < sizeof (FibreEx->Lun) / sizeof (FibreEx->Lun[0]); Index++) {\r
-    CatPrint (Str, L"%02x", FibreEx->Lun[Index]);\r
-  }\r
-  CatPrint (Str, L")");\r
-}\r
-\r
-/**\r
-  Converts a Sas Ex device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextSasEx (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  SASEX_DEVICE_PATH  *SasEx;\r
-  UINTN              Index;\r
-\r
-  SasEx = DevPath;\r
-  CatPrint (Str, L"SasEx(0x");\r
-\r
-  for (Index = 0; Index < sizeof (SasEx->SasAddress) / sizeof (SasEx->SasAddress[0]); Index++) {\r
-    CatPrint (Str, L"%02x", SasEx->SasAddress[Index]);\r
-  }\r
-  CatPrint (Str, L",0x");\r
-  for (Index = 0; Index < sizeof (SasEx->Lun) / sizeof (SasEx->Lun[0]); Index++) {\r
-    CatPrint (Str, L"%02x", SasEx->Lun[Index]);\r
-  }\r
-  CatPrint (Str, L",0x%x,", SasEx->RelativeTargetPort);\r
-\r
-  if (((SasEx->DeviceTopology & 0x0f) == 0) && ((SasEx->DeviceTopology & BIT7) == 0)) {\r
-    CatPrint (Str, L"NoTopology,0,0,0");\r
-  } else if (((SasEx->DeviceTopology & 0x0f) <= 2) && ((SasEx->DeviceTopology & BIT7) == 0)) {\r
-    CatPrint (\r
-      Str,\r
-      L"%s,%s,%s,",\r
-      ((SasEx->DeviceTopology & BIT4) != 0) ? L"SATA" : L"SAS",\r
-      ((SasEx->DeviceTopology & BIT5) != 0) ? L"External" : L"Internal",\r
-      ((SasEx->DeviceTopology & BIT6) != 0) ? L"Expanded" : L"Direct"\r
-      );\r
-    if ((SasEx->DeviceTopology & 0x0f) == 1) {\r
-      CatPrint (Str, L"0");\r
-    } else {\r
-      //\r
-      // Value 0x0 thru 0xFF -> Drive 1 thru Drive 256\r
-      //\r
-      CatPrint (Str, L"0x%x", ((SasEx->DeviceTopology >> 8) & 0xff) + 1);\r
-    }\r
-  } else {\r
-    CatPrint (Str, L"0x%x,0,0,0", SasEx->DeviceTopology);\r
-  }\r
-\r
-  CatPrint (Str, L")");\r
-  return ;\r
-\r
-}\r
-\r
-/**\r
-  Converts a 1394 device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToText1394 (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  F1394_DEVICE_PATH *F1394DevPath;\r
-\r
-  F1394DevPath = DevPath;\r
-  //\r
-  // Guid has format of IEEE-EUI64\r
-  //\r
-  CatPrint (Str, L"I1394(%016lx)", F1394DevPath->Guid);\r
-}\r
-\r
-/**\r
-  Converts a USB device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextUsb (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  USB_DEVICE_PATH *Usb;\r
-\r
-  Usb = DevPath;\r
-  CatPrint (Str, L"USB(0x%x,0x%x)", Usb->ParentPortNumber, Usb->InterfaceNumber);\r
-}\r
-\r
-/**\r
-  Converts a USB WWID device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextUsbWWID (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  USB_WWID_DEVICE_PATH  *UsbWWId;\r
-  CHAR16                *SerialNumberStr;\r
-  CHAR16                *NewStr;\r
-  UINT16                Length;\r
-\r
-  UsbWWId = DevPath;\r
-\r
-  SerialNumberStr = (CHAR16 *) ((UINT8 *) UsbWWId + sizeof (USB_WWID_DEVICE_PATH));\r
-  Length = (UINT16) ((DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) UsbWWId) - sizeof (USB_WWID_DEVICE_PATH)) / sizeof (CHAR16));\r
-  if (SerialNumberStr [Length - 1] != 0) {\r
-    //\r
-    // In case no NULL terminator in SerialNumber, create a new one with NULL terminator\r
-    //\r
-    NewStr = AllocateCopyPool ((Length + 1) * sizeof (CHAR16), SerialNumberStr);\r
-    ASSERT (NewStr != NULL);\r
-    NewStr [Length] = 0;\r
-    SerialNumberStr = NewStr;\r
-  }\r
-\r
-  CatPrint (\r
-    Str,\r
-    L"UsbWwid(0x%x,0x%x,0x%x,\"%s\")",\r
-    UsbWWId->VendorId,\r
-    UsbWWId->ProductId,\r
-    UsbWWId->InterfaceNumber,\r
-    SerialNumberStr\r
-    );\r
-}\r
-\r
-/**\r
-  Converts a Logic Unit device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextLogicalUnit (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;\r
-\r
-  LogicalUnit = DevPath;\r
-  CatPrint (Str, L"Unit(0x%x)", LogicalUnit->Lun);\r
-}\r
-\r
-/**\r
-  Converts a USB class device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextUsbClass (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  USB_CLASS_DEVICE_PATH *UsbClass;\r
-  BOOLEAN               IsKnownSubClass;\r
-\r
-\r
-  UsbClass = DevPath;\r
-\r
-  IsKnownSubClass = TRUE;\r
-  switch (UsbClass->DeviceClass) {\r
-  case USB_CLASS_AUDIO:\r
-    CatPrint (Str, L"UsbAudio");\r
-    break;\r
-\r
-  case USB_CLASS_CDCCONTROL:\r
-    CatPrint (Str, L"UsbCDCControl");\r
-    break;\r
-\r
-  case USB_CLASS_HID:\r
-    CatPrint (Str, L"UsbHID");\r
-    break;\r
-\r
-  case USB_CLASS_IMAGE:\r
-    CatPrint (Str, L"UsbImage");\r
-    break;\r
-\r
-  case USB_CLASS_PRINTER:\r
-    CatPrint (Str, L"UsbPrinter");\r
-    break;\r
-\r
-  case USB_CLASS_MASS_STORAGE:\r
-    CatPrint (Str, L"UsbMassStorage");\r
-    break;\r
-\r
-  case USB_CLASS_HUB:\r
-    CatPrint (Str, L"UsbHub");\r
-    break;\r
-\r
-  case USB_CLASS_CDCDATA:\r
-    CatPrint (Str, L"UsbCDCData");\r
-    break;\r
-\r
-  case USB_CLASS_SMART_CARD:\r
-    CatPrint (Str, L"UsbSmartCard");\r
-    break;\r
-\r
-  case USB_CLASS_VIDEO:\r
-    CatPrint (Str, L"UsbVideo");\r
-    break;\r
-\r
-  case USB_CLASS_DIAGNOSTIC:\r
-    CatPrint (Str, L"UsbDiagnostic");\r
-    break;\r
-\r
-  case USB_CLASS_WIRELESS:\r
-    CatPrint (Str, L"UsbWireless");\r
-    break;\r
-\r
-  default:\r
-    IsKnownSubClass = FALSE;\r
-    break;\r
-  }\r
-\r
-  if (IsKnownSubClass) {\r
-    CatPrint (\r
-      Str,\r
-      L"(0x%x,0x%x,0x%x,0x%x)",\r
-      UsbClass->VendorId,\r
-      UsbClass->ProductId,\r
-      UsbClass->DeviceSubClass,\r
-      UsbClass->DeviceProtocol\r
-      );\r
-    return;\r
-  }\r
-\r
-  if (UsbClass->DeviceClass == USB_CLASS_RESERVE) {\r
-    if (UsbClass->DeviceSubClass == USB_SUBCLASS_FW_UPDATE) {\r
-      CatPrint (\r
-        Str,\r
-        L"UsbDeviceFirmwareUpdate(0x%x,0x%x,0x%x)",\r
-        UsbClass->VendorId,\r
-        UsbClass->ProductId,\r
-        UsbClass->DeviceProtocol\r
-        );\r
-      return;\r
-    } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_IRDA_BRIDGE) {\r
-      CatPrint (\r
-        Str,\r
-        L"UsbIrdaBridge(0x%x,0x%x,0x%x)",\r
-        UsbClass->VendorId,\r
-        UsbClass->ProductId,\r
-        UsbClass->DeviceProtocol\r
-        );\r
-      return;\r
-    } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_TEST) {\r
-      CatPrint (\r
-        Str,\r
-        L"UsbTestAndMeasurement(0x%x,0x%x,0x%x)",\r
-        UsbClass->VendorId,\r
-        UsbClass->ProductId,\r
-        UsbClass->DeviceProtocol\r
-        );\r
-      return;\r
-    }\r
-  }\r
-\r
-  CatPrint (\r
-    Str,\r
-    L"UsbClass(0x%x,0x%x,0x%x,0x%x,0x%x)",\r
-    UsbClass->VendorId,\r
-    UsbClass->ProductId,\r
-    UsbClass->DeviceClass,\r
-    UsbClass->DeviceSubClass,\r
-    UsbClass->DeviceProtocol\r
-    );\r
-}\r
-\r
-/**\r
-  Converts a SATA device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextSata (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  SATA_DEVICE_PATH *Sata;\r
-\r
-  Sata = DevPath;\r
-  if ((Sata->PortMultiplierPortNumber & SATA_HBA_DIRECT_CONNECT_FLAG) != 0) {\r
-    CatPrint (\r
-      Str,\r
-      L"Sata(0x%x,0x%x)",\r
-      Sata->HBAPortNumber,\r
-      Sata->Lun\r
-      );\r
-  } else {\r
-    CatPrint (\r
-      Str,\r
-      L"Sata(0x%x,0x%x,0x%x)",\r
-      Sata->HBAPortNumber,\r
-      Sata->PortMultiplierPortNumber,\r
-      Sata->Lun\r
-      );\r
-  }\r
-}\r
-\r
-/**\r
-  Converts a I20 device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextI2O (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  I2O_DEVICE_PATH *I2ODevPath;\r
-\r
-  I2ODevPath = DevPath;\r
-  CatPrint (Str, L"I2O(0x%x)", I2ODevPath->Tid);\r
-}\r
-\r
-/**\r
-  Converts a MAC address device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextMacAddr (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  MAC_ADDR_DEVICE_PATH  *MacDevPath;\r
-  UINTN                 HwAddressSize;\r
-  UINTN                 Index;\r
-\r
-  MacDevPath = DevPath;\r
-\r
-  HwAddressSize = sizeof (EFI_MAC_ADDRESS);\r
-  if (MacDevPath->IfType == 0x01 || MacDevPath->IfType == 0x00) {\r
-    HwAddressSize = 6;\r
-  }\r
-\r
-  CatPrint (Str, L"MAC(");\r
-\r
-  for (Index = 0; Index < HwAddressSize; Index++) {\r
-    CatPrint (Str, L"%02x", MacDevPath->MacAddress.Addr[Index]);\r
-  }\r
-\r
-  CatPrint (Str, L",0x%x)", MacDevPath->IfType);\r
-}\r
-\r
-/**\r
-  Converts network protocol string to its text representation.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param Protocol        The network protocol ID.\r
-\r
-**/\r
-VOID\r
-CatNetworkProtocol (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN UINT16          Protocol\r
-  )\r
-{\r
-  if (Protocol == RFC_1700_TCP_PROTOCOL) {\r
-    CatPrint (Str, L"TCP");\r
-  } else if (Protocol == RFC_1700_UDP_PROTOCOL) {\r
-    CatPrint (Str, L"UDP");\r
-  } else {\r
-    CatPrint (Str, L"0x%x", Protocol);\r
-  }\r
-}\r
-\r
-/**\r
-  Converts a IPv4 device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextIPv4 (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  IPv4_DEVICE_PATH  *IPDevPath;\r
-\r
-  IPDevPath = DevPath;\r
-  if (DisplayOnly) {\r
-    CatPrint (\r
-      Str,\r
-      L"IPv4(%d.%d.%d.%d)",\r
-      IPDevPath->RemoteIpAddress.Addr[0],\r
-      IPDevPath->RemoteIpAddress.Addr[1],\r
-      IPDevPath->RemoteIpAddress.Addr[2],\r
-      IPDevPath->RemoteIpAddress.Addr[3]\r
-      );\r
-    return ;\r
-  }\r
-\r
-  CatPrint (\r
-    Str,\r
-    L"IPv4(%d.%d.%d.%d,",\r
-    IPDevPath->RemoteIpAddress.Addr[0],\r
-    IPDevPath->RemoteIpAddress.Addr[1],\r
-    IPDevPath->RemoteIpAddress.Addr[2],\r
-    IPDevPath->RemoteIpAddress.Addr[3]\r
-    );\r
-\r
-  CatNetworkProtocol (\r
-    Str,\r
-    IPDevPath->Protocol\r
-    );\r
-\r
-  CatPrint (\r
-    Str,\r
-    L",%s,%d.%d.%d.%d",\r
-    IPDevPath->StaticIpAddress ? L"Static" : L"DHCP",\r
-    IPDevPath->LocalIpAddress.Addr[0],\r
-    IPDevPath->LocalIpAddress.Addr[1],\r
-    IPDevPath->LocalIpAddress.Addr[2],\r
-    IPDevPath->LocalIpAddress.Addr[3]\r
-    );\r
-  if (DevicePathNodeLength (IPDevPath) == sizeof (IPv4_DEVICE_PATH)) {\r
-    CatPrint (\r
-      Str,\r
-      L",%d.%d.%d.%d,%d.%d.%d.%d",\r
-      IPDevPath->GatewayIpAddress.Addr[0],\r
-      IPDevPath->GatewayIpAddress.Addr[1],\r
-      IPDevPath->GatewayIpAddress.Addr[2],\r
-      IPDevPath->GatewayIpAddress.Addr[3],\r
-      IPDevPath->SubnetMask.Addr[0],\r
-      IPDevPath->SubnetMask.Addr[1],\r
-      IPDevPath->SubnetMask.Addr[2],\r
-      IPDevPath->SubnetMask.Addr[3]\r
-      );\r
-  }\r
-  CatPrint (Str, L")");\r
-}\r
-\r
-/**\r
-  Converts a IPv6 device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextIPv6 (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  IPv6_DEVICE_PATH  *IPDevPath;\r
-\r
-  IPDevPath = DevPath;\r
-  if (DisplayOnly) {\r
-    CatPrint (\r
-      Str,\r
-      L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",\r
-      IPDevPath->RemoteIpAddress.Addr[0],\r
-      IPDevPath->RemoteIpAddress.Addr[1],\r
-      IPDevPath->RemoteIpAddress.Addr[2],\r
-      IPDevPath->RemoteIpAddress.Addr[3],\r
-      IPDevPath->RemoteIpAddress.Addr[4],\r
-      IPDevPath->RemoteIpAddress.Addr[5],\r
-      IPDevPath->RemoteIpAddress.Addr[6],\r
-      IPDevPath->RemoteIpAddress.Addr[7],\r
-      IPDevPath->RemoteIpAddress.Addr[8],\r
-      IPDevPath->RemoteIpAddress.Addr[9],\r
-      IPDevPath->RemoteIpAddress.Addr[10],\r
-      IPDevPath->RemoteIpAddress.Addr[11],\r
-      IPDevPath->RemoteIpAddress.Addr[12],\r
-      IPDevPath->RemoteIpAddress.Addr[13],\r
-      IPDevPath->RemoteIpAddress.Addr[14],\r
-      IPDevPath->RemoteIpAddress.Addr[15]\r
-      );\r
-    return ;\r
-  }\r
-\r
-  CatPrint (\r
-    Str,\r
-    L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x,",\r
-    IPDevPath->RemoteIpAddress.Addr[0],\r
-    IPDevPath->RemoteIpAddress.Addr[1],\r
-    IPDevPath->RemoteIpAddress.Addr[2],\r
-    IPDevPath->RemoteIpAddress.Addr[3],\r
-    IPDevPath->RemoteIpAddress.Addr[4],\r
-    IPDevPath->RemoteIpAddress.Addr[5],\r
-    IPDevPath->RemoteIpAddress.Addr[6],\r
-    IPDevPath->RemoteIpAddress.Addr[7],\r
-    IPDevPath->RemoteIpAddress.Addr[8],\r
-    IPDevPath->RemoteIpAddress.Addr[9],\r
-    IPDevPath->RemoteIpAddress.Addr[10],\r
-    IPDevPath->RemoteIpAddress.Addr[11],\r
-    IPDevPath->RemoteIpAddress.Addr[12],\r
-    IPDevPath->RemoteIpAddress.Addr[13],\r
-    IPDevPath->RemoteIpAddress.Addr[14],\r
-    IPDevPath->RemoteIpAddress.Addr[15]\r
-    );\r
-    \r
-  CatNetworkProtocol (\r
-    Str,\r
-    IPDevPath->Protocol\r
-    );\r
-\r
-  switch (IPDevPath->IpAddressOrigin) {\r
-    case 0:\r
-      CatPrint (Str, L",Static");\r
-      break;\r
-    case 1:\r
-      CatPrint (Str, L",StatelessAutoConfigure");\r
-      break;\r
-    default:\r
-      CatPrint (Str, L",StatefulAutoConfigure");\r
-      break;\r
-  }\r
-\r
-  CatPrint (\r
-    Str,\r
-    L",%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",\r
-    IPDevPath->LocalIpAddress.Addr[0],\r
-    IPDevPath->LocalIpAddress.Addr[1],\r
-    IPDevPath->LocalIpAddress.Addr[2],\r
-    IPDevPath->LocalIpAddress.Addr[3],\r
-    IPDevPath->LocalIpAddress.Addr[4],\r
-    IPDevPath->LocalIpAddress.Addr[5],\r
-    IPDevPath->LocalIpAddress.Addr[6],\r
-    IPDevPath->LocalIpAddress.Addr[7],\r
-    IPDevPath->LocalIpAddress.Addr[8],\r
-    IPDevPath->LocalIpAddress.Addr[9],\r
-    IPDevPath->LocalIpAddress.Addr[10],\r
-    IPDevPath->LocalIpAddress.Addr[11],\r
-    IPDevPath->LocalIpAddress.Addr[12],\r
-    IPDevPath->LocalIpAddress.Addr[13],\r
-    IPDevPath->LocalIpAddress.Addr[14],\r
-    IPDevPath->LocalIpAddress.Addr[15]\r
-    );\r
-\r
-  if (DevicePathNodeLength (IPDevPath) == sizeof (IPv6_DEVICE_PATH)) {\r
-    CatPrint (\r
-      Str,\r
-      L",0x%x,%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",\r
-      IPDevPath->PrefixLength,\r
-      IPDevPath->GatewayIpAddress.Addr[0],\r
-      IPDevPath->GatewayIpAddress.Addr[1],\r
-      IPDevPath->GatewayIpAddress.Addr[2],\r
-      IPDevPath->GatewayIpAddress.Addr[3],\r
-      IPDevPath->GatewayIpAddress.Addr[4],\r
-      IPDevPath->GatewayIpAddress.Addr[5],\r
-      IPDevPath->GatewayIpAddress.Addr[6],\r
-      IPDevPath->GatewayIpAddress.Addr[7],\r
-      IPDevPath->GatewayIpAddress.Addr[8],\r
-      IPDevPath->GatewayIpAddress.Addr[9],\r
-      IPDevPath->GatewayIpAddress.Addr[10],\r
-      IPDevPath->GatewayIpAddress.Addr[11],\r
-      IPDevPath->GatewayIpAddress.Addr[12],\r
-      IPDevPath->GatewayIpAddress.Addr[13],\r
-      IPDevPath->GatewayIpAddress.Addr[14],\r
-      IPDevPath->GatewayIpAddress.Addr[15]\r
-      );\r
-  }\r
-  CatPrint (Str, L")");\r
-}\r
-\r
-/**\r
-  Converts an Infini Band device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextInfiniBand (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  INFINIBAND_DEVICE_PATH  *InfiniBand;\r
-\r
-  InfiniBand = DevPath;\r
-  CatPrint (\r
-    Str,\r
-    L"Infiniband(0x%x,%g,0x%lx,0x%lx,0x%lx)",\r
-    InfiniBand->ResourceFlags,\r
-    InfiniBand->PortGid,\r
-    InfiniBand->ServiceId,\r
-    InfiniBand->TargetPortId,\r
-    InfiniBand->DeviceId\r
-    );\r
-}\r
-\r
-/**\r
-  Converts a UART device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextUart (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  UART_DEVICE_PATH  *Uart;\r
-  CHAR8             Parity;\r
-\r
-  Uart = DevPath;\r
-  switch (Uart->Parity) {\r
-  case 0:\r
-    Parity = 'D';\r
-    break;\r
-\r
-  case 1:\r
-    Parity = 'N';\r
-    break;\r
-\r
-  case 2:\r
-    Parity = 'E';\r
-    break;\r
-\r
-  case 3:\r
-    Parity = 'O';\r
-    break;\r
-\r
-  case 4:\r
-    Parity = 'M';\r
-    break;\r
-\r
-  case 5:\r
-    Parity = 'S';\r
-    break;\r
-\r
-  default:\r
-    Parity = 'x';\r
-    break;\r
-  }\r
-\r
-  if (Uart->BaudRate == 0) {\r
-    CatPrint (Str, L"Uart(DEFAULT,");\r
-  } else {\r
-    CatPrint (Str, L"Uart(%ld,", Uart->BaudRate);\r
-  }\r
-\r
-  if (Uart->DataBits == 0) {\r
-    CatPrint (Str, L"DEFAULT,");\r
-  } else {\r
-    CatPrint (Str, L"%d,", Uart->DataBits);\r
-  }\r
-\r
-  CatPrint (Str, L"%c,", Parity);\r
-\r
-  switch (Uart->StopBits) {\r
-  case 0:\r
-    CatPrint (Str, L"D)");\r
-    break;\r
-\r
-  case 1:\r
-    CatPrint (Str, L"1)");\r
-    break;\r
-\r
-  case 2:\r
-    CatPrint (Str, L"1.5)");\r
-    break;\r
-\r
-  case 3:\r
-    CatPrint (Str, L"2)");\r
-    break;\r
-\r
-  default:\r
-    CatPrint (Str, L"x)");\r
-    break;\r
-  }\r
-}\r
-\r
-/**\r
-  Converts an iSCSI device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextiSCSI (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;\r
-  UINT16                      Options;\r
-\r
-  ISCSIDevPath = DevPath;\r
-  CatPrint (\r
-    Str,\r
-    L"iSCSI(%a,0x%x,0x%lx,",\r
-    ISCSIDevPath->TargetName,\r
-    ISCSIDevPath->TargetPortalGroupTag,\r
-    ISCSIDevPath->Lun\r
-    );\r
-\r
-  Options = ISCSIDevPath->LoginOption;\r
-  CatPrint (Str, L"%s,", (((Options >> 1) & 0x0001) != 0) ? L"CRC32C" : L"None");\r
-  CatPrint (Str, L"%s,", (((Options >> 3) & 0x0001) != 0) ? L"CRC32C" : L"None");\r
-  if (((Options >> 11) & 0x0001) != 0) {\r
-    CatPrint (Str, L"%s,", L"None");\r
-  } else if (((Options >> 12) & 0x0001) != 0) {\r
-    CatPrint (Str, L"%s,", L"CHAP_UNI");\r
-  } else {\r
-    CatPrint (Str, L"%s,", L"CHAP_BI");\r
-\r
-  }\r
-\r
-  CatPrint (Str, L"%s)", (ISCSIDevPath->NetworkProtocol == 0) ? L"TCP" : L"reserved");\r
-}\r
-\r
-/**\r
-  Converts a VLAN device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextVlan (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  VLAN_DEVICE_PATH  *Vlan;\r
-\r
-  Vlan = DevPath;\r
-  CatPrint (Str, L"Vlan(%d)", Vlan->VlanId);\r
-}\r
-\r
-/**\r
-  Converts a Hard drive device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextHardDrive (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  HARDDRIVE_DEVICE_PATH *Hd;\r
-\r
-  Hd = DevPath;\r
-  switch (Hd->SignatureType) {\r
-  case SIGNATURE_TYPE_MBR:\r
-    CatPrint (\r
-      Str,\r
-      L"HD(%d,%s,0x%08x,",\r
-      Hd->PartitionNumber,\r
-      L"MBR",\r
-      *((UINT32 *) (&(Hd->Signature[0])))\r
-      );\r
-    break;\r
-\r
-  case SIGNATURE_TYPE_GUID:\r
-    CatPrint (\r
-      Str,\r
-      L"HD(%d,%s,%g,",\r
-      Hd->PartitionNumber,\r
-      L"GPT",\r
-      (EFI_GUID *) &(Hd->Signature[0])\r
-      );\r
-    break;\r
-\r
-  default:\r
-    CatPrint (\r
-      Str,\r
-      L"HD(%d,%d,0,",\r
-      Hd->PartitionNumber,\r
-      Hd->SignatureType\r
-      );\r
-    break;\r
-  }\r
-\r
-  CatPrint (Str, L"0x%lx,0x%lx)", Hd->PartitionStart, Hd->PartitionSize);\r
-}\r
-\r
-/**\r
-  Converts a CDROM device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextCDROM (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  CDROM_DEVICE_PATH *Cd;\r
-\r
-  Cd = DevPath;\r
-  if (DisplayOnly) {\r
-    CatPrint (Str, L"CDROM(0x%x)", Cd->BootEntry);\r
-    return ;\r
-  }\r
-\r
-  CatPrint (Str, L"CDROM(0x%x,0x%lx,0x%lx)", Cd->BootEntry, Cd->PartitionStart, Cd->PartitionSize);\r
-}\r
-\r
-/**\r
-  Converts a File device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextFilePath (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  FILEPATH_DEVICE_PATH  *Fp;\r
-\r
-  Fp = DevPath;\r
-  CatPrint (Str, L"%s", Fp->PathName);\r
-}\r
-\r
-/**\r
-  Converts a Media protocol device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextMediaProtocol (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  MEDIA_PROTOCOL_DEVICE_PATH  *MediaProt;\r
-\r
-  MediaProt = DevPath;\r
-  CatPrint (Str, L"Media(%g)", &MediaProt->Protocol);\r
-}\r
-\r
-/**\r
-  Converts a Firmware Volume device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextFv (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  MEDIA_FW_VOL_DEVICE_PATH  *Fv;\r
-\r
-  Fv = DevPath;\r
-  CatPrint (Str, L"Fv(%g)", &Fv->FvName);\r
-}\r
-\r
-/**\r
-  Converts a Firmware Volume File device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextFvFile (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH  *FvFile;\r
-\r
-  FvFile = DevPath;\r
-  CatPrint (Str, L"FvFile(%g)", &FvFile->FvFileName);\r
-}\r
-\r
-/**\r
-  Converts a Relative Offset device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathRelativeOffsetRange (\r
-  IN OUT POOL_PRINT       *Str,\r
-  IN VOID                 *DevPath,\r
-  IN BOOLEAN              DisplayOnly,\r
-  IN BOOLEAN              AllowShortcuts\r
-  )\r
-{\r
-  MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset;\r
-\r
-  Offset = DevPath;\r
-  CatPrint (\r
-    Str,\r
-    L"Offset(0x%lx,0x%lx)",\r
-    Offset->StartingOffset,\r
-    Offset->EndingOffset\r
-    );\r
-}\r
-\r
-/**\r
-  Converts a BIOS Boot Specification device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextBBS (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  BBS_BBS_DEVICE_PATH *Bbs;\r
-  CHAR16              *Type;\r
-\r
-  Bbs = DevPath;\r
-  switch (Bbs->DeviceType) {\r
-  case BBS_TYPE_FLOPPY:\r
-    Type = L"Floppy";\r
-    break;\r
-\r
-  case BBS_TYPE_HARDDRIVE:\r
-    Type = L"HD";\r
-    break;\r
-\r
-  case BBS_TYPE_CDROM:\r
-    Type = L"CDROM";\r
-    break;\r
-\r
-  case BBS_TYPE_PCMCIA:\r
-    Type = L"PCMCIA";\r
-    break;\r
-\r
-  case BBS_TYPE_USB:\r
-    Type = L"USB";\r
-    break;\r
-\r
-  case BBS_TYPE_EMBEDDED_NETWORK:\r
-    Type = L"Network";\r
-    break;\r
-\r
-  default:\r
-    Type = NULL;\r
-    break;\r
-  }\r
-\r
-  if (Type != NULL) {\r
-    CatPrint (Str, L"BBS(%s,%a", Type, Bbs->String);\r
-  } else {\r
-    CatPrint (Str, L"BBS(0x%x,%a", Bbs->DeviceType, Bbs->String);\r
-  }\r
-\r
-  if (DisplayOnly) {\r
-    CatPrint (Str, L")");\r
-    return ;\r
-  }\r
-\r
-  CatPrint (Str, L",0x%x)", Bbs->StatusFlag);\r
-}\r
-\r
-/**\r
-  Converts an End-of-Device-Path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextEndInstance (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  CatPrint (Str, L",");\r
-}\r
-\r
-/**\r
-  Converts an unknown device path structure to its string representative.\r
-\r
-  @param Str             The string representative of input device.\r
-  @param DevPath         The input device path structure.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-**/\r
-VOID\r
-DevPathToTextNodeUnknown (\r
-  IN OUT POOL_PRINT  *Str,\r
-  IN VOID            *DevPath,\r
-  IN BOOLEAN         DisplayOnly,\r
-  IN BOOLEAN         AllowShortcuts\r
-  )\r
-{\r
-  CatPrint (Str, L"?");\r
-}\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE DevPathToTextTable[] = {\r
-  {HARDWARE_DEVICE_PATH, HW_PCI_DP, DevPathToTextPci},\r
-  {HARDWARE_DEVICE_PATH, HW_PCCARD_DP, DevPathToTextPccard},\r
-  {HARDWARE_DEVICE_PATH, HW_MEMMAP_DP, DevPathToTextMemMap},\r
-  {HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DevPathToTextVendor},\r
-  {HARDWARE_DEVICE_PATH, HW_CONTROLLER_DP, DevPathToTextController},\r
-  {ACPI_DEVICE_PATH, ACPI_DP, DevPathToTextAcpi},\r
-  {ACPI_DEVICE_PATH, ACPI_EXTENDED_DP, DevPathToTextAcpiEx},\r
-  {ACPI_DEVICE_PATH, ACPI_ADR_DP, DevPathToTextAcpiAdr},\r
-  {MESSAGING_DEVICE_PATH, MSG_ATAPI_DP, DevPathToTextAtapi},\r
-  {MESSAGING_DEVICE_PATH, MSG_SCSI_DP, DevPathToTextScsi},\r
-  {MESSAGING_DEVICE_PATH, MSG_FIBRECHANNEL_DP, DevPathToTextFibre},\r
-  {MESSAGING_DEVICE_PATH, MSG_FIBRECHANNELEX_DP, DevPathToTextFibreEx},\r
-  {MESSAGING_DEVICE_PATH, MSG_SASEX_DP, DevPathToTextSasEx},\r
-  {MESSAGING_DEVICE_PATH, MSG_1394_DP, DevPathToText1394},\r
-  {MESSAGING_DEVICE_PATH, MSG_USB_DP, DevPathToTextUsb},\r
-  {MESSAGING_DEVICE_PATH, MSG_USB_WWID_DP, DevPathToTextUsbWWID},\r
-  {MESSAGING_DEVICE_PATH, MSG_DEVICE_LOGICAL_UNIT_DP, DevPathToTextLogicalUnit},\r
-  {MESSAGING_DEVICE_PATH, MSG_USB_CLASS_DP, DevPathToTextUsbClass},\r
-  {MESSAGING_DEVICE_PATH, MSG_SATA_DP, DevPathToTextSata},\r
-  {MESSAGING_DEVICE_PATH, MSG_I2O_DP, DevPathToTextI2O},\r
-  {MESSAGING_DEVICE_PATH, MSG_MAC_ADDR_DP, DevPathToTextMacAddr},\r
-  {MESSAGING_DEVICE_PATH, MSG_IPv4_DP, DevPathToTextIPv4},\r
-  {MESSAGING_DEVICE_PATH, MSG_IPv6_DP, DevPathToTextIPv6},\r
-  {MESSAGING_DEVICE_PATH, MSG_INFINIBAND_DP, DevPathToTextInfiniBand},\r
-  {MESSAGING_DEVICE_PATH, MSG_UART_DP, DevPathToTextUart},\r
-  {MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, DevPathToTextVendor},\r
-  {MESSAGING_DEVICE_PATH, MSG_ISCSI_DP, DevPathToTextiSCSI},\r
-  {MESSAGING_DEVICE_PATH, MSG_VLAN_DP, DevPathToTextVlan},\r
-  {MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, DevPathToTextHardDrive},\r
-  {MEDIA_DEVICE_PATH, MEDIA_CDROM_DP, DevPathToTextCDROM},\r
-  {MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP, DevPathToTextVendor},\r
-  {MEDIA_DEVICE_PATH, MEDIA_PROTOCOL_DP, DevPathToTextMediaProtocol},\r
-  {MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP, DevPathToTextFilePath},\r
-  {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_VOL_DP, DevPathToTextFv},\r
-  {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_FILE_DP, DevPathToTextFvFile},\r
-  {MEDIA_DEVICE_PATH, MEDIA_RELATIVE_OFFSET_RANGE_DP, DevPathRelativeOffsetRange},\r
-  {BBS_DEVICE_PATH, BBS_BBS_DP, DevPathToTextBBS},\r
-  {END_DEVICE_PATH_TYPE, END_INSTANCE_DEVICE_PATH_SUBTYPE, DevPathToTextEndInstance},\r
-  {0, 0, NULL}\r
-};\r
-\r
-/**\r
-  Converts a device node to its string representation.\r
-\r
-  @param DeviceNode        A Pointer to the device node to be converted.\r
-  @param DisplayOnly       If DisplayOnly is TRUE, then the shorter text representation\r
-                           of the display node is used, where applicable. If DisplayOnly\r
-                           is FALSE, then the longer text representation of the display node\r
-                           is used.\r
-  @param AllowShortcuts    If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                           representation for a device node can be used, where applicable.\r
-\r
-  @return A pointer to the allocated text representation of the device node or NULL if DeviceNode\r
-          is NULL or there was insufficient memory.\r
-\r
-**/\r
-CHAR16 *\r
-EFIAPI\r
-ConvertDeviceNodeToText (\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DeviceNode,\r
-  IN BOOLEAN                         DisplayOnly,\r
-  IN BOOLEAN                         AllowShortcuts\r
-  )\r
-{\r
-  POOL_PRINT  Str;\r
-  UINTN       Index;\r
-  VOID        (*DumpNode)(POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);\r
-\r
-  if (DeviceNode == NULL) {\r
-    return NULL;\r
-  }\r
-\r
-  ZeroMem (&Str, sizeof (Str));\r
-\r
-  //\r
-  // Process the device path node\r
-  //\r
-  DumpNode = NULL;\r
-  for (Index = 0; DevPathToTextTable[Index].Function != NULL; Index++) {\r
-    if (DevicePathType (DeviceNode) == DevPathToTextTable[Index].Type &&\r
-        DevicePathSubType (DeviceNode) == DevPathToTextTable[Index].SubType\r
-        ) {\r
-      DumpNode = DevPathToTextTable[Index].Function;\r
-      break;\r
-    }\r
-  }\r
-  //\r
-  // If not found, use a generic function\r
-  //\r
-  if (DumpNode == NULL) {\r
-    DumpNode = DevPathToTextNodeUnknown;\r
-  }\r
-\r
-  //\r
-  // Print this node\r
-  //\r
-  DumpNode (&Str, (VOID *) DeviceNode, DisplayOnly, AllowShortcuts);\r
-\r
-  ASSERT (Str.Str != NULL);\r
-  return Str.Str;\r
-}\r
-\r
-/**\r
-  Converts a device path to its text representation.\r
-\r
-  @param DevicePath      A Pointer to the device to be converted.\r
-  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
-                         of the display node is used, where applicable. If DisplayOnly\r
-                         is FALSE, then the longer text representation of the display node\r
-                         is used.\r
-  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
-                         representation for a device node can be used, where applicable.\r
-\r
-  @return A pointer to the allocated text representation of the device path or\r
-          NULL if DeviceNode is NULL or there was insufficient memory.\r
-\r
-**/\r
-CHAR16 *\r
-EFIAPI\r
-ConvertDevicePathToText (\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL   *DevicePath,\r
-  IN BOOLEAN                          DisplayOnly,\r
-  IN BOOLEAN                          AllowShortcuts\r
-  )\r
-{\r
-  POOL_PRINT                Str;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevPathNode;\r
-  EFI_DEVICE_PATH_PROTOCOL  *AlignedDevPathNode;\r
-  UINTN                     Index;\r
-  VOID                      (*DumpNode) (POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);\r
-\r
-  if (DevicePath == NULL) {\r
-    return NULL;\r
-  }\r
-\r
-  ZeroMem (&Str, sizeof (Str));\r
-\r
-  //\r
-  // Process each device path node\r
-  //\r
-  DevPathNode = (EFI_DEVICE_PATH_PROTOCOL *) DevicePath;\r
-  while (!IsDevicePathEnd (DevPathNode)) {\r
-    //\r
-    // Find the handler to dump this device path node\r
-    //\r
-    DumpNode = NULL;\r
-    for (Index = 0; DevPathToTextTable[Index].Function != NULL; Index += 1) {\r
-\r
-      if (DevicePathType (DevPathNode) == DevPathToTextTable[Index].Type &&\r
-          DevicePathSubType (DevPathNode) == DevPathToTextTable[Index].SubType\r
-          ) {\r
-        DumpNode = DevPathToTextTable[Index].Function;\r
-        break;\r
-      }\r
-    }\r
-    //\r
-    // If not found, use a generic function\r
-    //\r
-    if (!DumpNode) {\r
-      DumpNode = DevPathToTextNodeUnknown;\r
-    }\r
-    //\r
-    //  Put a path separator in if needed\r
-    //\r
-    if ((Str.Length != 0) && (DumpNode != DevPathToTextEndInstance)) {\r
-      if (*(Str.Str + Str.Length / sizeof (CHAR16) - 1) != L',') {\r
-        CatPrint (&Str, L"/");\r
-      }\r
-    }\r
-    \r
-    AlignedDevPathNode = AllocateCopyPool (DevicePathNodeLength (DevPathNode), DevPathNode);\r
-    //\r
-    // Print this node of the device path\r
-    //\r
-    DumpNode (&Str, AlignedDevPathNode, DisplayOnly, AllowShortcuts);\r
-    FreePool (AlignedDevPathNode);\r
-    \r
-    //\r
-    // Next device path node\r
-    //\r
-    DevPathNode = NextDevicePathNode (DevPathNode);\r
-  }\r
-\r
-  if (Str.Str == NULL) {\r
-    return AllocateZeroPool (sizeof (CHAR16));\r
-  } else {\r
-    return Str.Str;\r
-  }\r
-}\r
diff --git a/MdeModulePkg/Universal/DevicePathDxe/DevicePathUtilities.c b/MdeModulePkg/Universal/DevicePathDxe/DevicePathUtilities.c
deleted file mode 100644 (file)
index 78b2670..0000000
+++ /dev/null
@@ -1,234 +0,0 @@
-/** @file\r
-  Implementation file for Device Path Utilities Protocol\r
-\r
-Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "DevicePath.h"\r
-\r
-/**\r
-  Returns the size of a device path in bytes.\r
-\r
-  This function returns the size, in bytes, of the device path data structure specified by\r
-  DevicePath including the end of device path node.  If DevicePath is NULL, then 0 is returned.\r
-\r
-  @param  DevicePath                 A pointer to a device path data structure.\r
-\r
-  @return The size of a device path in bytes.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-GetDevicePathSizeProtocolInterface (\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
-  )\r
-{\r
-  return GetDevicePathSize (DevicePath);\r
-}\r
-\r
-\r
-/**\r
-  Creates a new device path by appending a second device path to a first device path.\r
-\r
-  This function allocates space for a new copy of the device path specified by DevicePath.  If\r
-  DevicePath is NULL, then NULL is returned.  If the memory is successfully allocated, then the\r
-  contents of DevicePath are copied to the newly allocated buffer, and a pointer to that buffer\r
-  is returned.  Otherwise, NULL is returned.\r
-\r
-  @param  DevicePath                 A pointer to a device path data structure.\r
-\r
-  @return A pointer to the duplicated device path.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-EFIAPI\r
-DuplicateDevicePathProtocolInterface (\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
-  )\r
-{\r
-  return DuplicateDevicePath (DevicePath);\r
-}\r
-\r
-/**\r
-  Creates a new device path by appending a second device path to a first device path.\r
-\r
-  This function creates a new device path by appending a copy of SecondDevicePath to a copy of\r
-  FirstDevicePath in a newly allocated buffer.  Only the end-of-device-path device node from\r
-  SecondDevicePath is retained. The newly created device path is returned.\r
-  If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned.\r
-  If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned.\r
-  If both FirstDevicePath and SecondDevicePath are NULL, then a copy of an end-of-device-path is\r
-  returned.\r
-  If there is not enough memory for the newly allocated buffer, then NULL is returned.\r
-  The memory for the new device path is allocated from EFI boot services memory. It is the\r
-  responsibility of the caller to free the memory allocated.\r
-\r
-  @param  FirstDevicePath            A pointer to a device path data structure.\r
-  @param  SecondDevicePath           A pointer to a device path data structure.\r
-\r
-  @return A pointer to the new device path.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-EFIAPI\r
-AppendDevicePathProtocolInterface (\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath,\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath\r
-  )\r
-{\r
-  return AppendDevicePath (FirstDevicePath, SecondDevicePath);\r
-}\r
-\r
-/**\r
-  Creates a new path by appending the device node to the device path.\r
-\r
-  This function creates a new device path by appending a copy of the device node specified by\r
-  DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer.\r
-  The end-of-device-path device node is moved after the end of the appended device node.\r
-  If DevicePathNode is NULL then a copy of DevicePath is returned.\r
-  If DevicePath is NULL then a copy of DevicePathNode, followed by an end-of-device path device\r
-  node is returned.\r
-  If both DevicePathNode and DevicePath are NULL then a copy of an end-of-device-path device node\r
-  is returned.\r
-  If there is not enough memory to allocate space for the new device path, then NULL is returned.\r
-  The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
-  free the memory allocated.\r
-\r
-  @param  DevicePath                 A pointer to a device path data structure.\r
-  @param  DevicePathNode             A pointer to a single device path node.\r
-\r
-  @return A pointer to the new device path.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-EFIAPI\r
-AppendDeviceNodeProtocolInterface (\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode\r
-  )\r
-{\r
-  return AppendDevicePathNode (DevicePath, DevicePathNode);\r
-}\r
-\r
-/**\r
-  Creates a new device path by appending the specified device path instance to the specified device\r
-  path.\r
-\r
-  This function creates a new device path by appending a copy of the device path instance specified\r
-  by DevicePathInstance to a copy of the device path specified by DevicePath in a allocated buffer.\r
-  The end-of-device-path device node is moved after the end of the appended device path instance\r
-  and a new end-of-device-path-instance node is inserted between.\r
-  If DevicePath is NULL, then a copy if DevicePathInstance is returned.\r
-  If DevicePathInstance is NULL, then NULL is returned.\r
-  If there is not enough memory to allocate space for the new device path, then NULL is returned.\r
-  The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
-  free the memory allocated.\r
-\r
-  @param  DevicePath                 A pointer to a device path data structure.\r
-  @param  DevicePathInstance         A pointer to a device path instance.\r
-\r
-  @return A pointer to the new device path.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-EFIAPI\r
-AppendDevicePathInstanceProtocolInterface (\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance\r
-  )\r
-{\r
-  return AppendDevicePathInstance (DevicePath, DevicePathInstance);\r
-}\r
-\r
-/**\r
-  Creates a copy of the current device path instance and returns a pointer to the next device path\r
-  instance.\r
-\r
-  This function creates a copy of the current device path instance. It also updates DevicePath to\r
-  point to the next device path instance in the device path (or NULL if no more) and updates Size\r
-  to hold the size of the device path instance copy.\r
-  If DevicePath is NULL, then NULL is returned.\r
-  If there is not enough memory to allocate space for the new device path, then NULL is returned.\r
-  The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
-  free the memory allocated.\r
-  If Size is NULL, then ASSERT().\r
-\r
-  @param  DevicePath                 On input, this holds the pointer to the current device path\r
-                                     instance. On output, this holds the pointer to the next device\r
-                                     path instance or NULL if there are no more device path\r
-                                     instances in the device path pointer to a device path data\r
-                                     structure.\r
-  @param  Size                       On output, this holds the size of the device path instance, in\r
-                                     bytes or zero, if DevicePath is NULL.\r
-\r
-  @return A pointer to the current device path instance.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-EFIAPI\r
-GetNextDevicePathInstanceProtocolInterface (\r
-  IN OUT EFI_DEVICE_PATH_PROTOCOL   **DevicePath,\r
-  OUT UINTN                         *Size\r
-  )\r
-{\r
-  return GetNextDevicePathInstance (DevicePath, Size);\r
-}\r
-\r
-/**\r
-  Determines if a device path is single or multi-instance.\r
-\r
-  This function returns TRUE if the device path specified by DevicePath is multi-instance.\r
-  Otherwise, FALSE is returned.  If DevicePath is NULL, then FALSE is returned.\r
-\r
-  @param  DevicePath                 A pointer to a device path data structure.\r
-\r
-  @retval  TRUE                      DevicePath is multi-instance.\r
-  @retval  FALSE                     DevicePath is not multi-instance or DevicePath is NULL.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-IsDevicePathMultiInstanceProtocolInterface (\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
-  )\r
-{\r
-  return IsDevicePathMultiInstance (DevicePath);\r
-}\r
-\r
-/**\r
-  Creates a copy of the current device path instance and returns a pointer to the next device path\r
-  instance.\r
-\r
-  This function creates a new device node in a newly allocated buffer of size NodeLength and\r
-  initializes the device path node header with NodeType and NodeSubType.  The new device path node\r
-  is returned.\r
-  If NodeLength is smaller than a device path header, then NULL is returned.\r
-  If there is not enough memory to allocate space for the new device path, then NULL is returned.\r
-  The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
-  free the memory allocated.\r
-\r
-  @param  NodeType                   The device node type for the new device node.\r
-  @param  NodeSubType                The device node sub-type for the new device node.\r
-  @param  NodeLength                 The length of the new device node.\r
-\r
-  @return The new device path.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-EFIAPI\r
-CreateDeviceNodeProtocolInterface (\r
-  IN UINT8  NodeType,\r
-  IN UINT8  NodeSubType,\r
-  IN UINT16 NodeLength\r
-  )\r
-{\r
-  return CreateDeviceNode (NodeType, NodeSubType, NodeLength);\r
-}\r
index 37acd45d6ec50d08df2eb53b94dbe9e0c46c8dbc..78aac35f81614f56012ffe9d10fe2efde272f471 100644 (file)
@@ -4,7 +4,7 @@
   This library provides defines, macros, and functions to help create and parse \r
   EFI_DEVICE_PATH_PROTOCOL structures.\r
 \r
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials are licensed and made available under \r
 the terms and conditions of the BSD License that accompanies this distribution.  \r
 The full text of the license may be found at\r
@@ -483,4 +483,84 @@ FileDevicePath (
   IN CONST CHAR16                    *FileName\r
   );\r
 \r
+/**\r
+  Converts a device path to its text representation.\r
+\r
+  @param DevicePath      A Pointer to the device to be converted.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+  @return A pointer to the allocated text representation of the device path or\r
+          NULL if DeviceNode is NULL or there was insufficient memory.\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+ConvertDevicePathToText (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL   *DevicePath,\r
+  IN BOOLEAN                          DisplayOnly,\r
+  IN BOOLEAN                          AllowShortcuts\r
+  );\r
+\r
+/**\r
+  Converts a device node to its string representation.\r
+\r
+  @param DeviceNode        A Pointer to the device node to be converted.\r
+  @param DisplayOnly       If DisplayOnly is TRUE, then the shorter text representation\r
+                           of the display node is used, where applicable. If DisplayOnly\r
+                           is FALSE, then the longer text representation of the display node\r
+                           is used.\r
+  @param AllowShortcuts    If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                           representation for a device node can be used, where applicable.\r
+\r
+  @return A pointer to the allocated text representation of the device node or NULL if DeviceNode\r
+          is NULL or there was insufficient memory.\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+ConvertDeviceNodeToText (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DeviceNode,\r
+  IN BOOLEAN                         DisplayOnly,\r
+  IN BOOLEAN                         AllowShortcuts\r
+  );\r
+\r
+/**\r
+  Convert text to the binary representation of a device node.\r
+\r
+  @param TextDeviceNode  TextDeviceNode points to the text representation of a device\r
+                         node. Conversion starts with the first character and continues\r
+                         until the first non-device node character.\r
+\r
+  @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was\r
+          insufficient memory or text unsupported.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+ConvertTextToDeviceNode (\r
+  IN CONST CHAR16 *TextDeviceNode\r
+  );\r
+\r
+/**\r
+  Convert text to the binary representation of a device path.\r
+\r
+  @param TextDevicePath  TextDevicePath points to the text representation of a device\r
+                         path. Conversion starts with the first character and continues\r
+                         until the first non-device node character.\r
+\r
+  @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or\r
+          there was insufficient memory.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+ConvertTextToDevicePath (\r
+  IN CONST CHAR16 *TextDevicePath\r
+  );\r
+\r
 #endif\r
diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
new file mode 100644 (file)
index 0000000..9120319
--- /dev/null
@@ -0,0 +1,3032 @@
+/** @file\r
+  DevicePathFromText protocol as defined in the UEFI 2.0 specification.\r
+\r
+Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "UefiDevicePathLib.h"\r
+\r
+/**\r
+\r
+  Duplicates a string.\r
+\r
+  @param  Src  Source string.\r
+\r
+  @return The duplicated string.\r
+\r
+**/\r
+CHAR16 *\r
+UefiDevicePathLibStrDuplicate (\r
+  IN CONST CHAR16  *Src\r
+  )\r
+{\r
+  return AllocateCopyPool (StrSize (Src), Src);\r
+}\r
+\r
+/**\r
+\r
+  Get parameter in a pair of parentheses follow the given node name.\r
+  For example, given the "Pci(0,1)" and NodeName "Pci", it returns "0,1".\r
+\r
+  @param  Str      Device Path Text.\r
+  @param  NodeName Name of the node.\r
+\r
+  @return Parameter text for the node.\r
+\r
+**/\r
+CHAR16 *\r
+GetParamByNodeName (\r
+  IN CHAR16 *Str,\r
+  IN CHAR16 *NodeName\r
+  )\r
+{\r
+  CHAR16  *ParamStr;\r
+  CHAR16  *StrPointer;\r
+  UINTN   NodeNameLength;\r
+  UINTN   ParameterLength;\r
+\r
+  //\r
+  // Check whether the node name matchs\r
+  //\r
+  NodeNameLength = StrLen (NodeName);\r
+  if (StrnCmp (Str, NodeName, NodeNameLength) != 0) {\r
+    return NULL;\r
+  }\r
+\r
+  ParamStr = Str + NodeNameLength;\r
+  if (!IS_LEFT_PARENTH (*ParamStr)) {\r
+    return NULL;\r
+  }\r
+\r
+  //\r
+  // Skip the found '(' and find first occurrence of ')'\r
+  //\r
+  ParamStr++;\r
+  ParameterLength = 0;\r
+  StrPointer = ParamStr;\r
+  while (!IS_NULL (*StrPointer)) {\r
+    if (IS_RIGHT_PARENTH (*StrPointer)) {\r
+      break;\r
+    }\r
+    StrPointer++;\r
+    ParameterLength++;\r
+  }\r
+  if (IS_NULL (*StrPointer)) {\r
+    //\r
+    // ')' not found\r
+    //\r
+    return NULL;\r
+  }\r
+\r
+  ParamStr = AllocateCopyPool ((ParameterLength + 1) * sizeof (CHAR16), ParamStr);\r
+  if (ParamStr == NULL) {\r
+    return NULL;\r
+  }\r
+  //\r
+  // Terminate the parameter string\r
+  //\r
+  ParamStr[ParameterLength] = L'\0';\r
+\r
+  return ParamStr;\r
+}\r
+\r
+/**\r
+  Gets current sub-string from a string list, before return\r
+  the list header is moved to next sub-string. The sub-string is separated\r
+  by the specified character. For example, the separator is ',', the string\r
+  list is "2,0,3", it returns "2", the remain list move to "0,3"\r
+\r
+  @param  List        A string list separated by the specified separator\r
+  @param  Separator   The separator character\r
+\r
+  @return A pointer to the current sub-string\r
+\r
+**/\r
+CHAR16 *\r
+SplitStr (\r
+  IN OUT CHAR16 **List,\r
+  IN     CHAR16 Separator\r
+  )\r
+{\r
+  CHAR16  *Str;\r
+  CHAR16  *ReturnStr;\r
+\r
+  Str = *List;\r
+  ReturnStr = Str;\r
+\r
+  if (IS_NULL (*Str)) {\r
+    return ReturnStr;\r
+  }\r
+\r
+  //\r
+  // Find first occurrence of the separator\r
+  //\r
+  while (!IS_NULL (*Str)) {\r
+    if (*Str == Separator) {\r
+      break;\r
+    }\r
+    Str++;\r
+  }\r
+\r
+  if (*Str == Separator) {\r
+    //\r
+    // Find a sub-string, terminate it\r
+    //\r
+    *Str = L'\0';\r
+    Str++;\r
+  }\r
+\r
+  //\r
+  // Move to next sub-string\r
+  //\r
+  *List = Str;\r
+\r
+  return ReturnStr;\r
+}\r
+\r
+/**\r
+  Gets the next parameter string from the list.\r
+\r
+  @param List            A string list separated by the specified separator\r
+\r
+  @return A pointer to the current sub-string\r
+\r
+**/\r
+CHAR16 *\r
+GetNextParamStr (\r
+  IN OUT CHAR16 **List\r
+  )\r
+{\r
+  //\r
+  // The separator is comma\r
+  //\r
+  return SplitStr (List, L',');\r
+}\r
+\r
+/**\r
+  Get one device node from entire device path text.\r
+\r
+  @param DevicePath      On input, the current Device Path node; on output, the next device path node\r
+  @param IsInstanceEnd   This node is the end of a device path instance\r
+\r
+  @return A device node text or NULL if no more device node available\r
+\r
+**/\r
+CHAR16 *\r
+GetNextDeviceNodeStr (\r
+  IN OUT CHAR16   **DevicePath,\r
+  OUT    BOOLEAN  *IsInstanceEnd\r
+  )\r
+{\r
+  CHAR16  *Str;\r
+  CHAR16  *ReturnStr;\r
+  UINTN   ParenthesesStack;\r
+\r
+  Str = *DevicePath;\r
+  if (IS_NULL (*Str)) {\r
+    return NULL;\r
+  }\r
+\r
+  //\r
+  // Skip the leading '/', '(', ')' and ','\r
+  //\r
+  while (!IS_NULL (*Str)) {\r
+    if (!IS_SLASH (*Str) &&\r
+        !IS_COMMA (*Str) &&\r
+        !IS_LEFT_PARENTH (*Str) &&\r
+        !IS_RIGHT_PARENTH (*Str)) {\r
+      break;\r
+    }\r
+    Str++;\r
+  }\r
+\r
+  ReturnStr = Str;\r
+\r
+  //\r
+  // Scan for the separator of this device node, '/' or ','\r
+  //\r
+  ParenthesesStack = 0;\r
+  while (!IS_NULL (*Str)) {\r
+    if ((IS_COMMA (*Str) || IS_SLASH (*Str)) && (ParenthesesStack == 0)) {\r
+      break;\r
+    }\r
+\r
+    if (IS_LEFT_PARENTH (*Str)) {\r
+      ParenthesesStack++;\r
+    } else if (IS_RIGHT_PARENTH (*Str)) {\r
+      ParenthesesStack--;\r
+    }\r
+\r
+    Str++;\r
+  }\r
+\r
+  if (ParenthesesStack != 0) {\r
+    //\r
+    // The '(' doesn't pair with ')', invalid device path text\r
+    //\r
+    return NULL;\r
+  }\r
+\r
+  if (IS_COMMA (*Str)) {\r
+    *IsInstanceEnd = TRUE;\r
+    *Str = L'\0';\r
+    Str++;\r
+  } else {\r
+    *IsInstanceEnd = FALSE;\r
+    if (!IS_NULL (*Str)) {\r
+      *Str = L'\0';\r
+      Str++;\r
+    }\r
+  }\r
+\r
+  *DevicePath = Str;\r
+\r
+  return ReturnStr;\r
+}\r
+\r
+\r
+/**\r
+  Return whether the integer string is a hex string.\r
+\r
+  @param Str             The integer string\r
+\r
+  @retval TRUE   Hex string\r
+  @retval FALSE  Decimal string\r
+\r
+**/\r
+BOOLEAN\r
+IsHexStr (\r
+  IN CHAR16   *Str\r
+  )\r
+{\r
+  //\r
+  // skip preceeding white space\r
+  //\r
+  while ((*Str != 0) && *Str == L' ') {\r
+    Str ++;\r
+  }\r
+  //\r
+  // skip preceeding zeros\r
+  //\r
+  while ((*Str != 0) && *Str == L'0') {\r
+    Str ++;\r
+  }\r
+  \r
+  return (BOOLEAN) (*Str == L'x' || *Str == L'X');\r
+}\r
+\r
+/**\r
+\r
+  Convert integer string to uint.\r
+\r
+  @param Str             The integer string. If leading with "0x" or "0X", it's hexadecimal.\r
+\r
+  @return A UINTN value represented by Str\r
+\r
+**/\r
+UINTN\r
+Strtoi (\r
+  IN CHAR16  *Str\r
+  )\r
+{\r
+  if (IsHexStr (Str)) {\r
+    return StrHexToUintn (Str);\r
+  } else {\r
+    return StrDecimalToUintn (Str);\r
+  }\r
+}\r
+\r
+/**\r
+\r
+  Convert integer string to 64 bit data.\r
+\r
+  @param Str             The integer string. If leading with "0x" or "0X", it's hexadecimal.\r
+  @param Data            A pointer to the UINT64 value represented by Str\r
+\r
+**/\r
+VOID\r
+Strtoi64 (\r
+  IN  CHAR16  *Str,\r
+  OUT UINT64  *Data\r
+  )\r
+{\r
+  if (IsHexStr (Str)) {\r
+    *Data = StrHexToUint64 (Str);\r
+  } else {\r
+    *Data = StrDecimalToUint64 (Str);\r
+  }\r
+}\r
+\r
+/**\r
+  Converts a list of string to a specified buffer.\r
+\r
+  @param Buf             The output buffer that contains the string.\r
+  @param BufferLength    The length of the buffer\r
+  @param Str             The input string that contains the hex number\r
+\r
+  @retval EFI_SUCCESS    The string was successfully converted to the buffer.\r
+\r
+**/\r
+EFI_STATUS\r
+StrToBuf (\r
+  OUT UINT8    *Buf,\r
+  IN  UINTN    BufferLength,\r
+  IN  CHAR16   *Str\r
+  )\r
+{\r
+  UINTN       Index;\r
+  UINTN       StrLength;\r
+  UINT8       Digit;\r
+  UINT8       Byte;\r
+\r
+  Digit = 0;\r
+\r
+  //\r
+  // Two hex char make up one byte\r
+  //\r
+  StrLength = BufferLength * sizeof (CHAR16);\r
+\r
+  for(Index = 0; Index < StrLength; Index++, Str++) {\r
+\r
+    if ((*Str >= L'a') && (*Str <= L'f')) {\r
+      Digit = (UINT8) (*Str - L'a' + 0x0A);\r
+    } else if ((*Str >= L'A') && (*Str <= L'F')) {\r
+      Digit = (UINT8) (*Str - L'A' + 0x0A);\r
+    } else if ((*Str >= L'0') && (*Str <= L'9')) {\r
+      Digit = (UINT8) (*Str - L'0');\r
+    } else {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+\r
+    //\r
+    // For odd characters, write the upper nibble for each buffer byte,\r
+    // and for even characters, the lower nibble.\r
+    //\r
+    if ((Index & 1) == 0) {\r
+      Byte = (UINT8) (Digit << 4);\r
+    } else {\r
+      Byte = Buf[Index / 2];\r
+      Byte &= 0xF0;\r
+      Byte = (UINT8) (Byte | Digit);\r
+    }\r
+\r
+    Buf[Index / 2] = Byte;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Converts a string to GUID value.\r
+  Guid Format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\r
+\r
+  @param Str              The registry format GUID string that contains the GUID value.\r
+  @param Guid             A pointer to the converted GUID value.\r
+\r
+  @retval EFI_SUCCESS     The GUID string was successfully converted to the GUID value.\r
+  @retval EFI_UNSUPPORTED The input string is not in registry format.\r
+  @return others          Some error occurred when converting part of GUID value.\r
+\r
+**/\r
+EFI_STATUS\r
+StrToGuid (\r
+  IN  CHAR16   *Str,\r
+  OUT EFI_GUID *Guid\r
+  )\r
+{\r
+  //\r
+  // Get the first UINT32 data\r
+  //\r
+  Guid->Data1 = (UINT32) StrHexToUint64  (Str);\r
+  while (!IS_HYPHEN (*Str) && !IS_NULL (*Str)) {\r
+    Str ++;\r
+  }\r
+  \r
+  if (IS_HYPHEN (*Str)) {\r
+    Str++;\r
+  } else {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  \r
+  //\r
+  // Get the second UINT16 data\r
+  //\r
+  Guid->Data2 = (UINT16) StrHexToUint64  (Str);\r
+  while (!IS_HYPHEN (*Str) && !IS_NULL (*Str)) {\r
+    Str ++;\r
+  }\r
+\r
+  if (IS_HYPHEN (*Str)) {\r
+    Str++;\r
+  } else {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  \r
+  //\r
+  // Get the third UINT16 data\r
+  //\r
+  Guid->Data3 = (UINT16) StrHexToUint64  (Str);\r
+  while (!IS_HYPHEN (*Str) && !IS_NULL (*Str)) {\r
+    Str ++;\r
+  }\r
+\r
+  if (IS_HYPHEN (*Str)) {\r
+    Str++;\r
+  } else {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Get the following 8 bytes data\r
+  //  \r
+  StrToBuf (&Guid->Data4[0], 2, Str);\r
+  //\r
+  // Skip 2 byte hex chars\r
+  //\r
+  Str += 2 * 2;\r
+\r
+  if (IS_HYPHEN (*Str)) {\r
+    Str++;\r
+  } else {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  StrToBuf (&Guid->Data4[2], 6, Str);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Converts a string to IPv4 address\r
+\r
+  @param Str             A string representation of IPv4 address.\r
+  @param IPv4Addr        A pointer to the converted IPv4 address.\r
+\r
+**/\r
+VOID\r
+StrToIPv4Addr (\r
+  IN OUT CHAR16           **Str,\r
+  OUT    EFI_IPv4_ADDRESS *IPv4Addr\r
+  )\r
+{\r
+  UINTN  Index;\r
+\r
+  for (Index = 0; Index < 4; Index++) {\r
+    IPv4Addr->Addr[Index] = (UINT8) StrDecimalToUintn (SplitStr (Str, L'.'));\r
+  }\r
+}\r
+\r
+/**\r
+  Converts a string to IPv4 address\r
+\r
+  @param Str             A string representation of IPv6 address.\r
+  @param IPv6Addr        A pointer to the converted IPv6 address.\r
+\r
+**/\r
+VOID\r
+StrToIPv6Addr (\r
+  IN OUT CHAR16           **Str,\r
+  OUT    EFI_IPv6_ADDRESS *IPv6Addr\r
+  )\r
+{\r
+  UINTN  Index;\r
+  UINT16 Data;\r
+\r
+  for (Index = 0; Index < 8; Index++) {\r
+    Data = (UINT16) StrHexToUintn (SplitStr (Str, L':'));\r
+    IPv6Addr->Addr[Index * 2] = (UINT8) (Data >> 8);\r
+    IPv6Addr->Addr[Index * 2 + 1] = (UINT8) (Data & 0xff);\r
+  }\r
+}\r
+\r
+/**\r
+  Converts a Unicode string to ASCII string.\r
+\r
+  @param Str             The equivalent Unicode string\r
+  @param AsciiStr        On input, it points to destination ASCII string buffer; on output, it points\r
+                         to the next ASCII string next to it\r
+\r
+**/\r
+VOID\r
+StrToAscii (\r
+  IN     CHAR16 *Str,\r
+  IN OUT CHAR8  **AsciiStr\r
+  )\r
+{\r
+  CHAR8 *Dest;\r
+\r
+  Dest = *AsciiStr;\r
+  while (!IS_NULL (*Str)) {\r
+    *(Dest++) = (CHAR8) *(Str++);\r
+  }\r
+  *Dest = 0;\r
+\r
+  //\r
+  // Return the string next to it\r
+  //\r
+  *AsciiStr = Dest + 1;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to Hardware PCI device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to Hardware PCI device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextPci (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16          *FunctionStr;\r
+  CHAR16          *DeviceStr;\r
+  PCI_DEVICE_PATH *Pci;\r
+\r
+  DeviceStr   = GetNextParamStr (&TextDeviceNode);\r
+  FunctionStr = GetNextParamStr (&TextDeviceNode);\r
+  Pci         = (PCI_DEVICE_PATH *) CreateDeviceNode (\r
+                                      HARDWARE_DEVICE_PATH,\r
+                                      HW_PCI_DP,\r
+                                      (UINT16) sizeof (PCI_DEVICE_PATH)\r
+                                      );\r
+\r
+  Pci->Function = (UINT8) Strtoi (FunctionStr);\r
+  Pci->Device   = (UINT8) Strtoi (DeviceStr);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) Pci;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to Hardware PC card device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to Hardware PC card device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextPcCard (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16              *FunctionNumberStr;\r
+  PCCARD_DEVICE_PATH  *Pccard;\r
+\r
+  FunctionNumberStr = GetNextParamStr (&TextDeviceNode);\r
+  Pccard            = (PCCARD_DEVICE_PATH *) CreateDeviceNode (\r
+                                               HARDWARE_DEVICE_PATH,\r
+                                               HW_PCCARD_DP,\r
+                                               (UINT16) sizeof (PCCARD_DEVICE_PATH)\r
+                                               );\r
+\r
+  Pccard->FunctionNumber  = (UINT8) Strtoi (FunctionNumberStr);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) Pccard;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to Hardware memory map device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to Hardware memory map device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextMemoryMapped (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16              *MemoryTypeStr;\r
+  CHAR16              *StartingAddressStr;\r
+  CHAR16              *EndingAddressStr;\r
+  MEMMAP_DEVICE_PATH  *MemMap;\r
+\r
+  MemoryTypeStr      = GetNextParamStr (&TextDeviceNode);\r
+  StartingAddressStr = GetNextParamStr (&TextDeviceNode);\r
+  EndingAddressStr   = GetNextParamStr (&TextDeviceNode);\r
+  MemMap             = (MEMMAP_DEVICE_PATH *) CreateDeviceNode (\r
+                                               HARDWARE_DEVICE_PATH,\r
+                                               HW_MEMMAP_DP,\r
+                                               (UINT16) sizeof (MEMMAP_DEVICE_PATH)\r
+                                               );\r
+\r
+  MemMap->MemoryType = (UINT32) Strtoi (MemoryTypeStr);\r
+  Strtoi64 (StartingAddressStr, &MemMap->StartingAddress);\r
+  Strtoi64 (EndingAddressStr, &MemMap->EndingAddress);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) MemMap;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to Vendor device path structure based on the input Type\r
+  and SubType.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+  @param Type            The type of device path node.\r
+  @param SubType         The subtype of device path node.\r
+\r
+  @return A pointer to the newly-created Vendor device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+ConvertFromTextVendor (\r
+  IN CHAR16 *TextDeviceNode,\r
+  IN UINT8  Type,\r
+  IN UINT8  SubType\r
+  )\r
+{\r
+  CHAR16              *GuidStr;\r
+  CHAR16              *DataStr;\r
+  UINTN               Length;\r
+  VENDOR_DEVICE_PATH  *Vendor;\r
+\r
+  GuidStr = GetNextParamStr (&TextDeviceNode);\r
+\r
+  DataStr = GetNextParamStr (&TextDeviceNode);\r
+  Length  = StrLen (DataStr);\r
+  //\r
+  // Two hex characters make up 1 buffer byte\r
+  //\r
+  Length  = (Length + 1) / 2;\r
+\r
+  Vendor  = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
+                                     Type,\r
+                                     SubType,\r
+                                     (UINT16) (sizeof (VENDOR_DEVICE_PATH) + Length)\r
+                                     );\r
+\r
+  StrToGuid (GuidStr, &Vendor->Guid);\r
+  StrToBuf (((UINT8 *) Vendor) + sizeof (VENDOR_DEVICE_PATH), Length, DataStr);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to Vendor Hardware device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created Vendor Hardware device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextVenHw (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  return ConvertFromTextVendor (\r
+           TextDeviceNode,\r
+           HARDWARE_DEVICE_PATH,\r
+           HW_VENDOR_DP\r
+           );\r
+}\r
+\r
+/**\r
+  Converts a text device path node to Hardware Controller device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created Hardware Controller device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextCtrl (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16                  *ControllerStr;\r
+  CONTROLLER_DEVICE_PATH  *Controller;\r
+\r
+  ControllerStr = GetNextParamStr (&TextDeviceNode);\r
+  Controller    = (CONTROLLER_DEVICE_PATH *) CreateDeviceNode (\r
+                                               HARDWARE_DEVICE_PATH,\r
+                                               HW_CONTROLLER_DP,\r
+                                               (UINT16) sizeof (CONTROLLER_DEVICE_PATH)\r
+                                               );\r
+  Controller->ControllerNumber = (UINT32) Strtoi (ControllerStr);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) Controller;\r
+}\r
+\r
+/**\r
+  Converts a string to EisaId.\r
+\r
+  @param Text   The input string.\r
+\r
+  @return UINT32 EISA ID.\r
+**/\r
+UINT32\r
+EisaIdFromText (\r
+  IN CHAR16 *Text\r
+  )\r
+{\r
+  return (((Text[0] - 'A' + 1) & 0x1f) << 10)\r
+       + (((Text[1] - 'A' + 1) & 0x1f) <<  5)\r
+       + (((Text[2] - 'A' + 1) & 0x1f) <<  0)\r
+       + (UINT32) (StrHexToUintn (&Text[3]) << 16)\r
+       ;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to ACPI HID device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created ACPI HID device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextAcpi (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16                *HIDStr;\r
+  CHAR16                *UIDStr;\r
+  ACPI_HID_DEVICE_PATH  *Acpi;\r
+\r
+  HIDStr = GetNextParamStr (&TextDeviceNode);\r
+  UIDStr = GetNextParamStr (&TextDeviceNode);\r
+  Acpi   = (ACPI_HID_DEVICE_PATH *) CreateDeviceNode (\r
+                                      ACPI_DEVICE_PATH,\r
+                                      ACPI_DP,\r
+                                      (UINT16) sizeof (ACPI_HID_DEVICE_PATH)\r
+                                      );\r
+\r
+  Acpi->HID = EisaIdFromText (HIDStr);\r
+  Acpi->UID = (UINT32) Strtoi (UIDStr);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) Acpi;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to ACPI HID device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+  @param PnPId           The input plug and play identification.\r
+\r
+  @return A pointer to the newly-created ACPI HID device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+ConvertFromTextAcpi (\r
+  IN CHAR16 *TextDeviceNode,\r
+  IN UINT32  PnPId\r
+  )\r
+{\r
+  CHAR16                *UIDStr;\r
+  ACPI_HID_DEVICE_PATH  *Acpi;\r
+\r
+  UIDStr = GetNextParamStr (&TextDeviceNode);\r
+  Acpi   = (ACPI_HID_DEVICE_PATH *) CreateDeviceNode (\r
+                                      ACPI_DEVICE_PATH,\r
+                                      ACPI_DP,\r
+                                      (UINT16) sizeof (ACPI_HID_DEVICE_PATH)\r
+                                      );\r
+\r
+  Acpi->HID = EFI_PNP_ID (PnPId);\r
+  Acpi->UID = (UINT32) Strtoi (UIDStr);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) Acpi;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to PCI root device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created PCI root device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextPciRoot (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  return ConvertFromTextAcpi (TextDeviceNode, 0x0a03);\r
+}\r
+\r
+/**\r
+  Converts a text device path node to PCIE root device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created PCIE root device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextPcieRoot (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  return ConvertFromTextAcpi (TextDeviceNode, 0x0a08);\r
+}\r
+\r
+/**\r
+  Converts a text device path node to Floppy device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created Floppy device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextFloppy (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  return ConvertFromTextAcpi (TextDeviceNode, 0x0604);\r
+}\r
+\r
+/**\r
+  Converts a text device path node to Keyboard device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created  Keyboard device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextKeyboard (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  return ConvertFromTextAcpi (TextDeviceNode, 0x0301);\r
+}\r
+\r
+/**\r
+  Converts a text device path node to Serial device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created Serial device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextSerial (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  return ConvertFromTextAcpi (TextDeviceNode, 0x0501);\r
+}\r
+\r
+/**\r
+  Converts a text device path node to Parallel Port device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created Parallel Port device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextParallelPort (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  return ConvertFromTextAcpi (TextDeviceNode, 0x0401);\r
+}\r
+\r
+/**\r
+  Converts a text device path node to ACPI extension device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created ACPI extension device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextAcpiEx (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16                         *HIDStr;\r
+  CHAR16                         *CIDStr;\r
+  CHAR16                         *UIDStr;\r
+  CHAR16                         *HIDSTRStr;\r
+  CHAR16                         *CIDSTRStr;\r
+  CHAR16                         *UIDSTRStr;\r
+  CHAR8                          *AsciiStr;\r
+  UINT16                         Length;\r
+  ACPI_EXTENDED_HID_DEVICE_PATH  *AcpiEx;\r
+\r
+  HIDStr    = GetNextParamStr (&TextDeviceNode);\r
+  CIDStr    = GetNextParamStr (&TextDeviceNode);\r
+  UIDStr    = GetNextParamStr (&TextDeviceNode);\r
+  HIDSTRStr = GetNextParamStr (&TextDeviceNode);\r
+  CIDSTRStr = GetNextParamStr (&TextDeviceNode);\r
+  UIDSTRStr = GetNextParamStr (&TextDeviceNode);\r
+\r
+  Length    = (UINT16) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH) + StrLen (HIDSTRStr) + 1);\r
+  Length    = (UINT16) (Length + StrLen (UIDSTRStr) + 1);\r
+  Length    = (UINT16) (Length + StrLen (CIDSTRStr) + 1);\r
+  AcpiEx = (ACPI_EXTENDED_HID_DEVICE_PATH *) CreateDeviceNode (\r
+                                               ACPI_DEVICE_PATH,\r
+                                               ACPI_EXTENDED_DP,\r
+                                               Length\r
+                                               );\r
+\r
+  AcpiEx->HID = EisaIdFromText (HIDStr);\r
+  AcpiEx->CID = EisaIdFromText (CIDStr);\r
+  AcpiEx->UID = (UINT32) Strtoi (UIDStr);\r
+\r
+  AsciiStr = (CHAR8 *) ((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));\r
+  StrToAscii (HIDSTRStr, &AsciiStr);\r
+  StrToAscii (UIDSTRStr, &AsciiStr);\r
+  StrToAscii (CIDSTRStr, &AsciiStr);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) AcpiEx;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to ACPI extension device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created ACPI extension device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextAcpiExp (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16                         *HIDStr;\r
+  CHAR16                         *CIDStr;\r
+  CHAR16                         *UIDSTRStr;\r
+  CHAR8                          *AsciiStr;\r
+  UINT16                         Length;\r
+  ACPI_EXTENDED_HID_DEVICE_PATH  *AcpiEx;\r
+\r
+  HIDStr    = GetNextParamStr (&TextDeviceNode);\r
+  CIDStr    = GetNextParamStr (&TextDeviceNode);\r
+  UIDSTRStr = GetNextParamStr (&TextDeviceNode);\r
+  Length    = (UINT16) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH) + StrLen (UIDSTRStr) + 3);\r
+  AcpiEx    = (ACPI_EXTENDED_HID_DEVICE_PATH *) CreateDeviceNode (\r
+                                                  ACPI_DEVICE_PATH,\r
+                                                  ACPI_EXTENDED_DP,\r
+                                                  Length\r
+                                                  );\r
+\r
+  AcpiEx->HID = EisaIdFromText (HIDStr);\r
+  AcpiEx->CID = EisaIdFromText (CIDStr);\r
+  AcpiEx->UID = 0;\r
+\r
+  AsciiStr = (CHAR8 *) ((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));\r
+  //\r
+  // HID string is NULL\r
+  //\r
+  *AsciiStr = '\0';\r
+  //\r
+  // Convert UID string\r
+  //\r
+  AsciiStr++;\r
+  StrToAscii (UIDSTRStr, &AsciiStr);\r
+  //\r
+  // CID string is NULL\r
+  //\r
+  *AsciiStr = '\0';\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) AcpiEx;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to ACPI _ADR device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created ACPI _ADR device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextAcpiAdr (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16                *DisplayDeviceStr;\r
+  ACPI_ADR_DEVICE_PATH  *AcpiAdr;\r
+  UINTN                 Index;\r
+  UINTN                 Length;\r
+\r
+  AcpiAdr = (ACPI_ADR_DEVICE_PATH *) CreateDeviceNode (\r
+                                       ACPI_DEVICE_PATH,\r
+                                       ACPI_ADR_DP,\r
+                                       (UINT16) sizeof (ACPI_ADR_DEVICE_PATH)\r
+                                       );\r
+  ASSERT (AcpiAdr != NULL);\r
+\r
+  for (Index = 0; ; Index++) {\r
+    DisplayDeviceStr = GetNextParamStr (&TextDeviceNode);\r
+    if (IS_NULL (*DisplayDeviceStr)) {\r
+      break;\r
+    }\r
+    if (Index > 0) {\r
+      Length  = DevicePathNodeLength (AcpiAdr);\r
+      AcpiAdr = ReallocatePool (\r
+                  Length,\r
+                  Length + sizeof (UINT32),\r
+                  AcpiAdr\r
+                  );\r
+      ASSERT (AcpiAdr != NULL);\r
+      SetDevicePathNodeLength (AcpiAdr, Length + sizeof (UINT32));\r
+    }\r
+    \r
+    (&AcpiAdr->ADR)[Index] = (UINT32) Strtoi (DisplayDeviceStr);\r
+  }\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) AcpiAdr;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to Parallel Port device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created Parallel Port device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextAta (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16            *PrimarySecondaryStr;\r
+  CHAR16            *SlaveMasterStr;\r
+  CHAR16            *LunStr;\r
+  ATAPI_DEVICE_PATH *Atapi;\r
+\r
+  Atapi = (ATAPI_DEVICE_PATH *) CreateDeviceNode (\r
+                                  MESSAGING_DEVICE_PATH,\r
+                                  MSG_ATAPI_DP,\r
+                                  (UINT16) sizeof (ATAPI_DEVICE_PATH)\r
+                                  );\r
+\r
+  PrimarySecondaryStr     = GetNextParamStr (&TextDeviceNode);\r
+  SlaveMasterStr          = GetNextParamStr (&TextDeviceNode);\r
+  LunStr                  = GetNextParamStr (&TextDeviceNode);\r
+\r
+  Atapi->PrimarySecondary = (UINT8) ((StrCmp (PrimarySecondaryStr, L"Primary") == 0) ? 0 : 1);\r
+  Atapi->SlaveMaster      = (UINT8) ((StrCmp (SlaveMasterStr, L"Master") == 0) ? 0 : 1);\r
+  Atapi->Lun              = (UINT16) Strtoi (LunStr);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) Atapi;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to SCSI device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created SCSI device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextScsi (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16            *PunStr;\r
+  CHAR16            *LunStr;\r
+  SCSI_DEVICE_PATH  *Scsi;\r
+\r
+  PunStr = GetNextParamStr (&TextDeviceNode);\r
+  LunStr = GetNextParamStr (&TextDeviceNode);\r
+  Scsi   = (SCSI_DEVICE_PATH *) CreateDeviceNode (\r
+                                   MESSAGING_DEVICE_PATH,\r
+                                   MSG_SCSI_DP,\r
+                                   (UINT16) sizeof (SCSI_DEVICE_PATH)\r
+                                   );\r
+\r
+  Scsi->Pun = (UINT16) Strtoi (PunStr);\r
+  Scsi->Lun = (UINT16) Strtoi (LunStr);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) Scsi;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to Fibre device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created Fibre device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextFibre (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16                    *WWNStr;\r
+  CHAR16                    *LunStr;\r
+  FIBRECHANNEL_DEVICE_PATH  *Fibre;\r
+\r
+  WWNStr = GetNextParamStr (&TextDeviceNode);\r
+  LunStr = GetNextParamStr (&TextDeviceNode);\r
+  Fibre  = (FIBRECHANNEL_DEVICE_PATH *) CreateDeviceNode (\r
+                                          MESSAGING_DEVICE_PATH,\r
+                                          MSG_FIBRECHANNEL_DP,\r
+                                          (UINT16) sizeof (FIBRECHANNEL_DEVICE_PATH)\r
+                                          );\r
+\r
+  Fibre->Reserved = 0;\r
+  Strtoi64 (WWNStr, &Fibre->WWN);\r
+  Strtoi64 (LunStr, &Fibre->Lun);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) Fibre;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to FibreEx device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created FibreEx device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextFibreEx (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16                      *WWNStr;\r
+  CHAR16                      *LunStr;\r
+  FIBRECHANNELEX_DEVICE_PATH  *FibreEx;\r
+\r
+  WWNStr  = GetNextParamStr (&TextDeviceNode);\r
+  LunStr  = GetNextParamStr (&TextDeviceNode);\r
+  FibreEx = (FIBRECHANNELEX_DEVICE_PATH *) CreateDeviceNode (\r
+                                             MESSAGING_DEVICE_PATH,\r
+                                             MSG_FIBRECHANNELEX_DP,\r
+                                             (UINT16) sizeof (FIBRECHANNELEX_DEVICE_PATH)\r
+                                             );\r
+\r
+  FibreEx->Reserved = 0;\r
+  Strtoi64 (WWNStr, (UINT64 *) (&FibreEx->WWN));\r
+  Strtoi64 (LunStr, (UINT64 *) (&FibreEx->Lun));\r
+\r
+  *(UINT64 *) (&FibreEx->WWN) = SwapBytes64 (*(UINT64 *) (&FibreEx->WWN));\r
+  *(UINT64 *) (&FibreEx->Lun) = SwapBytes64 (*(UINT64 *) (&FibreEx->Lun));\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) FibreEx;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to 1394 device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created 1394 device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromText1394 (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16            *GuidStr;\r
+  F1394_DEVICE_PATH *F1394DevPath;\r
+\r
+  GuidStr = GetNextParamStr (&TextDeviceNode);\r
+  F1394DevPath  = (F1394_DEVICE_PATH *) CreateDeviceNode (\r
+                                          MESSAGING_DEVICE_PATH,\r
+                                          MSG_1394_DP,\r
+                                          (UINT16) sizeof (F1394_DEVICE_PATH)\r
+                                          );\r
+\r
+  F1394DevPath->Reserved = 0;\r
+  F1394DevPath->Guid     = StrHexToUint64 (GuidStr);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) F1394DevPath;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to USB device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created USB device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsb (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16          *PortStr;\r
+  CHAR16          *InterfaceStr;\r
+  USB_DEVICE_PATH *Usb;\r
+\r
+  PortStr               = GetNextParamStr (&TextDeviceNode);\r
+  InterfaceStr          = GetNextParamStr (&TextDeviceNode);\r
+  Usb                   = (USB_DEVICE_PATH *) CreateDeviceNode (\r
+                                                MESSAGING_DEVICE_PATH,\r
+                                                MSG_USB_DP,\r
+                                                (UINT16) sizeof (USB_DEVICE_PATH)\r
+                                                );\r
+\r
+  Usb->ParentPortNumber = (UINT8) Strtoi (PortStr);\r
+  Usb->InterfaceNumber  = (UINT8) Strtoi (InterfaceStr);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) Usb;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to I20 device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created I20 device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextI2O (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16          *TIDStr;\r
+  I2O_DEVICE_PATH *I2ODevPath;\r
+\r
+  TIDStr     = GetNextParamStr (&TextDeviceNode);\r
+  I2ODevPath = (I2O_DEVICE_PATH *) CreateDeviceNode (\r
+                                    MESSAGING_DEVICE_PATH,\r
+                                    MSG_I2O_DP,\r
+                                    (UINT16) sizeof (I2O_DEVICE_PATH)\r
+                                    );\r
+\r
+  I2ODevPath->Tid  = (UINT32) Strtoi (TIDStr);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) I2ODevPath;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to Infini Band device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created Infini Band device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextInfiniband (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16                  *FlagsStr;\r
+  CHAR16                  *GuidStr;\r
+  CHAR16                  *SidStr;\r
+  CHAR16                  *TidStr;\r
+  CHAR16                  *DidStr;\r
+  EFI_GUID                PortGid;\r
+  INFINIBAND_DEVICE_PATH  *InfiniBand;\r
+\r
+  FlagsStr   = GetNextParamStr (&TextDeviceNode);\r
+  GuidStr    = GetNextParamStr (&TextDeviceNode);\r
+  SidStr     = GetNextParamStr (&TextDeviceNode);\r
+  TidStr     = GetNextParamStr (&TextDeviceNode);\r
+  DidStr     = GetNextParamStr (&TextDeviceNode);\r
+  InfiniBand = (INFINIBAND_DEVICE_PATH *) CreateDeviceNode (\r
+                                            MESSAGING_DEVICE_PATH,\r
+                                            MSG_INFINIBAND_DP,\r
+                                            (UINT16) sizeof (INFINIBAND_DEVICE_PATH)\r
+                                            );\r
+\r
+  InfiniBand->ResourceFlags = (UINT32) Strtoi (FlagsStr);\r
+  StrToGuid (GuidStr, &PortGid);\r
+  CopyMem (InfiniBand->PortGid, &PortGid, sizeof (EFI_GUID));\r
+  Strtoi64 (SidStr, &InfiniBand->ServiceId);\r
+  Strtoi64 (TidStr, &InfiniBand->TargetPortId);\r
+  Strtoi64 (DidStr, &InfiniBand->DeviceId);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) InfiniBand;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to Vendor-Defined Messaging device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created Vendor-Defined Messaging device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextVenMsg (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  return ConvertFromTextVendor (\r
+            TextDeviceNode,\r
+            MESSAGING_DEVICE_PATH,\r
+            MSG_VENDOR_DP\r
+            );\r
+}\r
+\r
+/**\r
+  Converts a text device path node to Vendor defined PC-ANSI device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created Vendor defined PC-ANSI device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextVenPcAnsi (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  VENDOR_DEVICE_PATH  *Vendor;\r
+\r
+  Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
+                                    MESSAGING_DEVICE_PATH,\r
+                                    MSG_VENDOR_DP,\r
+                                    (UINT16) sizeof (VENDOR_DEVICE_PATH));\r
+  CopyGuid (&Vendor->Guid, &gEfiPcAnsiGuid);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to Vendor defined VT100 device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created Vendor defined VT100 device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextVenVt100 (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  VENDOR_DEVICE_PATH  *Vendor;\r
+\r
+  Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
+                                    MESSAGING_DEVICE_PATH,\r
+                                    MSG_VENDOR_DP,\r
+                                    (UINT16) sizeof (VENDOR_DEVICE_PATH));\r
+  CopyGuid (&Vendor->Guid, &gEfiVT100Guid);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to Vendor defined VT100 Plus device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created Vendor defined VT100 Plus device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextVenVt100Plus (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  VENDOR_DEVICE_PATH  *Vendor;\r
+\r
+  Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
+                                    MESSAGING_DEVICE_PATH,\r
+                                    MSG_VENDOR_DP,\r
+                                    (UINT16) sizeof (VENDOR_DEVICE_PATH));\r
+  CopyGuid (&Vendor->Guid, &gEfiVT100PlusGuid);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to Vendor defined UTF8 device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created Vendor defined UTF8 device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextVenUtf8 (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  VENDOR_DEVICE_PATH  *Vendor;\r
+\r
+  Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
+                                    MESSAGING_DEVICE_PATH,\r
+                                    MSG_VENDOR_DP,\r
+                                    (UINT16) sizeof (VENDOR_DEVICE_PATH));\r
+  CopyGuid (&Vendor->Guid, &gEfiVTUTF8Guid);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) Vendor;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to UART Flow Control device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created UART Flow Control device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUartFlowCtrl (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16                        *ValueStr;\r
+  UART_FLOW_CONTROL_DEVICE_PATH *UartFlowControl;\r
+\r
+  ValueStr        = GetNextParamStr (&TextDeviceNode);\r
+  UartFlowControl = (UART_FLOW_CONTROL_DEVICE_PATH *) CreateDeviceNode (\r
+                                                        MESSAGING_DEVICE_PATH,\r
+                                                        MSG_VENDOR_DP,\r
+                                                        (UINT16) sizeof (UART_FLOW_CONTROL_DEVICE_PATH)\r
+                                                        );\r
+\r
+  CopyGuid (&UartFlowControl->Guid, &gEfiUartDevicePathGuid);\r
+  if (StrCmp (ValueStr, L"XonXoff") == 0) {\r
+    UartFlowControl->FlowControlMap = 2;\r
+  } else if (StrCmp (ValueStr, L"Hardware") == 0) {\r
+    UartFlowControl->FlowControlMap = 1;\r
+  } else {\r
+    UartFlowControl->FlowControlMap = 0;\r
+  }\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) UartFlowControl;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to Serial Attached SCSI device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created Serial Attached SCSI device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextSAS (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16          *AddressStr;\r
+  CHAR16          *LunStr;\r
+  CHAR16          *RTPStr;\r
+  CHAR16          *SASSATAStr;\r
+  CHAR16          *LocationStr;\r
+  CHAR16          *ConnectStr;\r
+  CHAR16          *DriveBayStr;\r
+  CHAR16          *ReservedStr;\r
+  UINT16          Info;\r
+  UINT16          Uint16;\r
+  SAS_DEVICE_PATH *Sas;\r
+\r
+  AddressStr  = GetNextParamStr (&TextDeviceNode);\r
+  LunStr      = GetNextParamStr (&TextDeviceNode);\r
+  RTPStr      = GetNextParamStr (&TextDeviceNode);\r
+  SASSATAStr  = GetNextParamStr (&TextDeviceNode);\r
+  LocationStr = GetNextParamStr (&TextDeviceNode);\r
+  ConnectStr  = GetNextParamStr (&TextDeviceNode);\r
+  DriveBayStr = GetNextParamStr (&TextDeviceNode);\r
+  ReservedStr = GetNextParamStr (&TextDeviceNode);\r
+  Sas         = (SAS_DEVICE_PATH *) CreateDeviceNode (\r
+                                       MESSAGING_DEVICE_PATH,\r
+                                       MSG_VENDOR_DP,\r
+                                       (UINT16) sizeof (SAS_DEVICE_PATH)\r
+                                       );\r
+\r
+  CopyGuid (&Sas->Guid, &gEfiSasDevicePathGuid);\r
+  Strtoi64 (AddressStr, &Sas->SasAddress);\r
+  Strtoi64 (LunStr, &Sas->Lun);\r
+  Sas->RelativeTargetPort = (UINT16) Strtoi (RTPStr);\r
+\r
+  if (StrCmp (SASSATAStr, L"NoTopology") == 0) {\r
+    Info = 0x0;\r
+\r
+  } else if ((StrCmp (SASSATAStr, L"SATA") == 0) || (StrCmp (SASSATAStr, L"SAS") == 0)) {\r
+\r
+    Uint16 = (UINT16) Strtoi (DriveBayStr);\r
+    if (Uint16 == 0) {\r
+      Info = 0x1;\r
+    } else {\r
+      Info = (UINT16) (0x2 | ((Uint16 - 1) << 8));\r
+    }\r
+\r
+    if (StrCmp (SASSATAStr, L"SATA") == 0) {\r
+      Info |= BIT4;\r
+    }\r
+\r
+    //\r
+    // Location is an integer between 0 and 1 or else\r
+    // the keyword Internal (0) or External (1).\r
+    //\r
+    if (StrCmp (LocationStr, L"External") == 0) {\r
+      Uint16 = 1;\r
+    } else if (StrCmp (LocationStr, L"Internal") == 0) {\r
+      Uint16 = 0;\r
+    } else {\r
+      Uint16 = ((UINT16) Strtoi (LocationStr) & BIT0);\r
+    }\r
+    Info |= (Uint16 << 5);\r
+\r
+    //\r
+    // Connect is an integer between 0 and 3 or else\r
+    // the keyword Direct (0) or Expanded (1).\r
+    //\r
+    if (StrCmp (ConnectStr, L"Expanded") == 0) {\r
+      Uint16 = 1;\r
+    } else if (StrCmp (ConnectStr, L"Direct") == 0) {\r
+      Uint16 = 0;\r
+    } else {\r
+      Uint16 = ((UINT16) Strtoi (ConnectStr) & (BIT0 | BIT1));\r
+    }\r
+    Info |= (Uint16 << 6);\r
+\r
+  } else {\r
+    Info = (UINT16) Strtoi (SASSATAStr);\r
+  }\r
+\r
+  Sas->DeviceTopology = Info;\r
+  Sas->Reserved       = (UINT32) Strtoi (ReservedStr);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) Sas;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to Serial Attached SCSI Ex device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created Serial Attached SCSI Ex device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextSasEx (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16            *AddressStr;\r
+  CHAR16            *LunStr;\r
+  CHAR16            *RTPStr;\r
+  CHAR16            *SASSATAStr;\r
+  CHAR16            *LocationStr;\r
+  CHAR16            *ConnectStr;\r
+  CHAR16            *DriveBayStr;\r
+  UINT16            Info;\r
+  UINT16            Uint16;\r
+  UINT64            SasAddress;\r
+  UINT64            Lun;\r
+  SASEX_DEVICE_PATH *SasEx;\r
+\r
+  AddressStr  = GetNextParamStr (&TextDeviceNode);\r
+  LunStr      = GetNextParamStr (&TextDeviceNode);\r
+  RTPStr      = GetNextParamStr (&TextDeviceNode);\r
+  SASSATAStr  = GetNextParamStr (&TextDeviceNode);\r
+  LocationStr = GetNextParamStr (&TextDeviceNode);\r
+  ConnectStr  = GetNextParamStr (&TextDeviceNode);\r
+  DriveBayStr = GetNextParamStr (&TextDeviceNode);\r
+  SasEx       = (SASEX_DEVICE_PATH *) CreateDeviceNode (\r
+                                        MESSAGING_DEVICE_PATH,\r
+                                        MSG_SASEX_DP,\r
+                                        (UINT16) sizeof (SASEX_DEVICE_PATH)\r
+                                        );\r
+\r
+  Strtoi64 (AddressStr, &SasAddress);\r
+  Strtoi64 (LunStr,     &Lun);\r
+  WriteUnaligned64 ((UINT64 *) &SasEx->SasAddress, SwapBytes64 (SasAddress));\r
+  WriteUnaligned64 ((UINT64 *) &SasEx->Lun,        SwapBytes64 (Lun));\r
+  SasEx->RelativeTargetPort      = (UINT16) Strtoi (RTPStr);\r
+\r
+  if (StrCmp (SASSATAStr, L"NoTopology") == 0) {\r
+    Info = 0x0;\r
+\r
+  } else if ((StrCmp (SASSATAStr, L"SATA") == 0) || (StrCmp (SASSATAStr, L"SAS") == 0)) {\r
+\r
+    Uint16 = (UINT16) Strtoi (DriveBayStr);\r
+    if (Uint16 == 0) {\r
+      Info = 0x1;\r
+    } else {\r
+      Info = (UINT16) (0x2 | ((Uint16 - 1) << 8));\r
+    }\r
+\r
+    if (StrCmp (SASSATAStr, L"SATA") == 0) {\r
+      Info |= BIT4;\r
+    }\r
+\r
+    //\r
+    // Location is an integer between 0 and 1 or else\r
+    // the keyword Internal (0) or External (1).\r
+    //\r
+    if (StrCmp (LocationStr, L"External") == 0) {\r
+      Uint16 = 1;\r
+    } else if (StrCmp (LocationStr, L"Internal") == 0) {\r
+      Uint16 = 0;\r
+    } else {\r
+      Uint16 = ((UINT16) Strtoi (LocationStr) & BIT0);\r
+    }\r
+    Info |= (Uint16 << 5);\r
+\r
+    //\r
+    // Connect is an integer between 0 and 3 or else\r
+    // the keyword Direct (0) or Expanded (1).\r
+    //\r
+    if (StrCmp (ConnectStr, L"Expanded") == 0) {\r
+      Uint16 = 1;\r
+    } else if (StrCmp (ConnectStr, L"Direct") == 0) {\r
+      Uint16 = 0;\r
+    } else {\r
+      Uint16 = ((UINT16) Strtoi (ConnectStr) & (BIT0 | BIT1));\r
+    }\r
+    Info |= (Uint16 << 6);\r
+\r
+  } else {\r
+    Info = (UINT16) Strtoi (SASSATAStr);\r
+  }\r
+\r
+  SasEx->DeviceTopology = Info;\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) SasEx;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to Debug Port device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created Debug Port device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextDebugPort (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  VENDOR_DEFINED_MESSAGING_DEVICE_PATH  *Vend;\r
+\r
+  Vend = (VENDOR_DEFINED_MESSAGING_DEVICE_PATH *) CreateDeviceNode (\r
+                                                    MESSAGING_DEVICE_PATH,\r
+                                                    MSG_VENDOR_DP,\r
+                                                    (UINT16) sizeof (VENDOR_DEFINED_MESSAGING_DEVICE_PATH)\r
+                                                    );\r
+\r
+  CopyGuid (&Vend->Guid, &gEfiDebugPortProtocolGuid);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) Vend;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to MAC device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created MAC device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextMAC (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16                *AddressStr;\r
+  CHAR16                *IfTypeStr;\r
+  UINTN                 Length;\r
+  MAC_ADDR_DEVICE_PATH  *MACDevPath;\r
+\r
+  AddressStr    = GetNextParamStr (&TextDeviceNode);\r
+  IfTypeStr     = GetNextParamStr (&TextDeviceNode);\r
+  MACDevPath    = (MAC_ADDR_DEVICE_PATH *) CreateDeviceNode (\r
+                                              MESSAGING_DEVICE_PATH,\r
+                                              MSG_MAC_ADDR_DP,\r
+                                              (UINT16) sizeof (MAC_ADDR_DEVICE_PATH)\r
+                                              );\r
+\r
+  MACDevPath->IfType   = (UINT8) Strtoi (IfTypeStr);\r
+\r
+  Length = sizeof (EFI_MAC_ADDRESS);\r
+  StrToBuf (&MACDevPath->MacAddress.Addr[0], Length, AddressStr);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) MACDevPath;\r
+}\r
+\r
+\r
+/**\r
+  Converts a text format to the network protocol ID.\r
+\r
+  @param Text  String of protocol field.\r
+\r
+  @return Network protocol ID .\r
+\r
+**/\r
+UINTN\r
+NetworkProtocolFromText (\r
+  IN CHAR16 *Text\r
+  )\r
+{\r
+  if (StrCmp (Text, L"UDP") == 0) {\r
+    return RFC_1700_UDP_PROTOCOL;\r
+  }\r
+\r
+  if (StrCmp (Text, L"TCP") == 0) {\r
+    return RFC_1700_TCP_PROTOCOL;\r
+  }\r
+\r
+  return Strtoi (Text);\r
+}\r
+\r
+\r
+/**\r
+  Converts a text device path node to IPV4 device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created IPV4 device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextIPv4 (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16            *RemoteIPStr;\r
+  CHAR16            *ProtocolStr;\r
+  CHAR16            *TypeStr;\r
+  CHAR16            *LocalIPStr;\r
+  CHAR16            *GatewayIPStr;\r
+  CHAR16            *SubnetMaskStr;\r
+  IPv4_DEVICE_PATH  *IPv4;\r
+\r
+  RemoteIPStr           = GetNextParamStr (&TextDeviceNode);\r
+  ProtocolStr           = GetNextParamStr (&TextDeviceNode);\r
+  TypeStr               = GetNextParamStr (&TextDeviceNode);\r
+  LocalIPStr            = GetNextParamStr (&TextDeviceNode);\r
+  GatewayIPStr          = GetNextParamStr (&TextDeviceNode);\r
+  SubnetMaskStr         = GetNextParamStr (&TextDeviceNode);\r
+  IPv4                  = (IPv4_DEVICE_PATH *) CreateDeviceNode (\r
+                                                 MESSAGING_DEVICE_PATH,\r
+                                                 MSG_IPv4_DP,\r
+                                                 (UINT16) sizeof (IPv4_DEVICE_PATH)\r
+                                                 );\r
+\r
+  StrToIPv4Addr (&RemoteIPStr, &IPv4->RemoteIpAddress);\r
+  IPv4->Protocol = (UINT16) NetworkProtocolFromText (ProtocolStr);\r
+  if (StrCmp (TypeStr, L"Static") == 0) {\r
+    IPv4->StaticIpAddress = TRUE;\r
+  } else {\r
+    IPv4->StaticIpAddress = FALSE;\r
+  }\r
+\r
+  StrToIPv4Addr (&LocalIPStr, &IPv4->LocalIpAddress);\r
+  if (!IS_NULL (*GatewayIPStr) && !IS_NULL (*SubnetMaskStr)) {\r
+    StrToIPv4Addr (&GatewayIPStr,  &IPv4->GatewayIpAddress);\r
+    StrToIPv4Addr (&SubnetMaskStr, &IPv4->SubnetMask);\r
+  } else {\r
+    ZeroMem (&IPv4->GatewayIpAddress, sizeof (IPv4->GatewayIpAddress));\r
+    ZeroMem (&IPv4->SubnetMask,    sizeof (IPv4->SubnetMask));\r
+  }\r
+\r
+  IPv4->LocalPort       = 0;\r
+  IPv4->RemotePort      = 0;\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) IPv4;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to IPV6 device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created IPV6 device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextIPv6 (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16            *RemoteIPStr;\r
+  CHAR16            *ProtocolStr;\r
+  CHAR16            *TypeStr;\r
+  CHAR16            *LocalIPStr;\r
+  CHAR16            *GatewayIPStr;\r
+  CHAR16            *PrefixLengthStr;\r
+  IPv6_DEVICE_PATH  *IPv6;\r
+\r
+  RemoteIPStr           = GetNextParamStr (&TextDeviceNode);\r
+  ProtocolStr           = GetNextParamStr (&TextDeviceNode);\r
+  TypeStr               = GetNextParamStr (&TextDeviceNode);\r
+  LocalIPStr            = GetNextParamStr (&TextDeviceNode);\r
+  PrefixLengthStr       = GetNextParamStr (&TextDeviceNode);\r
+  GatewayIPStr          = GetNextParamStr (&TextDeviceNode);\r
+  IPv6                  = (IPv6_DEVICE_PATH *) CreateDeviceNode (\r
+                                                 MESSAGING_DEVICE_PATH,\r
+                                                 MSG_IPv6_DP,\r
+                                                 (UINT16) sizeof (IPv6_DEVICE_PATH)\r
+                                                 );\r
+\r
+  StrToIPv6Addr (&RemoteIPStr, &IPv6->RemoteIpAddress);\r
+  IPv6->Protocol        = (UINT16) NetworkProtocolFromText (ProtocolStr);\r
+  if (StrCmp (TypeStr, L"Static") == 0) {\r
+    IPv6->IpAddressOrigin = 0;\r
+  } else if (StrCmp (TypeStr, L"StatelessAutoConfigure") == 0) {\r
+    IPv6->IpAddressOrigin = 1;\r
+  } else {\r
+    IPv6->IpAddressOrigin = 2;\r
+  }\r
+\r
+  StrToIPv6Addr (&LocalIPStr, &IPv6->LocalIpAddress);\r
+  if (!IS_NULL (*GatewayIPStr) && !IS_NULL (*PrefixLengthStr)) {\r
+    StrToIPv6Addr (&GatewayIPStr, &IPv6->GatewayIpAddress);\r
+    IPv6->PrefixLength = (UINT8) Strtoi (PrefixLengthStr);\r
+  } else {\r
+    ZeroMem (&IPv6->GatewayIpAddress, sizeof (IPv6->GatewayIpAddress));\r
+    IPv6->PrefixLength = 0;\r
+  }\r
+\r
+  IPv6->LocalPort       = 0;\r
+  IPv6->RemotePort      = 0;\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) IPv6;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to UART device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created UART device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUart (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16            *BaudStr;\r
+  CHAR16            *DataBitsStr;\r
+  CHAR16            *ParityStr;\r
+  CHAR16            *StopBitsStr;\r
+  UART_DEVICE_PATH  *Uart;\r
+\r
+  BaudStr         = GetNextParamStr (&TextDeviceNode);\r
+  DataBitsStr     = GetNextParamStr (&TextDeviceNode);\r
+  ParityStr       = GetNextParamStr (&TextDeviceNode);\r
+  StopBitsStr     = GetNextParamStr (&TextDeviceNode);\r
+  Uart            = (UART_DEVICE_PATH *) CreateDeviceNode (\r
+                                           MESSAGING_DEVICE_PATH,\r
+                                           MSG_UART_DP,\r
+                                           (UINT16) sizeof (UART_DEVICE_PATH)\r
+                                           );\r
+\r
+  Uart->BaudRate  = (StrCmp (BaudStr, L"DEFAULT") == 0) ? 115200 : StrDecimalToUintn (BaudStr);\r
+  Uart->DataBits  = (UINT8) ((StrCmp (DataBitsStr, L"DEFAULT") == 0) ? 8 : StrDecimalToUintn (DataBitsStr));\r
+  switch (*ParityStr) {\r
+  case L'D':\r
+    Uart->Parity = 0;\r
+    break;\r
+\r
+  case L'N':\r
+    Uart->Parity = 1;\r
+    break;\r
+\r
+  case L'E':\r
+    Uart->Parity = 2;\r
+    break;\r
+\r
+  case L'O':\r
+    Uart->Parity = 3;\r
+    break;\r
+\r
+  case L'M':\r
+    Uart->Parity = 4;\r
+    break;\r
+\r
+  case L'S':\r
+    Uart->Parity = 5;\r
+    break;\r
+\r
+  default:\r
+    Uart->Parity = 0xff;\r
+  }\r
+\r
+  if (StrCmp (StopBitsStr, L"D") == 0) {\r
+    Uart->StopBits = (UINT8) 0;\r
+  } else if (StrCmp (StopBitsStr, L"1") == 0) {\r
+    Uart->StopBits = (UINT8) 1;\r
+  } else if (StrCmp (StopBitsStr, L"1.5") == 0) {\r
+    Uart->StopBits = (UINT8) 2;\r
+  } else if (StrCmp (StopBitsStr, L"2") == 0) {\r
+    Uart->StopBits = (UINT8) 3;\r
+  } else {\r
+    Uart->StopBits = 0xff;\r
+  }\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) Uart;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to USB class device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+  @param UsbClassText    A pointer to USB_CLASS_TEXT structure to be integrated to USB Class Text.\r
+\r
+  @return A pointer to the newly-created USB class device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+ConvertFromTextUsbClass (\r
+  IN CHAR16         *TextDeviceNode,\r
+  IN USB_CLASS_TEXT *UsbClassText\r
+  )\r
+{\r
+  CHAR16                *VIDStr;\r
+  CHAR16                *PIDStr;\r
+  CHAR16                *ClassStr;\r
+  CHAR16                *SubClassStr;\r
+  CHAR16                *ProtocolStr;\r
+  USB_CLASS_DEVICE_PATH *UsbClass;\r
+\r
+  UsbClass    = (USB_CLASS_DEVICE_PATH *) CreateDeviceNode (\r
+                                            MESSAGING_DEVICE_PATH,\r
+                                            MSG_USB_CLASS_DP,\r
+                                            (UINT16) sizeof (USB_CLASS_DEVICE_PATH)\r
+                                            );\r
+\r
+  VIDStr      = GetNextParamStr (&TextDeviceNode);\r
+  PIDStr      = GetNextParamStr (&TextDeviceNode);\r
+  if (UsbClassText->ClassExist) {\r
+    ClassStr = GetNextParamStr (&TextDeviceNode);\r
+    UsbClass->DeviceClass = (UINT8) Strtoi (ClassStr);\r
+  } else {\r
+    UsbClass->DeviceClass = UsbClassText->Class;\r
+  }\r
+  if (UsbClassText->SubClassExist) {\r
+    SubClassStr = GetNextParamStr (&TextDeviceNode);\r
+    UsbClass->DeviceSubClass = (UINT8) Strtoi (SubClassStr);\r
+  } else {\r
+    UsbClass->DeviceSubClass = UsbClassText->SubClass;\r
+  }\r
+\r
+  ProtocolStr = GetNextParamStr (&TextDeviceNode);\r
+\r
+  UsbClass->VendorId        = (UINT16) Strtoi (VIDStr);\r
+  UsbClass->ProductId       = (UINT16) Strtoi (PIDStr);\r
+  UsbClass->DeviceProtocol  = (UINT8) Strtoi (ProtocolStr);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) UsbClass;\r
+}\r
+\r
+\r
+/**\r
+  Converts a text device path node to USB class device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created USB class device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbClass (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  USB_CLASS_TEXT  UsbClassText;\r
+\r
+  UsbClassText.ClassExist    = TRUE;\r
+  UsbClassText.SubClassExist = TRUE;\r
+\r
+  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+/**\r
+  Converts a text device path node to USB audio device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created USB audio device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbAudio (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  USB_CLASS_TEXT  UsbClassText;\r
+\r
+  UsbClassText.ClassExist    = FALSE;\r
+  UsbClassText.Class         = USB_CLASS_AUDIO;\r
+  UsbClassText.SubClassExist = TRUE;\r
+\r
+  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+/**\r
+  Converts a text device path node to USB CDC Control device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created USB CDC Control device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbCDCControl (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  USB_CLASS_TEXT  UsbClassText;\r
+\r
+  UsbClassText.ClassExist    = FALSE;\r
+  UsbClassText.Class         = USB_CLASS_CDCCONTROL;\r
+  UsbClassText.SubClassExist = TRUE;\r
+\r
+  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+/**\r
+  Converts a text device path node to USB HID device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created USB HID device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbHID (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  USB_CLASS_TEXT  UsbClassText;\r
+\r
+  UsbClassText.ClassExist    = FALSE;\r
+  UsbClassText.Class         = USB_CLASS_HID;\r
+  UsbClassText.SubClassExist = TRUE;\r
+\r
+  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+/**\r
+  Converts a text device path node to USB Image device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created USB Image device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbImage (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  USB_CLASS_TEXT  UsbClassText;\r
+\r
+  UsbClassText.ClassExist    = FALSE;\r
+  UsbClassText.Class         = USB_CLASS_IMAGE;\r
+  UsbClassText.SubClassExist = TRUE;\r
+\r
+  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+/**\r
+  Converts a text device path node to USB Print device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created USB Print device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbPrinter (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  USB_CLASS_TEXT  UsbClassText;\r
+\r
+  UsbClassText.ClassExist    = FALSE;\r
+  UsbClassText.Class         = USB_CLASS_PRINTER;\r
+  UsbClassText.SubClassExist = TRUE;\r
+\r
+  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+/**\r
+  Converts a text device path node to USB mass storage device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created USB mass storage device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbMassStorage (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  USB_CLASS_TEXT  UsbClassText;\r
+\r
+  UsbClassText.ClassExist    = FALSE;\r
+  UsbClassText.Class         = USB_CLASS_MASS_STORAGE;\r
+  UsbClassText.SubClassExist = TRUE;\r
+\r
+  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+/**\r
+  Converts a text device path node to USB HUB device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created USB HUB device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbHub (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  USB_CLASS_TEXT  UsbClassText;\r
+\r
+  UsbClassText.ClassExist    = FALSE;\r
+  UsbClassText.Class         = USB_CLASS_HUB;\r
+  UsbClassText.SubClassExist = TRUE;\r
+\r
+  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+/**\r
+  Converts a text device path node to USB CDC data device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created USB CDC data device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbCDCData (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  USB_CLASS_TEXT  UsbClassText;\r
+\r
+  UsbClassText.ClassExist    = FALSE;\r
+  UsbClassText.Class         = USB_CLASS_CDCDATA;\r
+  UsbClassText.SubClassExist = TRUE;\r
+\r
+  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+/**\r
+  Converts a text device path node to USB smart card device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created USB smart card device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbSmartCard (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  USB_CLASS_TEXT  UsbClassText;\r
+\r
+  UsbClassText.ClassExist    = FALSE;\r
+  UsbClassText.Class         = USB_CLASS_SMART_CARD;\r
+  UsbClassText.SubClassExist = TRUE;\r
+\r
+  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+/**\r
+  Converts a text device path node to USB video device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created USB video device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbVideo (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  USB_CLASS_TEXT  UsbClassText;\r
+\r
+  UsbClassText.ClassExist    = FALSE;\r
+  UsbClassText.Class         = USB_CLASS_VIDEO;\r
+  UsbClassText.SubClassExist = TRUE;\r
+\r
+  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+/**\r
+  Converts a text device path node to USB diagnostic device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created USB diagnostic device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbDiagnostic (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  USB_CLASS_TEXT  UsbClassText;\r
+\r
+  UsbClassText.ClassExist    = FALSE;\r
+  UsbClassText.Class         = USB_CLASS_DIAGNOSTIC;\r
+  UsbClassText.SubClassExist = TRUE;\r
+\r
+  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+/**\r
+  Converts a text device path node to USB wireless device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created USB wireless device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbWireless (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  USB_CLASS_TEXT  UsbClassText;\r
+\r
+  UsbClassText.ClassExist    = FALSE;\r
+  UsbClassText.Class         = USB_CLASS_WIRELESS;\r
+  UsbClassText.SubClassExist = TRUE;\r
+\r
+  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+/**\r
+  Converts a text device path node to USB device firmware update device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created USB device firmware update device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbDeviceFirmwareUpdate (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  USB_CLASS_TEXT  UsbClassText;\r
+\r
+  UsbClassText.ClassExist    = FALSE;\r
+  UsbClassText.Class         = USB_CLASS_RESERVE;\r
+  UsbClassText.SubClassExist = FALSE;\r
+  UsbClassText.SubClass      = USB_SUBCLASS_FW_UPDATE;\r
+\r
+  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+/**\r
+  Converts a text device path node to USB IRDA bridge device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created USB IRDA bridge device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbIrdaBridge (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  USB_CLASS_TEXT  UsbClassText;\r
+\r
+  UsbClassText.ClassExist    = FALSE;\r
+  UsbClassText.Class         = USB_CLASS_RESERVE;\r
+  UsbClassText.SubClassExist = FALSE;\r
+  UsbClassText.SubClass      = USB_SUBCLASS_IRDA_BRIDGE;\r
+\r
+  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+/**\r
+  Converts a text device path node to USB text and measurement device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created USB text and measurement device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbTestAndMeasurement (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  USB_CLASS_TEXT  UsbClassText;\r
+\r
+  UsbClassText.ClassExist    = FALSE;\r
+  UsbClassText.Class         = USB_CLASS_RESERVE;\r
+  UsbClassText.SubClassExist = FALSE;\r
+  UsbClassText.SubClass      = USB_SUBCLASS_TEST;\r
+\r
+  return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText);\r
+}\r
+\r
+/**\r
+  Converts a text device path node to USB WWID device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created USB WWID device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUsbWwid (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16                *VIDStr;\r
+  CHAR16                *PIDStr;\r
+  CHAR16                *InterfaceNumStr;\r
+  CHAR16                *SerialNumberStr;\r
+  USB_WWID_DEVICE_PATH  *UsbWwid;\r
+\r
+  VIDStr                    = GetNextParamStr (&TextDeviceNode);\r
+  PIDStr                    = GetNextParamStr (&TextDeviceNode);\r
+  InterfaceNumStr           = GetNextParamStr (&TextDeviceNode);\r
+  SerialNumberStr           = GetNextParamStr (&TextDeviceNode);\r
+  UsbWwid                   = (USB_WWID_DEVICE_PATH *) CreateDeviceNode (\r
+                                                         MESSAGING_DEVICE_PATH,\r
+                                                         MSG_USB_WWID_DP,\r
+                                                         (UINT16) (sizeof (USB_WWID_DEVICE_PATH) + StrSize (SerialNumberStr))\r
+                                                         );\r
+\r
+  UsbWwid->VendorId         = (UINT16) Strtoi (VIDStr);\r
+  UsbWwid->ProductId        = (UINT16) Strtoi (PIDStr);\r
+  UsbWwid->InterfaceNumber  = (UINT16) Strtoi (InterfaceNumStr);\r
+  StrCpy ((CHAR16 *) ((UINT8 *) UsbWwid + sizeof (USB_WWID_DEVICE_PATH)), SerialNumberStr);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) UsbWwid;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to Logic Unit device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created Logic Unit device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUnit (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16                          *LunStr;\r
+  DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;\r
+\r
+  LunStr      = GetNextParamStr (&TextDeviceNode);\r
+  LogicalUnit = (DEVICE_LOGICAL_UNIT_DEVICE_PATH *) CreateDeviceNode (\r
+                                                      MESSAGING_DEVICE_PATH,\r
+                                                      MSG_DEVICE_LOGICAL_UNIT_DP,\r
+                                                      (UINT16) sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH)\r
+                                                      );\r
+\r
+  LogicalUnit->Lun  = (UINT8) Strtoi (LunStr);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) LogicalUnit;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to iSCSI device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created iSCSI device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextiSCSI (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  UINT16                      Options;\r
+  CHAR16                      *NameStr;\r
+  CHAR16                      *PortalGroupStr;\r
+  CHAR16                      *LunStr;\r
+  CHAR16                      *HeaderDigestStr;\r
+  CHAR16                      *DataDigestStr;\r
+  CHAR16                      *AuthenticationStr;\r
+  CHAR16                      *ProtocolStr;\r
+  CHAR8                       *AsciiStr;\r
+  ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;\r
+\r
+  NameStr           = GetNextParamStr (&TextDeviceNode);\r
+  PortalGroupStr    = GetNextParamStr (&TextDeviceNode);\r
+  LunStr            = GetNextParamStr (&TextDeviceNode);\r
+  HeaderDigestStr   = GetNextParamStr (&TextDeviceNode);\r
+  DataDigestStr     = GetNextParamStr (&TextDeviceNode);\r
+  AuthenticationStr = GetNextParamStr (&TextDeviceNode);\r
+  ProtocolStr       = GetNextParamStr (&TextDeviceNode);\r
+  ISCSIDevPath      = (ISCSI_DEVICE_PATH_WITH_NAME *) CreateDeviceNode (\r
+                                                        MESSAGING_DEVICE_PATH,\r
+                                                        MSG_ISCSI_DP,\r
+                                                        (UINT16) (sizeof (ISCSI_DEVICE_PATH_WITH_NAME) + StrLen (NameStr))\r
+                                                        );\r
+\r
+  AsciiStr = ISCSIDevPath->TargetName;\r
+  StrToAscii (NameStr, &AsciiStr);\r
+\r
+  ISCSIDevPath->TargetPortalGroupTag = (UINT16) Strtoi (PortalGroupStr);\r
+  Strtoi64 (LunStr, &ISCSIDevPath->Lun);\r
+\r
+  Options = 0x0000;\r
+  if (StrCmp (HeaderDigestStr, L"CRC32C") == 0) {\r
+    Options |= 0x0002;\r
+  }\r
+\r
+  if (StrCmp (DataDigestStr, L"CRC32C") == 0) {\r
+    Options |= 0x0008;\r
+  }\r
+\r
+  if (StrCmp (AuthenticationStr, L"None") == 0) {\r
+    Options |= 0x0800;\r
+  }\r
+\r
+  if (StrCmp (AuthenticationStr, L"CHAP_UNI") == 0) {\r
+    Options |= 0x1000;\r
+  }\r
+\r
+  ISCSIDevPath->LoginOption      = (UINT16) Options;\r
+\r
+  ISCSIDevPath->NetworkProtocol  = (UINT16) StrCmp (ProtocolStr, L"TCP");\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) ISCSIDevPath;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to VLAN device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created VLAN device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextVlan (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16            *VlanStr;\r
+  VLAN_DEVICE_PATH  *Vlan;\r
+\r
+  VlanStr = GetNextParamStr (&TextDeviceNode);\r
+  Vlan    = (VLAN_DEVICE_PATH *) CreateDeviceNode (\r
+                                   MESSAGING_DEVICE_PATH,\r
+                                   MSG_VLAN_DP,\r
+                                   (UINT16) sizeof (VLAN_DEVICE_PATH)\r
+                                   );\r
+\r
+  Vlan->VlanId = (UINT16) Strtoi (VlanStr);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) Vlan;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to HD device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created HD device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextHD (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16                *PartitionStr;\r
+  CHAR16                *TypeStr;\r
+  CHAR16                *SignatureStr;\r
+  CHAR16                *StartStr;\r
+  CHAR16                *SizeStr;\r
+  UINT32                Signature32;\r
+  EFI_GUID              SignatureGuid;\r
+  HARDDRIVE_DEVICE_PATH *Hd;\r
+\r
+  PartitionStr        = GetNextParamStr (&TextDeviceNode);\r
+  TypeStr             = GetNextParamStr (&TextDeviceNode);\r
+  SignatureStr        = GetNextParamStr (&TextDeviceNode);\r
+  StartStr            = GetNextParamStr (&TextDeviceNode);\r
+  SizeStr             = GetNextParamStr (&TextDeviceNode);\r
+  Hd                  = (HARDDRIVE_DEVICE_PATH *) CreateDeviceNode (\r
+                                                    MEDIA_DEVICE_PATH,\r
+                                                    MEDIA_HARDDRIVE_DP,\r
+                                                    (UINT16) sizeof (HARDDRIVE_DEVICE_PATH)\r
+                                                    );\r
+\r
+  Hd->PartitionNumber = (UINT32) StrDecimalToUintn (PartitionStr);\r
+\r
+  ZeroMem (Hd->Signature, 16);\r
+  Hd->MBRType = (UINT8) 0;\r
+\r
+  if (StrCmp (TypeStr, L"MBR") == 0) {\r
+    Hd->SignatureType = SIGNATURE_TYPE_MBR;\r
+    Hd->MBRType       = 0x01;\r
+\r
+    Signature32       = (UINT32) Strtoi (SignatureStr);\r
+    CopyMem (Hd->Signature, &Signature32, sizeof (UINT32));\r
+  } else if (StrCmp (TypeStr, L"GPT") == 0) {\r
+    Hd->SignatureType = SIGNATURE_TYPE_GUID;\r
+    Hd->MBRType       = 0x02;\r
+\r
+    StrToGuid (SignatureStr, &SignatureGuid);\r
+    CopyMem (Hd->Signature, &SignatureGuid, sizeof (EFI_GUID));\r
+  } else {\r
+    Hd->SignatureType = (UINT8) Strtoi (TypeStr);\r
+  }\r
+\r
+  Strtoi64 (StartStr, &Hd->PartitionStart);\r
+  Strtoi64 (SizeStr, &Hd->PartitionSize);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) Hd;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to CDROM device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created CDROM device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextCDROM (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16            *EntryStr;\r
+  CHAR16            *StartStr;\r
+  CHAR16            *SizeStr;\r
+  CDROM_DEVICE_PATH *CDROMDevPath;\r
+\r
+  EntryStr              = GetNextParamStr (&TextDeviceNode);\r
+  StartStr              = GetNextParamStr (&TextDeviceNode);\r
+  SizeStr               = GetNextParamStr (&TextDeviceNode);\r
+  CDROMDevPath          = (CDROM_DEVICE_PATH *) CreateDeviceNode (\r
+                                                  MEDIA_DEVICE_PATH,\r
+                                                  MEDIA_CDROM_DP,\r
+                                                  (UINT16) sizeof (CDROM_DEVICE_PATH)\r
+                                                  );\r
+\r
+  CDROMDevPath->BootEntry = (UINT32) Strtoi (EntryStr);\r
+  Strtoi64 (StartStr, &CDROMDevPath->PartitionStart);\r
+  Strtoi64 (SizeStr, &CDROMDevPath->PartitionSize);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) CDROMDevPath;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to Vendor-defined media device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created Vendor-defined media device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextVenMEDIA (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  return ConvertFromTextVendor (\r
+           TextDeviceNode,\r
+           MEDIA_DEVICE_PATH,\r
+           MEDIA_VENDOR_DP\r
+           );\r
+}\r
+\r
+/**\r
+  Converts a text device path node to File device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created File device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextFilePath (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  FILEPATH_DEVICE_PATH  *File;\r
+\r
+  File = (FILEPATH_DEVICE_PATH *) CreateDeviceNode (\r
+                                    MEDIA_DEVICE_PATH,\r
+                                    MEDIA_FILEPATH_DP,\r
+                                    (UINT16) (sizeof (FILEPATH_DEVICE_PATH) + StrLen (TextDeviceNode) * 2)\r
+                                    );\r
+\r
+  StrCpy (File->PathName, TextDeviceNode);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) File;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to Media protocol device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created Media protocol device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextMedia (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16                      *GuidStr;\r
+  MEDIA_PROTOCOL_DEVICE_PATH  *Media;\r
+\r
+  GuidStr = GetNextParamStr (&TextDeviceNode);\r
+  Media   = (MEDIA_PROTOCOL_DEVICE_PATH *) CreateDeviceNode (\r
+                                             MEDIA_DEVICE_PATH,\r
+                                             MEDIA_PROTOCOL_DP,\r
+                                             (UINT16) sizeof (MEDIA_PROTOCOL_DEVICE_PATH)\r
+                                             );\r
+\r
+  StrToGuid (GuidStr, &Media->Protocol);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) Media;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to firmware volume device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created firmware volume device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextFv (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16                    *GuidStr;\r
+  MEDIA_FW_VOL_DEVICE_PATH  *Fv;\r
+\r
+  GuidStr = GetNextParamStr (&TextDeviceNode);\r
+  Fv      = (MEDIA_FW_VOL_DEVICE_PATH *) CreateDeviceNode (\r
+                                           MEDIA_DEVICE_PATH,\r
+                                           MEDIA_PIWG_FW_VOL_DP,\r
+                                           (UINT16) sizeof (MEDIA_FW_VOL_DEVICE_PATH)\r
+                                           );\r
+\r
+  StrToGuid (GuidStr, &Fv->FvName);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) Fv;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to firmware file device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created firmware file device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextFvFile (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16                             *GuidStr;\r
+  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH  *FvFile;\r
+\r
+  GuidStr = GetNextParamStr (&TextDeviceNode);\r
+  FvFile  = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) CreateDeviceNode (\r
+                                                    MEDIA_DEVICE_PATH,\r
+                                                    MEDIA_PIWG_FW_FILE_DP,\r
+                                                    (UINT16) sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH)\r
+                                                    );\r
+\r
+  StrToGuid (GuidStr, &FvFile->FvFileName);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) FvFile;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to text relative offset device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created Text device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextRelativeOffsetRange (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16                                  *StartingOffsetStr;\r
+  CHAR16                                  *EndingOffsetStr;\r
+  MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset;\r
+\r
+  StartingOffsetStr = GetNextParamStr (&TextDeviceNode);\r
+  EndingOffsetStr   = GetNextParamStr (&TextDeviceNode);\r
+  Offset            = (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *) CreateDeviceNode (\r
+                                                                    MEDIA_DEVICE_PATH,\r
+                                                                    MEDIA_RELATIVE_OFFSET_RANGE_DP,\r
+                                                                    (UINT16) sizeof (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH)\r
+                                                                    );\r
+\r
+  Strtoi64 (StartingOffsetStr, &Offset->StartingOffset);\r
+  Strtoi64 (EndingOffsetStr, &Offset->EndingOffset);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) Offset;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to BIOS Boot Specification device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created BIOS Boot Specification device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextBBS (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16              *TypeStr;\r
+  CHAR16              *IdStr;\r
+  CHAR16              *FlagsStr;\r
+  CHAR8               *AsciiStr;\r
+  BBS_BBS_DEVICE_PATH *Bbs;\r
+\r
+  TypeStr   = GetNextParamStr (&TextDeviceNode);\r
+  IdStr     = GetNextParamStr (&TextDeviceNode);\r
+  FlagsStr  = GetNextParamStr (&TextDeviceNode);\r
+  Bbs       = (BBS_BBS_DEVICE_PATH *) CreateDeviceNode (\r
+                                        BBS_DEVICE_PATH,\r
+                                        BBS_BBS_DP,\r
+                                        (UINT16) (sizeof (BBS_BBS_DEVICE_PATH) + StrLen (IdStr))\r
+                                        );\r
+\r
+  if (StrCmp (TypeStr, L"Floppy") == 0) {\r
+    Bbs->DeviceType = BBS_TYPE_FLOPPY;\r
+  } else if (StrCmp (TypeStr, L"HD") == 0) {\r
+    Bbs->DeviceType = BBS_TYPE_HARDDRIVE;\r
+  } else if (StrCmp (TypeStr, L"CDROM") == 0) {\r
+    Bbs->DeviceType = BBS_TYPE_CDROM;\r
+  } else if (StrCmp (TypeStr, L"PCMCIA") == 0) {\r
+    Bbs->DeviceType = BBS_TYPE_PCMCIA;\r
+  } else if (StrCmp (TypeStr, L"USB") == 0) {\r
+    Bbs->DeviceType = BBS_TYPE_USB;\r
+  } else if (StrCmp (TypeStr, L"Network") == 0) {\r
+    Bbs->DeviceType = BBS_TYPE_EMBEDDED_NETWORK;\r
+  } else {\r
+    Bbs->DeviceType = (UINT16) Strtoi (TypeStr);\r
+  }\r
+\r
+  AsciiStr = Bbs->String;\r
+  StrToAscii (IdStr, &AsciiStr);\r
+\r
+  Bbs->StatusFlag = (UINT16) Strtoi (FlagsStr);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) Bbs;\r
+}\r
+\r
+/**\r
+  Converts a text device path node to SATA device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created SATA device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextSata (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  SATA_DEVICE_PATH *Sata;\r
+  CHAR16           *Param1;\r
+  CHAR16           *Param2;\r
+  CHAR16           *Param3;\r
+\r
+  //\r
+  // The PMPN is optional.\r
+  //\r
+  Param1 = GetNextParamStr (&TextDeviceNode);\r
+  Param2 = GetNextParamStr (&TextDeviceNode);\r
+  Param3 = NULL;\r
+  if (!IS_NULL (TextDeviceNode)) {\r
+    Param3 = GetNextParamStr (&TextDeviceNode);\r
+  }\r
+\r
+  Sata = (SATA_DEVICE_PATH *) CreateDeviceNode (\r
+                                MESSAGING_DEVICE_PATH,\r
+                                MSG_SATA_DP,\r
+                                (UINT16) sizeof (SATA_DEVICE_PATH)\r
+                                );\r
+  Sata->HBAPortNumber = (UINT16) StrHexToUintn (Param1);\r
+  if (Param3 != NULL) {\r
+    Sata->PortMultiplierPortNumber = (UINT16) StrHexToUintn (Param2);\r
+    Param2                   = Param3;\r
+  } else {\r
+    Sata->PortMultiplierPortNumber = SATA_HBA_DIRECT_CONNECT_FLAG;\r
+  }\r
+  Sata->Lun = (UINT16) StrHexToUintn (Param2);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) Sata;\r
+}\r
+\r
+GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevPathFromTextTable[] = {\r
+  {L"Pci",                     DevPathFromTextPci                     },\r
+  {L"PcCard",                  DevPathFromTextPcCard                  },\r
+  {L"MemoryMapped",            DevPathFromTextMemoryMapped            },\r
+  {L"VenHw",                   DevPathFromTextVenHw                   },\r
+  {L"Ctrl",                    DevPathFromTextCtrl                    },\r
+  {L"Acpi",                    DevPathFromTextAcpi                    },\r
+  {L"PciRoot",                 DevPathFromTextPciRoot                 },\r
+  {L"PcieRoot",                DevPathFromTextPcieRoot                },\r
+  {L"Floppy",                  DevPathFromTextFloppy                  },\r
+  {L"Keyboard",                DevPathFromTextKeyboard                },\r
+  {L"Serial",                  DevPathFromTextSerial                  },\r
+  {L"ParallelPort",            DevPathFromTextParallelPort            },\r
+  {L"AcpiEx",                  DevPathFromTextAcpiEx                  },\r
+  {L"AcpiExp",                 DevPathFromTextAcpiExp                 },\r
+  {L"AcpiAdr",                 DevPathFromTextAcpiAdr                 },\r
+  {L"Ata",                     DevPathFromTextAta                     },\r
+  {L"Scsi",                    DevPathFromTextScsi                    },\r
+  {L"Fibre",                   DevPathFromTextFibre                   },\r
+  {L"FibreEx",                 DevPathFromTextFibreEx                 },\r
+  {L"I1394",                   DevPathFromText1394                    },\r
+  {L"USB",                     DevPathFromTextUsb                     },\r
+  {L"I2O",                     DevPathFromTextI2O                     },\r
+  {L"Infiniband",              DevPathFromTextInfiniband              },\r
+  {L"VenMsg",                  DevPathFromTextVenMsg                  },\r
+  {L"VenPcAnsi",               DevPathFromTextVenPcAnsi               },\r
+  {L"VenVt100",                DevPathFromTextVenVt100                },\r
+  {L"VenVt100Plus",            DevPathFromTextVenVt100Plus            },\r
+  {L"VenUtf8",                 DevPathFromTextVenUtf8                 },\r
+  {L"UartFlowCtrl",            DevPathFromTextUartFlowCtrl            },\r
+  {L"SAS",                     DevPathFromTextSAS                     },\r
+  {L"SasEx",                   DevPathFromTextSasEx                   },\r
+  {L"DebugPort",               DevPathFromTextDebugPort               },\r
+  {L"MAC",                     DevPathFromTextMAC                     },\r
+  {L"IPv4",                    DevPathFromTextIPv4                    },\r
+  {L"IPv6",                    DevPathFromTextIPv6                    },\r
+  {L"Uart",                    DevPathFromTextUart                    },\r
+  {L"UsbClass",                DevPathFromTextUsbClass                },\r
+  {L"UsbAudio",                DevPathFromTextUsbAudio                },\r
+  {L"UsbCDCControl",           DevPathFromTextUsbCDCControl           },\r
+  {L"UsbHID",                  DevPathFromTextUsbHID                  },\r
+  {L"UsbImage",                DevPathFromTextUsbImage                },\r
+  {L"UsbPrinter",              DevPathFromTextUsbPrinter              },\r
+  {L"UsbMassStorage",          DevPathFromTextUsbMassStorage          },\r
+  {L"UsbHub",                  DevPathFromTextUsbHub                  },\r
+  {L"UsbCDCData",              DevPathFromTextUsbCDCData              },\r
+  {L"UsbSmartCard",            DevPathFromTextUsbSmartCard            },\r
+  {L"UsbVideo",                DevPathFromTextUsbVideo                },\r
+  {L"UsbDiagnostic",           DevPathFromTextUsbDiagnostic           },\r
+  {L"UsbWireless",             DevPathFromTextUsbWireless             },\r
+  {L"UsbDeviceFirmwareUpdate", DevPathFromTextUsbDeviceFirmwareUpdate },\r
+  {L"UsbIrdaBridge",           DevPathFromTextUsbIrdaBridge           },\r
+  {L"UsbTestAndMeasurement",   DevPathFromTextUsbTestAndMeasurement   },\r
+  {L"UsbWwid",                 DevPathFromTextUsbWwid                 },\r
+  {L"Unit",                    DevPathFromTextUnit                    },\r
+  {L"iSCSI",                   DevPathFromTextiSCSI                   },\r
+  {L"Vlan",                    DevPathFromTextVlan                    },\r
+  {L"HD",                      DevPathFromTextHD                      },\r
+  {L"CDROM",                   DevPathFromTextCDROM                   },\r
+  {L"VenMEDIA",                DevPathFromTextVenMEDIA                },\r
+  {L"Media",                   DevPathFromTextMedia                   },\r
+  {L"Fv",                      DevPathFromTextFv                      },\r
+  {L"FvFile",                  DevPathFromTextFvFile                  },\r
+  {L"Offset",                  DevPathFromTextRelativeOffsetRange     },\r
+  {L"BBS",                     DevPathFromTextBBS                     },\r
+  {L"Sata",                    DevPathFromTextSata                    },\r
+  {NULL, NULL}\r
+};\r
+\r
+/**\r
+  Convert text to the binary representation of a device node.\r
+\r
+  @param TextDeviceNode  TextDeviceNode points to the text representation of a device\r
+                         node. Conversion starts with the first character and continues\r
+                         until the first non-device node character.\r
+\r
+  @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was\r
+          insufficient memory or text unsupported.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+UefiDevicePathLibConvertTextToDeviceNode (\r
+  IN CONST CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  DEVICE_PATH_FROM_TEXT    FromText;\r
+  CHAR16                   *ParamStr;\r
+  EFI_DEVICE_PATH_PROTOCOL *DeviceNode;\r
+  CHAR16                   *DeviceNodeStr;\r
+  UINTN                    Index;\r
+\r
+  if ((TextDeviceNode == NULL) || (IS_NULL (*TextDeviceNode))) {\r
+    return NULL;\r
+  }\r
+\r
+  ParamStr      = NULL;\r
+  FromText      = NULL;\r
+  DeviceNodeStr = UefiDevicePathLibStrDuplicate (TextDeviceNode);\r
+  ASSERT (DeviceNodeStr != NULL);\r
+\r
+  for (Index = 0; mUefiDevicePathLibDevPathFromTextTable[Index].Function != NULL; Index++) {\r
+    ParamStr = GetParamByNodeName (DeviceNodeStr, mUefiDevicePathLibDevPathFromTextTable[Index].DevicePathNodeText);\r
+    if (ParamStr != NULL) {\r
+      FromText = mUefiDevicePathLibDevPathFromTextTable[Index].Function;\r
+      break;\r
+    }\r
+  }\r
+\r
+  if (FromText == NULL) {\r
+    //\r
+    // A file path\r
+    //\r
+    FromText = DevPathFromTextFilePath;\r
+    DeviceNode = FromText (DeviceNodeStr);\r
+  } else {\r
+    DeviceNode = FromText (ParamStr);\r
+    FreePool (ParamStr);\r
+  }\r
+\r
+  FreePool (DeviceNodeStr);\r
+\r
+  return DeviceNode;\r
+}\r
+\r
+/**\r
+  Convert text to the binary representation of a device path.\r
+\r
+\r
+  @param TextDevicePath  TextDevicePath points to the text representation of a device\r
+                         path. Conversion starts with the first character and continues\r
+                         until the first non-device node character.\r
+\r
+  @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or\r
+          there was insufficient memory.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+UefiDevicePathLibConvertTextToDevicePath (\r
+  IN CONST CHAR16 *TextDevicePath\r
+  )\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL *DeviceNode;\r
+  EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;\r
+  CHAR16                   *DevicePathStr;\r
+  CHAR16                   *Str;\r
+  CHAR16                   *DeviceNodeStr;\r
+  BOOLEAN                  IsInstanceEnd;\r
+  EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+\r
+  if ((TextDevicePath == NULL) || (IS_NULL (*TextDevicePath))) {\r
+    return NULL;\r
+  }\r
+\r
+  DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);\r
+  ASSERT (DevicePath != NULL);\r
+  SetDevicePathEndNode (DevicePath);\r
+\r
+  DevicePathStr = UefiDevicePathLibStrDuplicate (TextDevicePath);\r
+\r
+  Str           = DevicePathStr;\r
+  while ((DeviceNodeStr = GetNextDeviceNodeStr (&Str, &IsInstanceEnd)) != NULL) {\r
+    DeviceNode = UefiDevicePathLibConvertTextToDeviceNode (DeviceNodeStr);\r
+\r
+    NewDevicePath = AppendDevicePathNode (DevicePath, DeviceNode);\r
+    FreePool (DevicePath);\r
+    FreePool (DeviceNode);\r
+    DevicePath = NewDevicePath;\r
+\r
+    if (IsInstanceEnd) {\r
+      DeviceNode = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);\r
+      ASSERT (DeviceNode != NULL);\r
+      SetDevicePathEndNode (DeviceNode);\r
+\r
+      NewDevicePath = AppendDevicePathNode (DevicePath, DeviceNode);\r
+      FreePool (DevicePath);\r
+      FreePool (DeviceNode);\r
+      DevicePath = NewDevicePath;\r
+    }\r
+  }\r
+\r
+  FreePool (DevicePathStr);\r
+  return DevicePath;\r
+}\r
diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
new file mode 100644 (file)
index 0000000..83c3f8b
--- /dev/null
@@ -0,0 +1,1969 @@
+/** @file\r
+  DevicePathToText protocol as defined in the UEFI 2.0 specification.\r
+\r
+Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "UefiDevicePathLib.h"\r
+\r
+/**\r
+  Concatenates a formatted unicode string to allocated pool. The caller must\r
+  free the resulting buffer.\r
+\r
+  @param Str             Tracks the allocated pool, size in use, and\r
+                         amount of pool allocated.\r
+  @param Fmt             The format string\r
+  @param ...             Variable arguments based on the format string.\r
+\r
+  @return Allocated buffer with the formatted string printed in it.\r
+          The caller must free the allocated buffer. The buffer\r
+          allocation is not packed.\r
+\r
+**/\r
+CHAR16 *\r
+UefiDevicePathLibCatPrint (\r
+  IN OUT POOL_PRINT   *Str,\r
+  IN CHAR16           *Fmt,\r
+  ...\r
+  )\r
+{\r
+  UINTN   Count;\r
+  VA_LIST Args;\r
+\r
+  VA_START (Args, Fmt);\r
+  Count = SPrintLength (Fmt, Args);\r
+\r
+  if ((Str->Count + (Count + 1)) * sizeof (CHAR16) > Str->Capacity) {\r
+    Str->Capacity = (Str->Count + (Count + 1) * 2) * sizeof (CHAR16);\r
+    Str->Str = ReallocatePool (\r
+                 Str->Count * sizeof (CHAR16),\r
+                 Str->Capacity,\r
+                 Str->Str\r
+                 );\r
+    ASSERT (Str->Str != NULL);\r
+  }\r
+  UnicodeVSPrint (&Str->Str[Str->Count], Str->Capacity - Str->Count * sizeof (CHAR16), Fmt, Args);\r
+  Str->Count += Count;\r
+  \r
+  VA_END (Args);\r
+  return Str->Str;\r
+}\r
+\r
+/**\r
+  Converts a PCI device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextPci (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  PCI_DEVICE_PATH *Pci;\r
+\r
+  Pci = DevPath;\r
+  UefiDevicePathLibCatPrint (Str, L"Pci(0x%x,0x%x)", Pci->Device, Pci->Function);\r
+}\r
+\r
+/**\r
+  Converts a PC Card device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextPccard (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  PCCARD_DEVICE_PATH  *Pccard;\r
+\r
+  Pccard = DevPath;\r
+  UefiDevicePathLibCatPrint (Str, L"PcCard(0x%x)", Pccard->FunctionNumber);\r
+}\r
+\r
+/**\r
+  Converts a Memory Map device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextMemMap (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  MEMMAP_DEVICE_PATH  *MemMap;\r
+\r
+  MemMap = DevPath;\r
+  UefiDevicePathLibCatPrint (\r
+    Str,\r
+    L"MemoryMapped(0x%x,0x%lx,0x%lx)",\r
+    MemMap->MemoryType,\r
+    MemMap->StartingAddress,\r
+    MemMap->EndingAddress\r
+    );\r
+}\r
+\r
+/**\r
+  Converts a Vendor device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextVendor (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  VENDOR_DEVICE_PATH  *Vendor;\r
+  CHAR16              *Type;\r
+  UINTN               Index;\r
+  UINTN               DataLength;\r
+  UINT32              FlowControlMap;\r
+  UINT16              Info;\r
+\r
+  Vendor = (VENDOR_DEVICE_PATH *) DevPath;\r
+  switch (DevicePathType (&Vendor->Header)) {\r
+  case HARDWARE_DEVICE_PATH:\r
+    Type = L"Hw";\r
+    break;\r
+\r
+  case MESSAGING_DEVICE_PATH:\r
+    Type = L"Msg";\r
+    if (AllowShortcuts) {\r
+      if (CompareGuid (&Vendor->Guid, &gEfiPcAnsiGuid)) {\r
+        UefiDevicePathLibCatPrint (Str, L"VenPcAnsi()");\r
+        return ;\r
+      } else if (CompareGuid (&Vendor->Guid, &gEfiVT100Guid)) {\r
+        UefiDevicePathLibCatPrint (Str, L"VenVt100()");\r
+        return ;\r
+      } else if (CompareGuid (&Vendor->Guid, &gEfiVT100PlusGuid)) {\r
+        UefiDevicePathLibCatPrint (Str, L"VenVt100Plus()");\r
+        return ;\r
+      } else if (CompareGuid (&Vendor->Guid, &gEfiVTUTF8Guid)) {\r
+        UefiDevicePathLibCatPrint (Str, L"VenUft8()");\r
+        return ;\r
+      } else if (CompareGuid (&Vendor->Guid, &gEfiUartDevicePathGuid)) {\r
+        FlowControlMap = (((UART_FLOW_CONTROL_DEVICE_PATH *) Vendor)->FlowControlMap);\r
+        switch (FlowControlMap & 0x00000003) {\r
+        case 0:\r
+          UefiDevicePathLibCatPrint (Str, L"UartFlowCtrl(%s)", L"None");\r
+          break;\r
+\r
+        case 1:\r
+          UefiDevicePathLibCatPrint (Str, L"UartFlowCtrl(%s)", L"Hardware");\r
+          break;\r
+\r
+        case 2:\r
+          UefiDevicePathLibCatPrint (Str, L"UartFlowCtrl(%s)", L"XonXoff");\r
+          break;\r
+\r
+        default:\r
+          break;\r
+        }\r
+\r
+        return ;\r
+      } else if (CompareGuid (&Vendor->Guid, &gEfiSasDevicePathGuid)) {\r
+        UefiDevicePathLibCatPrint (\r
+          Str,\r
+          L"SAS(0x%lx,0x%lx,0x%x,",\r
+          ((SAS_DEVICE_PATH *) Vendor)->SasAddress,\r
+          ((SAS_DEVICE_PATH *) Vendor)->Lun,\r
+          ((SAS_DEVICE_PATH *) Vendor)->RelativeTargetPort\r
+          );\r
+        Info = (((SAS_DEVICE_PATH *) Vendor)->DeviceTopology);\r
+        if (((Info & 0x0f) == 0) && ((Info & BIT7) == 0)) {\r
+          UefiDevicePathLibCatPrint (Str, L"NoTopology,0,0,0,");\r
+        } else if (((Info & 0x0f) <= 2) && ((Info & BIT7) == 0)) {\r
+          UefiDevicePathLibCatPrint (\r
+            Str,\r
+            L"%s,%s,%s,",\r
+            ((Info & BIT4) != 0) ? L"SATA" : L"SAS",\r
+            ((Info & BIT5) != 0) ? L"External" : L"Internal",\r
+            ((Info & BIT6) != 0) ? L"Expanded" : L"Direct"\r
+            );\r
+          if ((Info & 0x0f) == 1) {\r
+            UefiDevicePathLibCatPrint (Str, L"0,");\r
+          } else {\r
+            //\r
+            // Value 0x0 thru 0xFF -> Drive 1 thru Drive 256\r
+            //\r
+            UefiDevicePathLibCatPrint (Str, L"0x%x,", ((Info >> 8) & 0xff) + 1);\r
+          }\r
+        } else {\r
+          UefiDevicePathLibCatPrint (Str, L"0x%x,0,0,0,", Info);\r
+        }\r
+\r
+        UefiDevicePathLibCatPrint (Str, L"0x%x)", ((SAS_DEVICE_PATH *) Vendor)->Reserved);\r
+        return ;\r
+      } else if (CompareGuid (&Vendor->Guid, &gEfiDebugPortProtocolGuid)) {\r
+        UefiDevicePathLibCatPrint (Str, L"DebugPort()");\r
+        return ;\r
+      }\r
+    }\r
+    break;\r
+\r
+  case MEDIA_DEVICE_PATH:\r
+    Type = L"Media";\r
+    break;\r
+\r
+  default:\r
+    Type = L"?";\r
+    break;\r
+  }\r
+\r
+  DataLength = DevicePathNodeLength (&Vendor->Header) - sizeof (VENDOR_DEVICE_PATH);\r
+  UefiDevicePathLibCatPrint (Str, L"Ven%s(%g", Type, &Vendor->Guid);\r
+  if (DataLength != 0) {\r
+    UefiDevicePathLibCatPrint (Str, L",");\r
+    for (Index = 0; Index < DataLength; Index++) {\r
+      UefiDevicePathLibCatPrint (Str, L"%02x", ((VENDOR_DEVICE_PATH_WITH_DATA *) Vendor)->VendorDefinedData[Index]);\r
+    }\r
+  }\r
+\r
+  UefiDevicePathLibCatPrint (Str, L")");\r
+}\r
+\r
+/**\r
+  Converts a Controller device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextController (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  CONTROLLER_DEVICE_PATH  *Controller;\r
+\r
+  Controller = DevPath;\r
+  UefiDevicePathLibCatPrint (\r
+    Str,\r
+    L"Ctrl(0x%x)",\r
+    Controller->ControllerNumber\r
+    );\r
+}\r
+\r
+/**\r
+  Converts a ACPI device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextAcpi (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  ACPI_HID_DEVICE_PATH  *Acpi;\r
+\r
+  Acpi = DevPath;\r
+  if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
+    switch (EISA_ID_TO_NUM (Acpi->HID)) {\r
+    case 0x0a03:\r
+      UefiDevicePathLibCatPrint (Str, L"PciRoot(0x%x)", Acpi->UID);\r
+      break;\r
+\r
+    case 0x0a08:\r
+      UefiDevicePathLibCatPrint (Str, L"PcieRoot(0x%x)", Acpi->UID);\r
+      break;\r
+\r
+    case 0x0604:\r
+      UefiDevicePathLibCatPrint (Str, L"Floppy(0x%x)", Acpi->UID);\r
+      break;\r
+\r
+    case 0x0301:\r
+      UefiDevicePathLibCatPrint (Str, L"Keyboard(0x%x)", Acpi->UID);\r
+      break;\r
+\r
+    case 0x0501:\r
+      UefiDevicePathLibCatPrint (Str, L"Serial(0x%x)", Acpi->UID);\r
+      break;\r
+\r
+    case 0x0401:\r
+      UefiDevicePathLibCatPrint (Str, L"ParallelPort(0x%x)", Acpi->UID);\r
+      break;\r
+\r
+    default:\r
+      UefiDevicePathLibCatPrint (Str, L"Acpi(PNP%04x,0x%x)", EISA_ID_TO_NUM (Acpi->HID), Acpi->UID);\r
+      break;\r
+    }\r
+  } else {\r
+    UefiDevicePathLibCatPrint (Str, L"Acpi(0x%08x,0x%x)", Acpi->HID, Acpi->UID);\r
+  }\r
+}\r
+\r
+/**\r
+  Converts a ACPI extended HID device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextAcpiEx (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  ACPI_EXTENDED_HID_DEVICE_PATH  *AcpiEx;\r
+  CHAR8                          *HIDStr;\r
+  CHAR8                          *UIDStr;\r
+  CHAR8                          *CIDStr;\r
+  CHAR16                         HIDText[11];\r
+  CHAR16                         CIDText[11];\r
+\r
+  AcpiEx = DevPath;\r
+  HIDStr = (CHAR8 *) (((UINT8 *) AcpiEx) + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));\r
+  UIDStr = HIDStr + AsciiStrLen (HIDStr) + 1;\r
+  CIDStr = UIDStr + AsciiStrLen (UIDStr) + 1;\r
+\r
+  //\r
+  // Converts EISA identification to string.\r
+  // \r
+  UnicodeSPrint (\r
+    HIDText,\r
+    sizeof (HIDText),\r
+    L"%c%c%c%04X",\r
+    ((AcpiEx->HID >> 10) & 0x1f) + 'A' - 1,\r
+    ((AcpiEx->HID >>  5) & 0x1f) + 'A' - 1,\r
+    ((AcpiEx->HID >>  0) & 0x1f) + 'A' - 1,\r
+    (AcpiEx->HID >> 16) & 0xFFFF\r
+    );\r
+  UnicodeSPrint (\r
+    CIDText,\r
+    sizeof (CIDText),\r
+    L"%c%c%c%04X",\r
+    ((AcpiEx->CID >> 10) & 0x1f) + 'A' - 1,\r
+    ((AcpiEx->CID >>  5) & 0x1f) + 'A' - 1,\r
+    ((AcpiEx->CID >>  0) & 0x1f) + 'A' - 1,\r
+    (AcpiEx->CID >> 16) & 0xFFFF\r
+    );\r
+\r
+  if ((*HIDStr == '\0') && (*CIDStr == '\0') && (AcpiEx->UID == 0)) {\r
+    //\r
+    // use AcpiExp()\r
+    //\r
+    UefiDevicePathLibCatPrint (\r
+      Str,\r
+      L"AcpiExp(%s,%s,%a)",\r
+      HIDText,\r
+      CIDText,\r
+      UIDStr\r
+      );\r
+  } else {\r
+    if (AllowShortcuts) {\r
+      //\r
+      // display only\r
+      //\r
+      if (AcpiEx->HID == 0) {\r
+        UefiDevicePathLibCatPrint (Str, L"AcpiEx(%a,", HIDStr);\r
+      } else {\r
+        UefiDevicePathLibCatPrint (Str, L"AcpiEx(%s,", HIDText);\r
+      }\r
+\r
+      if (AcpiEx->UID == 0) {\r
+        UefiDevicePathLibCatPrint (Str, L"%a,", UIDStr);\r
+      } else {\r
+        UefiDevicePathLibCatPrint (Str, L"0x%x,", AcpiEx->UID);\r
+      }\r
+\r
+      if (AcpiEx->CID == 0) {\r
+        UefiDevicePathLibCatPrint (Str, L"%a)", CIDStr);\r
+      } else {\r
+        UefiDevicePathLibCatPrint (Str, L"%s)", CIDText);\r
+      }\r
+    } else {\r
+      UefiDevicePathLibCatPrint (\r
+        Str,\r
+        L"AcpiEx(%s,%s,0x%x,%a,%a,%a)",\r
+        HIDText,\r
+        CIDText,\r
+        AcpiEx->UID,\r
+        HIDStr,\r
+        CIDStr,\r
+        UIDStr\r
+        );\r
+    }\r
+  }\r
+}\r
+\r
+/**\r
+  Converts a ACPI address device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextAcpiAdr (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  ACPI_ADR_DEVICE_PATH    *AcpiAdr;\r
+  UINT16                  Index;\r
+  UINT16                  Length;\r
+  UINT16                  AdditionalAdrCount;\r
+\r
+  AcpiAdr            = DevPath;\r
+  Length             = (UINT16) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) AcpiAdr);\r
+  AdditionalAdrCount = (UINT16) ((Length - 8) / 4);\r
+\r
+  UefiDevicePathLibCatPrint (Str, L"AcpiAdr(0x%x", AcpiAdr->ADR);\r
+  for (Index = 0; Index < AdditionalAdrCount; Index++) {\r
+    UefiDevicePathLibCatPrint (Str, L",0x%x", *(UINT32 *) ((UINT8 *) AcpiAdr + 8 + Index * 4));\r
+  }\r
+  UefiDevicePathLibCatPrint (Str, L")");\r
+}\r
+\r
+/**\r
+  Converts a ATAPI device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextAtapi (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  ATAPI_DEVICE_PATH *Atapi;\r
+\r
+  Atapi = DevPath;\r
+\r
+  if (DisplayOnly) {\r
+    UefiDevicePathLibCatPrint (Str, L"Ata(0x%x)", Atapi->Lun);\r
+  } else {\r
+    UefiDevicePathLibCatPrint (\r
+      Str,\r
+      L"Ata(%s,%s,0x%x)",\r
+      (Atapi->PrimarySecondary == 1) ? L"Secondary" : L"Primary",\r
+      (Atapi->SlaveMaster == 1) ? L"Slave" : L"Master",\r
+      Atapi->Lun\r
+      );\r
+  }\r
+}\r
+\r
+/**\r
+  Converts a SCSI device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextScsi (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  SCSI_DEVICE_PATH  *Scsi;\r
+\r
+  Scsi = DevPath;\r
+  UefiDevicePathLibCatPrint (Str, L"Scsi(0x%x,0x%x)", Scsi->Pun, Scsi->Lun);\r
+}\r
+\r
+/**\r
+  Converts a Fibre device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextFibre (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  FIBRECHANNEL_DEVICE_PATH  *Fibre;\r
+\r
+  Fibre = DevPath;\r
+  UefiDevicePathLibCatPrint (Str, L"Fibre(0x%lx,0x%lx)", Fibre->WWN, Fibre->Lun);\r
+}\r
+\r
+/**\r
+  Converts a FibreEx device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextFibreEx (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  FIBRECHANNELEX_DEVICE_PATH  *FibreEx;\r
+  UINTN                       Index;\r
+\r
+  FibreEx = DevPath;\r
+  UefiDevicePathLibCatPrint (Str, L"FibreEx(0x");\r
+  for (Index = 0; Index < sizeof (FibreEx->WWN) / sizeof (FibreEx->WWN[0]); Index++) {\r
+    UefiDevicePathLibCatPrint (Str, L"%02x", FibreEx->WWN[Index]);\r
+  }\r
+  UefiDevicePathLibCatPrint (Str, L",0x");\r
+  for (Index = 0; Index < sizeof (FibreEx->Lun) / sizeof (FibreEx->Lun[0]); Index++) {\r
+    UefiDevicePathLibCatPrint (Str, L"%02x", FibreEx->Lun[Index]);\r
+  }\r
+  UefiDevicePathLibCatPrint (Str, L")");\r
+}\r
+\r
+/**\r
+  Converts a Sas Ex device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextSasEx (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  SASEX_DEVICE_PATH  *SasEx;\r
+  UINTN              Index;\r
+\r
+  SasEx = DevPath;\r
+  UefiDevicePathLibCatPrint (Str, L"SasEx(0x");\r
+\r
+  for (Index = 0; Index < sizeof (SasEx->SasAddress) / sizeof (SasEx->SasAddress[0]); Index++) {\r
+    UefiDevicePathLibCatPrint (Str, L"%02x", SasEx->SasAddress[Index]);\r
+  }\r
+  UefiDevicePathLibCatPrint (Str, L",0x");\r
+  for (Index = 0; Index < sizeof (SasEx->Lun) / sizeof (SasEx->Lun[0]); Index++) {\r
+    UefiDevicePathLibCatPrint (Str, L"%02x", SasEx->Lun[Index]);\r
+  }\r
+  UefiDevicePathLibCatPrint (Str, L",0x%x,", SasEx->RelativeTargetPort);\r
+\r
+  if (((SasEx->DeviceTopology & 0x0f) == 0) && ((SasEx->DeviceTopology & BIT7) == 0)) {\r
+    UefiDevicePathLibCatPrint (Str, L"NoTopology,0,0,0");\r
+  } else if (((SasEx->DeviceTopology & 0x0f) <= 2) && ((SasEx->DeviceTopology & BIT7) == 0)) {\r
+    UefiDevicePathLibCatPrint (\r
+      Str,\r
+      L"%s,%s,%s,",\r
+      ((SasEx->DeviceTopology & BIT4) != 0) ? L"SATA" : L"SAS",\r
+      ((SasEx->DeviceTopology & BIT5) != 0) ? L"External" : L"Internal",\r
+      ((SasEx->DeviceTopology & BIT6) != 0) ? L"Expanded" : L"Direct"\r
+      );\r
+    if ((SasEx->DeviceTopology & 0x0f) == 1) {\r
+      UefiDevicePathLibCatPrint (Str, L"0");\r
+    } else {\r
+      //\r
+      // Value 0x0 thru 0xFF -> Drive 1 thru Drive 256\r
+      //\r
+      UefiDevicePathLibCatPrint (Str, L"0x%x", ((SasEx->DeviceTopology >> 8) & 0xff) + 1);\r
+    }\r
+  } else {\r
+    UefiDevicePathLibCatPrint (Str, L"0x%x,0,0,0", SasEx->DeviceTopology);\r
+  }\r
+\r
+  UefiDevicePathLibCatPrint (Str, L")");\r
+  return ;\r
+\r
+}\r
+\r
+/**\r
+  Converts a 1394 device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToText1394 (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  F1394_DEVICE_PATH *F1394DevPath;\r
+\r
+  F1394DevPath = DevPath;\r
+  //\r
+  // Guid has format of IEEE-EUI64\r
+  //\r
+  UefiDevicePathLibCatPrint (Str, L"I1394(%016lx)", F1394DevPath->Guid);\r
+}\r
+\r
+/**\r
+  Converts a USB device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextUsb (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  USB_DEVICE_PATH *Usb;\r
+\r
+  Usb = DevPath;\r
+  UefiDevicePathLibCatPrint (Str, L"USB(0x%x,0x%x)", Usb->ParentPortNumber, Usb->InterfaceNumber);\r
+}\r
+\r
+/**\r
+  Converts a USB WWID device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextUsbWWID (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  USB_WWID_DEVICE_PATH  *UsbWWId;\r
+  CHAR16                *SerialNumberStr;\r
+  CHAR16                *NewStr;\r
+  UINT16                Length;\r
+\r
+  UsbWWId = DevPath;\r
+\r
+  SerialNumberStr = (CHAR16 *) ((UINT8 *) UsbWWId + sizeof (USB_WWID_DEVICE_PATH));\r
+  Length = (UINT16) ((DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) UsbWWId) - sizeof (USB_WWID_DEVICE_PATH)) / sizeof (CHAR16));\r
+  if (SerialNumberStr [Length - 1] != 0) {\r
+    //\r
+    // In case no NULL terminator in SerialNumber, create a new one with NULL terminator\r
+    //\r
+    NewStr = AllocateCopyPool ((Length + 1) * sizeof (CHAR16), SerialNumberStr);\r
+    ASSERT (NewStr != NULL);\r
+    NewStr [Length] = 0;\r
+    SerialNumberStr = NewStr;\r
+  }\r
+\r
+  UefiDevicePathLibCatPrint (\r
+    Str,\r
+    L"UsbWwid(0x%x,0x%x,0x%x,\"%s\")",\r
+    UsbWWId->VendorId,\r
+    UsbWWId->ProductId,\r
+    UsbWWId->InterfaceNumber,\r
+    SerialNumberStr\r
+    );\r
+}\r
+\r
+/**\r
+  Converts a Logic Unit device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextLogicalUnit (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;\r
+\r
+  LogicalUnit = DevPath;\r
+  UefiDevicePathLibCatPrint (Str, L"Unit(0x%x)", LogicalUnit->Lun);\r
+}\r
+\r
+/**\r
+  Converts a USB class device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextUsbClass (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  USB_CLASS_DEVICE_PATH *UsbClass;\r
+  BOOLEAN               IsKnownSubClass;\r
+\r
+\r
+  UsbClass = DevPath;\r
+\r
+  IsKnownSubClass = TRUE;\r
+  switch (UsbClass->DeviceClass) {\r
+  case USB_CLASS_AUDIO:\r
+    UefiDevicePathLibCatPrint (Str, L"UsbAudio");\r
+    break;\r
+\r
+  case USB_CLASS_CDCCONTROL:\r
+    UefiDevicePathLibCatPrint (Str, L"UsbCDCControl");\r
+    break;\r
+\r
+  case USB_CLASS_HID:\r
+    UefiDevicePathLibCatPrint (Str, L"UsbHID");\r
+    break;\r
+\r
+  case USB_CLASS_IMAGE:\r
+    UefiDevicePathLibCatPrint (Str, L"UsbImage");\r
+    break;\r
+\r
+  case USB_CLASS_PRINTER:\r
+    UefiDevicePathLibCatPrint (Str, L"UsbPrinter");\r
+    break;\r
+\r
+  case USB_CLASS_MASS_STORAGE:\r
+    UefiDevicePathLibCatPrint (Str, L"UsbMassStorage");\r
+    break;\r
+\r
+  case USB_CLASS_HUB:\r
+    UefiDevicePathLibCatPrint (Str, L"UsbHub");\r
+    break;\r
+\r
+  case USB_CLASS_CDCDATA:\r
+    UefiDevicePathLibCatPrint (Str, L"UsbCDCData");\r
+    break;\r
+\r
+  case USB_CLASS_SMART_CARD:\r
+    UefiDevicePathLibCatPrint (Str, L"UsbSmartCard");\r
+    break;\r
+\r
+  case USB_CLASS_VIDEO:\r
+    UefiDevicePathLibCatPrint (Str, L"UsbVideo");\r
+    break;\r
+\r
+  case USB_CLASS_DIAGNOSTIC:\r
+    UefiDevicePathLibCatPrint (Str, L"UsbDiagnostic");\r
+    break;\r
+\r
+  case USB_CLASS_WIRELESS:\r
+    UefiDevicePathLibCatPrint (Str, L"UsbWireless");\r
+    break;\r
+\r
+  default:\r
+    IsKnownSubClass = FALSE;\r
+    break;\r
+  }\r
+\r
+  if (IsKnownSubClass) {\r
+    UefiDevicePathLibCatPrint (\r
+      Str,\r
+      L"(0x%x,0x%x,0x%x,0x%x)",\r
+      UsbClass->VendorId,\r
+      UsbClass->ProductId,\r
+      UsbClass->DeviceSubClass,\r
+      UsbClass->DeviceProtocol\r
+      );\r
+    return;\r
+  }\r
+\r
+  if (UsbClass->DeviceClass == USB_CLASS_RESERVE) {\r
+    if (UsbClass->DeviceSubClass == USB_SUBCLASS_FW_UPDATE) {\r
+      UefiDevicePathLibCatPrint (\r
+        Str,\r
+        L"UsbDeviceFirmwareUpdate(0x%x,0x%x,0x%x)",\r
+        UsbClass->VendorId,\r
+        UsbClass->ProductId,\r
+        UsbClass->DeviceProtocol\r
+        );\r
+      return;\r
+    } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_IRDA_BRIDGE) {\r
+      UefiDevicePathLibCatPrint (\r
+        Str,\r
+        L"UsbIrdaBridge(0x%x,0x%x,0x%x)",\r
+        UsbClass->VendorId,\r
+        UsbClass->ProductId,\r
+        UsbClass->DeviceProtocol\r
+        );\r
+      return;\r
+    } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_TEST) {\r
+      UefiDevicePathLibCatPrint (\r
+        Str,\r
+        L"UsbTestAndMeasurement(0x%x,0x%x,0x%x)",\r
+        UsbClass->VendorId,\r
+        UsbClass->ProductId,\r
+        UsbClass->DeviceProtocol\r
+        );\r
+      return;\r
+    }\r
+  }\r
+\r
+  UefiDevicePathLibCatPrint (\r
+    Str,\r
+    L"UsbClass(0x%x,0x%x,0x%x,0x%x,0x%x)",\r
+    UsbClass->VendorId,\r
+    UsbClass->ProductId,\r
+    UsbClass->DeviceClass,\r
+    UsbClass->DeviceSubClass,\r
+    UsbClass->DeviceProtocol\r
+    );\r
+}\r
+\r
+/**\r
+  Converts a SATA device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextSata (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  SATA_DEVICE_PATH *Sata;\r
+\r
+  Sata = DevPath;\r
+  if ((Sata->PortMultiplierPortNumber & SATA_HBA_DIRECT_CONNECT_FLAG) != 0) {\r
+    UefiDevicePathLibCatPrint (\r
+      Str,\r
+      L"Sata(0x%x,0x%x)",\r
+      Sata->HBAPortNumber,\r
+      Sata->Lun\r
+      );\r
+  } else {\r
+    UefiDevicePathLibCatPrint (\r
+      Str,\r
+      L"Sata(0x%x,0x%x,0x%x)",\r
+      Sata->HBAPortNumber,\r
+      Sata->PortMultiplierPortNumber,\r
+      Sata->Lun\r
+      );\r
+  }\r
+}\r
+\r
+/**\r
+  Converts a I20 device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextI2O (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  I2O_DEVICE_PATH *I2ODevPath;\r
+\r
+  I2ODevPath = DevPath;\r
+  UefiDevicePathLibCatPrint (Str, L"I2O(0x%x)", I2ODevPath->Tid);\r
+}\r
+\r
+/**\r
+  Converts a MAC address device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextMacAddr (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  MAC_ADDR_DEVICE_PATH  *MacDevPath;\r
+  UINTN                 HwAddressSize;\r
+  UINTN                 Index;\r
+\r
+  MacDevPath = DevPath;\r
+\r
+  HwAddressSize = sizeof (EFI_MAC_ADDRESS);\r
+  if (MacDevPath->IfType == 0x01 || MacDevPath->IfType == 0x00) {\r
+    HwAddressSize = 6;\r
+  }\r
+\r
+  UefiDevicePathLibCatPrint (Str, L"MAC(");\r
+\r
+  for (Index = 0; Index < HwAddressSize; Index++) {\r
+    UefiDevicePathLibCatPrint (Str, L"%02x", MacDevPath->MacAddress.Addr[Index]);\r
+  }\r
+\r
+  UefiDevicePathLibCatPrint (Str, L",0x%x)", MacDevPath->IfType);\r
+}\r
+\r
+/**\r
+  Converts network protocol string to its text representation.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param Protocol        The network protocol ID.\r
+\r
+**/\r
+VOID\r
+CatNetworkProtocol (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN UINT16          Protocol\r
+  )\r
+{\r
+  if (Protocol == RFC_1700_TCP_PROTOCOL) {\r
+    UefiDevicePathLibCatPrint (Str, L"TCP");\r
+  } else if (Protocol == RFC_1700_UDP_PROTOCOL) {\r
+    UefiDevicePathLibCatPrint (Str, L"UDP");\r
+  } else {\r
+    UefiDevicePathLibCatPrint (Str, L"0x%x", Protocol);\r
+  }\r
+}\r
+\r
+/**\r
+  Converts IP v4 address to its text representation.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param Address         The IP v4 address.\r
+**/\r
+VOID\r
+CatIPv4Address (\r
+  IN OUT POOL_PRINT   *Str,\r
+  IN EFI_IPv4_ADDRESS *Address\r
+  )\r
+{\r
+  UefiDevicePathLibCatPrint (Str, L"%d.%d.%d.%d", Address->Addr[0], Address->Addr[1], Address->Addr[2], Address->Addr[3]);\r
+}\r
+\r
+/**\r
+  Converts IP v6 address to its text representation.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param Address         The IP v6 address.\r
+**/\r
+VOID\r
+CatIPv6Address (\r
+  IN OUT POOL_PRINT   *Str,\r
+  IN EFI_IPv6_ADDRESS *Address\r
+  )\r
+{\r
+  UefiDevicePathLibCatPrint (\r
+    Str, L"%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",\r
+    Address->Addr[0],  Address->Addr[1],\r
+    Address->Addr[2],  Address->Addr[3],\r
+    Address->Addr[4],  Address->Addr[5],\r
+    Address->Addr[6],  Address->Addr[7],\r
+    Address->Addr[8],  Address->Addr[9],\r
+    Address->Addr[10], Address->Addr[11],\r
+    Address->Addr[12], Address->Addr[13],\r
+    Address->Addr[14], Address->Addr[15]\r
+  );\r
+}\r
+\r
+/**\r
+  Converts a IPv4 device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextIPv4 (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  IPv4_DEVICE_PATH  *IPDevPath;\r
+\r
+  IPDevPath = DevPath;\r
+  UefiDevicePathLibCatPrint (Str, L"IPv4(");\r
+  CatIPv4Address (Str, &IPDevPath->RemoteIpAddress);\r
+\r
+  if (DisplayOnly) {\r
+    UefiDevicePathLibCatPrint (Str, L")");\r
+    return ;\r
+  }\r
+\r
+  UefiDevicePathLibCatPrint (Str, L",");\r
+  CatNetworkProtocol (Str, IPDevPath->Protocol);\r
+\r
+  UefiDevicePathLibCatPrint (Str, L",%s,", IPDevPath->StaticIpAddress ? L"Static" : L"DHCP");\r
+  CatIPv4Address (Str, &IPDevPath->LocalIpAddress);\r
+  if (DevicePathNodeLength (IPDevPath) == sizeof (IPv4_DEVICE_PATH)) {\r
+    UefiDevicePathLibCatPrint (Str, L",");\r
+    CatIPv4Address (Str, &IPDevPath->GatewayIpAddress);\r
+    UefiDevicePathLibCatPrint (Str, L",");\r
+    CatIPv4Address (Str, &IPDevPath->SubnetMask);\r
+  }\r
+  UefiDevicePathLibCatPrint (Str, L")");\r
+}\r
+\r
+/**\r
+  Converts a IPv6 device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextIPv6 (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  IPv6_DEVICE_PATH  *IPDevPath;\r
+\r
+  IPDevPath = DevPath;\r
+  UefiDevicePathLibCatPrint (Str, L"IPv6(");\r
+  CatIPv6Address (Str, &IPDevPath->RemoteIpAddress);\r
+  if (DisplayOnly) {\r
+    UefiDevicePathLibCatPrint (Str, L")");\r
+    return ;\r
+  }\r
+  \r
+  UefiDevicePathLibCatPrint (Str, L",");\r
+  CatNetworkProtocol (Str, IPDevPath->Protocol);\r
+\r
+  switch (IPDevPath->IpAddressOrigin) {\r
+    case 0:\r
+      UefiDevicePathLibCatPrint (Str, L",Static,");\r
+      break;\r
+    case 1:\r
+      UefiDevicePathLibCatPrint (Str, L",StatelessAutoConfigure,");\r
+      break;\r
+    default:\r
+      UefiDevicePathLibCatPrint (Str, L",StatefulAutoConfigure,");\r
+      break;\r
+  }\r
+\r
+  CatIPv6Address (Str, &IPDevPath->LocalIpAddress);\r
+\r
+  if (DevicePathNodeLength (IPDevPath) == sizeof (IPv6_DEVICE_PATH)) {\r
+    UefiDevicePathLibCatPrint (Str, L",0x%x,", IPDevPath->PrefixLength);\r
+    CatIPv6Address (Str, &IPDevPath->GatewayIpAddress);\r
+  }\r
+  UefiDevicePathLibCatPrint (Str, L")");\r
+}\r
+\r
+/**\r
+  Converts an Infini Band device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextInfiniBand (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  INFINIBAND_DEVICE_PATH  *InfiniBand;\r
+\r
+  InfiniBand = DevPath;\r
+  UefiDevicePathLibCatPrint (\r
+    Str,\r
+    L"Infiniband(0x%x,%g,0x%lx,0x%lx,0x%lx)",\r
+    InfiniBand->ResourceFlags,\r
+    InfiniBand->PortGid,\r
+    InfiniBand->ServiceId,\r
+    InfiniBand->TargetPortId,\r
+    InfiniBand->DeviceId\r
+    );\r
+}\r
+\r
+/**\r
+  Converts a UART device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextUart (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  UART_DEVICE_PATH  *Uart;\r
+  CHAR8             Parity;\r
+\r
+  Uart = DevPath;\r
+  switch (Uart->Parity) {\r
+  case 0:\r
+    Parity = 'D';\r
+    break;\r
+\r
+  case 1:\r
+    Parity = 'N';\r
+    break;\r
+\r
+  case 2:\r
+    Parity = 'E';\r
+    break;\r
+\r
+  case 3:\r
+    Parity = 'O';\r
+    break;\r
+\r
+  case 4:\r
+    Parity = 'M';\r
+    break;\r
+\r
+  case 5:\r
+    Parity = 'S';\r
+    break;\r
+\r
+  default:\r
+    Parity = 'x';\r
+    break;\r
+  }\r
+\r
+  if (Uart->BaudRate == 0) {\r
+    UefiDevicePathLibCatPrint (Str, L"Uart(DEFAULT,");\r
+  } else {\r
+    UefiDevicePathLibCatPrint (Str, L"Uart(%ld,", Uart->BaudRate);\r
+  }\r
+\r
+  if (Uart->DataBits == 0) {\r
+    UefiDevicePathLibCatPrint (Str, L"DEFAULT,");\r
+  } else {\r
+    UefiDevicePathLibCatPrint (Str, L"%d,", Uart->DataBits);\r
+  }\r
+\r
+  UefiDevicePathLibCatPrint (Str, L"%c,", Parity);\r
+\r
+  switch (Uart->StopBits) {\r
+  case 0:\r
+    UefiDevicePathLibCatPrint (Str, L"D)");\r
+    break;\r
+\r
+  case 1:\r
+    UefiDevicePathLibCatPrint (Str, L"1)");\r
+    break;\r
+\r
+  case 2:\r
+    UefiDevicePathLibCatPrint (Str, L"1.5)");\r
+    break;\r
+\r
+  case 3:\r
+    UefiDevicePathLibCatPrint (Str, L"2)");\r
+    break;\r
+\r
+  default:\r
+    UefiDevicePathLibCatPrint (Str, L"x)");\r
+    break;\r
+  }\r
+}\r
+\r
+/**\r
+  Converts an iSCSI device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextiSCSI (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;\r
+  UINT16                      Options;\r
+\r
+  ISCSIDevPath = DevPath;\r
+  UefiDevicePathLibCatPrint (\r
+    Str,\r
+    L"iSCSI(%a,0x%x,0x%lx,",\r
+    ISCSIDevPath->TargetName,\r
+    ISCSIDevPath->TargetPortalGroupTag,\r
+    ISCSIDevPath->Lun\r
+    );\r
+\r
+  Options = ISCSIDevPath->LoginOption;\r
+  UefiDevicePathLibCatPrint (Str, L"%s,", (((Options >> 1) & 0x0001) != 0) ? L"CRC32C" : L"None");\r
+  UefiDevicePathLibCatPrint (Str, L"%s,", (((Options >> 3) & 0x0001) != 0) ? L"CRC32C" : L"None");\r
+  if (((Options >> 11) & 0x0001) != 0) {\r
+    UefiDevicePathLibCatPrint (Str, L"%s,", L"None");\r
+  } else if (((Options >> 12) & 0x0001) != 0) {\r
+    UefiDevicePathLibCatPrint (Str, L"%s,", L"CHAP_UNI");\r
+  } else {\r
+    UefiDevicePathLibCatPrint (Str, L"%s,", L"CHAP_BI");\r
+\r
+  }\r
+\r
+  UefiDevicePathLibCatPrint (Str, L"%s)", (ISCSIDevPath->NetworkProtocol == 0) ? L"TCP" : L"reserved");\r
+}\r
+\r
+/**\r
+  Converts a VLAN device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextVlan (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  VLAN_DEVICE_PATH  *Vlan;\r
+\r
+  Vlan = DevPath;\r
+  UefiDevicePathLibCatPrint (Str, L"Vlan(%d)", Vlan->VlanId);\r
+}\r
+\r
+/**\r
+  Converts a Hard drive device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextHardDrive (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  HARDDRIVE_DEVICE_PATH *Hd;\r
+\r
+  Hd = DevPath;\r
+  switch (Hd->SignatureType) {\r
+  case SIGNATURE_TYPE_MBR:\r
+    UefiDevicePathLibCatPrint (\r
+      Str,\r
+      L"HD(%d,%s,0x%08x,",\r
+      Hd->PartitionNumber,\r
+      L"MBR",\r
+      *((UINT32 *) (&(Hd->Signature[0])))\r
+      );\r
+    break;\r
+\r
+  case SIGNATURE_TYPE_GUID:\r
+    UefiDevicePathLibCatPrint (\r
+      Str,\r
+      L"HD(%d,%s,%g,",\r
+      Hd->PartitionNumber,\r
+      L"GPT",\r
+      (EFI_GUID *) &(Hd->Signature[0])\r
+      );\r
+    break;\r
+\r
+  default:\r
+    UefiDevicePathLibCatPrint (\r
+      Str,\r
+      L"HD(%d,%d,0,",\r
+      Hd->PartitionNumber,\r
+      Hd->SignatureType\r
+      );\r
+    break;\r
+  }\r
+\r
+  UefiDevicePathLibCatPrint (Str, L"0x%lx,0x%lx)", Hd->PartitionStart, Hd->PartitionSize);\r
+}\r
+\r
+/**\r
+  Converts a CDROM device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextCDROM (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  CDROM_DEVICE_PATH *Cd;\r
+\r
+  Cd = DevPath;\r
+  if (DisplayOnly) {\r
+    UefiDevicePathLibCatPrint (Str, L"CDROM(0x%x)", Cd->BootEntry);\r
+    return ;\r
+  }\r
+\r
+  UefiDevicePathLibCatPrint (Str, L"CDROM(0x%x,0x%lx,0x%lx)", Cd->BootEntry, Cd->PartitionStart, Cd->PartitionSize);\r
+}\r
+\r
+/**\r
+  Converts a File device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextFilePath (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  FILEPATH_DEVICE_PATH  *Fp;\r
+\r
+  Fp = DevPath;\r
+  UefiDevicePathLibCatPrint (Str, L"%s", Fp->PathName);\r
+}\r
+\r
+/**\r
+  Converts a Media protocol device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextMediaProtocol (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  MEDIA_PROTOCOL_DEVICE_PATH  *MediaProt;\r
+\r
+  MediaProt = DevPath;\r
+  UefiDevicePathLibCatPrint (Str, L"Media(%g)", &MediaProt->Protocol);\r
+}\r
+\r
+/**\r
+  Converts a Firmware Volume device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextFv (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  MEDIA_FW_VOL_DEVICE_PATH  *Fv;\r
+\r
+  Fv = DevPath;\r
+  UefiDevicePathLibCatPrint (Str, L"Fv(%g)", &Fv->FvName);\r
+}\r
+\r
+/**\r
+  Converts a Firmware Volume File device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextFvFile (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH  *FvFile;\r
+\r
+  FvFile = DevPath;\r
+  UefiDevicePathLibCatPrint (Str, L"FvFile(%g)", &FvFile->FvFileName);\r
+}\r
+\r
+/**\r
+  Converts a Relative Offset device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathRelativeOffsetRange (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath,\r
+  IN BOOLEAN              DisplayOnly,\r
+  IN BOOLEAN              AllowShortcuts\r
+  )\r
+{\r
+  MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset;\r
+\r
+  Offset = DevPath;\r
+  UefiDevicePathLibCatPrint (\r
+    Str,\r
+    L"Offset(0x%lx,0x%lx)",\r
+    Offset->StartingOffset,\r
+    Offset->EndingOffset\r
+    );\r
+}\r
+\r
+/**\r
+  Converts a BIOS Boot Specification device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextBBS (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  BBS_BBS_DEVICE_PATH *Bbs;\r
+  CHAR16              *Type;\r
+\r
+  Bbs = DevPath;\r
+  switch (Bbs->DeviceType) {\r
+  case BBS_TYPE_FLOPPY:\r
+    Type = L"Floppy";\r
+    break;\r
+\r
+  case BBS_TYPE_HARDDRIVE:\r
+    Type = L"HD";\r
+    break;\r
+\r
+  case BBS_TYPE_CDROM:\r
+    Type = L"CDROM";\r
+    break;\r
+\r
+  case BBS_TYPE_PCMCIA:\r
+    Type = L"PCMCIA";\r
+    break;\r
+\r
+  case BBS_TYPE_USB:\r
+    Type = L"USB";\r
+    break;\r
+\r
+  case BBS_TYPE_EMBEDDED_NETWORK:\r
+    Type = L"Network";\r
+    break;\r
+\r
+  default:\r
+    Type = NULL;\r
+    break;\r
+  }\r
+\r
+  if (Type != NULL) {\r
+    UefiDevicePathLibCatPrint (Str, L"BBS(%s,%a", Type, Bbs->String);\r
+  } else {\r
+    UefiDevicePathLibCatPrint (Str, L"BBS(0x%x,%a", Bbs->DeviceType, Bbs->String);\r
+  }\r
+\r
+  if (DisplayOnly) {\r
+    UefiDevicePathLibCatPrint (Str, L")");\r
+    return ;\r
+  }\r
+\r
+  UefiDevicePathLibCatPrint (Str, L",0x%x)", Bbs->StatusFlag);\r
+}\r
+\r
+/**\r
+  Converts an End-of-Device-Path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextEndInstance (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  UefiDevicePathLibCatPrint (Str, L",");\r
+}\r
+\r
+/**\r
+  Converts an unknown device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextNodeUnknown (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  UefiDevicePathLibCatPrint (Str, L"?");\r
+}\r
+\r
+GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE mUefiDevicePathLibDevPathToTextTable[] = {\r
+  {HARDWARE_DEVICE_PATH,  HW_PCI_DP,                        DevPathToTextPci            },\r
+  {HARDWARE_DEVICE_PATH,  HW_PCCARD_DP,                     DevPathToTextPccard         },\r
+  {HARDWARE_DEVICE_PATH,  HW_MEMMAP_DP,                     DevPathToTextMemMap         },\r
+  {HARDWARE_DEVICE_PATH,  HW_VENDOR_DP,                     DevPathToTextVendor         },\r
+  {HARDWARE_DEVICE_PATH,  HW_CONTROLLER_DP,                 DevPathToTextController     },\r
+  {ACPI_DEVICE_PATH,      ACPI_DP,                          DevPathToTextAcpi           },\r
+  {ACPI_DEVICE_PATH,      ACPI_EXTENDED_DP,                 DevPathToTextAcpiEx         },\r
+  {ACPI_DEVICE_PATH,      ACPI_ADR_DP,                      DevPathToTextAcpiAdr        },\r
+  {MESSAGING_DEVICE_PATH, MSG_ATAPI_DP,                     DevPathToTextAtapi          },\r
+  {MESSAGING_DEVICE_PATH, MSG_SCSI_DP,                      DevPathToTextScsi           },\r
+  {MESSAGING_DEVICE_PATH, MSG_FIBRECHANNEL_DP,              DevPathToTextFibre          },\r
+  {MESSAGING_DEVICE_PATH, MSG_FIBRECHANNELEX_DP,            DevPathToTextFibreEx        },\r
+  {MESSAGING_DEVICE_PATH, MSG_SASEX_DP,                     DevPathToTextSasEx          },\r
+  {MESSAGING_DEVICE_PATH, MSG_1394_DP,                      DevPathToText1394           },\r
+  {MESSAGING_DEVICE_PATH, MSG_USB_DP,                       DevPathToTextUsb            },\r
+  {MESSAGING_DEVICE_PATH, MSG_USB_WWID_DP,                  DevPathToTextUsbWWID        },\r
+  {MESSAGING_DEVICE_PATH, MSG_DEVICE_LOGICAL_UNIT_DP,       DevPathToTextLogicalUnit    },\r
+  {MESSAGING_DEVICE_PATH, MSG_USB_CLASS_DP,                 DevPathToTextUsbClass       },\r
+  {MESSAGING_DEVICE_PATH, MSG_SATA_DP,                      DevPathToTextSata           },\r
+  {MESSAGING_DEVICE_PATH, MSG_I2O_DP,                       DevPathToTextI2O            },\r
+  {MESSAGING_DEVICE_PATH, MSG_MAC_ADDR_DP,                  DevPathToTextMacAddr        },\r
+  {MESSAGING_DEVICE_PATH, MSG_IPv4_DP,                      DevPathToTextIPv4           },\r
+  {MESSAGING_DEVICE_PATH, MSG_IPv6_DP,                      DevPathToTextIPv6           },\r
+  {MESSAGING_DEVICE_PATH, MSG_INFINIBAND_DP,                DevPathToTextInfiniBand     },\r
+  {MESSAGING_DEVICE_PATH, MSG_UART_DP,                      DevPathToTextUart           },\r
+  {MESSAGING_DEVICE_PATH, MSG_VENDOR_DP,                    DevPathToTextVendor         },\r
+  {MESSAGING_DEVICE_PATH, MSG_ISCSI_DP,                     DevPathToTextiSCSI          },\r
+  {MESSAGING_DEVICE_PATH, MSG_VLAN_DP,                      DevPathToTextVlan           },\r
+  {MEDIA_DEVICE_PATH,     MEDIA_HARDDRIVE_DP,               DevPathToTextHardDrive      },\r
+  {MEDIA_DEVICE_PATH,     MEDIA_CDROM_DP,                   DevPathToTextCDROM          },\r
+  {MEDIA_DEVICE_PATH,     MEDIA_VENDOR_DP,                  DevPathToTextVendor         },\r
+  {MEDIA_DEVICE_PATH,     MEDIA_PROTOCOL_DP,                DevPathToTextMediaProtocol  },\r
+  {MEDIA_DEVICE_PATH,     MEDIA_FILEPATH_DP,                DevPathToTextFilePath       },\r
+  {MEDIA_DEVICE_PATH,     MEDIA_PIWG_FW_VOL_DP,             DevPathToTextFv             },\r
+  {MEDIA_DEVICE_PATH,     MEDIA_PIWG_FW_FILE_DP,            DevPathToTextFvFile         },\r
+  {MEDIA_DEVICE_PATH,     MEDIA_RELATIVE_OFFSET_RANGE_DP,   DevPathRelativeOffsetRange  },\r
+  {BBS_DEVICE_PATH,       BBS_BBS_DP,                       DevPathToTextBBS            },\r
+  {END_DEVICE_PATH_TYPE,  END_INSTANCE_DEVICE_PATH_SUBTYPE, DevPathToTextEndInstance    },\r
+  {0, 0, NULL}\r
+};\r
+\r
+/**\r
+  Converts a device node to its string representation.\r
+\r
+  @param DeviceNode        A Pointer to the device node to be converted.\r
+  @param DisplayOnly       If DisplayOnly is TRUE, then the shorter text representation\r
+                           of the display node is used, where applicable. If DisplayOnly\r
+                           is FALSE, then the longer text representation of the display node\r
+                           is used.\r
+  @param AllowShortcuts    If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                           representation for a device node can be used, where applicable.\r
+\r
+  @return A pointer to the allocated text representation of the device node or NULL if DeviceNode\r
+          is NULL or there was insufficient memory.\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+UefiDevicePathLibConvertDeviceNodeToText (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DeviceNode,\r
+  IN BOOLEAN                         DisplayOnly,\r
+  IN BOOLEAN                         AllowShortcuts\r
+  )\r
+{\r
+  POOL_PRINT          Str;\r
+  UINTN               Index;\r
+  DEVICE_PATH_TO_TEXT ToText;\r
+\r
+  if (DeviceNode == NULL) {\r
+    return NULL;\r
+  }\r
+\r
+  ZeroMem (&Str, sizeof (Str));\r
+\r
+  //\r
+  // Process the device path node\r
+  // If not found, use a generic function\r
+  //\r
+  ToText = DevPathToTextNodeUnknown;\r
+  for (Index = 0; mUefiDevicePathLibDevPathToTextTable[Index].Function != NULL; Index++) {\r
+    if (DevicePathType (DeviceNode) == mUefiDevicePathLibDevPathToTextTable[Index].Type &&\r
+        DevicePathSubType (DeviceNode) == mUefiDevicePathLibDevPathToTextTable[Index].SubType\r
+        ) {\r
+      ToText = mUefiDevicePathLibDevPathToTextTable[Index].Function;\r
+      break;\r
+    }\r
+  }\r
+\r
+  //\r
+  // Print this node\r
+  //\r
+  ToText (&Str, (VOID *) DeviceNode, DisplayOnly, AllowShortcuts);\r
+\r
+  ASSERT (Str.Str != NULL);\r
+  return Str.Str;\r
+}\r
+\r
+/**\r
+  Converts a device path to its text representation.\r
+\r
+  @param DevicePath      A Pointer to the device to be converted.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+  @return A pointer to the allocated text representation of the device path or\r
+          NULL if DeviceNode is NULL or there was insufficient memory.\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+UefiDevicePathLibConvertDevicePathToText (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL   *DevicePath,\r
+  IN BOOLEAN                          DisplayOnly,\r
+  IN BOOLEAN                          AllowShortcuts\r
+  )\r
+{\r
+  POOL_PRINT               Str;\r
+  EFI_DEVICE_PATH_PROTOCOL *Node;\r
+  EFI_DEVICE_PATH_PROTOCOL *AlignedNode;\r
+  UINTN                    Index;\r
+  DEVICE_PATH_TO_TEXT      ToText;\r
+\r
+  if (DevicePath == NULL) {\r
+    return NULL;\r
+  }\r
+\r
+  ZeroMem (&Str, sizeof (Str));\r
+\r
+  //\r
+  // Process each device path node\r
+  //\r
+  Node = (EFI_DEVICE_PATH_PROTOCOL *) DevicePath;\r
+  while (!IsDevicePathEnd (Node)) {\r
+    //\r
+    // Find the handler to dump this device path node\r
+    // If not found, use a generic function\r
+    //\r
+    ToText = DevPathToTextNodeUnknown;\r
+    for (Index = 0; mUefiDevicePathLibDevPathToTextTable[Index].Function != NULL; Index += 1) {\r
+\r
+      if (DevicePathType (Node) == mUefiDevicePathLibDevPathToTextTable[Index].Type &&\r
+          DevicePathSubType (Node) == mUefiDevicePathLibDevPathToTextTable[Index].SubType\r
+          ) {\r
+        ToText = mUefiDevicePathLibDevPathToTextTable[Index].Function;\r
+        break;\r
+      }\r
+    }\r
+    //\r
+    //  Put a path separator in if needed\r
+    //\r
+    if ((Str.Count != 0) && (ToText != DevPathToTextEndInstance)) {\r
+      if (Str.Str[Str.Count] != L',') {\r
+        UefiDevicePathLibCatPrint (&Str, L"/");\r
+      }\r
+    }\r
+    \r
+    AlignedNode = AllocateCopyPool (DevicePathNodeLength (Node), Node);\r
+    //\r
+    // Print this node of the device path\r
+    //\r
+    ToText (&Str, AlignedNode, DisplayOnly, AllowShortcuts);\r
+    FreePool (AlignedNode);\r
+    \r
+    //\r
+    // Next device path node\r
+    //\r
+    Node = NextDevicePathNode (Node);\r
+  }\r
+\r
+  if (Str.Str == NULL) {\r
+    return AllocateZeroPool (sizeof (CHAR16));\r
+  } else {\r
+    return Str.Str;\r
+  }\r
+}\r
diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c b/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
new file mode 100644 (file)
index 0000000..b48bf02
--- /dev/null
@@ -0,0 +1,882 @@
+/** @file\r
+  Device Path services. The thing to remember is device paths are built out of\r
+  nodes. The device path is terminated by an end node that is length\r
+  sizeof(EFI_DEVICE_PATH_PROTOCOL). That would be why there is sizeof(EFI_DEVICE_PATH_PROTOCOL)\r
+  all over this file.\r
+\r
+  The only place where multi-instance device paths are supported is in\r
+  environment varibles. Multi-instance device paths should never be placed\r
+  on a Handle.\r
+\r
+  Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php.                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+#include "UefiDevicePathLib.h"\r
+\r
+//\r
+// Template for an end-of-device path node.\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_DEVICE_PATH_PROTOCOL  mUefiDevicePathLibEndDevicePath = {\r
+  END_DEVICE_PATH_TYPE,\r
+  END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
+  {\r
+    END_DEVICE_PATH_LENGTH,\r
+    0\r
+  }\r
+};\r
+\r
+/**\r
+  Determine whether a given device path is valid.\r
+  If DevicePath is NULL, then ASSERT().\r
+\r
+  @param  DevicePath  A pointer to a device path data structure.\r
+  @param  MaxSize     The maximum size of the device path data structure.\r
+\r
+  @retval TRUE        DevicePath is valid.\r
+  @retval FALSE       The length of any node node in the DevicePath is less\r
+                      than sizeof (EFI_DEVICE_PATH_PROTOCOL).\r
+  @retval FALSE       If MaxSize is not zero, the size of the DevicePath\r
+                      exceeds MaxSize.\r
+  @retval FALSE       If PcdMaximumDevicePathNodeCount is not zero, the node\r
+                      count of the DevicePath exceeds PcdMaximumDevicePathNodeCount.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+IsDevicePathValid (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
+  IN       UINTN                    MaxSize\r
+  )\r
+{\r
+  UINTN Count;\r
+  UINTN Size;\r
+  UINTN NodeLength;\r
+\r
+  ASSERT (DevicePath != NULL);\r
+\r
+  for (Count = 0, Size = 0; !IsDevicePathEnd (DevicePath); DevicePath = NextDevicePathNode (DevicePath)) {\r
+    NodeLength = DevicePathNodeLength (DevicePath);\r
+    if (NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {\r
+      return FALSE;\r
+    }\r
+\r
+    if (MaxSize > 0) {\r
+      Size += NodeLength;\r
+      if (Size + END_DEVICE_PATH_LENGTH > MaxSize) {\r
+        return FALSE;\r
+      }\r
+    }\r
+\r
+    if (PcdGet32 (PcdMaximumDevicePathNodeCount) > 0) {\r
+      Count++;\r
+      if (Count >= PcdGet32 (PcdMaximumDevicePathNodeCount)) {\r
+        return FALSE;\r
+      }\r
+    }\r
+  }\r
+\r
+  //\r
+  // Only return TRUE when the End Device Path node is valid.\r
+  //\r
+  return (BOOLEAN) (DevicePathNodeLength (DevicePath) == END_DEVICE_PATH_LENGTH);\r
+}\r
+\r
+/**\r
+  Returns the Type field of a device path node.\r
+\r
+  Returns the Type field of the device path node specified by Node.\r
+\r
+  If Node is NULL, then ASSERT().\r
+\r
+  @param  Node      A pointer to a device path node data structure.\r
+\r
+  @return The Type field of the device path node specified by Node.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+DevicePathType (\r
+  IN CONST VOID  *Node\r
+  )\r
+{\r
+  ASSERT (Node != NULL);\r
+  return ((EFI_DEVICE_PATH_PROTOCOL *)(Node))->Type;\r
+}\r
+\r
+/**\r
+  Returns the SubType field of a device path node.\r
+\r
+  Returns the SubType field of the device path node specified by Node.\r
+\r
+  If Node is NULL, then ASSERT().\r
+\r
+  @param  Node      A pointer to a device path node data structure.\r
+\r
+  @return The SubType field of the device path node specified by Node.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+DevicePathSubType (\r
+  IN CONST VOID  *Node\r
+  )\r
+{\r
+  ASSERT (Node != NULL);\r
+  return ((EFI_DEVICE_PATH_PROTOCOL *)(Node))->SubType;\r
+}\r
+\r
+/**\r
+  Returns the 16-bit Length field of a device path node.\r
+\r
+  Returns the 16-bit Length field of the device path node specified by Node.  \r
+  Node is not required to be aligned on a 16-bit boundary, so it is recommended\r
+  that a function such as ReadUnaligned16() be used to extract the contents of \r
+  the Length field.\r
+\r
+  If Node is NULL, then ASSERT().\r
+\r
+  @param  Node      A pointer to a device path node data structure.\r
+\r
+  @return The 16-bit Length field of the device path node specified by Node.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+DevicePathNodeLength (\r
+  IN CONST VOID  *Node\r
+  )\r
+{\r
+  UINTN Length;\r
+\r
+  ASSERT (Node != NULL);\r
+  Length = ReadUnaligned16 ((UINT16 *)&((EFI_DEVICE_PATH_PROTOCOL *)(Node))->Length[0]);\r
+  ASSERT (Length >= sizeof (EFI_DEVICE_PATH_PROTOCOL));\r
+  return Length;\r
+}\r
+\r
+/**\r
+  Returns a pointer to the next node in a device path.\r
+\r
+  Returns a pointer to the device path node that follows the device path node \r
+  specified by Node.\r
+\r
+  If Node is NULL, then ASSERT().\r
+\r
+  @param  Node      A pointer to a device path node data structure.\r
+\r
+  @return a pointer to the device path node that follows the device path node \r
+  specified by Node.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+NextDevicePathNode (\r
+  IN CONST VOID  *Node\r
+  )\r
+{\r
+  ASSERT (Node != NULL);\r
+  return (EFI_DEVICE_PATH_PROTOCOL *)((UINT8 *)(Node) + DevicePathNodeLength(Node));\r
+}\r
+\r
+/**\r
+  Determines if a device path node is an end node of a device path.\r
+  This includes nodes that are the end of a device path instance and nodes that \r
+  are the end of an entire device path.\r
+\r
+  Determines if the device path node specified by Node is an end node of a device path.  \r
+  This includes nodes that are the end of a device path instance and nodes that are the \r
+  end of an entire device path.  If Node represents an end node of a device path, \r
+  then TRUE is returned.  Otherwise, FALSE is returned.\r
+\r
+  If Node is NULL, then ASSERT().\r
+\r
+  @param  Node      A pointer to a device path node data structure.\r
+\r
+  @retval TRUE      The device path node specified by Node is an end node of a \r
+                    device path.\r
+  @retval FALSE     The device path node specified by Node is not an end node of \r
+                    a device path.\r
+  \r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+IsDevicePathEndType (\r
+  IN CONST VOID  *Node\r
+  )\r
+{\r
+  ASSERT (Node != NULL);\r
+  return (BOOLEAN) (DevicePathType (Node) == END_DEVICE_PATH_TYPE);\r
+}\r
+\r
+/**\r
+  Determines if a device path node is an end node of an entire device path.\r
+\r
+  Determines if a device path node specified by Node is an end node of an entire \r
+  device path. If Node represents the end of an entire device path, then TRUE is \r
+  returned.  Otherwise, FALSE is returned.\r
+\r
+  If Node is NULL, then ASSERT().\r
+\r
+  @param  Node      A pointer to a device path node data structure.\r
+\r
+  @retval TRUE      The device path node specified by Node is the end of an entire \r
+                    device path.\r
+  @retval FALSE     The device path node specified by Node is not the end of an \r
+                    entire device path.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+IsDevicePathEnd (\r
+  IN CONST VOID  *Node\r
+  )\r
+{\r
+  ASSERT (Node != NULL);\r
+  return (BOOLEAN) (IsDevicePathEndType (Node) && DevicePathSubType(Node) == END_ENTIRE_DEVICE_PATH_SUBTYPE);\r
+}\r
+\r
+/**\r
+  Determines if a device path node is an end node of a device path instance.\r
+\r
+  Determines if a device path node specified by Node is an end node of a device \r
+  path instance. If Node represents the end of a device path instance, then TRUE \r
+  is returned.  Otherwise, FALSE is returned.\r
+\r
+  If Node is NULL, then ASSERT().\r
+\r
+  @param  Node      A pointer to a device path node data structure.\r
+\r
+  @retval TRUE      The device path node specified by Node is the end of a device \r
+                    path instance.\r
+  @retval FALSE     The device path node specified by Node is not the end of a \r
+                    device path instance.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+IsDevicePathEndInstance (\r
+  IN CONST VOID  *Node\r
+  )\r
+{\r
+  ASSERT (Node != NULL);\r
+  return (BOOLEAN) (IsDevicePathEndType (Node) && DevicePathSubType(Node) == END_INSTANCE_DEVICE_PATH_SUBTYPE);\r
+}\r
+\r
+/**\r
+  Sets the length, in bytes, of a device path node.\r
+\r
+  Sets the length of the device path node specified by Node to the value specified \r
+  by NodeLength.  NodeLength is returned.  Node is not required to be aligned on \r
+  a 16-bit boundary, so it is recommended that a function such as WriteUnaligned16()\r
+  be used to set the contents of the Length field.\r
+\r
+  If Node is NULL, then ASSERT().\r
+  If NodeLength >= SIZE_64KB, then ASSERT().\r
+  If NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL), then ASSERT().\r
+\r
+  @param  Node      A pointer to a device path node data structure.\r
+  @param  Length    The length, in bytes, of the device path node.\r
+\r
+  @return Length\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+SetDevicePathNodeLength (\r
+  IN OUT VOID  *Node,\r
+  IN UINTN     Length\r
+  )\r
+{\r
+  ASSERT (Node != NULL);\r
+  ASSERT ((Length >= sizeof (EFI_DEVICE_PATH_PROTOCOL)) && (Length < SIZE_64KB));\r
+  return WriteUnaligned16 ((UINT16 *)&((EFI_DEVICE_PATH_PROTOCOL *)(Node))->Length[0], (UINT16)(Length));\r
+}\r
+\r
+/**\r
+  Fills in all the fields of a device path node that is the end of an entire device path.\r
+\r
+  Fills in all the fields of a device path node specified by Node so Node represents \r
+  the end of an entire device path.  The Type field of Node is set to \r
+  END_DEVICE_PATH_TYPE, the SubType field of Node is set to \r
+  END_ENTIRE_DEVICE_PATH_SUBTYPE, and the Length field of Node is set to \r
+  END_DEVICE_PATH_LENGTH.  Node is not required to be aligned on a 16-bit boundary, \r
+  so it is recommended that a function such as WriteUnaligned16() be used to set \r
+  the contents of the Length field. \r
+\r
+  If Node is NULL, then ASSERT(). \r
+\r
+  @param  Node      A pointer to a device path node data structure.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+SetDevicePathEndNode (\r
+  OUT VOID  *Node\r
+  )\r
+{\r
+  ASSERT (Node != NULL);\r
+  CopyMem (Node, &mUefiDevicePathLibEndDevicePath, sizeof (mUefiDevicePathLibEndDevicePath));\r
+}\r
+\r
+/**\r
+  Returns the size of a device path in bytes.\r
+\r
+  This function returns the size, in bytes, of the device path data structure \r
+  specified by DevicePath including the end of device path node.\r
+  If DevicePath is NULL or invalid, then 0 is returned.\r
+\r
+  @param  DevicePath  A pointer to a device path data structure.\r
+\r
+  @retval 0           If DevicePath is NULL or invalid.\r
+  @retval Others      The size of a device path in bytes.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+UefiDevicePathLibGetDevicePathSize (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+  )\r
+{\r
+  CONST EFI_DEVICE_PATH_PROTOCOL  *Start;\r
+\r
+  if (DevicePath == NULL) {\r
+    return 0;\r
+  }\r
+\r
+  if (!IsDevicePathValid (DevicePath, 0)) {\r
+    return 0;\r
+  }\r
+\r
+  //\r
+  // Search for the end of the device path structure\r
+  //\r
+  Start = DevicePath;\r
+  while (!IsDevicePathEnd (DevicePath)) {\r
+    DevicePath = NextDevicePathNode (DevicePath);\r
+  }\r
+\r
+  //\r
+  // Compute the size and add back in the size of the end device path structure\r
+  //\r
+  return ((UINTN) DevicePath - (UINTN) Start) + DevicePathNodeLength (DevicePath);\r
+}\r
+\r
+/**\r
+  Creates a new copy of an existing device path.\r
+\r
+  This function allocates space for a new copy of the device path specified by DevicePath.  \r
+  If DevicePath is NULL, then NULL is returned.  If the memory is successfully \r
+  allocated, then the contents of DevicePath are copied to the newly allocated \r
+  buffer, and a pointer to that buffer is returned.  Otherwise, NULL is returned.  \r
+  The memory for the new device path is allocated from EFI boot services memory. \r
+  It is the responsibility of the caller to free the memory allocated. \r
+  \r
+  @param  DevicePath    A pointer to a device path data structure.\r
+\r
+  @retval NULL          DevicePath is NULL or invalid.\r
+  @retval Others        A pointer to the duplicated device path.\r
+  \r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+UefiDevicePathLibDuplicateDevicePath (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+  )\r
+{\r
+  UINTN                     Size;\r
+\r
+  //\r
+  // Compute the size\r
+  //\r
+  Size = GetDevicePathSize (DevicePath);\r
+  if (Size == 0) {\r
+    return NULL;\r
+  }\r
+\r
+  //\r
+  // Allocate space for duplicate device path\r
+  //\r
+\r
+  return AllocateCopyPool (Size, DevicePath);\r
+}\r
+\r
+/**\r
+  Creates a new device path by appending a second device path to a first device path.\r
+\r
+  This function creates a new device path by appending a copy of SecondDevicePath \r
+  to a copy of FirstDevicePath in a newly allocated buffer.  Only the end-of-device-path \r
+  device node from SecondDevicePath is retained. The newly created device path is \r
+  returned. If FirstDevicePath is NULL, then it is ignored, and a duplicate of \r
+  SecondDevicePath is returned.  If SecondDevicePath is NULL, then it is ignored, \r
+  and a duplicate of FirstDevicePath is returned. If both FirstDevicePath and \r
+  SecondDevicePath are NULL, then a copy of an end-of-device-path is returned.  \r
+  \r
+  If there is not enough memory for the newly allocated buffer, then NULL is returned.\r
+  The memory for the new device path is allocated from EFI boot services memory. \r
+  It is the responsibility of the caller to free the memory allocated.\r
+\r
+  @param  FirstDevicePath            A pointer to a device path data structure.\r
+  @param  SecondDevicePath           A pointer to a device path data structure.\r
+  \r
+  @retval NULL      If there is not enough memory for the newly allocated buffer.\r
+  @retval NULL      If FirstDevicePath or SecondDevicePath is invalid.\r
+  @retval Others    A pointer to the new device path if success.\r
+                    Or a copy an end-of-device-path if both FirstDevicePath and SecondDevicePath are NULL.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+UefiDevicePathLibAppendDevicePath (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *FirstDevicePath,  OPTIONAL\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *SecondDevicePath  OPTIONAL\r
+  )\r
+{\r
+  UINTN                     Size;\r
+  UINTN                     Size1;\r
+  UINTN                     Size2;\r
+  EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath2;\r
+\r
+  //\r
+  // If there's only 1 path, just duplicate it.\r
+  //\r
+  if (FirstDevicePath == NULL) {\r
+    return DuplicateDevicePath ((SecondDevicePath != NULL) ? SecondDevicePath : &mUefiDevicePathLibEndDevicePath);\r
+  }\r
+\r
+  if (SecondDevicePath == NULL) {\r
+    return DuplicateDevicePath (FirstDevicePath);\r
+  }\r
+\r
+  if (!IsDevicePathValid (FirstDevicePath, 0) || !IsDevicePathValid (SecondDevicePath, 0)) {\r
+    return NULL;\r
+  }\r
+\r
+  //\r
+  // Allocate space for the combined device path. It only has one end node of\r
+  // length EFI_DEVICE_PATH_PROTOCOL.\r
+  //\r
+  Size1         = GetDevicePathSize (FirstDevicePath);\r
+  Size2         = GetDevicePathSize (SecondDevicePath);\r
+  Size          = Size1 + Size2 - END_DEVICE_PATH_LENGTH;\r
+\r
+  NewDevicePath = AllocatePool (Size);\r
+\r
+  if (NewDevicePath != NULL) {\r
+    NewDevicePath = CopyMem (NewDevicePath, FirstDevicePath, Size1);\r
+    //\r
+    // Over write FirstDevicePath EndNode and do the copy\r
+    //\r
+    DevicePath2 = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath +\r
+                  (Size1 - END_DEVICE_PATH_LENGTH));\r
+    CopyMem (DevicePath2, SecondDevicePath, Size2);\r
+  }\r
+\r
+  return NewDevicePath;\r
+}\r
+\r
+/**\r
+  Creates a new path by appending the device node to the device path.\r
+\r
+  This function creates a new device path by appending a copy of the device node \r
+  specified by DevicePathNode to a copy of the device path specified by DevicePath \r
+  in an allocated buffer. The end-of-device-path device node is moved after the \r
+  end of the appended device node.\r
+  If DevicePathNode is NULL then a copy of DevicePath is returned.\r
+  If DevicePath is NULL then a copy of DevicePathNode, followed by an end-of-device \r
+  path device node is returned.\r
+  If both DevicePathNode and DevicePath are NULL then a copy of an end-of-device-path \r
+  device node is returned.\r
+  If there is not enough memory to allocate space for the new device path, then \r
+  NULL is returned.  \r
+  The memory is allocated from EFI boot services memory. It is the responsibility \r
+  of the caller to free the memory allocated.\r
+\r
+  @param  DevicePath                 A pointer to a device path data structure.\r
+  @param  DevicePathNode             A pointer to a single device path node.\r
+\r
+  @retval NULL      If there is not enough memory for the new device path.\r
+  @retval Others    A pointer to the new device path if success.\r
+                    A copy of DevicePathNode followed by an end-of-device-path node \r
+                    if both FirstDevicePath and SecondDevicePath are NULL.\r
+                    A copy of an end-of-device-path node if both FirstDevicePath \r
+                    and SecondDevicePath are NULL.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+UefiDevicePathLibAppendDevicePathNode (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath,     OPTIONAL\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePathNode  OPTIONAL\r
+  )\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *TempDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *NextNode;\r
+  EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;\r
+  UINTN                     NodeLength;\r
+\r
+  if (DevicePathNode == NULL) {\r
+    return DuplicateDevicePath ((DevicePath != NULL) ? DevicePath : &mUefiDevicePathLibEndDevicePath);\r
+  }\r
+  //\r
+  // Build a Node that has a terminator on it\r
+  //\r
+  NodeLength = DevicePathNodeLength (DevicePathNode);\r
+\r
+  TempDevicePath = AllocatePool (NodeLength + END_DEVICE_PATH_LENGTH);\r
+  if (TempDevicePath == NULL) {\r
+    return NULL;\r
+  }\r
+  TempDevicePath = CopyMem (TempDevicePath, DevicePathNode, NodeLength);\r
+  //\r
+  // Add and end device path node to convert Node to device path\r
+  //\r
+  NextNode = NextDevicePathNode (TempDevicePath);\r
+  SetDevicePathEndNode (NextNode);\r
+  //\r
+  // Append device paths\r
+  //\r
+  NewDevicePath = AppendDevicePath (DevicePath, TempDevicePath);\r
+\r
+  FreePool (TempDevicePath);\r
+\r
+  return NewDevicePath;\r
+}\r
+\r
+/**\r
+  Creates a new device path by appending the specified device path instance to the specified device\r
+  path.\r
\r
+  This function creates a new device path by appending a copy of the device path \r
+  instance specified by DevicePathInstance to a copy of the device path specified \r
+  by DevicePath in a allocated buffer.\r
+  The end-of-device-path device node is moved after the end of the appended device \r
+  path instance and a new end-of-device-path-instance node is inserted between. \r
+  If DevicePath is NULL, then a copy if DevicePathInstance is returned.\r
+  If DevicePathInstance is NULL, then NULL is returned.\r
+  If DevicePath or DevicePathInstance is invalid, then NULL is returned.\r
+  If there is not enough memory to allocate space for the new device path, then \r
+  NULL is returned.  \r
+  The memory is allocated from EFI boot services memory. It is the responsibility \r
+  of the caller to free the memory allocated.\r
+  \r
+  @param  DevicePath                 A pointer to a device path data structure.\r
+  @param  DevicePathInstance         A pointer to a device path instance.\r
+\r
+  @return A pointer to the new device path.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+UefiDevicePathLibAppendDevicePathInstance (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath,        OPTIONAL\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePathInstance OPTIONAL\r
+  )\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *TempDevicePath;\r
+  UINTN                     SrcSize;\r
+  UINTN                     InstanceSize;\r
+\r
+  if (DevicePath == NULL) {\r
+    return DuplicateDevicePath (DevicePathInstance);\r
+  }\r
+\r
+  if (DevicePathInstance == NULL) {\r
+    return NULL;\r
+  }\r
+\r
+  if (!IsDevicePathValid (DevicePath, 0) || !IsDevicePathValid (DevicePathInstance, 0)) {\r
+    return NULL;\r
+  }\r
+\r
+  SrcSize       = GetDevicePathSize (DevicePath);\r
+  InstanceSize  = GetDevicePathSize (DevicePathInstance);\r
+\r
+  NewDevicePath = AllocatePool (SrcSize + InstanceSize);\r
+  if (NewDevicePath != NULL) {\r
+    \r
+    TempDevicePath = CopyMem (NewDevicePath, DevicePath, SrcSize);;\r
\r
+    while (!IsDevicePathEnd (TempDevicePath)) {\r
+      TempDevicePath = NextDevicePathNode (TempDevicePath);\r
+    }\r
+    \r
+    TempDevicePath->SubType  = END_INSTANCE_DEVICE_PATH_SUBTYPE;\r
+    TempDevicePath           = NextDevicePathNode (TempDevicePath);\r
+    CopyMem (TempDevicePath, DevicePathInstance, InstanceSize);\r
+  }\r
+\r
+  return NewDevicePath;\r
+}\r
+\r
+/**\r
+  Creates a copy of the current device path instance and returns a pointer to the next device path\r
+  instance.\r
+\r
+  This function creates a copy of the current device path instance. It also updates \r
+  DevicePath to point to the next device path instance in the device path (or NULL \r
+  if no more) and updates Size to hold the size of the device path instance copy.\r
+  If DevicePath is NULL, then NULL is returned.\r
+  If DevicePath points to a invalid device path, then NULL is returned.\r
+  If there is not enough memory to allocate space for the new device path, then \r
+  NULL is returned.  \r
+  The memory is allocated from EFI boot services memory. It is the responsibility \r
+  of the caller to free the memory allocated.\r
+  If Size is NULL, then ASSERT().\r
\r
+  @param  DevicePath                 On input, this holds the pointer to the current \r
+                                     device path instance. On output, this holds \r
+                                     the pointer to the next device path instance \r
+                                     or NULL if there are no more device path\r
+                                     instances in the device path pointer to a \r
+                                     device path data structure.\r
+  @param  Size                       On output, this holds the size of the device \r
+                                     path instance, in bytes or zero, if DevicePath \r
+                                     is NULL.\r
+\r
+  @return A pointer to the current device path instance.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+UefiDevicePathLibGetNextDevicePathInstance (\r
+  IN OUT EFI_DEVICE_PATH_PROTOCOL    **DevicePath,\r
+  OUT UINTN                          *Size\r
+  )\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevPath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *ReturnValue;\r
+  UINT8                     Temp;\r
+\r
+  ASSERT (Size != NULL);\r
+\r
+  if (DevicePath == NULL || *DevicePath == NULL) {\r
+    *Size = 0;\r
+    return NULL;\r
+  }\r
+\r
+  if (!IsDevicePathValid (*DevicePath, 0)) {\r
+    return NULL;\r
+  }\r
+\r
+  //\r
+  // Find the end of the device path instance\r
+  //\r
+  DevPath = *DevicePath;\r
+  while (!IsDevicePathEndType (DevPath)) {\r
+    DevPath = NextDevicePathNode (DevPath);\r
+  }\r
+\r
+  //\r
+  // Compute the size of the device path instance\r
+  //\r
+  *Size = ((UINTN) DevPath - (UINTN) (*DevicePath)) + sizeof (EFI_DEVICE_PATH_PROTOCOL);\r
\r
+  //\r
+  // Make a copy and return the device path instance\r
+  //\r
+  Temp              = DevPath->SubType;\r
+  DevPath->SubType  = END_ENTIRE_DEVICE_PATH_SUBTYPE;\r
+  ReturnValue       = DuplicateDevicePath (*DevicePath);\r
+  DevPath->SubType  = Temp;\r
+\r
+  //\r
+  // If DevPath is the end of an entire device path, then another instance\r
+  // does not follow, so *DevicePath is set to NULL.\r
+  //\r
+  if (DevicePathSubType (DevPath) == END_ENTIRE_DEVICE_PATH_SUBTYPE) {\r
+    *DevicePath = NULL;\r
+  } else {\r
+    *DevicePath = NextDevicePathNode (DevPath);\r
+  }\r
+\r
+  return ReturnValue;\r
+}\r
+\r
+/**\r
+  Creates a device node.\r
+\r
+  This function creates a new device node in a newly allocated buffer of size \r
+  NodeLength and initializes the device path node header with NodeType and NodeSubType.  \r
+  The new device path node is returned.\r
+  If NodeLength is smaller than a device path header, then NULL is returned.  \r
+  If there is not enough memory to allocate space for the new device path, then \r
+  NULL is returned.  \r
+  The memory is allocated from EFI boot services memory. It is the responsibility \r
+  of the caller to free the memory allocated.\r
+\r
+  @param  NodeType                   The device node type for the new device node.\r
+  @param  NodeSubType                The device node sub-type for the new device node.\r
+  @param  NodeLength                 The length of the new device node.\r
+\r
+  @return The new device path.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+UefiDevicePathLibCreateDeviceNode (\r
+  IN UINT8                           NodeType,\r
+  IN UINT8                           NodeSubType,\r
+  IN UINT16                          NodeLength\r
+  )\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL      *DevicePath;\r
+\r
+  if (NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {\r
+    //\r
+    // NodeLength is less than the size of the header.\r
+    //\r
+    return NULL;\r
+  }\r
\r
+  DevicePath = AllocateZeroPool (NodeLength);\r
+  if (DevicePath != NULL) {\r
+     DevicePath->Type    = NodeType;\r
+     DevicePath->SubType = NodeSubType;\r
+     SetDevicePathNodeLength (DevicePath, NodeLength);\r
+  }\r
+\r
+  return DevicePath;\r
+}\r
+\r
+/**\r
+  Determines if a device path is single or multi-instance.\r
+\r
+  This function returns TRUE if the device path specified by DevicePath is\r
+  multi-instance.\r
+  Otherwise, FALSE is returned.\r
+  If DevicePath is NULL or invalid, then FALSE is returned.\r
+\r
+  @param  DevicePath                 A pointer to a device path data structure.\r
+\r
+  @retval  TRUE                      DevicePath is multi-instance.\r
+  @retval  FALSE                     DevicePath is not multi-instance, or DevicePath \r
+                                     is NULL or invalid.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+UefiDevicePathLibIsDevicePathMultiInstance (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+  )\r
+{\r
+  CONST EFI_DEVICE_PATH_PROTOCOL     *Node;\r
+\r
+  if (DevicePath == NULL) {\r
+    return FALSE;\r
+  }\r
+\r
+  if (!IsDevicePathValid (DevicePath, 0)) {\r
+    return FALSE;\r
+  }\r
+\r
+  Node = DevicePath;\r
+  while (!IsDevicePathEnd (Node)) {\r
+    if (IsDevicePathEndInstance (Node)) {\r
+      return TRUE;\r
+    }\r
+\r
+    Node = NextDevicePathNode (Node);\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+\r
+/**\r
+  Retrieves the device path protocol from a handle.\r
+\r
+  This function returns the device path protocol from the handle specified by Handle.  \r
+  If Handle is NULL or Handle does not contain a device path protocol, then NULL \r
+  is returned.\r
\r
+  @param  Handle                     The handle from which to retrieve the device \r
+                                     path protocol.\r
+\r
+  @return The device path protocol from the handle specified by Handle.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+DevicePathFromHandle (\r
+  IN EFI_HANDLE                      Handle\r
+  )\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  EFI_STATUS                Status;\r
+\r
+  Status = gBS->HandleProtocol (\r
+                  Handle,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID *) &DevicePath\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    DevicePath = NULL;\r
+  }\r
+  return DevicePath;\r
+}\r
+\r
+/**\r
+  Allocates a device path for a file and appends it to an existing device path.\r
+\r
+  If Device is a valid device handle that contains a device path protocol, then a device path for\r
+  the file specified by FileName  is allocated and appended to the device path associated with the\r
+  handle Device.  The allocated device path is returned.  If Device is NULL or Device is a handle\r
+  that does not support the device path protocol, then a device path containing a single device\r
+  path node for the file specified by FileName is allocated and returned.\r
+  The memory for the new device path is allocated from EFI boot services memory. It is the responsibility\r
+  of the caller to free the memory allocated.\r
+  \r
+  If FileName is NULL, then ASSERT().\r
+  If FileName is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  @param  Device                     A pointer to a device handle.  This parameter \r
+                                     is optional and may be NULL.\r
+  @param  FileName                   A pointer to a Null-terminated Unicode string.\r
+\r
+  @return The allocated device path.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+FileDevicePath (\r
+  IN EFI_HANDLE                      Device,     OPTIONAL\r
+  IN CONST CHAR16                    *FileName\r
+  )\r
+{\r
+  UINTN                     Size;\r
+  FILEPATH_DEVICE_PATH      *FilePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *FileDevicePath;\r
+\r
+  DevicePath = NULL;\r
+\r
+  Size = StrSize (FileName);\r
+  FileDevicePath = AllocatePool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + END_DEVICE_PATH_LENGTH);\r
+  if (FileDevicePath != NULL) {\r
+    FilePath = (FILEPATH_DEVICE_PATH *) FileDevicePath;\r
+    FilePath->Header.Type    = MEDIA_DEVICE_PATH;\r
+    FilePath->Header.SubType = MEDIA_FILEPATH_DP;\r
+    CopyMem (&FilePath->PathName, FileName, Size);\r
+    SetDevicePathNodeLength (&FilePath->Header, Size + SIZE_OF_FILEPATH_DEVICE_PATH);\r
+    SetDevicePathEndNode (NextDevicePathNode (&FilePath->Header));\r
+\r
+    if (Device != NULL) {\r
+      DevicePath = DevicePathFromHandle (Device);\r
+    }\r
+\r
+    DevicePath = AppendDevicePath (DevicePath, FileDevicePath);\r
+    FreePool (FileDevicePath);\r
+  }\r
+\r
+  return DevicePath;\r
+}\r
+\r
index a91a7a3582b329bd82138a79073c9e2eec8fd967..baad7bc1f7f156ecee63b2befdd50166a2675895 100644 (file)
@@ -8,7 +8,7 @@
   environment varibles. Multi-instance device paths should never be placed\r
   on a Handle.\r
 \r
-  Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials                          \r
   are licensed and made available under the terms and conditions of the BSD License         \r
   which accompanies this distribution.  The full text of the license may be found at        \r
 **/\r
 \r
 \r
-#include <Uefi.h>\r
-\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/PcdLib.h>\r
-\r
-//\r
-// Template for an end-of-device path node.\r
-//\r
-GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_DEVICE_PATH_PROTOCOL  mUefiDevicePathLibEndDevicePath = {\r
-  END_DEVICE_PATH_TYPE,\r
-  END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
-  {\r
-    END_DEVICE_PATH_LENGTH,\r
-    0\r
-  }\r
-};\r
-\r
-/**\r
-  Determine whether a given device path is valid.\r
-  If DevicePath is NULL, then ASSERT().\r
-\r
-  @param  DevicePath  A pointer to a device path data structure.\r
-  @param  MaxSize     The maximum size of the device path data structure.\r
-\r
-  @retval TRUE        DevicePath is valid.\r
-  @retval FALSE       The length of any node node in the DevicePath is less\r
-                      than sizeof (EFI_DEVICE_PATH_PROTOCOL).\r
-  @retval FALSE       If MaxSize is not zero, the size of the DevicePath\r
-                      exceeds MaxSize.\r
-  @retval FALSE       If PcdMaximumDevicePathNodeCount is not zero, the node\r
-                      count of the DevicePath exceeds PcdMaximumDevicePathNodeCount.\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-IsDevicePathValid (\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
-  IN       UINTN                    MaxSize\r
-  )\r
-{\r
-  UINTN Count;\r
-  UINTN Size;\r
-  UINTN NodeLength;\r
-\r
-  ASSERT (DevicePath != NULL);\r
-\r
-  for (Count = 0, Size = 0; !IsDevicePathEnd (DevicePath); DevicePath = NextDevicePathNode (DevicePath)) {\r
-    NodeLength = DevicePathNodeLength (DevicePath);\r
-    if (NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {\r
-      return FALSE;\r
-    }\r
-\r
-    if (MaxSize > 0) {\r
-      Size += NodeLength;\r
-      if (Size + END_DEVICE_PATH_LENGTH > MaxSize) {\r
-        return FALSE;\r
-      }\r
-    }\r
-\r
-    if (PcdGet32 (PcdMaximumDevicePathNodeCount) > 0) {\r
-      Count++;\r
-      if (Count >= PcdGet32 (PcdMaximumDevicePathNodeCount)) {\r
-        return FALSE;\r
-      }\r
-    }\r
-  }\r
-\r
-  //\r
-  // Only return TRUE when the End Device Path node is valid.\r
-  //\r
-  return (BOOLEAN) (DevicePathNodeLength (DevicePath) == END_DEVICE_PATH_LENGTH);\r
-}\r
-\r
-/**\r
-  Returns the Type field of a device path node.\r
-\r
-  Returns the Type field of the device path node specified by Node.\r
-\r
-  If Node is NULL, then ASSERT().\r
-\r
-  @param  Node      A pointer to a device path node data structure.\r
-\r
-  @return The Type field of the device path node specified by Node.\r
-\r
-**/\r
-UINT8\r
-EFIAPI\r
-DevicePathType (\r
-  IN CONST VOID  *Node\r
-  )\r
-{\r
-  ASSERT (Node != NULL);\r
-  return ((EFI_DEVICE_PATH_PROTOCOL *)(Node))->Type;\r
-}\r
-\r
-/**\r
-  Returns the SubType field of a device path node.\r
-\r
-  Returns the SubType field of the device path node specified by Node.\r
-\r
-  If Node is NULL, then ASSERT().\r
-\r
-  @param  Node      A pointer to a device path node data structure.\r
-\r
-  @return The SubType field of the device path node specified by Node.\r
-\r
-**/\r
-UINT8\r
-EFIAPI\r
-DevicePathSubType (\r
-  IN CONST VOID  *Node\r
-  )\r
-{\r
-  ASSERT (Node != NULL);\r
-  return ((EFI_DEVICE_PATH_PROTOCOL *)(Node))->SubType;\r
-}\r
-\r
-/**\r
-  Returns the 16-bit Length field of a device path node.\r
-\r
-  Returns the 16-bit Length field of the device path node specified by Node.  \r
-  Node is not required to be aligned on a 16-bit boundary, so it is recommended\r
-  that a function such as ReadUnaligned16() be used to extract the contents of \r
-  the Length field.\r
-\r
-  If Node is NULL, then ASSERT().\r
-\r
-  @param  Node      A pointer to a device path node data structure.\r
-\r
-  @return The 16-bit Length field of the device path node specified by Node.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-DevicePathNodeLength (\r
-  IN CONST VOID  *Node\r
-  )\r
-{\r
-  UINTN Length;\r
-\r
-  ASSERT (Node != NULL);\r
-  Length = ReadUnaligned16 ((UINT16 *)&((EFI_DEVICE_PATH_PROTOCOL *)(Node))->Length[0]);\r
-  ASSERT (Length >= sizeof (EFI_DEVICE_PATH_PROTOCOL));\r
-  return Length;\r
-}\r
-\r
-/**\r
-  Returns a pointer to the next node in a device path.\r
-\r
-  Returns a pointer to the device path node that follows the device path node \r
-  specified by Node.\r
-\r
-  If Node is NULL, then ASSERT().\r
-\r
-  @param  Node      A pointer to a device path node data structure.\r
-\r
-  @return a pointer to the device path node that follows the device path node \r
-  specified by Node.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-EFIAPI\r
-NextDevicePathNode (\r
-  IN CONST VOID  *Node\r
-  )\r
-{\r
-  ASSERT (Node != NULL);\r
-  return (EFI_DEVICE_PATH_PROTOCOL *)((UINT8 *)(Node) + DevicePathNodeLength(Node));\r
-}\r
-\r
-/**\r
-  Determines if a device path node is an end node of a device path.\r
-  This includes nodes that are the end of a device path instance and nodes that \r
-  are the end of an entire device path.\r
-\r
-  Determines if the device path node specified by Node is an end node of a device path.  \r
-  This includes nodes that are the end of a device path instance and nodes that are the \r
-  end of an entire device path.  If Node represents an end node of a device path, \r
-  then TRUE is returned.  Otherwise, FALSE is returned.\r
-\r
-  If Node is NULL, then ASSERT().\r
-\r
-  @param  Node      A pointer to a device path node data structure.\r
-\r
-  @retval TRUE      The device path node specified by Node is an end node of a \r
-                    device path.\r
-  @retval FALSE     The device path node specified by Node is not an end node of \r
-                    a device path.\r
-  \r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-IsDevicePathEndType (\r
-  IN CONST VOID  *Node\r
-  )\r
-{\r
-  ASSERT (Node != NULL);\r
-  return (BOOLEAN) (DevicePathType (Node) == END_DEVICE_PATH_TYPE);\r
-}\r
-\r
-/**\r
-  Determines if a device path node is an end node of an entire device path.\r
-\r
-  Determines if a device path node specified by Node is an end node of an entire \r
-  device path. If Node represents the end of an entire device path, then TRUE is \r
-  returned.  Otherwise, FALSE is returned.\r
-\r
-  If Node is NULL, then ASSERT().\r
-\r
-  @param  Node      A pointer to a device path node data structure.\r
-\r
-  @retval TRUE      The device path node specified by Node is the end of an entire \r
-                    device path.\r
-  @retval FALSE     The device path node specified by Node is not the end of an \r
-                    entire device path.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-IsDevicePathEnd (\r
-  IN CONST VOID  *Node\r
-  )\r
-{\r
-  ASSERT (Node != NULL);\r
-  return (BOOLEAN) (IsDevicePathEndType (Node) && DevicePathSubType(Node) == END_ENTIRE_DEVICE_PATH_SUBTYPE);\r
-}\r
-\r
-/**\r
-  Determines if a device path node is an end node of a device path instance.\r
-\r
-  Determines if a device path node specified by Node is an end node of a device \r
-  path instance. If Node represents the end of a device path instance, then TRUE \r
-  is returned.  Otherwise, FALSE is returned.\r
-\r
-  If Node is NULL, then ASSERT().\r
-\r
-  @param  Node      A pointer to a device path node data structure.\r
-\r
-  @retval TRUE      The device path node specified by Node is the end of a device \r
-                    path instance.\r
-  @retval FALSE     The device path node specified by Node is not the end of a \r
-                    device path instance.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-IsDevicePathEndInstance (\r
-  IN CONST VOID  *Node\r
-  )\r
-{\r
-  ASSERT (Node != NULL);\r
-  return (BOOLEAN) (IsDevicePathEndType (Node) && DevicePathSubType(Node) == END_INSTANCE_DEVICE_PATH_SUBTYPE);\r
-}\r
-\r
-/**\r
-  Sets the length, in bytes, of a device path node.\r
-\r
-  Sets the length of the device path node specified by Node to the value specified \r
-  by NodeLength.  NodeLength is returned.  Node is not required to be aligned on \r
-  a 16-bit boundary, so it is recommended that a function such as WriteUnaligned16()\r
-  be used to set the contents of the Length field.\r
-\r
-  If Node is NULL, then ASSERT().\r
-  If NodeLength >= SIZE_64KB, then ASSERT().\r
-  If NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL), then ASSERT().\r
-\r
-  @param  Node      A pointer to a device path node data structure.\r
-  @param  Length    The length, in bytes, of the device path node.\r
-\r
-  @return Length\r
-\r
-**/\r
-UINT16\r
-EFIAPI\r
-SetDevicePathNodeLength (\r
-  IN OUT VOID  *Node,\r
-  IN UINTN     Length\r
-  )\r
-{\r
-  ASSERT (Node != NULL);\r
-  ASSERT ((Length >= sizeof (EFI_DEVICE_PATH_PROTOCOL)) && (Length < SIZE_64KB));\r
-  return WriteUnaligned16 ((UINT16 *)&((EFI_DEVICE_PATH_PROTOCOL *)(Node))->Length[0], (UINT16)(Length));\r
-}\r
-\r
-/**\r
-  Fills in all the fields of a device path node that is the end of an entire device path.\r
-\r
-  Fills in all the fields of a device path node specified by Node so Node represents \r
-  the end of an entire device path.  The Type field of Node is set to \r
-  END_DEVICE_PATH_TYPE, the SubType field of Node is set to \r
-  END_ENTIRE_DEVICE_PATH_SUBTYPE, and the Length field of Node is set to \r
-  END_DEVICE_PATH_LENGTH.  Node is not required to be aligned on a 16-bit boundary, \r
-  so it is recommended that a function such as WriteUnaligned16() be used to set \r
-  the contents of the Length field. \r
-\r
-  If Node is NULL, then ASSERT(). \r
-\r
-  @param  Node      A pointer to a device path node data structure.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-SetDevicePathEndNode (\r
-  OUT VOID  *Node\r
-  )\r
-{\r
-  ASSERT (Node != NULL);\r
-  CopyMem (Node, &mUefiDevicePathLibEndDevicePath, sizeof (mUefiDevicePathLibEndDevicePath));\r
-}\r
+#include "UefiDevicePathLib.h"\r
 \r
 /**\r
   Returns the size of a device path in bytes.\r
@@ -353,28 +41,7 @@ GetDevicePathSize (
   IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
   )\r
 {\r
-  CONST EFI_DEVICE_PATH_PROTOCOL  *Start;\r
-\r
-  if (DevicePath == NULL) {\r
-    return 0;\r
-  }\r
-\r
-  if (!IsDevicePathValid (DevicePath, 0)) {\r
-    return 0;\r
-  }\r
-\r
-  //\r
-  // Search for the end of the device path structure\r
-  //\r
-  Start = DevicePath;\r
-  while (!IsDevicePathEnd (DevicePath)) {\r
-    DevicePath = NextDevicePathNode (DevicePath);\r
-  }\r
-\r
-  //\r
-  // Compute the size and add back in the size of the end device path structure\r
-  //\r
-  return ((UINTN) DevicePath - (UINTN) Start) + DevicePathNodeLength (DevicePath);\r
+  return UefiDevicePathLibGetDevicePathSize (DevicePath);\r
 }\r
 \r
 /**\r
@@ -399,21 +66,7 @@ DuplicateDevicePath (
   IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
   )\r
 {\r
-  UINTN                     Size;\r
-\r
-  //\r
-  // Compute the size\r
-  //\r
-  Size = GetDevicePathSize (DevicePath);\r
-  if (Size == 0) {\r
-    return NULL;\r
-  }\r
-\r
-  //\r
-  // Allocate space for duplicate device path\r
-  //\r
-\r
-  return AllocateCopyPool (Size, DevicePath);\r
+  return UefiDevicePathLibDuplicateDevicePath (DevicePath);\r
 }\r
 \r
 /**\r
@@ -447,48 +100,7 @@ AppendDevicePath (
   IN CONST EFI_DEVICE_PATH_PROTOCOL  *SecondDevicePath  OPTIONAL\r
   )\r
 {\r
-  UINTN                     Size;\r
-  UINTN                     Size1;\r
-  UINTN                     Size2;\r
-  EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath2;\r
-\r
-  //\r
-  // If there's only 1 path, just duplicate it.\r
-  //\r
-  if (FirstDevicePath == NULL) {\r
-    return DuplicateDevicePath ((SecondDevicePath != NULL) ? SecondDevicePath : &mUefiDevicePathLibEndDevicePath);\r
-  }\r
-\r
-  if (SecondDevicePath == NULL) {\r
-    return DuplicateDevicePath (FirstDevicePath);\r
-  }\r
-\r
-  if (!IsDevicePathValid (FirstDevicePath, 0) || !IsDevicePathValid (SecondDevicePath, 0)) {\r
-    return NULL;\r
-  }\r
-\r
-  //\r
-  // Allocate space for the combined device path. It only has one end node of\r
-  // length EFI_DEVICE_PATH_PROTOCOL.\r
-  //\r
-  Size1         = GetDevicePathSize (FirstDevicePath);\r
-  Size2         = GetDevicePathSize (SecondDevicePath);\r
-  Size          = Size1 + Size2 - END_DEVICE_PATH_LENGTH;\r
-\r
-  NewDevicePath = AllocatePool (Size);\r
-\r
-  if (NewDevicePath != NULL) {\r
-    NewDevicePath = CopyMem (NewDevicePath, FirstDevicePath, Size1);\r
-    //\r
-    // Over write FirstDevicePath EndNode and do the copy\r
-    //\r
-    DevicePath2 = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath +\r
-                  (Size1 - END_DEVICE_PATH_LENGTH));\r
-    CopyMem (DevicePath2, SecondDevicePath, Size2);\r
-  }\r
-\r
-  return NewDevicePath;\r
+  return UefiDevicePathLibAppendDevicePath (FirstDevicePath, SecondDevicePath);\r
 }\r
 \r
 /**\r
@@ -526,37 +138,7 @@ AppendDevicePathNode (
   IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePathNode  OPTIONAL\r
   )\r
 {\r
-  EFI_DEVICE_PATH_PROTOCOL  *TempDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *NextNode;\r
-  EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;\r
-  UINTN                     NodeLength;\r
-\r
-  if (DevicePathNode == NULL) {\r
-    return DuplicateDevicePath ((DevicePath != NULL) ? DevicePath : &mUefiDevicePathLibEndDevicePath);\r
-  }\r
-  //\r
-  // Build a Node that has a terminator on it\r
-  //\r
-  NodeLength = DevicePathNodeLength (DevicePathNode);\r
-\r
-  TempDevicePath = AllocatePool (NodeLength + END_DEVICE_PATH_LENGTH);\r
-  if (TempDevicePath == NULL) {\r
-    return NULL;\r
-  }\r
-  TempDevicePath = CopyMem (TempDevicePath, DevicePathNode, NodeLength);\r
-  //\r
-  // Add and end device path node to convert Node to device path\r
-  //\r
-  NextNode = NextDevicePathNode (TempDevicePath);\r
-  SetDevicePathEndNode (NextNode);\r
-  //\r
-  // Append device paths\r
-  //\r
-  NewDevicePath = AppendDevicePath (DevicePath, TempDevicePath);\r
-\r
-  FreePool (TempDevicePath);\r
-\r
-  return NewDevicePath;\r
+  return UefiDevicePathLibAppendDevicePathNode (DevicePath, DevicePathNode);\r
 }\r
 \r
 /**\r
@@ -589,41 +171,7 @@ AppendDevicePathInstance (
   IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePathInstance OPTIONAL\r
   )\r
 {\r
-  EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *TempDevicePath;\r
-  UINTN                     SrcSize;\r
-  UINTN                     InstanceSize;\r
-\r
-  if (DevicePath == NULL) {\r
-    return DuplicateDevicePath (DevicePathInstance);\r
-  }\r
-\r
-  if (DevicePathInstance == NULL) {\r
-    return NULL;\r
-  }\r
-\r
-  if (!IsDevicePathValid (DevicePath, 0) || !IsDevicePathValid (DevicePathInstance, 0)) {\r
-    return NULL;\r
-  }\r
-\r
-  SrcSize       = GetDevicePathSize (DevicePath);\r
-  InstanceSize  = GetDevicePathSize (DevicePathInstance);\r
-\r
-  NewDevicePath = AllocatePool (SrcSize + InstanceSize);\r
-  if (NewDevicePath != NULL) {\r
-    \r
-    TempDevicePath = CopyMem (NewDevicePath, DevicePath, SrcSize);;\r
\r
-    while (!IsDevicePathEnd (TempDevicePath)) {\r
-      TempDevicePath = NextDevicePathNode (TempDevicePath);\r
-    }\r
-    \r
-    TempDevicePath->SubType  = END_INSTANCE_DEVICE_PATH_SUBTYPE;\r
-    TempDevicePath           = NextDevicePathNode (TempDevicePath);\r
-    CopyMem (TempDevicePath, DevicePathInstance, InstanceSize);\r
-  }\r
-\r
-  return NewDevicePath;\r
+  return UefiDevicePathLibAppendDevicePathInstance (DevicePath, DevicePathInstance);\r
 }\r
 \r
 /**\r
@@ -661,53 +209,7 @@ GetNextDevicePathInstance (
   OUT UINTN                          *Size\r
   )\r
 {\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevPath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *ReturnValue;\r
-  UINT8                     Temp;\r
-\r
-  ASSERT (Size != NULL);\r
-\r
-  if (DevicePath == NULL || *DevicePath == NULL) {\r
-    *Size = 0;\r
-    return NULL;\r
-  }\r
-\r
-  if (!IsDevicePathValid (*DevicePath, 0)) {\r
-    return NULL;\r
-  }\r
-\r
-  //\r
-  // Find the end of the device path instance\r
-  //\r
-  DevPath = *DevicePath;\r
-  while (!IsDevicePathEndType (DevPath)) {\r
-    DevPath = NextDevicePathNode (DevPath);\r
-  }\r
-\r
-  //\r
-  // Compute the size of the device path instance\r
-  //\r
-  *Size = ((UINTN) DevPath - (UINTN) (*DevicePath)) + sizeof (EFI_DEVICE_PATH_PROTOCOL);\r
\r
-  //\r
-  // Make a copy and return the device path instance\r
-  //\r
-  Temp              = DevPath->SubType;\r
-  DevPath->SubType  = END_ENTIRE_DEVICE_PATH_SUBTYPE;\r
-  ReturnValue       = DuplicateDevicePath (*DevicePath);\r
-  DevPath->SubType  = Temp;\r
-\r
-  //\r
-  // If DevPath is the end of an entire device path, then another instance\r
-  // does not follow, so *DevicePath is set to NULL.\r
-  //\r
-  if (DevicePathSubType (DevPath) == END_ENTIRE_DEVICE_PATH_SUBTYPE) {\r
-    *DevicePath = NULL;\r
-  } else {\r
-    *DevicePath = NextDevicePathNode (DevPath);\r
-  }\r
-\r
-  return ReturnValue;\r
+  return UefiDevicePathLibGetNextDevicePathInstance (DevicePath, Size);\r
 }\r
 \r
 /**\r
@@ -737,23 +239,7 @@ CreateDeviceNode (
   IN UINT16                          NodeLength\r
   )\r
 {\r
-  EFI_DEVICE_PATH_PROTOCOL      *DevicePath;\r
-\r
-  if (NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {\r
-    //\r
-    // NodeLength is less than the size of the header.\r
-    //\r
-    return NULL;\r
-  }\r
\r
-  DevicePath = AllocateZeroPool (NodeLength);\r
-  if (DevicePath != NULL) {\r
-     DevicePath->Type    = NodeType;\r
-     DevicePath->SubType = NodeSubType;\r
-     SetDevicePathNodeLength (DevicePath, NodeLength);\r
-  }\r
-\r
-  return DevicePath;\r
+  return UefiDevicePathLibCreateDeviceNode (NodeType, NodeSubType, NodeLength);\r
 }\r
 \r
 /**\r
@@ -777,115 +263,98 @@ IsDevicePathMultiInstance (
   IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
   )\r
 {\r
-  CONST EFI_DEVICE_PATH_PROTOCOL     *Node;\r
-\r
-  if (DevicePath == NULL) {\r
-    return FALSE;\r
-  }\r
+  return UefiDevicePathLibIsDevicePathMultiInstance (DevicePath);\r
+}\r
 \r
-  if (!IsDevicePathValid (DevicePath, 0)) {\r
-    return FALSE;\r
-  }\r
+/**\r
+  Converts a device node to its string representation.\r
 \r
-  Node = DevicePath;\r
-  while (!IsDevicePathEnd (Node)) {\r
-    if (IsDevicePathEndInstance (Node)) {\r
-      return TRUE;\r
-    }\r
+  @param DeviceNode        A Pointer to the device node to be converted.\r
+  @param DisplayOnly       If DisplayOnly is TRUE, then the shorter text representation\r
+                           of the display node is used, where applicable. If DisplayOnly\r
+                           is FALSE, then the longer text representation of the display node\r
+                           is used.\r
+  @param AllowShortcuts    If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                           representation for a device node can be used, where applicable.\r
 \r
-    Node = NextDevicePathNode (Node);\r
-  }\r
+  @return A pointer to the allocated text representation of the device node or NULL if DeviceNode\r
+          is NULL or there was insufficient memory.\r
 \r
-  return FALSE;\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+ConvertDeviceNodeToText (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DeviceNode,\r
+  IN BOOLEAN                         DisplayOnly,\r
+  IN BOOLEAN                         AllowShortcuts\r
+  )\r
+{\r
+  return UefiDevicePathLibConvertDeviceNodeToText (DeviceNode, DisplayOnly, AllowShortcuts);\r
 }\r
 \r
+/**\r
+  Converts a device path to its text representation.\r
+\r
+  @param DevicePath      A Pointer to the device to be converted.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+  @return A pointer to the allocated text representation of the device path or\r
+          NULL if DeviceNode is NULL or there was insufficient memory.\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+ConvertDevicePathToText (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL   *DevicePath,\r
+  IN BOOLEAN                          DisplayOnly,\r
+  IN BOOLEAN                          AllowShortcuts\r
+  )\r
+{\r
+  return UefiDevicePathLibConvertDevicePathToText (DevicePath, DisplayOnly, AllowShortcuts);\r
+}\r
 \r
 /**\r
-  Retrieves the device path protocol from a handle.\r
+  Convert text to the binary representation of a device node.\r
 \r
-  This function returns the device path protocol from the handle specified by Handle.  \r
-  If Handle is NULL or Handle does not contain a device path protocol, then NULL \r
-  is returned.\r
\r
-  @param  Handle                     The handle from which to retrieve the device \r
-                                     path protocol.\r
+  @param TextDeviceNode  TextDeviceNode points to the text representation of a device\r
+                         node. Conversion starts with the first character and continues\r
+                         until the first non-device node character.\r
 \r
-  @return The device path protocol from the handle specified by Handle.\r
+  @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was\r
+          insufficient memory or text unsupported.\r
 \r
 **/\r
 EFI_DEVICE_PATH_PROTOCOL *\r
 EFIAPI\r
-DevicePathFromHandle (\r
-  IN EFI_HANDLE                      Handle\r
+ConvertTextToDeviceNode (\r
+  IN CONST CHAR16 *TextDeviceNode\r
   )\r
 {\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  EFI_STATUS                Status;\r
-\r
-  Status = gBS->HandleProtocol (\r
-                  Handle,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID *) &DevicePath\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    DevicePath = NULL;\r
-  }\r
-  return DevicePath;\r
+  return UefiDevicePathLibConvertTextToDeviceNode (TextDeviceNode);\r
 }\r
 \r
 /**\r
-  Allocates a device path for a file and appends it to an existing device path.\r
-\r
-  If Device is a valid device handle that contains a device path protocol, then a device path for\r
-  the file specified by FileName  is allocated and appended to the device path associated with the\r
-  handle Device.  The allocated device path is returned.  If Device is NULL or Device is a handle\r
-  that does not support the device path protocol, then a device path containing a single device\r
-  path node for the file specified by FileName is allocated and returned.\r
-  The memory for the new device path is allocated from EFI boot services memory. It is the responsibility\r
-  of the caller to free the memory allocated.\r
-  \r
-  If FileName is NULL, then ASSERT().\r
-  If FileName is not aligned on a 16-bit boundary, then ASSERT().\r
+  Convert text to the binary representation of a device path.\r
 \r
-  @param  Device                     A pointer to a device handle.  This parameter \r
-                                     is optional and may be NULL.\r
-  @param  FileName                   A pointer to a Null-terminated Unicode string.\r
 \r
-  @return The allocated device path.\r
+  @param TextDevicePath  TextDevicePath points to the text representation of a device\r
+                         path. Conversion starts with the first character and continues\r
+                         until the first non-device node character.\r
+\r
+  @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or\r
+          there was insufficient memory.\r
 \r
 **/\r
 EFI_DEVICE_PATH_PROTOCOL *\r
 EFIAPI\r
-FileDevicePath (\r
-  IN EFI_HANDLE                      Device,     OPTIONAL\r
-  IN CONST CHAR16                    *FileName\r
+ConvertTextToDevicePath (\r
+  IN CONST CHAR16 *TextDevicePath\r
   )\r
 {\r
-  UINTN                     Size;\r
-  FILEPATH_DEVICE_PATH      *FilePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *FileDevicePath;\r
-\r
-  DevicePath = NULL;\r
-\r
-  Size = StrSize (FileName);\r
-  FileDevicePath = AllocatePool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + END_DEVICE_PATH_LENGTH);\r
-  if (FileDevicePath != NULL) {\r
-    FilePath = (FILEPATH_DEVICE_PATH *) FileDevicePath;\r
-    FilePath->Header.Type    = MEDIA_DEVICE_PATH;\r
-    FilePath->Header.SubType = MEDIA_FILEPATH_DP;\r
-    CopyMem (&FilePath->PathName, FileName, Size);\r
-    SetDevicePathNodeLength (&FilePath->Header, Size + SIZE_OF_FILEPATH_DEVICE_PATH);\r
-    SetDevicePathEndNode (NextDevicePathNode (&FilePath->Header));\r
-\r
-    if (Device != NULL) {\r
-      DevicePath = DevicePathFromHandle (Device);\r
-    }\r
-\r
-    DevicePath = AppendDevicePath (DevicePath, FileDevicePath);\r
-    FreePool (FileDevicePath);\r
-  }\r
-\r
-  return DevicePath;\r
+  return UefiDevicePathLibConvertTextToDevicePath (TextDevicePath);\r
 }\r
-\r
diff --git a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.h b/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.h
new file mode 100644 (file)
index 0000000..a7ed531
--- /dev/null
@@ -0,0 +1,451 @@
+/** @file\r
+  Definition for Device Path library.\r
+\r
+Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _UEFI_DEVICE_PATH_LIB_H_\r
+#define _UEFI_DEVICE_PATH_LIB_H_\r
+#include <Uefi.h>\r
+#include <Protocol/DevicePathUtilities.h>\r
+#include <Protocol/DebugPort.h>\r
+#include <Protocol/DevicePathToText.h>\r
+#include <Protocol/DevicePathFromText.h>\r
+#include <Guid/PcAnsi.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/PrintLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/DevicePathLib.h>\r
+#include <Library/PcdLib.h>\r
+\r
+#define IS_COMMA(a)                ((a) == L',')\r
+#define IS_HYPHEN(a)               ((a) == L'-')\r
+#define IS_DOT(a)                  ((a) == L'.')\r
+#define IS_LEFT_PARENTH(a)         ((a) == L'(')\r
+#define IS_RIGHT_PARENTH(a)        ((a) == L')')\r
+#define IS_SLASH(a)                ((a) == L'/')\r
+#define IS_NULL(a)                 ((a) == L'\0')\r
+\r
+\r
+//\r
+// Private Data structure\r
+//\r
+typedef struct {\r
+  CHAR16  *Str;\r
+  UINTN   Count;\r
+  UINTN   Capacity;\r
+} POOL_PRINT;\r
+\r
+typedef\r
+EFI_DEVICE_PATH_PROTOCOL  *\r
+(*DEVICE_PATH_FROM_TEXT) (\r
+  IN  CHAR16 *Str\r
+  );\r
+\r
+typedef\r
+VOID\r
+(*DEVICE_PATH_TO_TEXT) (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevicePath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  );\r
+\r
+typedef struct {\r
+  UINT8                Type;\r
+  UINT8                SubType;\r
+  DEVICE_PATH_TO_TEXT  Function;\r
+} DEVICE_PATH_TO_TEXT_TABLE;\r
+\r
+typedef struct {\r
+  CHAR16                    *DevicePathNodeText;\r
+  DEVICE_PATH_FROM_TEXT     Function;\r
+} DEVICE_PATH_FROM_TEXT_TABLE;\r
+\r
+typedef struct {\r
+  BOOLEAN ClassExist;\r
+  UINT8   Class;\r
+  BOOLEAN SubClassExist;\r
+  UINT8   SubClass;\r
+} USB_CLASS_TEXT;\r
+\r
+#define USB_CLASS_AUDIO            1\r
+#define USB_CLASS_CDCCONTROL       2\r
+#define USB_CLASS_HID              3\r
+#define USB_CLASS_IMAGE            6\r
+#define USB_CLASS_PRINTER          7\r
+#define USB_CLASS_MASS_STORAGE     8\r
+#define USB_CLASS_HUB              9\r
+#define USB_CLASS_CDCDATA          10\r
+#define USB_CLASS_SMART_CARD       11\r
+#define USB_CLASS_VIDEO            14\r
+#define USB_CLASS_DIAGNOSTIC       220\r
+#define USB_CLASS_WIRELESS         224\r
+\r
+#define USB_CLASS_RESERVE          254\r
+#define USB_SUBCLASS_FW_UPDATE     1\r
+#define USB_SUBCLASS_IRDA_BRIDGE   2\r
+#define USB_SUBCLASS_TEST          3\r
+\r
+#define RFC_1700_UDP_PROTOCOL      17\r
+#define RFC_1700_TCP_PROTOCOL      6\r
+\r
+#pragma pack(1)\r
+\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL  Header;\r
+  EFI_GUID                  Guid;\r
+  UINT8                     VendorDefinedData[1];\r
+} VENDOR_DEFINED_HARDWARE_DEVICE_PATH;\r
+\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL  Header;\r
+  EFI_GUID                  Guid;\r
+  UINT8                     VendorDefinedData[1];\r
+} VENDOR_DEFINED_MESSAGING_DEVICE_PATH;\r
+\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL  Header;\r
+  EFI_GUID                  Guid;\r
+  UINT8                     VendorDefinedData[1];\r
+} VENDOR_DEFINED_MEDIA_DEVICE_PATH;\r
+\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL  Header;\r
+  UINT32                    Hid;\r
+  UINT32                    Uid;\r
+  UINT32                    Cid;\r
+  CHAR8                     HidUidCidStr[3];\r
+} ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR;\r
+\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL  Header;\r
+  UINT16                    NetworkProtocol;\r
+  UINT16                    LoginOption;\r
+  UINT64                    Lun;\r
+  UINT16                    TargetPortalGroupTag;\r
+  CHAR8                     TargetName[1];\r
+} ISCSI_DEVICE_PATH_WITH_NAME;\r
+\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL  Header;\r
+  EFI_GUID                  Guid;\r
+  UINT8                     VendorDefinedData[1];\r
+} VENDOR_DEVICE_PATH_WITH_DATA;\r
+\r
+#pragma pack()\r
+\r
+/**\r
+  Returns the size of a device path in bytes.\r
+\r
+  This function returns the size, in bytes, of the device path data structure \r
+  specified by DevicePath including the end of device path node.\r
+  If DevicePath is NULL or invalid, then 0 is returned.\r
+\r
+  @param  DevicePath  A pointer to a device path data structure.\r
+\r
+  @retval 0           If DevicePath is NULL or invalid.\r
+  @retval Others      The size of a device path in bytes.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+UefiDevicePathLibGetDevicePathSize (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+  );\r
+\r
+/**\r
+  Creates a new copy of an existing device path.\r
+\r
+  This function allocates space for a new copy of the device path specified by DevicePath.  \r
+  If DevicePath is NULL, then NULL is returned.  If the memory is successfully \r
+  allocated, then the contents of DevicePath are copied to the newly allocated \r
+  buffer, and a pointer to that buffer is returned.  Otherwise, NULL is returned.  \r
+  The memory for the new device path is allocated from EFI boot services memory. \r
+  It is the responsibility of the caller to free the memory allocated. \r
+  \r
+  @param  DevicePath    A pointer to a device path data structure.\r
+\r
+  @retval NULL          DevicePath is NULL or invalid.\r
+  @retval Others        A pointer to the duplicated device path.\r
+  \r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+UefiDevicePathLibDuplicateDevicePath (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+  );\r
+\r
+/**\r
+  Creates a new device path by appending a second device path to a first device path.\r
+\r
+  This function creates a new device path by appending a copy of SecondDevicePath \r
+  to a copy of FirstDevicePath in a newly allocated buffer.  Only the end-of-device-path \r
+  device node from SecondDevicePath is retained. The newly created device path is \r
+  returned. If FirstDevicePath is NULL, then it is ignored, and a duplicate of \r
+  SecondDevicePath is returned.  If SecondDevicePath is NULL, then it is ignored, \r
+  and a duplicate of FirstDevicePath is returned. If both FirstDevicePath and \r
+  SecondDevicePath are NULL, then a copy of an end-of-device-path is returned.  \r
+  \r
+  If there is not enough memory for the newly allocated buffer, then NULL is returned.\r
+  The memory for the new device path is allocated from EFI boot services memory. \r
+  It is the responsibility of the caller to free the memory allocated.\r
+\r
+  @param  FirstDevicePath            A pointer to a device path data structure.\r
+  @param  SecondDevicePath           A pointer to a device path data structure.\r
+  \r
+  @retval NULL      If there is not enough memory for the newly allocated buffer.\r
+  @retval NULL      If FirstDevicePath or SecondDevicePath is invalid.\r
+  @retval Others    A pointer to the new device path if success.\r
+                    Or a copy an end-of-device-path if both FirstDevicePath and SecondDevicePath are NULL.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+UefiDevicePathLibAppendDevicePath (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *FirstDevicePath,  OPTIONAL\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *SecondDevicePath  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Creates a new path by appending the device node to the device path.\r
+\r
+  This function creates a new device path by appending a copy of the device node \r
+  specified by DevicePathNode to a copy of the device path specified by DevicePath \r
+  in an allocated buffer. The end-of-device-path device node is moved after the \r
+  end of the appended device node.\r
+  If DevicePathNode is NULL then a copy of DevicePath is returned.\r
+  If DevicePath is NULL then a copy of DevicePathNode, followed by an end-of-device \r
+  path device node is returned.\r
+  If both DevicePathNode and DevicePath are NULL then a copy of an end-of-device-path \r
+  device node is returned.\r
+  If there is not enough memory to allocate space for the new device path, then \r
+  NULL is returned.  \r
+  The memory is allocated from EFI boot services memory. It is the responsibility \r
+  of the caller to free the memory allocated.\r
+\r
+  @param  DevicePath                 A pointer to a device path data structure.\r
+  @param  DevicePathNode             A pointer to a single device path node.\r
+\r
+  @retval NULL      If there is not enough memory for the new device path.\r
+  @retval Others    A pointer to the new device path if success.\r
+                    A copy of DevicePathNode followed by an end-of-device-path node \r
+                    if both FirstDevicePath and SecondDevicePath are NULL.\r
+                    A copy of an end-of-device-path node if both FirstDevicePath \r
+                    and SecondDevicePath are NULL.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+UefiDevicePathLibAppendDevicePathNode (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath,     OPTIONAL\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePathNode  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Creates a new device path by appending the specified device path instance to the specified device\r
+  path.\r
\r
+  This function creates a new device path by appending a copy of the device path \r
+  instance specified by DevicePathInstance to a copy of the device path specified \r
+  by DevicePath in a allocated buffer.\r
+  The end-of-device-path device node is moved after the end of the appended device \r
+  path instance and a new end-of-device-path-instance node is inserted between. \r
+  If DevicePath is NULL, then a copy if DevicePathInstance is returned.\r
+  If DevicePathInstance is NULL, then NULL is returned.\r
+  If DevicePath or DevicePathInstance is invalid, then NULL is returned.\r
+  If there is not enough memory to allocate space for the new device path, then \r
+  NULL is returned.  \r
+  The memory is allocated from EFI boot services memory. It is the responsibility \r
+  of the caller to free the memory allocated.\r
+  \r
+  @param  DevicePath                 A pointer to a device path data structure.\r
+  @param  DevicePathInstance         A pointer to a device path instance.\r
+\r
+  @return A pointer to the new device path.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+UefiDevicePathLibAppendDevicePathInstance (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath,        OPTIONAL\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePathInstance OPTIONAL\r
+  );\r
+\r
+/**\r
+  Creates a copy of the current device path instance and returns a pointer to the next device path\r
+  instance.\r
+\r
+  This function creates a copy of the current device path instance. It also updates \r
+  DevicePath to point to the next device path instance in the device path (or NULL \r
+  if no more) and updates Size to hold the size of the device path instance copy.\r
+  If DevicePath is NULL, then NULL is returned.\r
+  If DevicePath points to a invalid device path, then NULL is returned.\r
+  If there is not enough memory to allocate space for the new device path, then \r
+  NULL is returned.  \r
+  The memory is allocated from EFI boot services memory. It is the responsibility \r
+  of the caller to free the memory allocated.\r
+  If Size is NULL, then ASSERT().\r
\r
+  @param  DevicePath                 On input, this holds the pointer to the current \r
+                                     device path instance. On output, this holds \r
+                                     the pointer to the next device path instance \r
+                                     or NULL if there are no more device path\r
+                                     instances in the device path pointer to a \r
+                                     device path data structure.\r
+  @param  Size                       On output, this holds the size of the device \r
+                                     path instance, in bytes or zero, if DevicePath \r
+                                     is NULL.\r
+\r
+  @return A pointer to the current device path instance.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+UefiDevicePathLibGetNextDevicePathInstance (\r
+  IN OUT EFI_DEVICE_PATH_PROTOCOL    **DevicePath,\r
+  OUT UINTN                          *Size\r
+  );\r
+\r
+/**\r
+  Creates a device node.\r
+\r
+  This function creates a new device node in a newly allocated buffer of size \r
+  NodeLength and initializes the device path node header with NodeType and NodeSubType.  \r
+  The new device path node is returned.\r
+  If NodeLength is smaller than a device path header, then NULL is returned.  \r
+  If there is not enough memory to allocate space for the new device path, then \r
+  NULL is returned.  \r
+  The memory is allocated from EFI boot services memory. It is the responsibility \r
+  of the caller to free the memory allocated.\r
+\r
+  @param  NodeType                   The device node type for the new device node.\r
+  @param  NodeSubType                The device node sub-type for the new device node.\r
+  @param  NodeLength                 The length of the new device node.\r
+\r
+  @return The new device path.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+UefiDevicePathLibCreateDeviceNode (\r
+  IN UINT8                           NodeType,\r
+  IN UINT8                           NodeSubType,\r
+  IN UINT16                          NodeLength\r
+  );\r
+\r
+/**\r
+  Determines if a device path is single or multi-instance.\r
+\r
+  This function returns TRUE if the device path specified by DevicePath is\r
+  multi-instance.\r
+  Otherwise, FALSE is returned.\r
+  If DevicePath is NULL or invalid, then FALSE is returned.\r
+\r
+  @param  DevicePath                 A pointer to a device path data structure.\r
+\r
+  @retval  TRUE                      DevicePath is multi-instance.\r
+  @retval  FALSE                     DevicePath is not multi-instance, or DevicePath \r
+                                     is NULL or invalid.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+UefiDevicePathLibIsDevicePathMultiInstance (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+  );\r
+\r
+\r
+/**\r
+  Converts a device path to its text representation.\r
+\r
+  @param DevicePath      A Pointer to the device to be converted.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+  @return A pointer to the allocated text representation of the device path or\r
+          NULL if DeviceNode is NULL or there was insufficient memory.\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+UefiDevicePathLibConvertDevicePathToText (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL   *DevicePath,\r
+  IN BOOLEAN                          DisplayOnly,\r
+  IN BOOLEAN                          AllowShortcuts\r
+  );\r
+\r
+/**\r
+  Converts a device node to its string representation.\r
+\r
+  @param DeviceNode        A Pointer to the device node to be converted.\r
+  @param DisplayOnly       If DisplayOnly is TRUE, then the shorter text representation\r
+                           of the display node is used, where applicable. If DisplayOnly\r
+                           is FALSE, then the longer text representation of the display node\r
+                           is used.\r
+  @param AllowShortcuts    If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                           representation for a device node can be used, where applicable.\r
+\r
+  @return A pointer to the allocated text representation of the device node or NULL if DeviceNode\r
+          is NULL or there was insufficient memory.\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+UefiDevicePathLibConvertDeviceNodeToText (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DeviceNode,\r
+  IN BOOLEAN                         DisplayOnly,\r
+  IN BOOLEAN                         AllowShortcuts\r
+  );\r
+\r
+/**\r
+  Convert text to the binary representation of a device node.\r
+\r
+  @param TextDeviceNode  TextDeviceNode points to the text representation of a device\r
+                         node. Conversion starts with the first character and continues\r
+                         until the first non-device node character.\r
+\r
+  @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was\r
+          insufficient memory or text unsupported.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+UefiDevicePathLibConvertTextToDeviceNode (\r
+  IN CONST CHAR16 *TextDeviceNode\r
+  );\r
+\r
+/**\r
+  Convert text to the binary representation of a device path.\r
+\r
+\r
+  @param TextDevicePath  TextDevicePath points to the text representation of a device\r
+                         path. Conversion starts with the first character and continues\r
+                         until the first non-device node character.\r
+\r
+  @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or\r
+          there was insufficient memory.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+UefiDevicePathLibConvertTextToDevicePath (\r
+  IN CONST CHAR16 *TextDevicePath\r
+  );\r
+\r
+#endif\r
index 2ae151d8b4553fce1d1a2473bfb737f5e5ef6934..fc9b5c019d3a7b07131fca9a1cf6d10fb9134a5a 100644 (file)
@@ -3,7 +3,7 @@
 #\r
 # Device Path Library that layers on top of the Memory Allocation Library.\r
 #\r
-# Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
 #\r
 \r
 [Sources]\r
+  DevicePathUtilities.c\r
+  DevicePathToText.c\r
+  DevicePathFromText.c\r
   UefiDevicePathLib.c\r
-\r
+  UefiDevicePathLib.h\r
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
 \r
 [LibraryClasses]\r
   BaseLib\r
-  UefiBootServicesTableLib\r
   MemoryAllocationLib\r
   DebugLib\r
   BaseMemoryLib\r
   PcdLib\r
+  PrintLib\r
+\r
+[Guids]\r
+  gEfiVTUTF8Guid\r
+  gEfiVT100Guid\r
+  gEfiVT100PlusGuid\r
+  gEfiPcAnsiGuid\r
+  gEfiUartDevicePathGuid\r
+  gEfiSasDevicePathGuid\r
 \r
 [Protocols]\r
   gEfiDevicePathProtocolGuid                    ## CONSUMES\r
+  gEfiDebugPortProtocolGuid                     ## SOMETIMES_CONSUMES ## GUID\r
 \r
 [Pcd]\r
   gEfiMdePkgTokenSpaceGuid.PcdMaximumDevicePathNodeCount\r
diff --git a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibOptionalDevicePathProtocol.c b/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibOptionalDevicePathProtocol.c
new file mode 100644 (file)
index 0000000..9580e39
--- /dev/null
@@ -0,0 +1,484 @@
+/** @file\r
+  Device Path services. The thing to remember is device paths are built out of\r
+  nodes. The device path is terminated by an end node that is length\r
+  sizeof(EFI_DEVICE_PATH_PROTOCOL). That would be why there is sizeof(EFI_DEVICE_PATH_PROTOCOL)\r
+  all over this file.\r
+\r
+  The only place where multi-instance device paths are supported is in\r
+  environment varibles. Multi-instance device paths should never be placed\r
+  on a Handle.\r
+\r
+  Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials                          \r
+  are licensed and made available under the terms and conditions of the BSD License         \r
+  which accompanies this distribution.  The full text of the license may be found at        \r
+  http://opensource.org/licenses/bsd-license.php.                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+\r
+#include "UefiDevicePathLib.h"\r
+\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_DEVICE_PATH_UTILITIES_PROTOCOL *mDevicePathLibDevicePathUtilities = NULL;\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_DEVICE_PATH_TO_TEXT_PROTOCOL   *mDevicePathLibDevicePathToText    = NULL;\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *mDevicePathLibDevicePathFromText  = NULL;\r
+\r
+/**\r
+  The constructor function caches the pointer to DevicePathUtilites protocol,\r
+  DevicePathToText protocol and DevicePathFromText protocol.\r
+  \r
+  The constructor function locates these three protocols from protocol database.\r
+  It will caches the pointer to local protocol instance if that operation fails\r
+  and it will always return EFI_SUCCESS. \r
+\r
+  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
+  @param  SystemTable   A pointer to the EFI System Table.\r
+  \r
+  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UefiDevicePathLibOptionalDevicePathProtocolConstructor (\r
+  IN      EFI_HANDLE                ImageHandle,\r
+  IN      EFI_SYSTEM_TABLE          *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS                        Status;\r
+\r
+  Status = gBS->LocateProtocol (\r
+                  &gEfiDevicePathUtilitiesProtocolGuid,\r
+                  NULL,\r
+                  (VOID**) &mDevicePathLibDevicePathUtilities\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+  ASSERT (mDevicePathLibDevicePathUtilities != NULL);\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Returns the size of a device path in bytes.\r
+\r
+  This function returns the size, in bytes, of the device path data structure \r
+  specified by DevicePath including the end of device path node.\r
+  If DevicePath is NULL or invalid, then 0 is returned.\r
+\r
+  @param  DevicePath  A pointer to a device path data structure.\r
+\r
+  @retval 0           If DevicePath is NULL or invalid.\r
+  @retval Others      The size of a device path in bytes.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+GetDevicePathSize (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+  )\r
+{\r
+  if (mDevicePathLibDevicePathUtilities != NULL) {\r
+    return mDevicePathLibDevicePathUtilities->GetDevicePathSize (DevicePath);\r
+  } else {\r
+    return UefiDevicePathLibGetDevicePathSize (DevicePath);\r
+  }\r
+}\r
+\r
+/**\r
+  Creates a new copy of an existing device path.\r
+\r
+  This function allocates space for a new copy of the device path specified by DevicePath.  \r
+  If DevicePath is NULL, then NULL is returned.  If the memory is successfully \r
+  allocated, then the contents of DevicePath are copied to the newly allocated \r
+  buffer, and a pointer to that buffer is returned.  Otherwise, NULL is returned.  \r
+  The memory for the new device path is allocated from EFI boot services memory. \r
+  It is the responsibility of the caller to free the memory allocated. \r
+  \r
+  @param  DevicePath    A pointer to a device path data structure.\r
+\r
+  @retval NULL          DevicePath is NULL or invalid.\r
+  @retval Others        A pointer to the duplicated device path.\r
+  \r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+DuplicateDevicePath (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+  )\r
+{\r
+  if (mDevicePathLibDevicePathUtilities != NULL) {\r
+    return mDevicePathLibDevicePathUtilities->DuplicateDevicePath (DevicePath);\r
+  } else {\r
+    return UefiDevicePathLibDuplicateDevicePath (DevicePath);\r
+  }\r
+}\r
+\r
+/**\r
+  Creates a new device path by appending a second device path to a first device path.\r
+\r
+  This function creates a new device path by appending a copy of SecondDevicePath \r
+  to a copy of FirstDevicePath in a newly allocated buffer.  Only the end-of-device-path \r
+  device node from SecondDevicePath is retained. The newly created device path is \r
+  returned. If FirstDevicePath is NULL, then it is ignored, and a duplicate of \r
+  SecondDevicePath is returned.  If SecondDevicePath is NULL, then it is ignored, \r
+  and a duplicate of FirstDevicePath is returned. If both FirstDevicePath and \r
+  SecondDevicePath are NULL, then a copy of an end-of-device-path is returned.  \r
+  \r
+  If there is not enough memory for the newly allocated buffer, then NULL is returned.\r
+  The memory for the new device path is allocated from EFI boot services memory. \r
+  It is the responsibility of the caller to free the memory allocated.\r
+\r
+  @param  FirstDevicePath            A pointer to a device path data structure.\r
+  @param  SecondDevicePath           A pointer to a device path data structure.\r
+  \r
+  @retval NULL      If there is not enough memory for the newly allocated buffer.\r
+  @retval NULL      If FirstDevicePath or SecondDevicePath is invalid.\r
+  @retval Others    A pointer to the new device path if success.\r
+                    Or a copy an end-of-device-path if both FirstDevicePath and SecondDevicePath are NULL.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+AppendDevicePath (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *FirstDevicePath,  OPTIONAL\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *SecondDevicePath  OPTIONAL\r
+  )\r
+{\r
+  if (mDevicePathLibDevicePathUtilities != NULL) {\r
+    return mDevicePathLibDevicePathUtilities->AppendDevicePath (FirstDevicePath, SecondDevicePath);\r
+  } else {\r
+    return UefiDevicePathLibAppendDevicePath (FirstDevicePath, SecondDevicePath);\r
+  }\r
+}\r
+\r
+/**\r
+  Creates a new path by appending the device node to the device path.\r
+\r
+  This function creates a new device path by appending a copy of the device node \r
+  specified by DevicePathNode to a copy of the device path specified by DevicePath \r
+  in an allocated buffer. The end-of-device-path device node is moved after the \r
+  end of the appended device node.\r
+  If DevicePathNode is NULL then a copy of DevicePath is returned.\r
+  If DevicePath is NULL then a copy of DevicePathNode, followed by an end-of-device \r
+  path device node is returned.\r
+  If both DevicePathNode and DevicePath are NULL then a copy of an end-of-device-path \r
+  device node is returned.\r
+  If there is not enough memory to allocate space for the new device path, then \r
+  NULL is returned.  \r
+  The memory is allocated from EFI boot services memory. It is the responsibility \r
+  of the caller to free the memory allocated.\r
+\r
+  @param  DevicePath                 A pointer to a device path data structure.\r
+  @param  DevicePathNode             A pointer to a single device path node.\r
+\r
+  @retval NULL      If there is not enough memory for the new device path.\r
+  @retval Others    A pointer to the new device path if success.\r
+                    A copy of DevicePathNode followed by an end-of-device-path node \r
+                    if both FirstDevicePath and SecondDevicePath are NULL.\r
+                    A copy of an end-of-device-path node if both FirstDevicePath \r
+                    and SecondDevicePath are NULL.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+AppendDevicePathNode (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath,     OPTIONAL\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePathNode  OPTIONAL\r
+  )\r
+{\r
+  if (mDevicePathLibDevicePathUtilities != NULL) {\r
+    return mDevicePathLibDevicePathUtilities->AppendDeviceNode (DevicePath, DevicePathNode);\r
+  } else {\r
+    return UefiDevicePathLibAppendDevicePathNode (DevicePath, DevicePathNode);\r
+  }\r
+}\r
+\r
+/**\r
+  Creates a new device path by appending the specified device path instance to the specified device\r
+  path.\r
\r
+  This function creates a new device path by appending a copy of the device path \r
+  instance specified by DevicePathInstance to a copy of the device path specified \r
+  by DevicePath in a allocated buffer.\r
+  The end-of-device-path device node is moved after the end of the appended device \r
+  path instance and a new end-of-device-path-instance node is inserted between. \r
+  If DevicePath is NULL, then a copy if DevicePathInstance is returned.\r
+  If DevicePathInstance is NULL, then NULL is returned.\r
+  If DevicePath or DevicePathInstance is invalid, then NULL is returned.\r
+  If there is not enough memory to allocate space for the new device path, then \r
+  NULL is returned.  \r
+  The memory is allocated from EFI boot services memory. It is the responsibility \r
+  of the caller to free the memory allocated.\r
+  \r
+  @param  DevicePath                 A pointer to a device path data structure.\r
+  @param  DevicePathInstance         A pointer to a device path instance.\r
+\r
+  @return A pointer to the new device path.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+AppendDevicePathInstance (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath,        OPTIONAL\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePathInstance OPTIONAL\r
+  )\r
+{\r
+  if (mDevicePathLibDevicePathUtilities != NULL) {\r
+    return mDevicePathLibDevicePathUtilities->AppendDevicePathInstance (DevicePath, DevicePathInstance);\r
+  } else {\r
+    return UefiDevicePathLibAppendDevicePathInstance (DevicePath, DevicePathInstance);\r
+  }\r
+}\r
+\r
+/**\r
+  Creates a copy of the current device path instance and returns a pointer to the next device path\r
+  instance.\r
+\r
+  This function creates a copy of the current device path instance. It also updates \r
+  DevicePath to point to the next device path instance in the device path (or NULL \r
+  if no more) and updates Size to hold the size of the device path instance copy.\r
+  If DevicePath is NULL, then NULL is returned.\r
+  If DevicePath points to a invalid device path, then NULL is returned.\r
+  If there is not enough memory to allocate space for the new device path, then \r
+  NULL is returned.  \r
+  The memory is allocated from EFI boot services memory. It is the responsibility \r
+  of the caller to free the memory allocated.\r
+  If Size is NULL, then ASSERT().\r
\r
+  @param  DevicePath                 On input, this holds the pointer to the current \r
+                                     device path instance. On output, this holds \r
+                                     the pointer to the next device path instance \r
+                                     or NULL if there are no more device path\r
+                                     instances in the device path pointer to a \r
+                                     device path data structure.\r
+  @param  Size                       On output, this holds the size of the device \r
+                                     path instance, in bytes or zero, if DevicePath \r
+                                     is NULL.\r
+\r
+  @return A pointer to the current device path instance.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+GetNextDevicePathInstance (\r
+  IN OUT EFI_DEVICE_PATH_PROTOCOL    **DevicePath,\r
+  OUT UINTN                          *Size\r
+  )\r
+{\r
+  if (mDevicePathLibDevicePathUtilities != NULL) {\r
+    return mDevicePathLibDevicePathUtilities->GetNextDevicePathInstance (DevicePath, Size);\r
+  } else {\r
+    return UefiDevicePathLibGetNextDevicePathInstance (DevicePath, Size);\r
+  }\r
+}\r
+\r
+/**\r
+  Creates a device node.\r
+\r
+  This function creates a new device node in a newly allocated buffer of size \r
+  NodeLength and initializes the device path node header with NodeType and NodeSubType.  \r
+  The new device path node is returned.\r
+  If NodeLength is smaller than a device path header, then NULL is returned.  \r
+  If there is not enough memory to allocate space for the new device path, then \r
+  NULL is returned.  \r
+  The memory is allocated from EFI boot services memory. It is the responsibility \r
+  of the caller to free the memory allocated.\r
+\r
+  @param  NodeType                   The device node type for the new device node.\r
+  @param  NodeSubType                The device node sub-type for the new device node.\r
+  @param  NodeLength                 The length of the new device node.\r
+\r
+  @return The new device path.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+CreateDeviceNode (\r
+  IN UINT8                           NodeType,\r
+  IN UINT8                           NodeSubType,\r
+  IN UINT16                          NodeLength\r
+  )\r
+{\r
+  if (mDevicePathLibDevicePathUtilities != NULL) {\r
+    return mDevicePathLibDevicePathUtilities->CreateDeviceNode (NodeType, NodeSubType, NodeLength);\r
+  } else {\r
+    return UefiDevicePathLibCreateDeviceNode (NodeType, NodeSubType, NodeLength);\r
+  }\r
+}\r
+\r
+/**\r
+  Determines if a device path is single or multi-instance.\r
+\r
+  This function returns TRUE if the device path specified by DevicePath is\r
+  multi-instance.\r
+  Otherwise, FALSE is returned.\r
+  If DevicePath is NULL or invalid, then FALSE is returned.\r
+\r
+  @param  DevicePath                 A pointer to a device path data structure.\r
+\r
+  @retval  TRUE                      DevicePath is multi-instance.\r
+  @retval  FALSE                     DevicePath is not multi-instance, or DevicePath \r
+                                     is NULL or invalid.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+IsDevicePathMultiInstance (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+  )\r
+{\r
+  if (mDevicePathLibDevicePathUtilities != NULL) {\r
+    return mDevicePathLibDevicePathUtilities->IsDevicePathMultiInstance (DevicePath);\r
+  } else {\r
+    return UefiDevicePathLibIsDevicePathMultiInstance (DevicePath);\r
+  }\r
+}\r
+\r
+/**\r
+  Locate and return the protocol instance identified by the ProtocolGuid.\r
+\r
+  @param ProtocolGuid     The GUID of the protocol.\r
+\r
+  @return A pointer to the protocol instance or NULL when absent.\r
+**/\r
+VOID *\r
+UefiDevicePathLibLocateProtocol (\r
+  EFI_GUID                         *ProtocolGuid\r
+  )\r
+{\r
+  EFI_STATUS Status;\r
+  VOID       *Protocol;\r
+  Status = gBS->LocateProtocol (\r
+                  ProtocolGuid,\r
+                  NULL,\r
+                  (VOID**) &Protocol\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return NULL;\r
+  } else {\r
+    return Protocol;\r
+  }\r
+}\r
+\r
+/**\r
+  Converts a device node to its string representation.\r
+\r
+  @param DeviceNode        A Pointer to the device node to be converted.\r
+  @param DisplayOnly       If DisplayOnly is TRUE, then the shorter text representation\r
+                           of the display node is used, where applicable. If DisplayOnly\r
+                           is FALSE, then the longer text representation of the display node\r
+                           is used.\r
+  @param AllowShortcuts    If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                           representation for a device node can be used, where applicable.\r
+\r
+  @return A pointer to the allocated text representation of the device node or NULL if DeviceNode\r
+          is NULL or there was insufficient memory.\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+ConvertDeviceNodeToText (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DeviceNode,\r
+  IN BOOLEAN                         DisplayOnly,\r
+  IN BOOLEAN                         AllowShortcuts\r
+  )\r
+{\r
+  if (mDevicePathLibDevicePathToText == NULL) {\r
+    mDevicePathLibDevicePathToText = UefiDevicePathLibLocateProtocol (&gEfiDevicePathToTextProtocolGuid);\r
+  }\r
+  if (mDevicePathLibDevicePathToText != NULL) {\r
+    return mDevicePathLibDevicePathToText->ConvertDeviceNodeToText (DeviceNode, DisplayOnly, AllowShortcuts);\r
+  }\r
+\r
+  return UefiDevicePathLibConvertDeviceNodeToText (DeviceNode, DisplayOnly, AllowShortcuts);\r
+}\r
+\r
+/**\r
+  Converts a device path to its text representation.\r
+\r
+  @param DevicePath      A Pointer to the device to be converted.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+  @return A pointer to the allocated text representation of the device path or\r
+          NULL if DeviceNode is NULL or there was insufficient memory.\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+ConvertDevicePathToText (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL   *DevicePath,\r
+  IN BOOLEAN                          DisplayOnly,\r
+  IN BOOLEAN                          AllowShortcuts\r
+  )\r
+{\r
+  if (mDevicePathLibDevicePathToText == NULL) {\r
+    mDevicePathLibDevicePathToText = UefiDevicePathLibLocateProtocol (&gEfiDevicePathToTextProtocolGuid);\r
+  }\r
+  if (mDevicePathLibDevicePathToText != NULL) {\r
+    return mDevicePathLibDevicePathToText->ConvertDevicePathToText (DevicePath, DisplayOnly, AllowShortcuts);\r
+  }\r
+\r
+  return UefiDevicePathLibConvertDevicePathToText (DevicePath, DisplayOnly, AllowShortcuts);\r
+}\r
+\r
+/**\r
+  Convert text to the binary representation of a device node.\r
+\r
+  @param TextDeviceNode  TextDeviceNode points to the text representation of a device\r
+                         node. Conversion starts with the first character and continues\r
+                         until the first non-device node character.\r
+\r
+  @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was\r
+          insufficient memory or text unsupported.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+ConvertTextToDeviceNode (\r
+  IN CONST CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  if (mDevicePathLibDevicePathFromText == NULL) {\r
+    mDevicePathLibDevicePathFromText = UefiDevicePathLibLocateProtocol (&gEfiDevicePathFromTextProtocolGuid);\r
+  }\r
+  if (mDevicePathLibDevicePathFromText != NULL) {\r
+    return mDevicePathLibDevicePathFromText->ConvertTextToDeviceNode (TextDeviceNode);\r
+  }\r
+\r
+  return UefiDevicePathLibConvertTextToDeviceNode (TextDeviceNode);\r
+}\r
+\r
+/**\r
+  Convert text to the binary representation of a device path.\r
+\r
+\r
+  @param TextDevicePath  TextDevicePath points to the text representation of a device\r
+                         path. Conversion starts with the first character and continues\r
+                         until the first non-device node character.\r
+\r
+  @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or\r
+          there was insufficient memory.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+ConvertTextToDevicePath (\r
+  IN CONST CHAR16 *TextDevicePath\r
+  )\r
+{\r
+  if (mDevicePathLibDevicePathFromText == NULL) {\r
+    mDevicePathLibDevicePathFromText = UefiDevicePathLibLocateProtocol (&gEfiDevicePathFromTextProtocolGuid);\r
+  }\r
+  if (mDevicePathLibDevicePathFromText != NULL) {\r
+    return mDevicePathLibDevicePathFromText->ConvertTextToDevicePath (TextDevicePath);\r
+  }\r
+\r
+  return UefiDevicePathLibConvertTextToDevicePath (TextDevicePath);\r
+}\r
+\r
diff --git a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibOptionalDevicePathProtocol.inf b/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibOptionalDevicePathProtocol.inf
new file mode 100644 (file)
index 0000000..34bc120
--- /dev/null
@@ -0,0 +1,73 @@
+## @file\r
+# Instance of Device Path Library based on Device Path Protocol.\r
+#\r
+#  Device Path Library that layers on top of the UEFI 2.0 Device Path Protocol.\r
+#  If the DevicePathFromText/DevicePathToText protocol doesn't exist, the library\r
+#  uses its internal conversion logic.\r
+#\r
+# Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>\r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php.\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = UefiDevicePathLibOptionalDevicePathProtocol\r
+  FILE_GUID                      = 3E1C696D-FCF0-45a7-85A7-E86C2A1C1080\r
+  MODULE_TYPE                    = UEFI_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = DevicePathLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE\r
+\r
+  CONSTRUCTOR                    = UefiDevicePathLibOptionalDevicePathProtocolConstructor\r
+\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  DevicePathUtilities.c\r
+  DevicePathToText.c\r
+  DevicePathFromText.c\r
+  UefiDevicePathLibOptionalDevicePathProtocol.c\r
+  UefiDevicePathLib.h\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+\r
+\r
+[LibraryClasses]\r
+  BaseLib\r
+  UefiBootServicesTableLib\r
+  MemoryAllocationLib\r
+  DebugLib\r
+  BaseMemoryLib\r
+  PcdLib\r
+  PrintLib\r
+\r
+[Guids]\r
+  gEfiVTUTF8Guid\r
+  gEfiVT100Guid\r
+  gEfiVT100PlusGuid\r
+  gEfiPcAnsiGuid\r
+  gEfiUartDevicePathGuid\r
+  gEfiSasDevicePathGuid\r
+\r
+[Protocols]\r
+  gEfiDevicePathProtocolGuid                    ## CONSUMES\r
+  gEfiDevicePathUtilitiesProtocolGuid           ## CONSUMES\r
+  gEfiDevicePathToTextProtocolGuid              ## CONSUMES\r
+  gEfiDevicePathFromTextProtocolGuid            ## CONSUMES\r
+  gEfiDebugPortProtocolGuid                     ## SOMETIMES_CONSUMES ## GUID\r
+\r
+[Pcd]\r
+  gEfiMdePkgTokenSpaceGuid.PcdMaximumDevicePathNodeCount\r
+\r
+[Depex.common.DXE_DRIVER, Depex.common.DXE_RUNTIME_DRIVER, Depex.common.DXE_SAL_DRIVER, Depex.common.DXE_SMM_DRIVER]\r
+  gEfiDevicePathUtilitiesProtocolGuid
\ No newline at end of file
index 1052988e7318a097f4caf8b7575df38558a29184..b73bcce07c14a5f50075cb9f1ad337716293932a 100644 (file)
@@ -2,7 +2,7 @@
   Library instance that implement UEFI Device Path Library class based on protocol\r
   gEfiDevicePathUtilitiesProtocolGuid.\r
 \r
-  Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -17,6 +17,8 @@
 #include <Uefi.h>\r
 \r
 #include <Protocol/DevicePathUtilities.h>\r
+#include <Protocol/DevicePathToText.h>\r
+#include <Protocol/DevicePathFromText.h>\r
 \r
 #include <Library/DevicePathLib.h>\r
 #include <Library/DebugLib.h>\r
@@ -26,7 +28,9 @@
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/PcdLib.h>\r
 \r
-EFI_DEVICE_PATH_UTILITIES_PROTOCOL          *mDevicePathUtilities = NULL;\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_DEVICE_PATH_UTILITIES_PROTOCOL *mDevicePathLibDevicePathUtilities = NULL;\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_DEVICE_PATH_TO_TEXT_PROTOCOL   *mDevicePathLibDevicePathToText    = NULL;\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *mDevicePathLibDevicePathFromText  = NULL;\r
 \r
 //\r
 // Template for an end-of-device path node.\r
@@ -64,11 +68,10 @@ DevicePathLibConstructor (
   Status = gBS->LocateProtocol (\r
                   &gEfiDevicePathUtilitiesProtocolGuid,\r
                   NULL,\r
-                  (VOID**) &mDevicePathUtilities\r
+                  (VOID**) &mDevicePathLibDevicePathUtilities\r
                   );\r
   ASSERT_EFI_ERROR (Status);\r
-  ASSERT (mDevicePathUtilities != NULL);\r
-\r
+  ASSERT (mDevicePathLibDevicePathUtilities != NULL);\r
   return Status;\r
 }\r
 \r
@@ -382,7 +385,7 @@ GetDevicePathSize (
   IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
   )\r
 {\r
-  return mDevicePathUtilities->GetDevicePathSize (DevicePath);\r
+  return mDevicePathLibDevicePathUtilities->GetDevicePathSize (DevicePath);\r
 }\r
 \r
 /**\r
@@ -408,7 +411,7 @@ DuplicateDevicePath (
   IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
   )\r
 {\r
-  return mDevicePathUtilities->DuplicateDevicePath (DevicePath);\r
+  return mDevicePathLibDevicePathUtilities->DuplicateDevicePath (DevicePath);\r
 }\r
 \r
 /**\r
@@ -442,7 +445,7 @@ AppendDevicePath (
   IN CONST EFI_DEVICE_PATH_PROTOCOL  *SecondDevicePath  OPTIONAL\r
   )\r
 {\r
-  return mDevicePathUtilities->AppendDevicePath (FirstDevicePath, SecondDevicePath);\r
+  return mDevicePathLibDevicePathUtilities->AppendDevicePath (FirstDevicePath, SecondDevicePath);\r
 }\r
 \r
 /**\r
@@ -480,7 +483,7 @@ AppendDevicePathNode (
   IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePathNode  OPTIONAL\r
   )\r
 {\r
-  return mDevicePathUtilities->AppendDeviceNode (DevicePath, DevicePathNode);\r
+  return mDevicePathLibDevicePathUtilities->AppendDeviceNode (DevicePath, DevicePathNode);\r
 }\r
 \r
 /**\r
@@ -513,7 +516,7 @@ AppendDevicePathInstance (
   IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePathInstance OPTIONAL\r
   )\r
 {\r
-  return mDevicePathUtilities->AppendDevicePathInstance (DevicePath, DevicePathInstance);\r
+  return mDevicePathLibDevicePathUtilities->AppendDevicePathInstance (DevicePath, DevicePathInstance);\r
 }\r
 \r
 /**\r
@@ -551,7 +554,7 @@ GetNextDevicePathInstance (
   )\r
 {\r
   ASSERT (Size != NULL);\r
-  return mDevicePathUtilities->GetNextDevicePathInstance (DevicePath, Size);\r
+  return mDevicePathLibDevicePathUtilities->GetNextDevicePathInstance (DevicePath, Size);\r
 }\r
 \r
 /**\r
@@ -582,7 +585,7 @@ CreateDeviceNode (
   IN UINT16                          NodeLength\r
   )\r
 {\r
-  return mDevicePathUtilities->CreateDeviceNode (NodeType, NodeSubType, NodeLength);\r
+  return mDevicePathLibDevicePathUtilities->CreateDeviceNode (NodeType, NodeSubType, NodeLength);\r
 }\r
 \r
 /**\r
@@ -606,7 +609,7 @@ IsDevicePathMultiInstance (
   IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
   )\r
 {\r
-  return mDevicePathUtilities->IsDevicePathMultiInstance (DevicePath);\r
+  return mDevicePathLibDevicePathUtilities->IsDevicePathMultiInstance (DevicePath);\r
 }\r
 \r
 /**\r
@@ -698,3 +701,151 @@ FileDevicePath (
 \r
   return DevicePath;\r
 }\r
+\r
+/**\r
+  Locate and return the protocol instance identified by the ProtocolGuid.\r
+\r
+  @param ProtocolGuid     The GUID of the protocol.\r
+\r
+  @return A pointer to the protocol instance or NULL when absent.\r
+**/\r
+VOID *\r
+UefiDevicePathLibLocateProtocol (\r
+  EFI_GUID                         *ProtocolGuid\r
+  )\r
+{\r
+  EFI_STATUS Status;\r
+  VOID       *Protocol;\r
+  Status = gBS->LocateProtocol (\r
+                  ProtocolGuid,\r
+                  NULL,\r
+                  (VOID**) &Protocol\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return NULL;\r
+  } else {\r
+    return Protocol;\r
+  }\r
+}\r
+\r
+/**\r
+  Converts a device node to its string representation.\r
+\r
+  @param DeviceNode        A Pointer to the device node to be converted.\r
+  @param DisplayOnly       If DisplayOnly is TRUE, then the shorter text representation\r
+                           of the display node is used, where applicable. If DisplayOnly\r
+                           is FALSE, then the longer text representation of the display node\r
+                           is used.\r
+  @param AllowShortcuts    If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                           representation for a device node can be used, where applicable.\r
+\r
+  @return A pointer to the allocated text representation of the device node or NULL if DeviceNode\r
+          is NULL or there was insufficient memory.\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+ConvertDeviceNodeToText (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DeviceNode,\r
+  IN BOOLEAN                         DisplayOnly,\r
+  IN BOOLEAN                         AllowShortcuts\r
+  )\r
+{\r
+  if (mDevicePathLibDevicePathToText == NULL) {\r
+    mDevicePathLibDevicePathToText = UefiDevicePathLibLocateProtocol (&gEfiDevicePathToTextProtocolGuid);\r
+  }\r
+  if (mDevicePathLibDevicePathToText != NULL) {\r
+    return mDevicePathLibDevicePathToText->ConvertDeviceNodeToText (DeviceNode, DisplayOnly, AllowShortcuts);\r
+  } else {\r
+    return NULL;\r
+  }\r
+}\r
+\r
+/**\r
+  Converts a device path to its text representation.\r
+\r
+  @param DevicePath      A Pointer to the device to be converted.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+  @return A pointer to the allocated text representation of the device path or\r
+          NULL if DeviceNode is NULL or there was insufficient memory.\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+ConvertDevicePathToText (\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL   *DevicePath,\r
+  IN BOOLEAN                          DisplayOnly,\r
+  IN BOOLEAN                          AllowShortcuts\r
+  )\r
+{\r
+  if (mDevicePathLibDevicePathToText == NULL) {\r
+    mDevicePathLibDevicePathToText = UefiDevicePathLibLocateProtocol (&gEfiDevicePathToTextProtocolGuid);\r
+  }\r
+  if (mDevicePathLibDevicePathToText != NULL) {\r
+    return mDevicePathLibDevicePathToText->ConvertDevicePathToText (DevicePath, DisplayOnly, AllowShortcuts);\r
+  } else {\r
+    return NULL;\r
+  }\r
+}\r
+\r
+/**\r
+  Convert text to the binary representation of a device node.\r
+\r
+  @param TextDeviceNode  TextDeviceNode points to the text representation of a device\r
+                         node. Conversion starts with the first character and continues\r
+                         until the first non-device node character.\r
+\r
+  @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was\r
+          insufficient memory or text unsupported.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+ConvertTextToDeviceNode (\r
+  IN CONST CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  if (mDevicePathLibDevicePathFromText == NULL) {\r
+    mDevicePathLibDevicePathFromText = UefiDevicePathLibLocateProtocol (&gEfiDevicePathFromTextProtocolGuid);\r
+  }\r
+  if (mDevicePathLibDevicePathFromText != NULL) {\r
+    return mDevicePathLibDevicePathFromText->ConvertTextToDeviceNode (TextDeviceNode);\r
+  } else {\r
+    return NULL;\r
+  }\r
+}\r
+\r
+/**\r
+  Convert text to the binary representation of a device path.\r
+\r
+\r
+  @param TextDevicePath  TextDevicePath points to the text representation of a device\r
+                         path. Conversion starts with the first character and continues\r
+                         until the first non-device node character.\r
+\r
+  @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or\r
+          there was insufficient memory.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+ConvertTextToDevicePath (\r
+  IN CONST CHAR16 *TextDevicePath\r
+  )\r
+{\r
+  if (mDevicePathLibDevicePathFromText == NULL) {\r
+    mDevicePathLibDevicePathFromText = UefiDevicePathLibLocateProtocol (&gEfiDevicePathFromTextProtocolGuid);\r
+  }\r
+  if (mDevicePathLibDevicePathFromText != NULL) {\r
+    return mDevicePathLibDevicePathFromText->ConvertTextToDevicePath (TextDevicePath);\r
+  } else {\r
+    return NULL;\r
+  }\r
+}\r
+\r
index 16b47e38832c7fd77281d7dc6d01f5c20b18512c..48ae8d0d1feefa1d46282e02b5ff37f2ae318a4a 100644 (file)
@@ -22,7 +22,7 @@
   FILE_GUID                      = 050EB8C6-C12E-4b86-892B-40985E8B3137\r
   MODULE_TYPE                    = UEFI_DRIVER\r
   VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = DevicePathLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER \r
+  LIBRARY_CLASS                  = DevicePathLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE\r
 \r
   CONSTRUCTOR                    = DevicePathLibConstructor\r
 \r
@@ -49,6 +49,8 @@
 [Protocols]\r
   gEfiDevicePathProtocolGuid                    ## CONSUMES\r
   gEfiDevicePathUtilitiesProtocolGuid           ## CONSUMES\r
+  gEfiDevicePathToTextProtocolGuid              ## CONSUMES\r
+  gEfiDevicePathFromTextProtocolGuid            ## CONSUMES\r
 \r
 [Pcd]\r
   gEfiMdePkgTokenSpaceGuid.PcdMaximumDevicePathNodeCount\r
index 0fd6fcb187c747af7a1478bc57000254ebefd9d6..092a67de8e93cf140b2d5c2c8e41581288af45fd 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # EFI/PI MdePkg Package\r
 #\r
-# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR>\r
 # Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
 #\r
 #    This program and the accompanying materials\r
   MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf\r
   MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf\r
   MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf\r
+  MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibOptionalDevicePathProtocol.inf\r
   MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLibDevicePathProtocol.inf\r
   MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf\r
   MdePkg/Library/UefiLib/UefiLib.inf\r