]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Convert macros in the DevicePathLib to functions.
authormdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 6 Feb 2009 01:46:55 +0000 (01:46 +0000)
committermdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 6 Feb 2009 01:46:55 +0000 (01:46 +0000)
Addresses coding convention issues in the DevicePathLib
Should not cause any compatibility issues with any existing modules.
Adds ASSERT() checks for NULL device path nodes passed into these functions.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7445 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Include/Library/DevicePathLib.h
MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c
MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLib.c

index 7a6624c951582bf3ccb2c0f508dca56dc6ff3008..805ab5070463452fa0dbdec85c0ff2e750f21167 100644 (file)
@@ -20,60 +20,81 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #ifndef __DEVICE_PATH_LIB_H__\r
 #define __DEVICE_PATH_LIB_H__\r
 \r
-#include <Library/BaseLib.h>\r
-\r
 #define END_DEVICE_PATH_LENGTH               (sizeof (EFI_DEVICE_PATH_PROTOCOL))\r
 \r
 /**\r
-  Macro that returns the Type field of a device path node.\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
-#define DevicePathType(Node)                 (((EFI_DEVICE_PATH_PROTOCOL *)(Node))->Type)\r
+UINT8\r
+DevicePathType (\r
+  IN CONST VOID  *Node\r
+  );\r
 \r
 /**\r
-  Macro that returns the SubType field of a device path node.\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
-#define DevicePathSubType(Node)              (((EFI_DEVICE_PATH_PROTOCOL *)(Node))->SubType)\r
+UINT8\r
+DevicePathSubType (\r
+  IN CONST VOID  *Node\r
+  );\r
 \r
 /**\r
-  Macro that returns the 16-bit Length field of a device path node.\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
-  Returns the 16-bit Length field of the device path node specified by Node.\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
-#define DevicePathNodeLength(Node)           ReadUnaligned16 ((UINT16 *)&((EFI_DEVICE_PATH_PROTOCOL *)(Node))->Length[0])\r
+UINTN\r
+DevicePathNodeLength (\r
+  IN CONST VOID  *Node\r
+  );\r
 \r
 /**\r
-  Macro that returns a pointer to the next node in a device path.\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 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 specified by Node.\r
 \r
 **/\r
-#define NextDevicePathNode(Node)             ((EFI_DEVICE_PATH_PROTOCOL *)((UINT8 *)(Node) + DevicePathNodeLength(Node)))\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+NextDevicePathNode (\r
+  IN CONST VOID  *Node\r
+  );\r
 \r
 /**\r
-  Macro that determines if a device path node is an end node of a device path.\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 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
@@ -81,46 +102,67 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   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 device path.\r
   @retval FALSE     The device path node specified by Node is not an end node of a device path.\r
   \r
 **/\r
-#define IsDevicePathEndType(Node)            ((DevicePathType (Node) & 0x7f) == END_DEVICE_PATH_TYPE)\r
+BOOLEAN\r
+IsDevicePathEndType (\r
+  IN CONST VOID  *Node\r
+  );\r
 \r
 /**\r
-  Macro that determines if a device path node is an end node of an entire device path.\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 device path.\r
   If Node represents the end of an entire device path, 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 the end of an entire device path.\r
   @retval FALSE     The device path node specified by Node is not the end of an entire device path.\r
 \r
 **/\r
-#define IsDevicePathEnd(Node)                (IsDevicePathEndType (Node) && DevicePathSubType(Node) == END_ENTIRE_DEVICE_PATH_SUBTYPE)\r
+BOOLEAN\r
+IsDevicePathEnd (\r
+  IN CONST VOID  *Node\r
+  );\r
 \r
 /**\r
-  Macro that determines if a device path node is an end node of a device path instance.\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 path instance.\r
   If Node represents the end of a device path instance, 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 the end of a device path instance.\r
   @retval FALSE     The device path node specified by Node is not the end of a device path instance.\r
 \r
 **/\r
-#define IsDevicePathEndInstance(Node)        (IsDevicePathEndType (Node) && DevicePathSubType(Node) == END_INSTANCE_DEVICE_PATH_SUBTYPE)\r
+BOOLEAN\r
+IsDevicePathEndInstance (\r
+  IN CONST VOID  *Node\r
+  );\r
 \r
 /**\r
-  Macro that sets the length, in bytes, of a device path node.\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
-  Sets the length of the device path node specified by Node to the value specified by Length. Length is returned.\r
+  If Node is NULL, then ASSERT().\r
+  If NodeLength >= 0x10000, 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
@@ -128,21 +170,32 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   @return Length\r
 \r
 **/\r
-#define SetDevicePathNodeLength(Node,NodeLength)  WriteUnaligned16 ((UINT16 *)&((EFI_DEVICE_PATH_PROTOCOL *)(Node))->Length[0], (UINT16)(NodeLength))\r
+UINT16\r
+SetDevicePathNodeLength (\r
+  IN VOID   *Node,\r
+  IN UINTN  Length\r
+  );\r
 \r
 /**\r
-  Macro that fills in all the fields of a device path node that is the end of an entire device path.\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
-  Fills in all the fields of a device path node specified by Node so Node represents the end of an entire device path.\r
+  If Node is NULL, then ASSERT(). \r
 \r
   @param  Node      A pointer to a device path node data structure.\r
 \r
 **/\r
-#define SetDevicePathEndNode(Node)  {                                   \\r
-          DevicePathType (Node)    = END_DEVICE_PATH_TYPE;              \\r
-          DevicePathSubType (Node) = END_ENTIRE_DEVICE_PATH_SUBTYPE;    \\r
-          SetDevicePathNodeLength ((Node), END_DEVICE_PATH_LENGTH);     \\r
-          }\r
+VOID\r
+SetDevicePathEndNode (\r
+  IN VOID  *Node\r
+  );\r
 \r
 /**\r
   Returns the size of a device path in bytes.\r
index 43966fc2395ce33a506f7955788e2b4b49e02a28..be49ba40422a856c501bcecb88da6f01e3fd7bbf 100644 (file)
@@ -43,6 +43,218 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_DEVICE_PATH_PROTOCOL  mUefiDevicePathLib
   }\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
+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
+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
+DevicePathNodeLength (\r
+  IN CONST VOID  *Node\r
+  )\r
+{\r
+  ASSERT (Node != NULL);\r
+  return ReadUnaligned16 ((UINT16 *)&((EFI_DEVICE_PATH_PROTOCOL *)(Node))->Length[0]);\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 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 specified by Node.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\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 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 device path.\r
+  @retval FALSE     The device path node specified by Node is not an end node of a device path.\r
+  \r
+**/\r
+BOOLEAN\r
+IsDevicePathEndType (\r
+  IN CONST VOID  *Node\r
+  )\r
+{\r
+  ASSERT (Node != NULL);\r
+  return ((DevicePathType (Node) & 0x7f) == 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 device path.\r
+  If Node represents the end of an entire device path, 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 the end of an entire device path.\r
+  @retval FALSE     The device path node specified by Node is not the end of an entire device path.\r
+\r
+**/\r
+BOOLEAN\r
+IsDevicePathEnd (\r
+  IN CONST VOID  *Node\r
+  )\r
+{\r
+  ASSERT (Node != NULL);\r
+  return (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 path instance.\r
+  If Node represents the end of a device path instance, 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 the end of a device path instance.\r
+  @retval FALSE     The device path node specified by Node is not the end of a device path instance.\r
+\r
+**/\r
+BOOLEAN\r
+IsDevicePathEndInstance (\r
+  IN CONST VOID  *Node\r
+  )\r
+{\r
+  ASSERT (Node != NULL);\r
+  return (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 >= 0x10000, 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
+SetDevicePathNodeLength (\r
+  IN VOID   *Node,\r
+  IN UINTN  NodeLength\r
+  )\r
+{\r
+  ASSERT (Node != NULL);\r
+  ASSERT (NodeLength < 0x10000);\r
+  return WriteUnaligned16 ((UINT16 *)&((EFI_DEVICE_PATH_PROTOCOL *)(Node))->Length[0], (UINT16)(NodeLength));\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
+SetDevicePathEndNode (\r
+  IN 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
index 5dba17b2aafea4cabe30dbca0ef97563089d8a5a..393c7f45280674213b080fab55c50fe0004ad601 100644 (file)
 \r
 EFI_DEVICE_PATH_UTILITIES_PROTOCOL          *mDevicePathUtilities = NULL;\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
   The constructor function caches the pointer to DevicePathUtilites protocol.\r
   \r
@@ -60,6 +72,218 @@ DevicePathLibConstructor (
   return Status;\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
+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
+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
+DevicePathNodeLength (\r
+  IN CONST VOID  *Node\r
+  )\r
+{\r
+  ASSERT (Node != NULL);\r
+  return ReadUnaligned16 ((UINT16 *)&((EFI_DEVICE_PATH_PROTOCOL *)(Node))->Length[0]);\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 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 specified by Node.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\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 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 device path.\r
+  @retval FALSE     The device path node specified by Node is not an end node of a device path.\r
+  \r
+**/\r
+BOOLEAN\r
+IsDevicePathEndType (\r
+  IN CONST VOID  *Node\r
+  )\r
+{\r
+  ASSERT (Node != NULL);\r
+  return ((DevicePathType (Node) & 0x7f) == 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 device path.\r
+  If Node represents the end of an entire device path, 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 the end of an entire device path.\r
+  @retval FALSE     The device path node specified by Node is not the end of an entire device path.\r
+\r
+**/\r
+BOOLEAN\r
+IsDevicePathEnd (\r
+  IN CONST VOID  *Node\r
+  )\r
+{\r
+  ASSERT (Node != NULL);\r
+  return (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 path instance.\r
+  If Node represents the end of a device path instance, 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 the end of a device path instance.\r
+  @retval FALSE     The device path node specified by Node is not the end of a device path instance.\r
+\r
+**/\r
+BOOLEAN\r
+IsDevicePathEndInstance (\r
+  IN CONST VOID  *Node\r
+  )\r
+{\r
+  ASSERT (Node != NULL);\r
+  return (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 >= 0x10000, 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
+SetDevicePathNodeLength (\r
+IN VOID   *Node,\r
+IN UINTN  NodeLength\r
+  )\r
+{\r
+  ASSERT (Node != NULL);\r
+  ASSERT (NodeLength < 0x10000);\r
+  return WriteUnaligned16 ((UINT16 *)&((EFI_DEVICE_PATH_PROTOCOL *)(Node))->Length[0], (UINT16)(NodeLength));\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
+SetDevicePathEndNode (\r
+  IN 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