]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c
Add 4 APIs to DevicePathLib: ConvertDeviceNodeToText, ConvertDevicePathToText, Conver...
[mirror_edk2.git] / MdePkg / Library / UefiDevicePathLib / UefiDevicePathLib.c
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