]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Include/Library/DevicePathLib.h
1, Move device path utility macros from protocol's header file to DevicePathLib libra...
[mirror_edk2.git] / MdePkg / Include / Library / DevicePathLib.h
index 244e351400d0336691f7ced46e82441be1cbf908..8df025353bee251cc8f1af2aa0acef9bbdc656c1 100644 (file)
 #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
+#define DevicePathNodeLength(Node)           ReadUnaligned16 ((UINT16 *)&((EFI_DEVICE_PATH_PROTOCOL *)(Node))->Length[0])\r
+#define NextDevicePathNode(Node)             ((EFI_DEVICE_PATH_PROTOCOL *)((UINT8 *)(Node) + DevicePathNodeLength(Node)))\r
+#define DevicePathType(Node)                 (((EFI_DEVICE_PATH_PROTOCOL *)(Node))->Type) \r
+#define DevicePathSubType(Node)              (((EFI_DEVICE_PATH_PROTOCOL *)(Node))->SubType)\r
+#define IsDevicePathEndType(Node)            (DevicePathType (Node) == END_DEVICE_PATH_TYPE)\r
+#define IsDevicePathEnd(Node)                (IsDevicePathEndType (Node) && DevicePathSubType(Node) == END_ENTIRE_DEVICE_PATH_SUBTYPE)\r
+#define IsDevicePathEndInstance(Node)        (IsDevicePathEndType (Node) && DevicePathSubType(Node) == END_INSTANCE_DEVICE_PATH_SUBTYPE)\r
+\r
+#define SetDevicePathNodeLength(Node,NodeLength)  WriteUnaligned16 ((UINT16 *)&((EFI_DEVICE_PATH_PROTOCOL *)(Node))->Length[0], (UINT16)(NodeLength))\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
+\r
 /**\r
   Returns the size of a device path in bytes.\r
 \r