]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1, Add <Library/DevicePathLib.h> for all source that use device path utility macros
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 11 Nov 2008 15:42:40 +0000 (15:42 +0000)
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 11 Nov 2008 15:42:40 +0000 (15:42 +0000)
2, Add DevicePathLib library class to module's INF that use device path utility macros

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

21 files changed:
MdeModulePkg/Bus/Pci/UndiRuntimeDxe/Undi32.h
MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c
MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
MdeModulePkg/Include/Library/GenericBdsLib.h
MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf
MdeModulePkg/Library/DxePlatDriOverLib/PlatDriOverLib.c
MdeModulePkg/Library/ExtendedHiiLib/ExtendedHiiLib.c
MdeModulePkg/Library/ExtendedHiiLib/ExtendedHiiLib.inf
MdeModulePkg/Library/GenericBdsLib/BdsBoot.c
MdeModulePkg/Library/GenericBdsLib/DevicePath.c
MdeModulePkg/Universal/BdsDxe/BootMaint/Variable.c
MdeModulePkg/Universal/DebugPortDxe/DebugPort.c
MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c
MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c
MdeModulePkg/Universal/FirmwareVolume/FaultTolerantWriteDxe/FtwLite.h
MdeModulePkg/Universal/FirmwareVolume/FaultTolerantWriteDxe/FtwLite.inf
MdeModulePkg/Universal/Network/IScsiDxe/IScsiExtScsiPassThru.c
MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.c
MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.h
MdeModulePkg/Universal/PlatformDriverOverride/PlatOverMngr/PlatOverMngr.inf

index 05f3844a8145f60905920bce49c139449495fc70..b997873a39101564a9d3691257502cb4464e82d2 100644 (file)
@@ -28,6 +28,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/UefiLib.h>\r
+#include <Library/DevicePathLib.h>\r
 \r
 #include <IndustryStandard/Pci.h>\r
 \r
index ad84da90e79dcb63db36ca0073036d33fc6333ae..24653f06257b77f594c600e07b240ab4622849c3 100644 (file)
@@ -759,7 +759,7 @@ GetUsbDPFromFullDP (
   // Get the Usb part first Begin node in full device path\r
   //\r
   UsbDevicePathBeginPtr = DevicePath;\r
-  while ( (!EfiIsDevicePathEnd (UsbDevicePathBeginPtr))&&\r
+  while ( (!IsDevicePathEnd (UsbDevicePathBeginPtr))&&\r
          ((UsbDevicePathBeginPtr->Type != MESSAGING_DEVICE_PATH) ||\r
          (UsbDevicePathBeginPtr->SubType != MSG_USB_DP &&\r
           UsbDevicePathBeginPtr->SubType != MSG_USB_CLASS_DP\r
@@ -773,7 +773,7 @@ GetUsbDPFromFullDP (
   // Get the Usb part first End node in full device path\r
   //\r
   UsbDevicePathEndPtr = UsbDevicePathBeginPtr;\r
-  while ((!EfiIsDevicePathEnd (UsbDevicePathEndPtr))&&\r
+  while ((!IsDevicePathEnd (UsbDevicePathEndPtr))&&\r
          (UsbDevicePathEndPtr->Type == MESSAGING_DEVICE_PATH) &&\r
          (UsbDevicePathEndPtr->SubType == MSG_USB_DP ||\r
           UsbDevicePathEndPtr->SubType == MSG_USB_CLASS_DP\r
index b2faff1a867ad6f7ed5f72e4958a135be438040c..f1f940716cbd9950e3486c6d38e0e8eb469b7adc 100644 (file)
@@ -691,9 +691,7 @@ CoreFvToDevicePath (
     // Build a device path to the file in the FV to pass into gBS->LoadImage\r
     //\r
     EfiInitializeFwVolDevicepathNode (&mFvDevicePath.File, DriverName);\r
-    mFvDevicePath.End.Type = EFI_END_ENTIRE_DEVICE_PATH;\r
-    mFvDevicePath.End.SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;\r
-    SetDevicePathNodeLength (&mFvDevicePath.End, sizeof (EFI_DEVICE_PATH_PROTOCOL));\r
+    SetDevicePathEndNode (&mFvDevicePath.End);\r
 \r
     FileNameDevicePath = AppendDevicePath (\r
                             FvDevicePath,\r
@@ -1046,9 +1044,7 @@ CoreFwVolEventProtocolNotify (
                 // be initialized completely.\r
                 //\r
                 EfiInitializeFwVolDevicepathNode (&mFvDevicePath.File, &NameGuid);\r
-                mFvDevicePath.End.Type = EFI_END_ENTIRE_DEVICE_PATH;\r
-                mFvDevicePath.End.SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;\r
-                SetDevicePathNodeLength (&mFvDevicePath.End, sizeof (EFI_DEVICE_PATH_PROTOCOL));\r
+                SetDevicePathEndNode (&mFvDevicePath.End);\r
 \r
                 gDxeCoreLoadedImage->FilePath = DuplicateDevicePath (\r
                                                   (EFI_DEVICE_PATH_PROTOCOL *)&mFvDevicePath\r
index 76b7f9484f476667ec274a319a24df21ff316cfc..fd46f8af74d386831493e0efd6a1bae1a88f73b9 100644 (file)
@@ -505,22 +505,6 @@ BdsLibConnectConsoleVariable (
 //\r
 // Bds device path related lib functions\r
 //\r
-/**\r
-  Function unpacks a device path data structure so that all the nodes\r
-  of a device path are naturally aligned.\r
-\r
-  @param  DevPath  A pointer to a device path data structure\r
-\r
-  @return If the memory for the device path is successfully allocated, then a\r
-          pointer to the new device path is returned.  Otherwise, NULL is returned.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-EFIAPI\r
-BdsLibUnpackDevicePath (\r
-  IN EFI_DEVICE_PATH_PROTOCOL  *DevPath\r
-  );\r
-\r
 /**\r
   Delete the instance in Multi which matches partly with Single instance\r
 \r
index 7c7dd74694cf35a7fc73b03e2f59dad223c09374..4eeab90e05ca5c5aad86ebbb8852c5fee7beb792 100644 (file)
@@ -38,7 +38,7 @@ Abstract:
 #include <Library/UefiRuntimeServicesTableLib.h>\r
 #include <Library/UefiLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
-\r
+#include <Library/DevicePathLib.h>\r
 \r
 EFI_DPC_PROTOCOL *mDpc = NULL;\r
 \r
index db2c318afb54e08080ec02430c04131870343694..1f148b25395f1a5f67d8e2d493c0df43317c6023 100644 (file)
@@ -51,7 +51,8 @@
   UefiRuntimeServicesTableLib\r
   UefiLib\r
   MemoryAllocationLib\r
-\r
+  DevicePathLib\r
+  \r
 [Protocols]\r
   gEfiSimpleNetworkProtocolGuid                 # PROTOCOL ALWAYS_CONSUMED\r
   gEfiNicIp4ConfigProtocolGuid                  # PROTOCOL ALWAYS_CONSUMED\r
index 21bfb8a7c288b771ec1c71cb3554c5f61e57c115..b746c68bf5ca247d43d3a626dbbe1978e8976baa 100644 (file)
@@ -1590,9 +1590,9 @@ UpdateFvFileDevicePath (
   //\r
   TempDevicePath = *DevicePath;\r
   LastDeviceNode = TempDevicePath;\r
-  while (!EfiIsDevicePathEnd (TempDevicePath)) {\r
-    LastDeviceNode = TempDevicePath;\r
-    TempDevicePath = EfiNextDevicePathNode (TempDevicePath);\r
+  while (!IsDevicePathEnd (TempDevicePath)) {\r
+     LastDeviceNode = TempDevicePath;\r
+     TempDevicePath = NextDevicePathNode (TempDevicePath);\r
   }\r
   GuidPoint = EfiGetNameGuidFromFwVolDevicePathNode ((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) LastDeviceNode);\r
   if (GuidPoint == NULL) {\r
@@ -1618,7 +1618,7 @@ UpdateFvFileDevicePath (
   //\r
   TempDevicePath = *DevicePath;\r
   HasFvNode = FALSE;\r
-  while (!EfiIsDevicePathEnd (TempDevicePath)) {\r
+  while (!IsDevicePathEnd (TempDevicePath)) {\r
     //\r
     // Use old Device Path\r
     //\r
@@ -1627,7 +1627,7 @@ UpdateFvFileDevicePath (
       HasFvNode = TRUE;\r
       break;\r
     }\r
-    TempDevicePath = EfiNextDevicePathNode (TempDevicePath);\r
+    TempDevicePath = NextDevicePathNode (TempDevicePath);\r
   }\r
 \r
   if (!HasFvNode) {\r
index b29e13a375a676121a76743460bbef642175c04d..a3970ecf74e95217ed7c6edaee2c23725a383396 100644 (file)
@@ -21,6 +21,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/DebugLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/DevicePathLib.h>\r
 #include <MdeModuleHii.h>\r
 \r
 \r
index 65c71baf341b35ec2b57bd290b278c55852fca2e..f5a7fc2ca32dffd662bd7d60331521f6200352a5 100644 (file)
@@ -42,7 +42,8 @@
   DebugLib\r
   PcdLib\r
   UefiRuntimeServicesTableLib\r
-\r
+  DevicePathLib\r
+  \r
 [Protocols]\r
   gEfiDevicePathProtocolGuid  \r
   \r
index c8b2c59f5244e08ebbeeb5bc07119447c1225c6a..efaf82addc4c671d710f2d7260216295901d5825 100644 (file)
@@ -523,7 +523,6 @@ MatchPartitionDevicePathNode (
   )\r
 {\r
   HARDDRIVE_DEVICE_PATH     *TmpHdPath;\r
-  HARDDRIVE_DEVICE_PATH     *TempPath;\r
   EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
   BOOLEAN                   Match;\r
   EFI_DEVICE_PATH_PROTOCOL  *BlockIoHdDevicePathNode;\r
@@ -559,20 +558,19 @@ MatchPartitionDevicePathNode (
   // See if the harddrive device path in blockio matches the orig Hard Drive Node\r
   //\r
   TmpHdPath = (HARDDRIVE_DEVICE_PATH *) BlockIoHdDevicePathNode;\r
-  TempPath  = (HARDDRIVE_DEVICE_PATH *) BdsLibUnpackDevicePath ((EFI_DEVICE_PATH_PROTOCOL *) HardDriveDevicePath);\r
   Match = FALSE;\r
   \r
   //\r
   // Check for the match\r
   //\r
-  if ((TmpHdPath->MBRType == TempPath->MBRType) &&\r
-      (TmpHdPath->SignatureType == TempPath->SignatureType)) {\r
+  if ((TmpHdPath->MBRType == HardDriveDevicePath->MBRType) &&\r
+      (TmpHdPath->SignatureType == HardDriveDevicePath->SignatureType)) {\r
     switch (TmpHdPath->SignatureType) {\r
     case SIGNATURE_TYPE_GUID:\r
-      Match = CompareGuid ((EFI_GUID *)TmpHdPath->Signature, (EFI_GUID *)TempPath->Signature);\r
+      Match = CompareGuid ((EFI_GUID *)TmpHdPath->Signature, (EFI_GUID *)HardDriveDevicePath->Signature);\r
       break;\r
     case SIGNATURE_TYPE_MBR:\r
-      Match = (BOOLEAN)(*((UINT32 *)(&(TmpHdPath->Signature[0]))) == *(UINT32 *)(&(TempPath->Signature[0])));\r
+      Match = (BOOLEAN)(*((UINT32 *)(&(TmpHdPath->Signature[0]))) == ReadUnaligned32((UINT32 *)(&(HardDriveDevicePath->Signature[0]))));\r
       break;\r
     default:\r
       Match = FALSE;\r
@@ -1624,9 +1622,9 @@ BdsLibIsValidEFIBootOptDevicePath (
   // If the boot option point to a file, it is a valid EFI boot option,\r
   // and assume it is ready to boot now\r
   //\r
-  while (!EfiIsDevicePathEnd (TempDevicePath)) {\r
+  while (!IsDevicePathEnd (TempDevicePath)) {\r
      LastDeviceNode = TempDevicePath;\r
-     TempDevicePath = EfiNextDevicePathNode (TempDevicePath);\r
+     TempDevicePath = NextDevicePathNode (TempDevicePath);\r
   }\r
   if ((DevicePathType (LastDeviceNode) == MEDIA_DEVICE_PATH) &&\r
     (DevicePathSubType (LastDeviceNode) == MEDIA_FILEPATH_DP)) {\r
@@ -1765,9 +1763,9 @@ BdsLibUpdateFvFileDevicePath (
   //\r
   TempDevicePath = *DevicePath;\r
   LastDeviceNode = TempDevicePath;\r
-  while (!EfiIsDevicePathEnd (TempDevicePath)) {\r
+  while (!IsDevicePathEnd (TempDevicePath)) {\r
      LastDeviceNode = TempDevicePath;\r
-     TempDevicePath = EfiNextDevicePathNode (TempDevicePath);\r
+     TempDevicePath = NextDevicePathNode (TempDevicePath);\r
   }\r
   GuidPoint = EfiGetNameGuidFromFwVolDevicePathNode (\r
                 (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) LastDeviceNode\r
index affb009d4b5a553b5cb65b10b3d1f2568095e9e4..f420625fc920fa1518d5eeed8c14c753806863ac 100644 (file)
@@ -112,75 +112,6 @@ CatPrint (
   return Str->str;\r
 }\r
 \r
-\r
-/**\r
-  Function unpacks a device path data structure so that all the nodes\r
-  of a device path are naturally aligned.\r
-\r
-  @param  DevPath  A pointer to a device path data structure\r
-\r
-  @return A ponter to new device If the memory for the device path is successfully allocated, then a\r
-          pointer to the new device path is returned.  Otherwise, NULL is returned.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-EFIAPI\r
-BdsLibUnpackDevicePath (\r
-  IN EFI_DEVICE_PATH_PROTOCOL  *DevPath\r
-  )\r
-{\r
-  EFI_DEVICE_PATH_PROTOCOL  *Src;\r
-  EFI_DEVICE_PATH_PROTOCOL  *Dest;\r
-  EFI_DEVICE_PATH_PROTOCOL  *NewPath;\r
-  UINTN                     Size;\r
-\r
-  //\r
-  // Walk device path and round sizes to valid boundries\r
-  //\r
-  Src   = DevPath;\r
-  Size  = 0;\r
-  for (;;) {\r
-    Size += DevicePathNodeLength (Src);\r
-    Size += ALIGN_SIZE (Size);\r
-\r
-    if (IsDevicePathEnd (Src)) {\r
-      break;\r
-    }\r
-\r
-    Src = NextDevicePathNode (Src);\r
-  }\r
-  //\r
-  // Allocate space for the unpacked path\r
-  //\r
-  NewPath = AllocateZeroPool (Size);\r
-  if (NewPath != NULL) {\r
-\r
-    ASSERT (((UINTN) NewPath) % MIN_ALIGNMENT_SIZE == 0);\r
-\r
-    //\r
-    // Copy each node\r
-    //\r
-    Src   = DevPath;\r
-    Dest  = NewPath;\r
-    for (;;) {\r
-      Size = DevicePathNodeLength (Src);\r
-      CopyMem (Dest, Src, Size);\r
-      Size += ALIGN_SIZE (Size);\r
-      SetDevicePathNodeLength (Dest, Size);\r
-      Dest->Type |= EFI_DP_TYPE_UNPACKED;\r
-      Dest = (EFI_DEVICE_PATH_PROTOCOL *) (((UINT8 *) Dest) + Size);\r
-\r
-      if (IsDevicePathEnd (Src)) {\r
-        break;\r
-      }\r
-\r
-      Src = NextDevicePathNode (Src);\r
-    }\r
-  }\r
-\r
-  return NewPath;\r
-}\r
-\r
 /**\r
   Convert Device Path to a Unicode string for printing.\r
 \r
@@ -1545,12 +1476,6 @@ DevicePathToStr (
     return ToText;\r
   }\r
 \r
-  //\r
-  // Unpacked the device path\r
-  //\r
-  DevPath = BdsLibUnpackDevicePath (DevPath);\r
-  ASSERT (DevPath);\r
-\r
   //\r
   // Process each device path node\r
   //\r
index 622093c8bb4912c807bd10987b11fb3de54ba43f..a211ae24170d9232fb447c467477fb53f2a7a8fa 100644 (file)
@@ -1257,7 +1257,7 @@ Var_UpdateBBSOption (
     NewOptionSize = sizeof (UINT32) + sizeof (UINT16) + StrSize (DescString) +\r
                     sizeof (BBS_BBS_DEVICE_PATH);\r
     NewOptionSize += AsciiStrLen (DescAsciiString) +\r
-                    EFI_END_DEVICE_PATH_LENGTH + sizeof (BBS_TABLE) + sizeof (UINT16);\r
+                    END_DEVICE_PATH_LENGTH + sizeof (BBS_TABLE) + sizeof (UINT16);\r
 \r
     UnicodeSPrint (VarName, 100, L"Boot%04x", Index);\r
 \r
@@ -1300,7 +1300,7 @@ Var_UpdateBBSOption (
     //\r
     *((UINT16 *) TempPtr) = (UINT16) (sizeof (BBS_BBS_DEVICE_PATH) +\r
                          AsciiStrLen (DescAsciiString) +\r
-                         EFI_END_DEVICE_PATH_LENGTH);\r
+                         END_DEVICE_PATH_LENGTH);\r
 \r
     TempPtr += sizeof (UINT16);\r
 \r
@@ -1343,9 +1343,9 @@ Var_UpdateBBSOption (
     CopyMem (\r
       TempPtr,\r
       EndDevicePath,\r
-      EFI_END_DEVICE_PATH_LENGTH\r
+      END_DEVICE_PATH_LENGTH\r
       );\r
-    TempPtr += EFI_END_DEVICE_PATH_LENGTH;\r
+    TempPtr += END_DEVICE_PATH_LENGTH;\r
 \r
     //\r
     // Now TempPtr point to optional data, i.e. Bbs Table\r
index 932c772d48fca683974dc2e1d63c685c5c42eac8..0ddbf1ed2a1d2ef41ee5fd8d53941fcba6ed30d1 100644 (file)
@@ -73,11 +73,11 @@ GetDebugPortVariable (
             DebugPortDevice->DebugPortVariable\r
             );\r
       DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) DebugPortDevice->DebugPortVariable;\r
-      while (!EfiIsDevicePathEnd (DevicePath) && !IS_UART_DEVICEPATH (DevicePath)) {\r
-        DevicePath = EfiNextDevicePathNode (DevicePath);\r
+      while (!IsDevicePathEnd (DevicePath) && !IS_UART_DEVICEPATH (DevicePath)) {\r
+        DevicePath = NextDevicePathNode (DevicePath);\r
       }\r
 \r
-      if (EfiIsDevicePathEnd (DevicePath)) {\r
+      if (IsDevicePathEnd (DevicePath)) {\r
         FreePool (gDebugPortDevice->DebugPortVariable);\r
         DebugPortDevice->DebugPortVariable = NULL;\r
       } else {\r
index a1d560cfd536b045601f458add37ae5e3e62ff0b..a9f6afcf4a177f58778e41bfbc8eed1ceee9cf10 100644 (file)
@@ -14,76 +14,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include "DevicePath.h"\r
 \r
-/**\r
-  Function unpacks a device path data structure so that all the nodes of a device path\r
-  are naturally aligned.\r
-\r
-  @param DevPath         A pointer to a device path data structure\r
-\r
-  @return If the memory for the device path is successfully allocated, then a pointer to the\r
-          new device path is returned.  Otherwise, NULL is returned.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-UnpackDevicePath (\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevPath\r
-  )\r
-{\r
-  CONST EFI_DEVICE_PATH_PROTOCOL  *Src;\r
-  EFI_DEVICE_PATH_PROTOCOL  *Dest;\r
-  EFI_DEVICE_PATH_PROTOCOL  *NewPath;\r
-  UINTN                     Size;\r
-\r
-  if (DevPath == NULL) {\r
-    return NULL;\r
-  }\r
-  //\r
-  // Walk device path and round sizes to valid boundries\r
-  //\r
-  Src   = DevPath;\r
-  Size  = 0;\r
-  for (;;) {\r
-    Size += DevicePathNodeLength (Src);\r
-    Size += ALIGN_SIZE (Size);\r
-\r
-    if (IsDevicePathEnd (Src)) {\r
-      break;\r
-    }\r
-\r
-    Src = (EFI_DEVICE_PATH_PROTOCOL *) NextDevicePathNode (Src);\r
-  }\r
-  //\r
-  // Allocate space for the unpacked path\r
-  //\r
-  NewPath = AllocateZeroPool (Size);\r
-  if (NewPath != NULL) {\r
-\r
-    ASSERT (((UINTN) NewPath) % MIN_ALIGNMENT_SIZE == 0);\r
-\r
-    //\r
-    // Copy each node\r
-    //\r
-    Src   = DevPath;\r
-    Dest  = NewPath;\r
-    for (;;) {\r
-      Size = DevicePathNodeLength (Src);\r
-      CopyMem (Dest, Src, Size);\r
-      Size += ALIGN_SIZE (Size);\r
-      SetDevicePathNodeLength (Dest, Size);\r
-      Dest->Type |= EFI_DP_TYPE_UNPACKED;\r
-      Dest = (EFI_DEVICE_PATH_PROTOCOL *) (((UINT8 *) Dest) + Size);\r
-\r
-      if (IsDevicePathEnd (Src)) {\r
-        break;\r
-      }\r
-\r
-      Src = (EFI_DEVICE_PATH_PROTOCOL *) NextDevicePathNode (Src);\r
-    }\r
-  }\r
-\r
-  return NewPath;\r
-}\r
-\r
 /**\r
   Adjusts the size of a previously allocated buffer.\r
 \r
@@ -1853,7 +1783,7 @@ ConvertDevicePathToText (
 {\r
   POOL_PRINT                Str;\r
   EFI_DEVICE_PATH_PROTOCOL  *DevPathNode;\r
-  EFI_DEVICE_PATH_PROTOCOL  *UnpackDevPath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *AlignedDevPathNode;\r
   UINTN                     Index;\r
   UINTN                     NewSize;\r
   VOID                      (*DumpNode) (POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);\r
@@ -1864,16 +1794,10 @@ ConvertDevicePathToText (
 \r
   ZeroMem (&Str, sizeof (Str));\r
 \r
-  //\r
-  // Unpacked the device path\r
-  //\r
-  UnpackDevPath = UnpackDevicePath ((EFI_DEVICE_PATH_PROTOCOL *) DevicePath);\r
-  ASSERT (UnpackDevPath != NULL);\r
-\r
   //\r
   // Process each device path node\r
   //\r
-  DevPathNode = UnpackDevPath;\r
+  DevPathNode = (EFI_DEVICE_PATH_PROTOCOL *) DevicePath;\r
   while (!IsDevicePathEnd (DevPathNode)) {\r
     //\r
     // Find the handler to dump this device path node\r
@@ -1902,20 +1826,19 @@ ConvertDevicePathToText (
         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, DevPathNode, DisplayOnly, AllowShortcuts);\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
-  // Shrink pool used for string allocation\r
-  //\r
-  FreePool (UnpackDevPath);\r
 \r
   NewSize = (Str.Len + 1) * sizeof (CHAR16);\r
   Str.Str = ReallocatePool (Str.Str, NewSize, NewSize);\r
index 51fdca4254a4f78e6cb418400c4ec4a1cdf0a946..21d1163ab7819c3238b8be0b62a1aba41bcced42 100644 (file)
@@ -163,9 +163,9 @@ PartitionInstallMbrChildHandles (
   LastDevicePathNode = NULL;\r
   ZeroMem (&ParentHdDev, sizeof (ParentHdDev));\r
   DevicePathNode = DevicePath;\r
-  while (!EfiIsDevicePathEnd (DevicePathNode)) {\r
+  while (!IsDevicePathEnd (DevicePathNode)) {\r
     LastDevicePathNode  = DevicePathNode;\r
-    DevicePathNode      = EfiNextDevicePathNode (DevicePathNode);\r
+    DevicePathNode      = NextDevicePathNode (DevicePathNode);\r
   }\r
 \r
   if (LastDevicePathNode != NULL) {\r
index 2a5195bb4f85d8dde5a44626c0d0856db71c29f7..a7cc406c328bb3c1b0142a51ac55ffe900e7a0e9 100644 (file)
@@ -31,6 +31,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/DevicePathLib.h>\r
 \r
 #include <WorkingBlockHeader.h>\r
 \r
index 6011c74d14d093433e5951b500e7ef7cc1b04f73..113f6eda90e5b3683818f6ce63aecd1696d445cf 100644 (file)
@@ -63,7 +63,8 @@
   UefiDriverEntryPoint\r
   DebugLib\r
   PcdLib\r
-\r
+  DevicePathLib\r
+  \r
 [Guids]\r
   gEfiSystemNvDataFvGuid                        # ALWAYS_CONSUMED\r
 \r
index 2e99efc03279fb19087d9ff26c8cd8c31eda037d..e1d2bc0e3c540af59c0c55e3e6275c9edc89686f 100644 (file)
@@ -188,7 +188,7 @@ IScsiExtScsiPassThruBuildDevicePath (
 \r
   Node->DevPath.Type    = MESSAGING_DEVICE_PATH;\r
   Node->DevPath.SubType = MSG_ISCSI_DP;\r
-  SetDevicePathNodeLength (&Node->DevPath, DevPathNodeLen);\r
+  SetDevicePathNodeLength (&Node->DevPath, (UINT16)DevPathNodeLen);\r
 \r
   //\r
   // 0 for TCP, others are reserved.\r
index 5269c35198716b6099d75828f9f32f090b40eed2..5d9bfe127a330ec5db4744803102f6d86a7f0a88 100644 (file)
@@ -340,8 +340,8 @@ GetImageName (
   )\r
 {\r
   EFI_STATUS                        Status;\r
-  EFI_DEVICE_PATH_PROTOCOL          *DevPath;\r
   EFI_DEVICE_PATH_PROTOCOL          *DevPathNode;\r
+  EFI_DEVICE_PATH_PROTOCOL          *AlignedDevPathNode;\r
   MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFilePath;\r
   VOID                              *Buffer;\r
   UINTN                             BufferSize;\r
@@ -357,21 +357,24 @@ GetImageName (
     return NULL;\r
   }\r
 \r
-  DevPath     = UnpackDevicePath (Image->FilePath);\r
+  DevPathNode  = Image->FilePath;\r
 \r
-  if (DevPath == NULL) {\r
+  if (DevPathNode == NULL) {\r
     return NULL;\r
   }\r
 \r
-  DevPathNode = DevPath;\r
-\r
   while (!IsDevicePathEnd (DevPathNode)) {\r
+    //\r
+    // Make sure device path node is aligned when accessing it's FV Name Guid field.\r
+    //\r
+    AlignedDevPathNode = AllocateCopyPool (DevicePathNodeLength(DevPathNode), DevPathNode);\r
+    \r
     //\r
     // Find the Fv File path\r
     //\r
-    NameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)DevPathNode);\r
+    NameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)AlignedDevPathNode);\r
     if (NameGuid != NULL) {\r
-      FvFilePath = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) DevPathNode;\r
+      FvFilePath = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) AlignedDevPathNode;\r
       Status = gBS->HandleProtocol (\r
                     Image->DeviceHandle,\r
                     &gEfiFirmwareVolume2ProtocolGuid,\r
@@ -388,18 +391,21 @@ GetImageName (
                         &AuthenticationStatus\r
                         );\r
         if (!EFI_ERROR (Status)) {\r
+          FreePool (AlignedDevPathNode);\r
           break;\r
         }\r
         Buffer = NULL;\r
       }\r
     }\r
+    \r
+    FreePool (AlignedDevPathNode);\r
+    \r
     //\r
     // Next device path node\r
     //\r
     DevPathNode = NextDevicePathNode (DevPathNode);\r
   }\r
 \r
-    gBS->FreePool (DevPath);\r
   return Buffer;\r
 }\r
 \r
@@ -1316,74 +1322,6 @@ PlatOverMngrCallback (
   return EFI_SUCCESS;\r
 }\r
 \r
-/**\r
-  Function unpacks a device path data structure so that all the nodes\r
-  of a device path are naturally aligned.\r
-\r
-  @param  DevPath  A pointer to a device path data structure\r
-\r
-  @return If the memory for the device path is successfully allocated, then a\r
-  @return pointer to the new device path is returned.  Otherwise, NULL is returned.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-UnpackDevicePath (\r
-  IN EFI_DEVICE_PATH_PROTOCOL  *DevPath\r
-  )\r
-{\r
-  EFI_DEVICE_PATH_PROTOCOL  *Src;\r
-  EFI_DEVICE_PATH_PROTOCOL  *Dest;\r
-  EFI_DEVICE_PATH_PROTOCOL  *NewPath;\r
-  UINTN                     Size;\r
-\r
-  //\r
-  // Walk device path and round sizes to valid boundries\r
-  //\r
-  Src   = DevPath;\r
-  Size  = 0;\r
-  for (;;) {\r
-    Size += DevicePathNodeLength (Src);\r
-    Size += ALIGN_SIZE (Size);\r
-\r
-    if (IsDevicePathEnd (Src)) {\r
-      break;\r
-    }\r
-\r
-    Src = NextDevicePathNode (Src);\r
-  }\r
-  //\r
-  // Allocate space for the unpacked path\r
-  //\r
-  NewPath = AllocateZeroPool (Size);\r
-  if (NewPath) {\r
-\r
-    ASSERT (((UINTN) NewPath) % MIN_ALIGNMENT_SIZE == 0);\r
-\r
-    //\r
-    // Copy each node\r
-    //\r
-    Src   = DevPath;\r
-    Dest  = NewPath;\r
-    for (;;) {\r
-      Size = DevicePathNodeLength (Src);\r
-      CopyMem (Dest, Src, Size);\r
-      Size += ALIGN_SIZE (Size);\r
-      SetDevicePathNodeLength (Dest, Size);\r
-      Dest->Type |= EFI_DP_TYPE_UNPACKED;\r
-      Dest = (EFI_DEVICE_PATH_PROTOCOL *) (((UINT8 *) Dest) + Size);\r
-\r
-      if (IsDevicePathEnd (Src)) {\r
-        break;\r
-      }\r
-\r
-      Src = NextDevicePathNode (Src);\r
-    }\r
-  }\r
-\r
-  return NewPath;\r
-}\r
-\r
-\r
 /**\r
   Get the description string by device path.\r
 \r
index 793f9d83c925f97b4d568c2aa656fa28c032ecd2..5ac780c8bf30222eb3bbec5f08f034baf7ff025b 100644 (file)
@@ -49,6 +49,7 @@ Abstract:
 #include <Library/HiiLib.h>\r
 #include <Library/ExtendedHiiLib.h>\r
 #include <Library/UefiRuntimeServicesTableLib.h>\r
+#include <Library/DevicePathLib.h>\r
 \r
 #define MIN_ALIGNMENT_SIZE  4\r
 #define ALIGN_SIZE(a)       ((a % MIN_ALIGNMENT_SIZE) ? MIN_ALIGNMENT_SIZE - (a % MIN_ALIGNMENT_SIZE) : 0)\r
@@ -171,10 +172,4 @@ DevicePathToStr (
   EFI_DEVICE_PATH_PROTOCOL     *DevPath\r
   );\r
 \r
-\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-UnpackDevicePath (\r
-  IN EFI_DEVICE_PATH_PROTOCOL  *DevPath\r
-  );\r
-\r
 #endif\r
index f4b37825d5e384d9fea648e593eb9f9638ea39a7..3f529133b1ba3cda4fd3661caab9556c5f9f383c 100644 (file)
@@ -58,7 +58,8 @@
   HiiLib\r
   ExtendedHiiLib\r
   UefiRuntimeServicesTableLib\r
-\r
+  DevicePathLib\r
+  \r
 [Protocols]\r
   gEfiLoadedImageProtocolGuid                   # PROTOCOL ALWAYS_CONSUMED\r
   gEfiPciIoProtocolGuid                         # PROTOCOL ALWAYS_CONSUMED\r