]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Support new format of IPv4 device path node, FibreEx and PcieRoot device path node...
authorniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 5 Sep 2011 04:51:51 +0000 (04:51 +0000)
committerniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 5 Sep 2011 04:51:51 +0000 (04:51 +0000)
Meanwhile, unnecessary (UINTN) typecast is removed and a buffer truncating bug is fixed. The buffer truncating bug may cause DevicePathToText generates wrong text representation if a input device path is too long.

Signed-off-by: niruiyu
Reviewed-by: tye
Reviewed-by: jjin9
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12276 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/DevicePathDxe/DevicePath.h
MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c
MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c

index 8c0db787563df2f1050eb9468f61a9bdb2a9c3c5..8beb68c7ab905c1fda09d806b8becfe02afdc525 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Definition for Device Path Utilities driver\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -31,9 +31,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/DevicePathLib.h>\r
 #include <Library/PcdLib.h>\r
 \r
-\r
-#define MAX_CHAR                   480\r
-\r
 #define IS_COMMA(a)                ((a) == L',')\r
 #define IS_HYPHEN(a)               ((a) == L'-')\r
 #define IS_DOT(a)                  ((a) == L'.')\r
@@ -55,8 +52,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 //\r
 typedef struct {\r
   CHAR16  *Str;\r
-  UINTN   Len;\r
-  UINTN   MaxLen;\r
+  UINTN   Length;\r
+  UINTN   Capacity;\r
 } POOL_PRINT;\r
 \r
 typedef\r
index fb84f65fd1c299e6e19c6906240b67aa749d088c..bc9af70135fc3e192bb678435dddaeefa8bfaf49 100644 (file)
@@ -970,6 +970,22 @@ DevPathFromTextPciRoot (
   return ConvertFromTextAcpi (TextDeviceNode, 0x0a03);\r
 }\r
 \r
+/**\r
+  Converts a text device path node to PCIE root device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created PCIE root device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextPcieRoot (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  return ConvertFromTextAcpi (TextDeviceNode, 0x0a08);\r
+}\r
+\r
 /**\r
   Converts a text device path node to Floppy device path structure.\r
 \r
@@ -1282,6 +1298,41 @@ DevPathFromTextFibre (
   return (EFI_DEVICE_PATH_PROTOCOL *) Fibre;\r
 }\r
 \r
+/**\r
+  Converts a text device path node to FibreEx device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created FibreEx device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextFibreEx (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16                      *WWNStr;\r
+  CHAR16                      *LunStr;\r
+  FIBRECHANNELEX_DEVICE_PATH  *FibreEx;\r
+\r
+  WWNStr  = GetNextParamStr (&TextDeviceNode);\r
+  LunStr  = GetNextParamStr (&TextDeviceNode);\r
+  FibreEx = (FIBRECHANNELEX_DEVICE_PATH *) CreateDeviceNode (\r
+                                             MESSAGING_DEVICE_PATH,\r
+                                             MSG_FIBRECHANNELEX_DP,\r
+                                             (UINT16) sizeof (FIBRECHANNELEX_DEVICE_PATH)\r
+                                             );\r
+\r
+  FibreEx->Reserved = 0;\r
+  Strtoi64 (WWNStr, (UINT64 *) (&FibreEx->WWN));\r
+  Strtoi64 (LunStr, (UINT64 *) (&FibreEx->Lun));\r
+\r
+  *(UINT64 *) (&FibreEx->WWN) = SwapBytes64 (*(UINT64 *) (&FibreEx->WWN));\r
+  *(UINT64 *) (&FibreEx->Lun) = SwapBytes64 (*(UINT64 *) (&FibreEx->Lun));\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) FibreEx;\r
+}\r
+\r
 /**\r
   Converts a text device path node to 1394 device path structure.\r
 \r
@@ -1736,12 +1787,16 @@ DevPathFromTextIPv4 (
   CHAR16            *ProtocolStr;\r
   CHAR16            *TypeStr;\r
   CHAR16            *LocalIPStr;\r
+  CHAR16            *GatewayIPStr;\r
+  CHAR16            *SubnetMaskStr;\r
   IPv4_DEVICE_PATH  *IPv4;\r
 \r
   RemoteIPStr           = GetNextParamStr (&TextDeviceNode);\r
   ProtocolStr           = GetNextParamStr (&TextDeviceNode);\r
   TypeStr               = GetNextParamStr (&TextDeviceNode);\r
   LocalIPStr            = GetNextParamStr (&TextDeviceNode);\r
+  GatewayIPStr          = GetNextParamStr (&TextDeviceNode);\r
+  SubnetMaskStr         = GetNextParamStr (&TextDeviceNode);\r
   IPv4                  = (IPv4_DEVICE_PATH *) CreateDeviceNode (\r
                                                  MESSAGING_DEVICE_PATH,\r
                                                  MSG_IPv4_DP,\r
@@ -1757,6 +1812,13 @@ DevPathFromTextIPv4 (
   }\r
 \r
   StrToIPv4Addr (&LocalIPStr, &IPv4->LocalIpAddress);\r
+  if (!IS_NULL (*GatewayIPStr) && !IS_NULL (*SubnetMaskStr)) {\r
+    StrToIPv4Addr (&GatewayIPStr,  &IPv4->GatewayIpAddress);\r
+    StrToIPv4Addr (&SubnetMaskStr, &IPv4->SubnetMask);\r
+  } else {\r
+    ZeroMem (&IPv4->GatewayIpAddress, sizeof (IPv4->GatewayIpAddress));\r
+    ZeroMem (&IPv4->SubnetMask,    sizeof (IPv4->SubnetMask));\r
+  }\r
 \r
   IPv4->LocalPort       = 0;\r
   IPv4->RemotePort      = 0;\r
@@ -2810,6 +2872,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE DevPathFromTextTable[]
   {L"Ctrl", DevPathFromTextCtrl},\r
   {L"Acpi", DevPathFromTextAcpi},\r
   {L"PciRoot", DevPathFromTextPciRoot},\r
+  {L"PcieRoot", DevPathFromTextPcieRoot},\r
   {L"Floppy", DevPathFromTextFloppy},\r
   {L"Keyboard", DevPathFromTextKeyboard},\r
   {L"Serial", DevPathFromTextSerial},\r
@@ -2820,6 +2883,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE DevPathFromTextTable[]
   {L"Ata", DevPathFromTextAta},\r
   {L"Scsi", DevPathFromTextScsi},\r
   {L"Fibre", DevPathFromTextFibre},\r
+  {L"FibreEx", DevPathFromTextFibreEx},\r
   {L"I1394", DevPathFromText1394},\r
   {L"USB", DevPathFromTextUsb},\r
   {L"I2O", DevPathFromTextI2O},\r
index 224b24ba62299d755bc97b1e4d8422a47398a2c0..d169c4d0d5013a5bad7ef0f4840b0765c599f6e9 100644 (file)
@@ -37,36 +37,32 @@ CatPrint (
   )\r
 {\r
   UINT16  *AppendStr;\r
+  UINTN   AppendCount;\r
   VA_LIST Args;\r
-  UINTN   Size;\r
 \r
   AppendStr = AllocateZeroPool (0x1000);\r
-  if (AppendStr == NULL) {\r
-    return Str->Str;\r
-  }\r
+  ASSERT (AppendStr != NULL);\r
 \r
   VA_START (Args, Fmt);\r
-  UnicodeVSPrint (AppendStr, 0x1000, Fmt, Args);\r
+  AppendCount = UnicodeVSPrint (AppendStr, 0x1000, Fmt, Args);\r
   VA_END (Args);\r
-  if (NULL == Str->Str) {\r
-    Size   = StrSize (AppendStr);\r
-    Str->Str  = AllocateZeroPool (Size);\r
-    ASSERT (Str->Str != NULL);\r
-  } else {\r
-    Size = StrSize (AppendStr) - sizeof (UINT16);\r
-    Size = Size + StrSize (Str->Str);\r
+\r
+  if (Str->Length + AppendCount * sizeof (CHAR16) > Str->Capacity) {\r
+    Str->Capacity = Str->Length + (AppendCount + 1) * sizeof (CHAR16) * 2;\r
     Str->Str = ReallocatePool (\r
-                 StrSize (Str->Str),\r
-                 Size,\r
+                 Str->Length,\r
+                 Str->Capacity,\r
                  Str->Str\r
                  );\r
     ASSERT (Str->Str != NULL);\r
   }\r
 \r
-  Str->MaxLen = MAX_CHAR * sizeof (UINT16);\r
-  if (Size < Str->MaxLen) {\r
+  if (Str->Length == 0) {\r
+    StrCpy (Str->Str, AppendStr);\r
+    Str->Length = (AppendCount + 1) * sizeof (CHAR16);\r
+  } else {\r
     StrCat (Str->Str, AppendStr);\r
-    Str->Len = Size - sizeof (UINT16);\r
+    Str->Length += AppendCount * sizeof (CHAR16);\r
   }\r
 \r
   FreePool (AppendStr);\r
@@ -97,7 +93,7 @@ DevPathToTextPci (
   PCI_DEVICE_PATH *Pci;\r
 \r
   Pci = DevPath;\r
-  CatPrint (Str, L"Pci(0x%x,0x%x)", (UINTN) Pci->Device, (UINTN) Pci->Function);\r
+  CatPrint (Str, L"Pci(0x%x,0x%x)", Pci->Device, Pci->Function);\r
 }\r
 \r
 /**\r
@@ -124,7 +120,7 @@ DevPathToTextPccard (
   PCCARD_DEVICE_PATH  *Pccard;\r
 \r
   Pccard = DevPath;\r
-  CatPrint (Str, L"PcCard(0x%x)", (UINTN) Pccard->FunctionNumber);\r
+  CatPrint (Str, L"PcCard(0x%x)", Pccard->FunctionNumber);\r
 }\r
 \r
 /**\r
@@ -154,7 +150,7 @@ DevPathToTextMemMap (
   CatPrint (\r
     Str,\r
     L"MemoryMapped(0x%x,0x%lx,0x%lx)",\r
-    (UINTN) MemMap->MemoryType,\r
+    MemMap->MemoryType,\r
     MemMap->StartingAddress,\r
     MemMap->EndingAddress\r
     );\r
@@ -235,7 +231,7 @@ DevPathToTextVendor (
           L"SAS(0x%lx,0x%lx,0x%x,",\r
           ((SAS_DEVICE_PATH *) Vendor)->SasAddress,\r
           ((SAS_DEVICE_PATH *) Vendor)->Lun,\r
-          (UINTN) ((SAS_DEVICE_PATH *) Vendor)->RelativeTargetPort\r
+          ((SAS_DEVICE_PATH *) Vendor)->RelativeTargetPort\r
           );\r
         Info = (((SAS_DEVICE_PATH *) Vendor)->DeviceTopology);\r
         if ((Info & 0x0f) == 0) {\r
@@ -251,13 +247,13 @@ DevPathToTextVendor (
           if ((Info & 0x0f) == 1) {\r
             CatPrint (Str, L"0,");\r
           } else {\r
-            CatPrint (Str, L"0x%x,",(UINTN) (Info >> 8) & 0xff);\r
+            CatPrint (Str, L"0x%x,", (Info >> 8) & 0xff);\r
           }\r
         } else {\r
           CatPrint (Str, L"0,0,0,0,");\r
         }\r
 \r
-        CatPrint (Str, L"0x%x)", (UINTN) ((SAS_DEVICE_PATH *) Vendor)->Reserved);\r
+        CatPrint (Str, L"0x%x)", ((SAS_DEVICE_PATH *) Vendor)->Reserved);\r
         return ;\r
       } else if (CompareGuid (&Vendor->Guid, &gEfiDebugPortProtocolGuid)) {\r
         CatPrint (Str, L"DebugPort()");\r
@@ -280,7 +276,7 @@ DevPathToTextVendor (
   if (DataLength != 0) {\r
     CatPrint (Str, L",");\r
     for (Index = 0; Index < DataLength; Index++) {\r
-      CatPrint (Str, L"%02x", (UINTN) ((VENDOR_DEVICE_PATH_WITH_DATA *) Vendor)->VendorDefinedData[Index]);\r
+      CatPrint (Str, L"%02x", ((VENDOR_DEVICE_PATH_WITH_DATA *) Vendor)->VendorDefinedData[Index]);\r
     }\r
   }\r
 \r
@@ -314,7 +310,7 @@ DevPathToTextController (
   CatPrint (\r
     Str,\r
     L"Ctrl(0x%x)",\r
-    (UINTN) Controller->ControllerNumber\r
+    Controller->ControllerNumber\r
     );\r
 }\r
 \r
@@ -345,31 +341,35 @@ DevPathToTextAcpi (
   if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
     switch (EISA_ID_TO_NUM (Acpi->HID)) {\r
     case 0x0a03:\r
-      CatPrint (Str, L"PciRoot(0x%x)", (UINTN) Acpi->UID);\r
+      CatPrint (Str, L"PciRoot(0x%x)", Acpi->UID);\r
+      break;\r
+\r
+    case 0x0a08:\r
+      CatPrint (Str, L"PcieRoot(0x%x)", Acpi->UID);\r
       break;\r
 \r
     case 0x0604:\r
-      CatPrint (Str, L"Floppy(0x%x)", (UINTN) Acpi->UID);\r
+      CatPrint (Str, L"Floppy(0x%x)", Acpi->UID);\r
       break;\r
 \r
     case 0x0301:\r
-      CatPrint (Str, L"Keyboard(0x%x)", (UINTN) Acpi->UID);\r
+      CatPrint (Str, L"Keyboard(0x%x)", Acpi->UID);\r
       break;\r
 \r
     case 0x0501:\r
-      CatPrint (Str, L"Serial(0x%x)", (UINTN) Acpi->UID);\r
+      CatPrint (Str, L"Serial(0x%x)", Acpi->UID);\r
       break;\r
 \r
     case 0x0401:\r
-      CatPrint (Str, L"ParallelPort(0x%x)", (UINTN) Acpi->UID);\r
+      CatPrint (Str, L"ParallelPort(0x%x)", Acpi->UID);\r
       break;\r
 \r
     default:\r
-      CatPrint (Str, L"Acpi(PNP%04x,0x%x)", (UINTN) EISA_ID_TO_NUM (Acpi->HID), (UINTN) Acpi->UID);\r
+      CatPrint (Str, L"Acpi(PNP%04x,0x%x)", EISA_ID_TO_NUM (Acpi->HID), Acpi->UID);\r
       break;\r
     }\r
   } else {\r
-    CatPrint (Str, L"Acpi(0x%08x,0x%x)", (UINTN) Acpi->HID, (UINTN) Acpi->UID);\r
+    CatPrint (Str, L"Acpi(0x%08x,0x%x)", Acpi->HID, Acpi->UID);\r
   }\r
 }\r
 \r
@@ -465,7 +465,7 @@ DevPathToTextAcpiEx (
       if (AcpiEx->UID == 0) {\r
         CatPrint (Str, L"%a,", UIDStr);\r
       } else {\r
-        CatPrint (Str, L"0x%x,", (UINTN) AcpiEx->UID);\r
+        CatPrint (Str, L"0x%x,", AcpiEx->UID);\r
       }\r
 \r
       if (AcpiEx->CID == 0) {\r
@@ -479,7 +479,7 @@ DevPathToTextAcpiEx (
         L"AcpiEx(%s,%s,0x%x,%a,%a,%a)",\r
         HIDText,\r
         CIDText,\r
-        (UINTN) AcpiEx->UID,\r
+        AcpiEx->UID,\r
         HIDStr,\r
         CIDStr,\r
         UIDStr\r
@@ -518,9 +518,9 @@ DevPathToTextAcpiAdr (
   Length             = (UINT16) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) AcpiAdr);\r
   AdditionalAdrCount = (UINT16) ((Length - 8) / 4);\r
 \r
-  CatPrint (Str, L"AcpiAdr(0x%x", (UINTN) AcpiAdr->ADR);\r
+  CatPrint (Str, L"AcpiAdr(0x%x", AcpiAdr->ADR);\r
   for (Index = 0; Index < AdditionalAdrCount; Index++) {\r
-    CatPrint (Str, L",0x%x", (UINTN) *(UINT32 *) ((UINT8 *) AcpiAdr + 8 + Index * 4));\r
+    CatPrint (Str, L",0x%x", *(UINT32 *) ((UINT8 *) AcpiAdr + 8 + Index * 4));\r
   }\r
   CatPrint (Str, L")");\r
 }\r
@@ -551,14 +551,14 @@ DevPathToTextAtapi (
   Atapi = DevPath;\r
 \r
   if (DisplayOnly) {\r
-    CatPrint (Str, L"Ata(0x%x)", (UINTN) Atapi->Lun);\r
+    CatPrint (Str, L"Ata(0x%x)", Atapi->Lun);\r
   } else {\r
     CatPrint (\r
       Str,\r
       L"Ata(%s,%s,0x%x)",\r
       (Atapi->PrimarySecondary == 1) ? L"Secondary" : L"Primary",\r
       (Atapi->SlaveMaster == 1) ? L"Slave" : L"Master",\r
-      (UINTN) Atapi->Lun\r
+      Atapi->Lun\r
       );\r
   }\r
 }\r
@@ -587,7 +587,7 @@ DevPathToTextScsi (
   SCSI_DEVICE_PATH  *Scsi;\r
 \r
   Scsi = DevPath;\r
-  CatPrint (Str, L"Scsi(0x%x,0x%x)", (UINTN) Scsi->Pun, (UINTN) Scsi->Lun);\r
+  CatPrint (Str, L"Scsi(0x%x,0x%x)", Scsi->Pun, Scsi->Lun);\r
 }\r
 \r
 /**\r
@@ -617,6 +617,42 @@ DevPathToTextFibre (
   CatPrint (Str, L"Fibre(0x%lx,0x%lx)", Fibre->WWN, Fibre->Lun);\r
 }\r
 \r
+/**\r
+  Converts a FibreEx device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextFibreEx (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  FIBRECHANNELEX_DEVICE_PATH  *FibreEx;\r
+  UINTN                       Index;\r
+\r
+  FibreEx = DevPath;\r
+  CatPrint (Str, L"FibreEx(0x");\r
+  for (Index = 0; Index < sizeof (FibreEx->WWN) / sizeof (FibreEx->WWN[0]); Index++) {\r
+    CatPrint (Str, L"%02x", FibreEx->WWN[Index]);\r
+  }\r
+  CatPrint (Str, L",0x");\r
+  for (Index = 0; Index < sizeof (FibreEx->Lun) / sizeof (FibreEx->Lun[0]); Index++) {\r
+    CatPrint (Str, L"%02x", FibreEx->Lun[Index]);\r
+  }\r
+  CatPrint (Str, L")");\r
+}\r
+\r
 /**\r
   Converts a 1394 device path structure to its string representative.\r
 \r
@@ -717,9 +753,9 @@ DevPathToTextUsbWWID (
   CatPrint (\r
     Str,\r
     L"UsbWwid(0x%x,0x%x,0x%x,\"%s\")",\r
-    (UINTN) UsbWWId->VendorId,\r
-    (UINTN) UsbWWId->ProductId,\r
-    (UINTN) UsbWWId->InterfaceNumber,\r
+    UsbWWId->VendorId,\r
+    UsbWWId->ProductId,\r
+    UsbWWId->InterfaceNumber,\r
     SerialNumberStr\r
     );\r
 }\r
@@ -748,7 +784,7 @@ DevPathToTextLogicalUnit (
   DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;\r
 \r
   LogicalUnit = DevPath;\r
-  CatPrint (Str, L"Unit(0x%x)", (UINTN) LogicalUnit->Lun);\r
+  CatPrint (Str, L"Unit(0x%x)", LogicalUnit->Lun);\r
 }\r
 \r
 /**\r
@@ -837,10 +873,10 @@ DevPathToTextUsbClass (
     CatPrint (\r
       Str,\r
       L"(0x%x,0x%x,0x%x,0x%x)",\r
-      (UINTN) UsbClass->VendorId,\r
-      (UINTN) UsbClass->ProductId,\r
-      (UINTN) UsbClass->DeviceSubClass,\r
-      (UINTN) UsbClass->DeviceProtocol\r
+      UsbClass->VendorId,\r
+      UsbClass->ProductId,\r
+      UsbClass->DeviceSubClass,\r
+      UsbClass->DeviceProtocol\r
       );\r
     return;\r
   }\r
@@ -850,27 +886,27 @@ DevPathToTextUsbClass (
       CatPrint (\r
         Str,\r
         L"UsbDeviceFirmwareUpdate(0x%x,0x%x,0x%x)",\r
-        (UINTN) UsbClass->VendorId,\r
-        (UINTN) UsbClass->ProductId,\r
-        (UINTN) UsbClass->DeviceProtocol\r
+        UsbClass->VendorId,\r
+        UsbClass->ProductId,\r
+        UsbClass->DeviceProtocol\r
         );\r
       return;\r
     } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_IRDA_BRIDGE) {\r
       CatPrint (\r
         Str,\r
         L"UsbIrdaBridge(0x%x,0x%x,0x%x)",\r
-        (UINTN) UsbClass->VendorId,\r
-        (UINTN) UsbClass->ProductId,\r
-        (UINTN) UsbClass->DeviceProtocol\r
+        UsbClass->VendorId,\r
+        UsbClass->ProductId,\r
+        UsbClass->DeviceProtocol\r
         );\r
       return;\r
     } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_TEST) {\r
       CatPrint (\r
         Str,\r
         L"UsbTestAndMeasurement(0x%x,0x%x,0x%x)",\r
-        (UINTN) UsbClass->VendorId,\r
-        (UINTN) UsbClass->ProductId,\r
-        (UINTN) UsbClass->DeviceProtocol\r
+        UsbClass->VendorId,\r
+        UsbClass->ProductId,\r
+        UsbClass->DeviceProtocol\r
         );\r
       return;\r
     }\r
@@ -879,11 +915,11 @@ DevPathToTextUsbClass (
   CatPrint (\r
     Str,\r
     L"UsbClass(0x%x,0x%x,0x%x,0x%x,0x%x)",\r
-    (UINTN) UsbClass->VendorId,\r
-    (UINTN) UsbClass->ProductId,\r
-    (UINTN) UsbClass->DeviceClass,\r
-    (UINTN) UsbClass->DeviceSubClass,\r
-    (UINTN) UsbClass->DeviceProtocol\r
+    UsbClass->VendorId,\r
+    UsbClass->ProductId,\r
+    UsbClass->DeviceClass,\r
+    UsbClass->DeviceSubClass,\r
+    UsbClass->DeviceProtocol\r
     );\r
 }\r
 \r
@@ -915,16 +951,16 @@ DevPathToTextSata (
     CatPrint (\r
       Str,\r
       L"Sata(0x%x,0x%x)",\r
-      (UINTN) Sata->HBAPortNumber,\r
-      (UINTN) Sata->Lun\r
+      Sata->HBAPortNumber,\r
+      Sata->Lun\r
       );\r
   } else {\r
     CatPrint (\r
       Str,\r
       L"Sata(0x%x,0x%x,0x%x)",\r
-      (UINTN) Sata->HBAPortNumber,\r
-      (UINTN) Sata->PortMultiplierPortNumber,\r
-      (UINTN) Sata->Lun\r
+      Sata->HBAPortNumber,\r
+      Sata->PortMultiplierPortNumber,\r
+      Sata->Lun\r
       );\r
   }\r
 }\r
@@ -953,7 +989,7 @@ DevPathToTextI2O (
   I2O_DEVICE_PATH *I2ODevPath;\r
 \r
   I2ODevPath = DevPath;\r
-  CatPrint (Str, L"I2O(0x%x)", (UINTN) I2ODevPath->Tid);\r
+  CatPrint (Str, L"I2O(0x%x)", I2ODevPath->Tid);\r
 }\r
 \r
 /**\r
@@ -991,10 +1027,10 @@ DevPathToTextMacAddr (
   CatPrint (Str, L"MAC(");\r
 \r
   for (Index = 0; Index < HwAddressSize; Index++) {\r
-    CatPrint (Str, L"%02x", (UINTN) MacDevPath->MacAddress.Addr[Index]);\r
+    CatPrint (Str, L"%02x", MacDevPath->MacAddress.Addr[Index]);\r
   }\r
 \r
-  CatPrint (Str, L",0x%x)", (UINTN) MacDevPath->IfType);\r
+  CatPrint (Str, L",0x%x)", MacDevPath->IfType);\r
 }\r
 \r
 /**\r
@@ -1047,10 +1083,10 @@ DevPathToTextIPv4 (
     CatPrint (\r
       Str,\r
       L"IPv4(%d.%d.%d.%d)",\r
-      (UINTN) IPDevPath->RemoteIpAddress.Addr[0],\r
-      (UINTN) IPDevPath->RemoteIpAddress.Addr[1],\r
-      (UINTN) IPDevPath->RemoteIpAddress.Addr[2],\r
-      (UINTN) IPDevPath->RemoteIpAddress.Addr[3]\r
+      IPDevPath->RemoteIpAddress.Addr[0],\r
+      IPDevPath->RemoteIpAddress.Addr[1],\r
+      IPDevPath->RemoteIpAddress.Addr[2],\r
+      IPDevPath->RemoteIpAddress.Addr[3]\r
       );\r
     return ;\r
   }\r
@@ -1058,10 +1094,10 @@ DevPathToTextIPv4 (
   CatPrint (\r
     Str,\r
     L"IPv4(%d.%d.%d.%d,",\r
-    (UINTN) IPDevPath->RemoteIpAddress.Addr[0],\r
-    (UINTN) IPDevPath->RemoteIpAddress.Addr[1],\r
-    (UINTN) IPDevPath->RemoteIpAddress.Addr[2],\r
-    (UINTN) IPDevPath->RemoteIpAddress.Addr[3]\r
+    IPDevPath->RemoteIpAddress.Addr[0],\r
+    IPDevPath->RemoteIpAddress.Addr[1],\r
+    IPDevPath->RemoteIpAddress.Addr[2],\r
+    IPDevPath->RemoteIpAddress.Addr[3]\r
     );\r
 \r
   CatNetworkProtocol (\r
@@ -1071,13 +1107,28 @@ DevPathToTextIPv4 (
 \r
   CatPrint (\r
     Str,\r
-    L",%s,%d.%d.%d.%d)",\r
+    L",%s,%d.%d.%d.%d",\r
     IPDevPath->StaticIpAddress ? L"Static" : L"DHCP",\r
-    (UINTN) IPDevPath->LocalIpAddress.Addr[0],\r
-    (UINTN) IPDevPath->LocalIpAddress.Addr[1],\r
-    (UINTN) IPDevPath->LocalIpAddress.Addr[2],\r
-    (UINTN) IPDevPath->LocalIpAddress.Addr[3]\r
+    IPDevPath->LocalIpAddress.Addr[0],\r
+    IPDevPath->LocalIpAddress.Addr[1],\r
+    IPDevPath->LocalIpAddress.Addr[2],\r
+    IPDevPath->LocalIpAddress.Addr[3]\r
     );\r
+  if (DevicePathNodeLength (IPDevPath) == sizeof (IPv4_DEVICE_PATH)) {\r
+    CatPrint (\r
+      Str,\r
+      L",%d.%d.%d.%d,%d.%d.%d.%d",\r
+      IPDevPath->GatewayIpAddress.Addr[0],\r
+      IPDevPath->GatewayIpAddress.Addr[1],\r
+      IPDevPath->GatewayIpAddress.Addr[2],\r
+      IPDevPath->GatewayIpAddress.Addr[3],\r
+      IPDevPath->SubnetMask.Addr[0],\r
+      IPDevPath->SubnetMask.Addr[1],\r
+      IPDevPath->SubnetMask.Addr[2],\r
+      IPDevPath->SubnetMask.Addr[3]\r
+      );\r
+  }\r
+  CatPrint (Str, L")");\r
 }\r
 \r
 /**\r
@@ -1108,22 +1159,22 @@ DevPathToTextIPv6 (
     CatPrint (\r
       Str,\r
       L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",\r
-      (UINTN) IPDevPath->RemoteIpAddress.Addr[0],\r
-      (UINTN) IPDevPath->RemoteIpAddress.Addr[1],\r
-      (UINTN) IPDevPath->RemoteIpAddress.Addr[2],\r
-      (UINTN) IPDevPath->RemoteIpAddress.Addr[3],\r
-      (UINTN) IPDevPath->RemoteIpAddress.Addr[4],\r
-      (UINTN) IPDevPath->RemoteIpAddress.Addr[5],\r
-      (UINTN) IPDevPath->RemoteIpAddress.Addr[6],\r
-      (UINTN) IPDevPath->RemoteIpAddress.Addr[7],\r
-      (UINTN) IPDevPath->RemoteIpAddress.Addr[8],\r
-      (UINTN) IPDevPath->RemoteIpAddress.Addr[9],\r
-      (UINTN) IPDevPath->RemoteIpAddress.Addr[10],\r
-      (UINTN) IPDevPath->RemoteIpAddress.Addr[11],\r
-      (UINTN) IPDevPath->RemoteIpAddress.Addr[12],\r
-      (UINTN) IPDevPath->RemoteIpAddress.Addr[13],\r
-      (UINTN) IPDevPath->RemoteIpAddress.Addr[14],\r
-      (UINTN) IPDevPath->RemoteIpAddress.Addr[15]\r
+      IPDevPath->RemoteIpAddress.Addr[0],\r
+      IPDevPath->RemoteIpAddress.Addr[1],\r
+      IPDevPath->RemoteIpAddress.Addr[2],\r
+      IPDevPath->RemoteIpAddress.Addr[3],\r
+      IPDevPath->RemoteIpAddress.Addr[4],\r
+      IPDevPath->RemoteIpAddress.Addr[5],\r
+      IPDevPath->RemoteIpAddress.Addr[6],\r
+      IPDevPath->RemoteIpAddress.Addr[7],\r
+      IPDevPath->RemoteIpAddress.Addr[8],\r
+      IPDevPath->RemoteIpAddress.Addr[9],\r
+      IPDevPath->RemoteIpAddress.Addr[10],\r
+      IPDevPath->RemoteIpAddress.Addr[11],\r
+      IPDevPath->RemoteIpAddress.Addr[12],\r
+      IPDevPath->RemoteIpAddress.Addr[13],\r
+      IPDevPath->RemoteIpAddress.Addr[14],\r
+      IPDevPath->RemoteIpAddress.Addr[15]\r
       );\r
     return ;\r
   }\r
@@ -1131,22 +1182,22 @@ DevPathToTextIPv6 (
   CatPrint (\r
     Str,\r
     L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x,",\r
-    (UINTN) IPDevPath->RemoteIpAddress.Addr[0],\r
-    (UINTN) IPDevPath->RemoteIpAddress.Addr[1],\r
-    (UINTN) IPDevPath->RemoteIpAddress.Addr[2],\r
-    (UINTN) IPDevPath->RemoteIpAddress.Addr[3],\r
-    (UINTN) IPDevPath->RemoteIpAddress.Addr[4],\r
-    (UINTN) IPDevPath->RemoteIpAddress.Addr[5],\r
-    (UINTN) IPDevPath->RemoteIpAddress.Addr[6],\r
-    (UINTN) IPDevPath->RemoteIpAddress.Addr[7],\r
-    (UINTN) IPDevPath->RemoteIpAddress.Addr[8],\r
-    (UINTN) IPDevPath->RemoteIpAddress.Addr[9],\r
-    (UINTN) IPDevPath->RemoteIpAddress.Addr[10],\r
-    (UINTN) IPDevPath->RemoteIpAddress.Addr[11],\r
-    (UINTN) IPDevPath->RemoteIpAddress.Addr[12],\r
-    (UINTN) IPDevPath->RemoteIpAddress.Addr[13],\r
-    (UINTN) IPDevPath->RemoteIpAddress.Addr[14],\r
-    (UINTN) IPDevPath->RemoteIpAddress.Addr[15]\r
+    IPDevPath->RemoteIpAddress.Addr[0],\r
+    IPDevPath->RemoteIpAddress.Addr[1],\r
+    IPDevPath->RemoteIpAddress.Addr[2],\r
+    IPDevPath->RemoteIpAddress.Addr[3],\r
+    IPDevPath->RemoteIpAddress.Addr[4],\r
+    IPDevPath->RemoteIpAddress.Addr[5],\r
+    IPDevPath->RemoteIpAddress.Addr[6],\r
+    IPDevPath->RemoteIpAddress.Addr[7],\r
+    IPDevPath->RemoteIpAddress.Addr[8],\r
+    IPDevPath->RemoteIpAddress.Addr[9],\r
+    IPDevPath->RemoteIpAddress.Addr[10],\r
+    IPDevPath->RemoteIpAddress.Addr[11],\r
+    IPDevPath->RemoteIpAddress.Addr[12],\r
+    IPDevPath->RemoteIpAddress.Addr[13],\r
+    IPDevPath->RemoteIpAddress.Addr[14],\r
+    IPDevPath->RemoteIpAddress.Addr[15]\r
     );\r
     \r
   CatNetworkProtocol (\r
@@ -1158,22 +1209,22 @@ DevPathToTextIPv6 (
     Str,\r
     L",%s,%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",\r
     IPDevPath->StaticIpAddress ? L"Static" : L"DHCP",\r
-    (UINTN) IPDevPath->LocalIpAddress.Addr[0],\r
-    (UINTN) IPDevPath->LocalIpAddress.Addr[1],\r
-    (UINTN) IPDevPath->LocalIpAddress.Addr[2],\r
-    (UINTN) IPDevPath->LocalIpAddress.Addr[3],\r
-    (UINTN) IPDevPath->LocalIpAddress.Addr[4],\r
-    (UINTN) IPDevPath->LocalIpAddress.Addr[5],\r
-    (UINTN) IPDevPath->LocalIpAddress.Addr[6],\r
-    (UINTN) IPDevPath->LocalIpAddress.Addr[7],\r
-    (UINTN) IPDevPath->LocalIpAddress.Addr[8],\r
-    (UINTN) IPDevPath->LocalIpAddress.Addr[9],\r
-    (UINTN) IPDevPath->LocalIpAddress.Addr[10],\r
-    (UINTN) IPDevPath->LocalIpAddress.Addr[11],\r
-    (UINTN) IPDevPath->LocalIpAddress.Addr[12],\r
-    (UINTN) IPDevPath->LocalIpAddress.Addr[13],\r
-    (UINTN) IPDevPath->LocalIpAddress.Addr[14],\r
-    (UINTN) IPDevPath->LocalIpAddress.Addr[15]\r
+    IPDevPath->LocalIpAddress.Addr[0],\r
+    IPDevPath->LocalIpAddress.Addr[1],\r
+    IPDevPath->LocalIpAddress.Addr[2],\r
+    IPDevPath->LocalIpAddress.Addr[3],\r
+    IPDevPath->LocalIpAddress.Addr[4],\r
+    IPDevPath->LocalIpAddress.Addr[5],\r
+    IPDevPath->LocalIpAddress.Addr[6],\r
+    IPDevPath->LocalIpAddress.Addr[7],\r
+    IPDevPath->LocalIpAddress.Addr[8],\r
+    IPDevPath->LocalIpAddress.Addr[9],\r
+    IPDevPath->LocalIpAddress.Addr[10],\r
+    IPDevPath->LocalIpAddress.Addr[11],\r
+    IPDevPath->LocalIpAddress.Addr[12],\r
+    IPDevPath->LocalIpAddress.Addr[13],\r
+    IPDevPath->LocalIpAddress.Addr[14],\r
+    IPDevPath->LocalIpAddress.Addr[15]\r
     );\r
 }\r
 \r
@@ -1204,7 +1255,7 @@ DevPathToTextInfiniBand (
   CatPrint (\r
     Str,\r
     L"Infiniband(0x%x,%g,0x%lx,0x%lx,0x%lx)",\r
-    (UINTN) InfiniBand->ResourceFlags,\r
+    InfiniBand->ResourceFlags,\r
     InfiniBand->PortGid,\r
     InfiniBand->ServiceId,\r
     InfiniBand->TargetPortId,\r
@@ -1276,7 +1327,7 @@ DevPathToTextUart (
   if (Uart->DataBits == 0) {\r
     CatPrint (Str, L"DEFAULT,");\r
   } else {\r
-    CatPrint (Str, L"%d,", (UINTN) Uart->DataBits);\r
+    CatPrint (Str, L"%d,", Uart->DataBits);\r
   }\r
 \r
   CatPrint (Str, L"%c,", Parity);\r
@@ -1333,7 +1384,7 @@ DevPathToTextiSCSI (
     Str,\r
     L"iSCSI(%a,0x%x,0x%lx,",\r
     ISCSIDevPath->TargetName,\r
-    (UINTN) ISCSIDevPath->TargetPortalGroupTag,\r
+    ISCSIDevPath->TargetPortalGroupTag,\r
     ISCSIDevPath->Lun\r
     );\r
 \r
@@ -1376,7 +1427,7 @@ DevPathToTextVlan (
   VLAN_DEVICE_PATH  *Vlan;\r
 \r
   Vlan = DevPath;\r
-  CatPrint (Str, L"Vlan(%d)", (UINTN) Vlan->VlanId);\r
+  CatPrint (Str, L"Vlan(%d)", Vlan->VlanId);\r
 }\r
 \r
 /**\r
@@ -1408,9 +1459,9 @@ DevPathToTextHardDrive (
     CatPrint (\r
       Str,\r
       L"HD(%d,%s,0x%08x,",\r
-      (UINTN) Hd->PartitionNumber,\r
+      Hd->PartitionNumber,\r
       L"MBR",\r
-      (UINTN) *((UINT32 *) (&(Hd->Signature[0])))\r
+      *((UINT32 *) (&(Hd->Signature[0])))\r
       );\r
     break;\r
 \r
@@ -1418,7 +1469,7 @@ DevPathToTextHardDrive (
     CatPrint (\r
       Str,\r
       L"HD(%d,%s,%g,",\r
-      (UINTN) Hd->PartitionNumber,\r
+      Hd->PartitionNumber,\r
       L"GPT",\r
       (EFI_GUID *) &(Hd->Signature[0])\r
       );\r
@@ -1428,8 +1479,8 @@ DevPathToTextHardDrive (
     CatPrint (\r
       Str,\r
       L"HD(%d,%d,0,",\r
-      (UINTN) Hd->PartitionNumber,\r
-      (UINTN) Hd->SignatureType\r
+      Hd->PartitionNumber,\r
+      Hd->SignatureType\r
       );\r
     break;\r
   }\r
@@ -1462,11 +1513,11 @@ DevPathToTextCDROM (
 \r
   Cd = DevPath;\r
   if (DisplayOnly) {\r
-    CatPrint (Str, L"CDROM(0x%x)", (UINTN) Cd->BootEntry);\r
+    CatPrint (Str, L"CDROM(0x%x)", Cd->BootEntry);\r
     return ;\r
   }\r
 \r
-  CatPrint (Str, L"CDROM(0x%x,0x%lx,0x%lx)", (UINTN) Cd->BootEntry, Cd->PartitionStart, Cd->PartitionSize);\r
+  CatPrint (Str, L"CDROM(0x%x,0x%lx,0x%lx)", Cd->BootEntry, Cd->PartitionStart, Cd->PartitionSize);\r
 }\r
 \r
 /**\r
@@ -1667,7 +1718,7 @@ DevPathToTextBBS (
   if (Type != NULL) {\r
     CatPrint (Str, L"BBS(%s,%a", Type, Bbs->String);\r
   } else {\r
-    CatPrint (Str, L"BBS(0x%x,%a", (UINTN) Bbs->DeviceType, Bbs->String);\r
+    CatPrint (Str, L"BBS(0x%x,%a", Bbs->DeviceType, Bbs->String);\r
   }\r
 \r
   if (DisplayOnly) {\r
@@ -1675,7 +1726,7 @@ DevPathToTextBBS (
     return ;\r
   }\r
 \r
-  CatPrint (Str, L",0x%x)", (UINTN) Bbs->StatusFlag);\r
+  CatPrint (Str, L",0x%x)", Bbs->StatusFlag);\r
 }\r
 \r
 /**\r
@@ -1738,6 +1789,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE DevPathToTextTable
   {MESSAGING_DEVICE_PATH, MSG_ATAPI_DP, DevPathToTextAtapi},\r
   {MESSAGING_DEVICE_PATH, MSG_SCSI_DP, DevPathToTextScsi},\r
   {MESSAGING_DEVICE_PATH, MSG_FIBRECHANNEL_DP, DevPathToTextFibre},\r
+  {MESSAGING_DEVICE_PATH, MSG_FIBRECHANNELEX_DP, DevPathToTextFibreEx},\r
   {MESSAGING_DEVICE_PATH, MSG_1394_DP, DevPathToText1394},\r
   {MESSAGING_DEVICE_PATH, MSG_USB_DP, DevPathToTextUsb},\r
   {MESSAGING_DEVICE_PATH, MSG_USB_WWID_DP, DevPathToTextUsbWWID},\r
@@ -1791,7 +1843,6 @@ ConvertDeviceNodeToText (
 {\r
   POOL_PRINT  Str;\r
   UINTN       Index;\r
-  UINTN       NewSize;\r
   VOID        (*DumpNode)(POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);\r
 \r
   if (DeviceNode == NULL) {\r
@@ -1824,13 +1875,6 @@ ConvertDeviceNodeToText (
   //\r
   DumpNode (&Str, (VOID *) DeviceNode, DisplayOnly, AllowShortcuts);\r
 \r
-  //\r
-  // Shrink pool used for string allocation\r
-  //\r
-  NewSize = (Str.Len + 1) * sizeof (CHAR16);\r
-  Str.Str = ReallocatePool (NewSize, NewSize, Str.Str);\r
-  ASSERT (Str.Str != NULL);\r
-  Str.Str[Str.Len] = 0;\r
   return Str.Str;\r
 }\r
 \r
@@ -1861,7 +1905,6 @@ ConvertDevicePathToText (
   EFI_DEVICE_PATH_PROTOCOL  *DevPathNode;\r
   EFI_DEVICE_PATH_PROTOCOL  *AlignedDevPathNode;\r
   UINTN                     Index;\r
-  UINTN                     NewSize;\r
   VOID                      (*DumpNode) (POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);\r
 \r
   if (DevicePath == NULL) {\r
@@ -1897,8 +1940,8 @@ ConvertDevicePathToText (
     //\r
     //  Put a path separator in if needed\r
     //\r
-    if ((Str.Len != 0) && DumpNode != DevPathToTextEndInstance) {\r
-      if (*(Str.Str + Str.Len / sizeof (CHAR16) - 1) != L',') {\r
+    if ((Str.Length != 0) && (DumpNode != DevPathToTextEndInstance)) {\r
+      if (*(Str.Str + Str.Length / sizeof (CHAR16) - 1) != L',') {\r
         CatPrint (&Str, L"/");\r
       }\r
     }\r
@@ -1916,9 +1959,5 @@ ConvertDevicePathToText (
     DevPathNode = NextDevicePathNode (DevPathNode);\r
   }\r
 \r
-  NewSize = (Str.Len + 1) * sizeof (CHAR16);\r
-  Str.Str = ReallocatePool (NewSize, NewSize, Str.Str);\r
-  ASSERT (Str.Str != NULL);\r
-  Str.Str[Str.Len] = 0;\r
   return Str.Str;\r
 }\r