]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1, Move device path utility macros from protocol's header file to DevicePathLib libra...
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 11 Nov 2008 15:39:02 +0000 (15:39 +0000)
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 11 Nov 2008 15:39:02 +0000 (15:39 +0000)
2, Remove Unpack type

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

MdePkg/Include/Library/DevicePathLib.h
MdePkg/Include/Protocol/DevicePath.h
MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c
MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLib.c
MdePkg/Library/UefiLib/UefiLib.inf
MdePkg/Library/UefiLib/UefiLibInternal.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
index f5df67a97f2704eb687a665fd9011ecc4a566a3a..23042057546bf2d6795e82a93a86866ee185e54d 100644 (file)
@@ -526,55 +526,9 @@ typedef union {
 \r
 #pragma pack()\r
                                              \r
-#define EFI_DP_TYPE_MASK                     0x7F\r
-#define EFI_DP_TYPE_UNPACKED                 0x80\r
 #define END_DEVICE_PATH_TYPE                 0x7f\r
-                                             \r
-#define EFI_END_ENTIRE_DEVICE_PATH           0xff\r
-#define EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE   0xff\r
-#define EFI_END_INSTANCE_DEVICE_PATH         0x01\r
-#define END_ENTIRE_DEVICE_PATH_SUBTYPE       EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE\r
-#define END_INSTANCE_DEVICE_PATH_SUBTYPE     EFI_END_INSTANCE_DEVICE_PATH\r
-                                             \r
-#define EFI_END_DEVICE_PATH_LENGTH           (sizeof (EFI_DEVICE_PATH_PROTOCOL))\r
-#define END_DEVICE_PATH_LENGTH               EFI_END_DEVICE_PATH_LENGTH\r
-                                             \r
-#define DP_IS_END_TYPE(a)                    \r
-#define DP_IS_END_SUBTYPE(a)                 (((a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE)\r
-#define DevicePathSubType(a)                 ((a)->SubType)\r
-#define IsDevicePathUnpacked(a)              ((a)->Type & EFI_DP_TYPE_UNPACKED)\r
-                                             \r
-#define EfiDevicePathNodeLength(a)           (((a)->Length[0]) | ((a)->Length[1] << 8))\r
-#define DevicePathNodeLength(a)              (EfiDevicePathNodeLength(a))\r
-#define EfiNextDevicePathNode(a)             ((EFI_DEVICE_PATH_PROTOCOL *) (((UINT8 *) (a)) + EfiDevicePathNodeLength (a)))\r
-#define NextDevicePathNode(a)                (EfiNextDevicePathNode(a)) \r
-                                             \r
-#define EfiDevicePathType(a)                 (((a)->Type) & EFI_DP_TYPE_MASK)\r
-#define DevicePathType(a)                    (EfiDevicePathType(a))\r
-#define EfiIsDevicePathEndType(a)            (EfiDevicePathType (a) == END_DEVICE_PATH_TYPE)\r
-#define IsDevicePathEndType(a)               (EfiIsDevicePathEndType(a)) \r
-                                             \r
-                                             \r
-#define EfiIsDevicePathEndSubType(a)         ((a)->SubType == EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE)\r
-#define IsDevicePathEndSubType(a)            (EfiIsDevicePathEndSubType(a))\r
-#define EfiIsDevicePathEndInstanceSubType(a) ((a)->SubType == EFI_END_INSTANCE_DEVICE_PATH)\r
-                                             \r
-#define EfiIsDevicePathEnd(a)                (EfiIsDevicePathEndType (a) && EfiIsDevicePathEndSubType (a))\r
-#define IsDevicePathEnd(a)                   (EfiIsDevicePathEnd(a))\r
-#define EfiIsDevicePathEndInstance(a)        (EfiIsDevicePathEndType (a) && EfiIsDevicePathEndInstanceSubType (a))\r
-\r
-\r
-#define SetDevicePathNodeLength(a,l) {                           \\r
-          (a)->Length[0] = (UINT8) (l);                          \\r
-          (a)->Length[1] = (UINT8) ((l) >> 8);                   \\r
-          }\r
-\r
-#define SetDevicePathEndNode(a)  {                               \\r
-          (a)->Type = END_DEVICE_PATH_TYPE;                      \\r
-          (a)->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;         \\r
-          (a)->Length[0] = sizeof(EFI_DEVICE_PATH_PROTOCOL);     \\r
-          (a)->Length[1] = 0;                                    \\r
-          }\r
+#define END_ENTIRE_DEVICE_PATH_SUBTYPE       0xFF\r
+#define END_INSTANCE_DEVICE_PATH_SUBTYPE     0x01\r
 \r
 extern EFI_GUID gEfiDevicePathProtocolGuid;\r
 \r
index 2d266c70b76fc7f97cec6fbadbdf0ff54904ae25..708b48a088e42d19ade75df6aa435f247a00de5e 100644 (file)
@@ -70,14 +70,14 @@ GetDevicePathSize (
   // Search for the end of the device path structure\r
   //\r
   Start = DevicePath;\r
-  while (!EfiIsDevicePathEnd (DevicePath)) {\r
-    DevicePath = EfiNextDevicePathNode (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) + EfiDevicePathNodeLength (DevicePath);\r
+  return ((UINTN) DevicePath - (UINTN) Start) + DevicePathNodeLength (DevicePath);\r
 }\r
 \r
 /**\r
@@ -166,7 +166,7 @@ AppendDevicePath (
   //\r
   Size1         = GetDevicePathSize (FirstDevicePath);\r
   Size2         = GetDevicePathSize (SecondDevicePath);\r
-  Size          = Size1 + Size2 - EFI_END_DEVICE_PATH_LENGTH;\r
+  Size          = Size1 + Size2 - END_DEVICE_PATH_LENGTH;\r
 \r
   NewDevicePath = AllocatePool (Size);\r
 \r
@@ -176,7 +176,7 @@ AppendDevicePath (
     // Over write FirstDevicePath EndNode and do the copy\r
     //\r
     DevicePath2 = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath +\r
-                  (Size1 - EFI_END_DEVICE_PATH_LENGTH));\r
+                  (Size1 - END_DEVICE_PATH_LENGTH));\r
     CopyMem (DevicePath2, SecondDevicePath, Size2);\r
   }\r
 \r
@@ -224,7 +224,7 @@ AppendDevicePathNode (
   //\r
   NodeLength = DevicePathNodeLength (DevicePathNode);\r
 \r
-  TempDevicePath = AllocatePool (NodeLength + EFI_END_DEVICE_PATH_LENGTH);\r
+  TempDevicePath = AllocatePool (NodeLength + END_DEVICE_PATH_LENGTH);\r
   if (TempDevicePath == NULL) {\r
     return NULL;\r
   }\r
@@ -451,12 +451,12 @@ IsDevicePathMultiInstance (
   }\r
 \r
   Node = DevicePath;\r
-  while (!EfiIsDevicePathEnd (Node)) {\r
-    if (EfiIsDevicePathEndInstance (Node)) {\r
+  while (!IsDevicePathEnd (Node)) {\r
+    if (IsDevicePathEndInstance (Node)) {\r
       return TRUE;\r
     }\r
 \r
-    Node = EfiNextDevicePathNode (Node);\r
+    Node = NextDevicePathNode (Node);\r
   }\r
 \r
   return FALSE;\r
@@ -518,15 +518,16 @@ FileDevicePath (
   IN CONST CHAR16                    *FileName\r
   )\r
 {\r
-  UINT                    Size;\r
+  UINT16                    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 + EFI_END_DEVICE_PATH_LENGTH);\r
+  Size = (UINT16) StrSize (FileName);\r
+  \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
index 6ea34237bc552e072f5235ee06dbf5f4e7efb35e..37a0ae792be21579854fd232208d199d3585b6a2 100644 (file)
@@ -342,7 +342,7 @@ FileDevicePath (
   DevicePath = NULL;\r
 \r
   Size = StrSize (FileName);\r
-  FileDevicePath = AllocatePool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + EFI_END_DEVICE_PATH_LENGTH);\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
index 315eec1d5c4cd172b1fb16c4ef6e107264aaf5df..103014cd3d52c06b2409a22612bb6fe492777f13 100644 (file)
@@ -55,7 +55,8 @@
   BaseLib\r
   UefiBootServicesTableLib\r
   UefiRuntimeServicesTableLib\r
-\r
+  DevicePathLib\r
+  \r
 [Guids]\r
   gEfiEventReadyToBootGuid                      # ALWAYS_CONSUMED\r
   gEfiEventLegacyBootGuid                       # ALWAYS_CONSUMED\r
index bd4f0560983e76180b78ba4583780bab720c1ed7..ef28195b975908468eee456fdf045942ef823b96 100644 (file)
@@ -35,6 +35,6 @@
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/PrintLib.h>\r
-\r
+#include <Library/DevicePathLib.h>\r
 \r
 #endif\r