]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c
sync comments, fix function header, rename variable name to follow coding style.
[mirror_edk2.git] / MdeModulePkg / Universal / DevicePathDxe / DevicePathToText.c
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