]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/GenericBdsLib/DevicePath.c
Clean up BDS lib to remove assembly files, remove R8Lib.h & R8Lib.c by applying Mde...
[mirror_edk2.git] / MdeModulePkg / Library / GenericBdsLib / DevicePath.c
index 6701fd2b44be15c91676a98e9cf2be8dce9d66f6..7801def6b6c47d78ecdb4829fe93a725e32a9fab 100644 (file)
-/** @file
-
-Copyright (c) 2004 - 2007, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution.  The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-Module Name:
-
-  DevicePath.c
-
-Abstract:
-
-  BDS internal function define the default device path string, it can be
-  replaced by platform device path.
-
-
-**/
-
-#include "InternalBdsLib.h"
-
-//
-// Platform Code should implement the Vendor specific Device Path display routine.
-//
-extern
-VOID
-DevPathVendor (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-;
-
-EFI_GUID  mEfiDevicePathMessagingUartFlowControlGuid = DEVICE_PATH_MESSAGING_UART_FLOW_CONTROL;
-
-EFI_GUID mEfiDevicePathMessagingSASGuid = DEVICE_PATH_MESSAGING_SAS;
-
-
-VOID *
-ReallocatePool (
-  IN VOID                 *OldPool,
-  IN UINTN                OldSize,
-  IN UINTN                NewSize
-  )
-/*++
-
-Routine Description:
-
-  Adjusts the size of a previously allocated buffer.
-
-Arguments:
-
-  OldPool               - A pointer to the buffer whose size is being adjusted.
-
-  OldSize               - The size of the current buffer.
-
-  NewSize               - The size of the new buffer.
-
-Returns:
-
-  EFI_SUCEESS           - The requested number of bytes were allocated.
-
-  EFI_OUT_OF_RESOURCES  - The pool requested could not be allocated.
-
-  EFI_INVALID_PARAMETER - The buffer was invalid.
-
---*/
-{
-  VOID  *NewPool;
-
-  NewPool = NULL;
-  if (NewSize) {
-    NewPool = AllocateZeroPool (NewSize);
-  }
-
-  if (OldPool) {
-    if (NewPool) {
-      CopyMem (NewPool, OldPool, OldSize < NewSize ? OldSize : NewSize);
-    }
-
-    gBS->FreePool (OldPool);
-  }
-
-  return NewPool;
-}
-
-
-/**
-  Concatenates a formatted unicode string to allocated pool.
-  The caller must free the resulting buffer.
-
-  @param  Str      Tracks the allocated pool, size in use, and  amount of pool
-                   allocated.
-  @param  fmt      The format string
-
-  @return Allocated buffer with the formatted string printed in it.
-  @return The caller must free the allocated buffer.   The buffer
-  @return allocation is not packed.
-
-**/
-CHAR16 *
-CatPrint (
-  IN OUT POOL_PRINT   *Str,
-  IN CHAR16           *fmt,
-  ...
-  )
-{
-  UINT16  *AppendStr;
-  VA_LIST args;
-  UINTN   strsize;
-
-  AppendStr = AllocateZeroPool (0x1000);
-  if (AppendStr == NULL) {
-    return Str->str;
-  }
-
-  VA_START (args, fmt);
-  UnicodeVSPrint (AppendStr, 0x1000, fmt, args);
-  VA_END (args);
-  if (NULL == Str->str) {
-    strsize   = StrSize (AppendStr);
-    Str->str  = AllocateZeroPool (strsize);
-    ASSERT (Str->str != NULL);
-  } else {
-    strsize = StrSize (AppendStr);
-    strsize += (StrSize (Str->str) - sizeof (UINT16));
-
-    Str->str = ReallocatePool (
-                Str->str,
-                StrSize (Str->str),
-                strsize
-                );
-    ASSERT (Str->str != NULL);
-  }
-
-  Str->maxlen = MAX_CHAR * sizeof (UINT16);
-  if (strsize < Str->maxlen) {
-    StrCat (Str->str, AppendStr);
-    Str->len = strsize - sizeof (UINT16);
-  }
-
-  gBS->FreePool (AppendStr);
-  return Str->str;
-}
-
-
-/**
-  Function unpacks a device path data structure so that all the nodes
-  of a device path are naturally aligned.
-
-  @param  DevPath  A pointer to a device path data structure
-
-  @return If the memory for the device path is successfully allocated, then a
-  @return pointer to the new device path is returned.  Otherwise, NULL is returned.
-
-**/
-EFI_DEVICE_PATH_PROTOCOL *
-BdsLibUnpackDevicePath (
-  IN EFI_DEVICE_PATH_PROTOCOL  *DevPath
-  )
-{
-  EFI_DEVICE_PATH_PROTOCOL  *Src;
-  EFI_DEVICE_PATH_PROTOCOL  *Dest;
-  EFI_DEVICE_PATH_PROTOCOL  *NewPath;
-  UINTN                     Size;
-
-  //
-  // Walk device path and round sizes to valid boundries
-  //
-  Src   = DevPath;
-  Size  = 0;
-  for (;;) {
-    Size += DevicePathNodeLength (Src);
-    Size += ALIGN_SIZE (Size);
-
-    if (IsDevicePathEnd (Src)) {
-      break;
-    }
-
-    Src = NextDevicePathNode (Src);
-  }
-  //
-  // Allocate space for the unpacked path
-  //
-  NewPath = AllocateZeroPool (Size);
-  if (NewPath) {
-
-    ASSERT (((UINTN) NewPath) % MIN_ALIGNMENT_SIZE == 0);
-
-    //
-    // Copy each node
-    //
-    Src   = DevPath;
-    Dest  = NewPath;
-    for (;;) {
-      Size = DevicePathNodeLength (Src);
-      CopyMem (Dest, Src, Size);
-      Size += ALIGN_SIZE (Size);
-      SetDevicePathNodeLength (Dest, Size);
-      Dest->Type |= EFI_DP_TYPE_UNPACKED;
-      Dest = (EFI_DEVICE_PATH_PROTOCOL *) (((UINT8 *) Dest) + Size);
-
-      if (IsDevicePathEnd (Src)) {
-        break;
-      }
-
-      Src = NextDevicePathNode (Src);
-    }
-  }
-
-  return NewPath;
-}
-
-VOID
-DevPathPci (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  PCI_DEVICE_PATH *Pci;
-
-  Pci = DevPath;
-  CatPrint (Str, L"Pci(%x|%x)", (UINTN) Pci->Device, (UINTN) Pci->Function);
-}
-
-VOID
-DevPathPccard (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  PCCARD_DEVICE_PATH  *Pccard;
-
-  Pccard = DevPath;
-  CatPrint (Str, L"Pcmcia(Function%x)", (UINTN) Pccard->FunctionNumber);
-}
-
-VOID
-DevPathMemMap (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  MEMMAP_DEVICE_PATH  *MemMap;
-
-  MemMap = DevPath;
-  CatPrint (
-    Str,
-    L"MemMap(%d:%lx-%lx)",
-    MemMap->MemoryType,
-    MemMap->StartingAddress,
-    MemMap->EndingAddress
-    );
-}
-
-VOID
-DevPathController (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  CONTROLLER_DEVICE_PATH  *Controller;
-
-  Controller = DevPath;
-  CatPrint (Str, L"Ctrl(%d)", (UINTN) Controller->ControllerNumber);
-}
-
-
-/**
-  Convert Vendor device path to device name
-
-  @param  Str      The buffer store device name
-  @param  DevPath  Pointer to vendor device path
-
-  @return When it return, the device name have been stored in *Str.
-
-**/
-VOID
-DevPathVendor (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  VENDOR_DEVICE_PATH  *Vendor;
-  CHAR16              *Type;
-  UINTN               DataLength;
-  UINTN               Index;
-  UINT32              FlowControlMap;
-
-  UINT16              Info;
-
-  Vendor  = DevPath;
-
-  switch (DevicePathType (&Vendor->Header)) {
-  case HARDWARE_DEVICE_PATH:
-    Type = L"Hw";
-// bugbug: nt 32 specific definition
-#if 0
-    //
-    // If the device is a winntbus device, we will give it a readable device name.
-    //
-    if (CompareGuid (&Vendor->Guid, &mEfiWinNtThunkProtocolGuid)) {
-      CatPrint (Str, L"%s", L"WinNtBus");
-      return ;
-    } else if (CompareGuid (&Vendor->Guid, &mEfiWinNtGopGuid)) {
-      CatPrint (Str, L"%s", L"GOP");
-      return ;
-    } else if (CompareGuid (&Vendor->Guid, &mEfiWinNtSerialPortGuid)) {
-      CatPrint (Str, L"%s", L"Serial");
-      return ;
-    }
-#endif
-    break;
-
-  case MESSAGING_DEVICE_PATH:
-    Type = L"Msg";
-    if (CompareGuid (&Vendor->Guid, &gEfiPcAnsiGuid)) {
-      CatPrint (Str, L"VenPcAnsi()");
-      return ;
-    } else if (CompareGuid (&Vendor->Guid, &gEfiVT100Guid)) {
-      CatPrint (Str, L"VenVt100()");
-      return ;
-    } else if (CompareGuid (&Vendor->Guid, &gEfiVT100PlusGuid)) {
-      CatPrint (Str, L"VenVt100Plus()");
-      return ;
-    } else if (CompareGuid (&Vendor->Guid, &gEfiVTUTF8Guid)) {
-      CatPrint (Str, L"VenUft8()");
-      return ;
-    } else if (CompareGuid (&Vendor->Guid, &mEfiDevicePathMessagingUartFlowControlGuid)) {
-      FlowControlMap = (((UART_FLOW_CONTROL_DEVICE_PATH *) Vendor)->FlowControlMap);
-      switch (FlowControlMap & 0x00000003) {
-      case 0:
-        CatPrint (Str, L"UartFlowCtrl(%s)", L"None");
-        break;
-
-      case 1:
-        CatPrint (Str, L"UartFlowCtrl(%s)", L"Hardware");
-        break;
-
-      case 2:
-        CatPrint (Str, L"UartFlowCtrl(%s)", L"XonXoff");
-        break;
-
-      default:
-        break;
-      }
-
-      return ;
-
-    } else if (CompareGuid (&Vendor->Guid, &mEfiDevicePathMessagingSASGuid)) {
-      CatPrint (
-        Str,
-        L"SAS(%lx,%lx,%x,",
-        ((SAS_DEVICE_PATH *) Vendor)->SasAddress,
-        ((SAS_DEVICE_PATH *) Vendor)->Lun,
-        ((SAS_DEVICE_PATH *) Vendor)->RelativeTargetPort
-        );
-      Info = (((SAS_DEVICE_PATH *) Vendor)->DeviceTopology);
-      if ((Info & 0x0f) == 0) {
-        CatPrint (Str, L"NoTopology,0,0,0,");
-      } else if (((Info & 0x0f) == 1) || ((Info & 0x0f) == 2)) {
-        CatPrint (
-          Str,
-          L"%s,%s,%s,",
-          (Info & (0x1 << 4)) ? L"SATA" : L"SAS",
-          (Info & (0x1 << 5)) ? L"External" : L"Internal",
-          (Info & (0x1 << 6)) ? L"Expanded" : L"Direct"
-          );
-        if ((Info & 0x0f) == 1) {
-          CatPrint (Str, L"0,");
-        } else {
-          CatPrint (Str, L"%x,", (UINTN) ((Info >> 8) & 0xff));
-        }
-      } else {
-        CatPrint (Str, L"0,0,0,0,");
-      }
-
-      CatPrint (Str, L"%x)", (UINTN) ((SAS_DEVICE_PATH *) Vendor)->Reserved);
-      return ;
-
-    } else if (CompareGuid (&Vendor->Guid, &gEfiDebugPortProtocolGuid)) {
-      CatPrint (Str, L"DebugPort()");
-      return ;
-    }
-    break;
-
-  case MEDIA_DEVICE_PATH:
-    Type = L"Media";
-    break;
-
-  default:
-    Type = L"?";
-    break;
-  }
-
-  CatPrint (Str, L"Ven%s(%g", Type, &Vendor->Guid);
-  DataLength = DevicePathNodeLength (&Vendor->Header) - sizeof (VENDOR_DEVICE_PATH);
-  if (DataLength > 0) {
-    CatPrint (Str, L",");
-    for (Index = 0; Index < DataLength; Index++) {
-      CatPrint (Str, L"%02x", (UINTN) ((VENDOR_DEVICE_PATH_WITH_DATA *) Vendor)->VendorDefinedData[Index]);
-    }
-  }
-  CatPrint (Str, L")");
-}
-
-
-VOID
-DevPathAcpi (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  ACPI_HID_DEVICE_PATH  *Acpi;
-
-  Acpi = DevPath;
-  if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {
-    CatPrint (Str, L"Acpi(PNP%04x,%x)", (UINTN)  EISA_ID_TO_NUM (Acpi->HID), (UINTN) Acpi->UID);
-  } else {
-    CatPrint (Str, L"Acpi(%08x,%x)", (UINTN) Acpi->HID, (UINTN) Acpi->UID);
-  }
-}
-
-VOID
-DevPathExtendedAcpi (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  ACPI_EXTENDED_HID_DEVICE_PATH   *ExtendedAcpi;
-  //
-  // Index for HID, UID and CID strings, 0 for non-exist
-  //
-  UINT16                          HIDSTRIdx;
-  UINT16                          UIDSTRIdx;
-  UINT16                          CIDSTRIdx;
-  UINT16                          Index;
-  UINT16                          Length;
-  UINT16                          Anchor;
-  CHAR8                           *AsChar8Array;
-
-  ASSERT (Str != NULL);
-  ASSERT (DevPath != NULL);
-
-  HIDSTRIdx    = 0;
-  UIDSTRIdx    = 0;
-  CIDSTRIdx    = 0;
-  ExtendedAcpi = DevPath;
-  Length       = (UINT16) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) ExtendedAcpi);
-
-  ASSERT (Length >= 19);
-  AsChar8Array = (CHAR8 *) ExtendedAcpi;
-
-  //
-  // find HIDSTR
-  //
-  Anchor = 16;
-  for (Index = Anchor; Index < Length && AsChar8Array[Index]; Index++) {
-    ;
-  }
-  if (Index > Anchor) {
-    HIDSTRIdx = Anchor;
-  }
-  //
-  // find UIDSTR
-  //
-  Anchor = (UINT16) (Index + 1);
-  for (Index = Anchor; Index < Length && AsChar8Array[Index]; Index++) {
-    ;
-  }
-  if (Index > Anchor) {
-    UIDSTRIdx = Anchor;
-  }
-  //
-  // find CIDSTR
-  //
-  Anchor = (UINT16) (Index + 1);
-  for (Index = Anchor; Index < Length && AsChar8Array[Index]; Index++) {
-    ;
-  }
-  if (Index > Anchor) {
-    CIDSTRIdx = Anchor;
-  }
-
-  if (HIDSTRIdx == 0 && CIDSTRIdx == 0 && ExtendedAcpi->UID == 0) {
-    CatPrint (Str, L"AcpiExp(");
-    if ((ExtendedAcpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {
-      CatPrint (Str, L"PNP%04x,", (UINTN) EISA_ID_TO_NUM (ExtendedAcpi->HID));
-    } else {
-      CatPrint (Str, L"%08x,", (UINTN) ExtendedAcpi->HID);
-    }
-    if ((ExtendedAcpi->CID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {
-      CatPrint (Str, L"PNP%04x,", (UINTN)  EISA_ID_TO_NUM (ExtendedAcpi->CID));
-    } else {
-      CatPrint (Str, L"%08x,", (UINTN)  ExtendedAcpi->CID);
-    }
-    if (UIDSTRIdx != 0) {
-      CatPrint (Str, L"%a)", AsChar8Array + UIDSTRIdx);
-    } else {
-      CatPrint (Str, L"\"\")");
-    }
-  } else {
-    CatPrint (Str, L"AcpiEx(");
-    if ((ExtendedAcpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {
-      CatPrint (Str, L"PNP%04x,", (UINTN)  EISA_ID_TO_NUM (ExtendedAcpi->HID));
-    } else {
-      CatPrint (Str, L"%08x,", (UINTN) ExtendedAcpi->HID);
-    }
-    if ((ExtendedAcpi->CID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {
-      CatPrint (Str, L"PNP%04x,", (UINTN) EISA_ID_TO_NUM (ExtendedAcpi->CID));
-    } else {
-      CatPrint (Str, L"%08x,", (UINTN) ExtendedAcpi->CID);
-    }
-    CatPrint (Str, L"%x,", (UINTN) ExtendedAcpi->UID);
-
-    if (HIDSTRIdx != 0) {
-      CatPrint (Str, L"%a,", AsChar8Array + HIDSTRIdx);
-    } else {
-      CatPrint (Str, L"\"\",");
-    }
-    if (CIDSTRIdx != 0) {
-      CatPrint (Str, L"%a,", AsChar8Array + CIDSTRIdx);
-    } else {
-      CatPrint (Str, L"\"\",");
-    }
-    if (UIDSTRIdx != 0) {
-      CatPrint (Str, L"%a)", AsChar8Array + UIDSTRIdx);
-    } else {
-      CatPrint (Str, L"\"\")");
-    }
-  }
-
-}
-
-VOID
-DevPathAdrAcpi (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  ACPI_ADR_DEVICE_PATH    *AcpiAdr;
-  UINT16                  Index;
-  UINT16                  Length;
-  UINT16                  AdditionalAdrCount;
-
-  AcpiAdr            = DevPath;
-  Length             = (UINT16) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) AcpiAdr);
-  AdditionalAdrCount = (UINT16) ((Length - 8) / 4);
-
-  CatPrint (Str, L"AcpiAdr(%x", (UINTN) AcpiAdr->ADR);
-  for (Index = 0; Index < AdditionalAdrCount; Index++) {
-    CatPrint (Str, L",%x", (UINTN) *(UINT32 *) ((UINT8 *) AcpiAdr + 8 + Index * 4));
-  }
-  CatPrint (Str, L")");
-}
-
-VOID
-DevPathAtapi (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  ATAPI_DEVICE_PATH *Atapi;
-
-  Atapi = DevPath;
-  CatPrint (
-    Str,
-    L"Ata(%s,%s)",
-    Atapi->PrimarySecondary ? L"Secondary" : L"Primary",
-    Atapi->SlaveMaster ? L"Slave" : L"Master"
-    );
-}
-
-VOID
-DevPathScsi (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  SCSI_DEVICE_PATH  *Scsi;
-
-  Scsi = DevPath;
-  CatPrint (Str, L"Scsi(Pun%x,Lun%x)", (UINTN) Scsi->Pun, (UINTN) Scsi->Lun);
-}
-
-VOID
-DevPathFibre (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  FIBRECHANNEL_DEVICE_PATH  *Fibre;
-
-  Fibre = DevPath;
-  CatPrint (Str, L"Fibre(Wwn%lx,Lun%x)", Fibre->WWN, Fibre->Lun);
-}
-
-VOID
-DevPath1394 (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  F1394_DEVICE_PATH *F1394;
-
-  F1394 = DevPath;
-  CatPrint (Str, L"1394(%g)", &F1394->Guid);
-}
-
-VOID
-DevPathUsb (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  USB_DEVICE_PATH *Usb;
-
-  Usb = DevPath;
-  CatPrint (Str, L"Usb(%x,%x)", (UINTN) Usb->ParentPortNumber, (UINTN) Usb->InterfaceNumber);
-}
-
-VOID
-DevPathUsbWWID (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  USB_WWID_DEVICE_PATH  *UsbWWId;
-
-  UsbWWId = DevPath;
-  CatPrint (
-    Str,
-    L"UsbWwid(%x,%x,%x,\"WWID\")",
-    (UINTN) UsbWWId->VendorId,
-    (UINTN) UsbWWId->ProductId,
-    (UINTN) UsbWWId->InterfaceNumber
-    );
-}
-
-VOID
-DevPathLogicalUnit (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;
-
-  LogicalUnit = DevPath;
-  CatPrint (Str, L"Unit(%x)", (UINTN) LogicalUnit->Lun);
-}
-
-VOID
-DevPathUsbClass (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  USB_CLASS_DEVICE_PATH *UsbClass;
-
-  UsbClass = DevPath;
-  CatPrint (
-    Str,
-    L"Usb Class(%x,%x,%x,%x,%x)",
-    (UINTN) UsbClass->VendorId,
-    (UINTN) UsbClass->ProductId,
-    (UINTN) UsbClass->DeviceClass,
-    (UINTN) UsbClass->DeviceSubClass,
-    (UINTN) UsbClass->DeviceProtocol
-    );
-}
-
-VOID
-DevPathSata (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  SATA_DEVICE_PATH *Sata;
-
-  Sata = DevPath;
-  CatPrint (
-    Str,
-    L"Sata(%x,%x,%x)",
-    (UINTN) Sata->HBAPortNumber,
-    (UINTN) Sata->PortMultiplierPortNumber,
-    (UINTN) Sata->Lun
-    );
-}
-
-VOID
-DevPathI2O (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  I2O_DEVICE_PATH *I2O;
-
-  I2O = DevPath;
-  CatPrint (Str, L"I2O(%x)", (UINTN) I2O->Tid);
-}
-
-VOID
-DevPathMacAddr (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  MAC_ADDR_DEVICE_PATH  *MAC;
-  UINTN                 HwAddressSize;
-  UINTN                 Index;
-
-  MAC           = DevPath;
-
-  HwAddressSize = sizeof (EFI_MAC_ADDRESS);
-  if (MAC->IfType == 0x01 || MAC->IfType == 0x00) {
-    HwAddressSize = 6;
-  }
-
-  CatPrint (Str, L"Mac(");
-
-  for (Index = 0; Index < HwAddressSize; Index++) {
-    CatPrint (Str, L"%02x", (UINTN) MAC->MacAddress.Addr[Index]);
-  }
-
-  CatPrint (Str, L")");
-}
-
-VOID
-DevPathIPv4 (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  IPv4_DEVICE_PATH  *IP;
-
-  IP = DevPath;
-  CatPrint (
-    Str,
-    L"IPv4(%d.%d.%d.%d:%d)",
-    (UINTN) IP->RemoteIpAddress.Addr[0],
-    (UINTN) IP->RemoteIpAddress.Addr[1],
-    (UINTN) IP->RemoteIpAddress.Addr[2],
-    (UINTN) IP->RemoteIpAddress.Addr[3],
-    (UINTN) IP->RemotePort
-    );
-}
-
-VOID
-DevPathIPv6 (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  IPv6_DEVICE_PATH  *IP;
-
-  IP = DevPath;
-  CatPrint (
-    Str,
-    L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",
-    (UINTN) IP->RemoteIpAddress.Addr[0],
-    (UINTN) IP->RemoteIpAddress.Addr[1],
-    (UINTN) IP->RemoteIpAddress.Addr[2],
-    (UINTN) IP->RemoteIpAddress.Addr[3],
-    (UINTN) IP->RemoteIpAddress.Addr[4],
-    (UINTN) IP->RemoteIpAddress.Addr[5],
-    (UINTN) IP->RemoteIpAddress.Addr[6],
-    (UINTN) IP->RemoteIpAddress.Addr[7],
-    (UINTN) IP->RemoteIpAddress.Addr[8],
-    (UINTN) IP->RemoteIpAddress.Addr[9],
-    (UINTN) IP->RemoteIpAddress.Addr[10],
-    (UINTN) IP->RemoteIpAddress.Addr[11],
-    (UINTN) IP->RemoteIpAddress.Addr[12],
-    (UINTN) IP->RemoteIpAddress.Addr[13],
-    (UINTN) IP->RemoteIpAddress.Addr[14],
-    (UINTN) IP->RemoteIpAddress.Addr[15]
-    );
-}
-
-VOID
-DevPathInfiniBand (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  INFINIBAND_DEVICE_PATH  *InfiniBand;
-
-  InfiniBand = DevPath;
-  CatPrint (
-    Str,
-    L"Infiniband(%x,%g,%lx,%lx,%lx)",
-    (UINTN) InfiniBand->ResourceFlags,
-    InfiniBand->PortGid,
-    InfiniBand->ServiceId,
-    InfiniBand->TargetPortId,
-    InfiniBand->DeviceId
-    );
-}
-
-VOID
-DevPathUart (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  UART_DEVICE_PATH  *Uart;
-  CHAR8             Parity;
-
-  Uart = DevPath;
-  switch (Uart->Parity) {
-  case 0:
-    Parity = 'D';
-    break;
-
-  case 1:
-    Parity = 'N';
-    break;
-
-  case 2:
-    Parity = 'E';
-    break;
-
-  case 3:
-    Parity = 'O';
-    break;
-
-  case 4:
-    Parity = 'M';
-    break;
-
-  case 5:
-    Parity = 'S';
-    break;
-
-  default:
-    Parity = 'x';
-    break;
-  }
-
-  if (Uart->BaudRate == 0) {
-    CatPrint (Str, L"Uart(DEFAULT,%c,", Parity);
-  } else {
-    CatPrint (Str, L"Uart(%d,%c,", Uart->BaudRate, Parity);
-  }
-
-  if (Uart->DataBits == 0) {
-    CatPrint (Str, L"D,");
-  } else {
-    CatPrint (Str, L"%d,", (UINTN) Uart->DataBits);
-  }
-
-  switch (Uart->StopBits) {
-  case 0:
-    CatPrint (Str, L"D)");
-    break;
-
-  case 1:
-    CatPrint (Str, L"1)");
-    break;
-
-  case 2:
-    CatPrint (Str, L"1.5)");
-    break;
-
-  case 3:
-    CatPrint (Str, L"2)");
-    break;
-
-  default:
-    CatPrint (Str, L"x)");
-    break;
-  }
-}
-
-VOID
-DevPathiSCSI (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  ISCSI_DEVICE_PATH_WITH_NAME *iSCSI;
-  UINT16                      Options;
-
-  ASSERT (Str != NULL);
-  ASSERT (DevPath != NULL);
-
-  iSCSI = DevPath;
-  CatPrint (
-    Str,
-    L"iSCSI(%s,%x,%lx,",
-    iSCSI->iSCSITargetName,
-    iSCSI->TargetPortalGroupTag,
-    iSCSI->Lun
-    );
-
-  Options = iSCSI->LoginOption;
-  CatPrint (Str, L"%s,", ((Options >> 1) & 0x0001) ? L"CRC32C" : L"None");
-  CatPrint (Str, L"%s,", ((Options >> 3) & 0x0001) ? L"CRC32C" : L"None");
-  if ((Options >> 11) & 0x0001) {
-    CatPrint (Str, L"%s,", L"None");
-  } else if ((Options >> 12) & 0x0001) {
-    CatPrint (Str, L"%s,", L"CHAP_UNI");
-  } else {
-    CatPrint (Str, L"%s,", L"CHAP_BI");
-
-  }
-
-  CatPrint (Str, L"%s)", (iSCSI->NetworkProtocol == 0) ? L"TCP" : L"reserved");
-}
-
-VOID
-DevPathHardDrive (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  HARDDRIVE_DEVICE_PATH *Hd;
-
-  Hd = DevPath;
-  switch (Hd->SignatureType) {
-  case SIGNATURE_TYPE_MBR:
-    CatPrint (
-      Str,
-      L"HD(Part%d,Sig%08x)",
-      (UINTN) Hd->PartitionNumber,
-      (UINTN) *((UINT32 *) (&(Hd->Signature[0])))
-      );
-    break;
-
-  case SIGNATURE_TYPE_GUID:
-    CatPrint (
-      Str,
-      L"HD(Part%d,Sig%g)",
-      (UINTN) Hd->PartitionNumber,
-      (EFI_GUID *) &(Hd->Signature[0])
-      );
-    break;
-
-  default:
-    CatPrint (
-      Str,
-      L"HD(Part%d,MBRType=%02x,SigType=%02x)",
-      (UINTN) Hd->PartitionNumber,
-      (UINTN) Hd->MBRType,
-      (UINTN) Hd->SignatureType
-      );
-    break;
-  }
-}
-
-VOID
-DevPathCDROM (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  CDROM_DEVICE_PATH *Cd;
-
-  Cd = DevPath;
-  CatPrint (Str, L"CDROM(Entry%x)", (UINTN) Cd->BootEntry);
-}
-
-VOID
-DevPathFilePath (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  FILEPATH_DEVICE_PATH  *Fp;
-
-  Fp = DevPath;
-  CatPrint (Str, L"%s", Fp->PathName);
-}
-
-VOID
-DevPathMediaProtocol (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  MEDIA_PROTOCOL_DEVICE_PATH  *MediaProt;
-
-  MediaProt = DevPath;
-  CatPrint (Str, L"Media(%g)", &MediaProt->Protocol);
-}
-
-VOID
-DevPathFvFilePath (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFilePath;
-
-  FvFilePath = DevPath;
-  CatPrint (Str, L"%g", &FvFilePath->FvFileName);
-}
-
-VOID
-DevPathBssBss (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  BBS_BBS_DEVICE_PATH *Bbs;
-  CHAR16              *Type;
-
-  Bbs = DevPath;
-  switch (Bbs->DeviceType) {
-  case BBS_TYPE_FLOPPY:
-    Type = L"Floppy";
-    break;
-
-  case BBS_TYPE_HARDDRIVE:
-    Type = L"Harddrive";
-    break;
-
-  case BBS_TYPE_CDROM:
-    Type = L"CDROM";
-    break;
-
-  case BBS_TYPE_PCMCIA:
-    Type = L"PCMCIA";
-    break;
-
-  case BBS_TYPE_USB:
-    Type = L"Usb";
-    break;
-
-  case BBS_TYPE_EMBEDDED_NETWORK:
-    Type = L"Net";
-    break;
-
-  case BBS_TYPE_BEV:
-    Type = L"BEV";
-    break;
-
-  default:
-    Type = L"?";
-    break;
-  }
-  CatPrint (Str, L"Legacy-%s", Type);
-}
-
-VOID
-DevPathEndInstance (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  CatPrint (Str, L",");
-}
-
-VOID
-DevPathNodeUnknown (
-  IN OUT POOL_PRINT       *Str,
-  IN VOID                 *DevPath
-  )
-{
-  CatPrint (Str, L"?");
-}
-
-DEVICE_PATH_STRING_TABLE  DevPathTable[] = {
-  HARDWARE_DEVICE_PATH,
-  HW_PCI_DP,
-  DevPathPci,
-  HARDWARE_DEVICE_PATH,
-  HW_PCCARD_DP,
-  DevPathPccard,
-  HARDWARE_DEVICE_PATH,
-  HW_MEMMAP_DP,
-  DevPathMemMap,
-  HARDWARE_DEVICE_PATH,
-  HW_VENDOR_DP,
-  DevPathVendor,
-  HARDWARE_DEVICE_PATH,
-  HW_CONTROLLER_DP,
-  DevPathController,
-  ACPI_DEVICE_PATH,
-  ACPI_DP,
-  DevPathAcpi,
-  ACPI_DEVICE_PATH,
-  ACPI_EXTENDED_DP,
-  DevPathExtendedAcpi,
-  ACPI_DEVICE_PATH,
-  ACPI_ADR_DP,
-  DevPathAdrAcpi,
-  MESSAGING_DEVICE_PATH,
-  MSG_ATAPI_DP,
-  DevPathAtapi,
-  MESSAGING_DEVICE_PATH,
-  MSG_SCSI_DP,
-  DevPathScsi,
-  MESSAGING_DEVICE_PATH,
-  MSG_FIBRECHANNEL_DP,
-  DevPathFibre,
-  MESSAGING_DEVICE_PATH,
-  MSG_1394_DP,
-  DevPath1394,
-  MESSAGING_DEVICE_PATH,
-  MSG_USB_DP,
-  DevPathUsb,
-  MESSAGING_DEVICE_PATH,
-  MSG_USB_WWID_DP,
-  DevPathUsbWWID,
-  MESSAGING_DEVICE_PATH,
-  MSG_DEVICE_LOGICAL_UNIT_DP,
-  DevPathLogicalUnit,
-  MESSAGING_DEVICE_PATH,
-  MSG_USB_CLASS_DP,
-  DevPathUsbClass,
-  MESSAGING_DEVICE_PATH,
-  MSG_SATA_DP,
-  DevPathSata,
-  MESSAGING_DEVICE_PATH,
-  MSG_I2O_DP,
-  DevPathI2O,
-  MESSAGING_DEVICE_PATH,
-  MSG_MAC_ADDR_DP,
-  DevPathMacAddr,
-  MESSAGING_DEVICE_PATH,
-  MSG_IPv4_DP,
-  DevPathIPv4,
-  MESSAGING_DEVICE_PATH,
-  MSG_IPv6_DP,
-  DevPathIPv6,
-  MESSAGING_DEVICE_PATH,
-  MSG_INFINIBAND_DP,
-  DevPathInfiniBand,
-  MESSAGING_DEVICE_PATH,
-  MSG_UART_DP,
-  DevPathUart,
-  MESSAGING_DEVICE_PATH,
-  MSG_VENDOR_DP,
-  DevPathVendor,
-  MESSAGING_DEVICE_PATH,
-  MSG_ISCSI_DP,
-  DevPathiSCSI,
-  MEDIA_DEVICE_PATH,
-  MEDIA_HARDDRIVE_DP,
-  DevPathHardDrive,
-  MEDIA_DEVICE_PATH,
-  MEDIA_CDROM_DP,
-  DevPathCDROM,
-  MEDIA_DEVICE_PATH,
-  MEDIA_VENDOR_DP,
-  DevPathVendor,
-  MEDIA_DEVICE_PATH,
-  MEDIA_FILEPATH_DP,
-  DevPathFilePath,
-  MEDIA_DEVICE_PATH,
-  MEDIA_PROTOCOL_DP,
-  DevPathMediaProtocol,
-  MEDIA_DEVICE_PATH,
-  MEDIA_PIWG_FW_FILE_DP,
-  DevPathFvFilePath,
-  BBS_DEVICE_PATH,
-  BBS_BBS_DP,
-  DevPathBssBss,
-  END_DEVICE_PATH_TYPE,
-  END_INSTANCE_DEVICE_PATH_SUBTYPE,
-  DevPathEndInstance,
-  0,
-  0,
-  NULL
-};
-
-
-/**
-
-**/
-CHAR16 *
-DevicePathToStr (
-  IN EFI_DEVICE_PATH_PROTOCOL     *DevPath
-  )
-{
-  POOL_PRINT                Str;
-  EFI_DEVICE_PATH_PROTOCOL  *DevPathNode;
-  VOID (*DumpNode) (POOL_PRINT *, VOID *);
-
-  UINTN Index;
-  UINTN NewSize;
-
-  EFI_STATUS                       Status;
-  CHAR16                           *ToText;
-  EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DevPathToText;
-
-  ZeroMem (&Str, sizeof (Str));
-
-  if (DevPath == NULL) {
-    goto Done;
-  }
-
-  Status = gBS->LocateProtocol (
-                  &gEfiDevicePathToTextProtocolGuid,
-                  NULL,
-                  (VOID **) &DevPathToText
-                  );
-  if (!EFI_ERROR (Status)) {
-    ToText = DevPathToText->ConvertDevicePathToText (
-                              DevPath,
-                              FALSE,
-                              TRUE
-                              );
-    ASSERT (ToText != NULL);
-    return ToText;
-  }
-
-  //
-  // Unpacked the device path
-  //
-  DevPath = BdsLibUnpackDevicePath (DevPath);
-  ASSERT (DevPath);
-
-  //
-  // Process each device path node
-  //
-  DevPathNode = DevPath;
-  while (!IsDevicePathEnd (DevPathNode)) {
-    //
-    // Find the handler to dump this device path node
-    //
-    DumpNode = NULL;
-    for (Index = 0; DevPathTable[Index].Function; Index += 1) {
-
-      if (DevicePathType (DevPathNode) == DevPathTable[Index].Type &&
-          DevicePathSubType (DevPathNode) == DevPathTable[Index].SubType
-          ) {
-        DumpNode = DevPathTable[Index].Function;
-        break;
-      }
-    }
-    //
-    // If not found, use a generic function
-    //
-    if (!DumpNode) {
-      DumpNode = DevPathNodeUnknown;
-    }
-    //
-    //  Put a path seperator in if needed
-    //
-    if (Str.len && DumpNode != DevPathEndInstance) {
-      CatPrint (&Str, L"/");
-    }
-    //
-    // Print this node of the device path
-    //
-    DumpNode (&Str, DevPathNode);
-
-    //
-    // Next device path node
-    //
-    DevPathNode = NextDevicePathNode (DevPathNode);
-  }
-  //
-  // Shrink pool used for string allocation
-  //
-  gBS->FreePool (DevPath);
-
-Done:
-  NewSize = (Str.len + 1) * sizeof (CHAR16);
-  Str.str = ReallocatePool (Str.str, NewSize, NewSize);
-  ASSERT (Str.str != NULL);
-  Str.str[Str.len] = 0;
-  return Str.str;
-}
-
-
-/**
-  Function creates a device path data structure that identically matches the
-  device path passed in.
-
-  @param  DevPath  A pointer to a device path data structure.
-
-  @return The new copy of DevPath is created to identically match the input.
-  @return Otherwise, NULL is returned.
-
-**/
-EFI_DEVICE_PATH_PROTOCOL *
-LibDuplicateDevicePathInstance (
-  IN EFI_DEVICE_PATH_PROTOCOL  *DevPath
-  )
-{
-  EFI_DEVICE_PATH_PROTOCOL  *NewDevPath;
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePathInst;
-  EFI_DEVICE_PATH_PROTOCOL  *Temp;
-  UINTN                     Size;
-
-  //
-  // get the size of an instance from the input
-  //
-  Temp            = DevPath;
-  DevicePathInst  = GetNextDevicePathInstance (&Temp, &Size);
-
-  //
-  // Make a copy
-  //
-  NewDevPath = NULL;
-  if (Size) {
-    NewDevPath = AllocateZeroPool (Size);
-    ASSERT (NewDevPath != NULL);
-  }
-
-  if (NewDevPath) {
-    CopyMem (NewDevPath, DevicePathInst, Size);
-  }
-
-  return NewDevPath;
-}
+/** @file\r
+  BDS internal function define the default device path string, it can be\r
+  replaced by platform device path.\r
+\r
+Copyright (c) 2004 - 2008, Intel Corporation. <BR>\r
+All rights reserved. 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
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "InternalBdsLib.h"\r
+\r
+\r
+EFI_GUID  mEfiDevicePathMessagingUartFlowControlGuid = DEVICE_PATH_MESSAGING_UART_FLOW_CONTROL;\r
+\r
+EFI_GUID mEfiDevicePathMessagingSASGuid = DEVICE_PATH_MESSAGING_SAS;\r
+\r
+\r
+VOID *\r
+ReallocatePool (\r
+  IN VOID                 *OldPool,\r
+  IN UINTN                OldSize,\r
+  IN UINTN                NewSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Adjusts the size of a previously allocated buffer.\r
+\r
+Arguments:\r
+\r
+  OldPool               - A pointer to the buffer whose size is being adjusted.\r
+\r
+  OldSize               - The size of the current buffer.\r
+\r
+  NewSize               - The size of the new buffer.\r
+\r
+Returns:\r
+\r
+  EFI_SUCEESS           - The requested number of bytes were allocated.\r
+\r
+  EFI_OUT_OF_RESOURCES  - The pool requested could not be allocated.\r
+\r
+  EFI_INVALID_PARAMETER - The buffer was invalid.\r
+\r
+--*/\r
+{\r
+  VOID  *NewPool;\r
+\r
+  NewPool = NULL;\r
+  if (NewSize) {\r
+    NewPool = AllocateZeroPool (NewSize);\r
+  }\r
+\r
+  if (OldPool) {\r
+    if (NewPool) {\r
+      CopyMem (NewPool, OldPool, OldSize < NewSize ? OldSize : NewSize);\r
+    }\r
+\r
+    gBS->FreePool (OldPool);\r
+  }\r
+\r
+  return NewPool;\r
+}\r
+\r
+\r
+/**\r
+  Concatenates a formatted unicode string to allocated pool.\r
+  The caller must free the resulting buffer.\r
+\r
+  @param  Str      Tracks the allocated pool, size in use, and  amount of pool\r
+                   allocated.\r
+  @param  fmt      The format string\r
+\r
+  @return Allocated buffer with the formatted string printed in it.\r
+  @return The caller must free the allocated buffer.   The buffer\r
+  @return allocation is not packed.\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+CatPrint (\r
+  IN OUT POOL_PRINT   *Str,\r
+  IN CHAR16           *fmt,\r
+  ...\r
+  )\r
+{\r
+  UINT16  *AppendStr;\r
+  VA_LIST args;\r
+  UINTN   strsize;\r
+\r
+  AppendStr = AllocateZeroPool (0x1000);\r
+  if (AppendStr == NULL) {\r
+    return Str->str;\r
+  }\r
+\r
+  VA_START (args, fmt);\r
+  UnicodeVSPrint (AppendStr, 0x1000, fmt, args);\r
+  VA_END (args);\r
+  if (NULL == Str->str) {\r
+    strsize   = StrSize (AppendStr);\r
+    Str->str  = AllocateZeroPool (strsize);\r
+    ASSERT (Str->str != NULL);\r
+  } else {\r
+    strsize = StrSize (AppendStr);\r
+    strsize += (StrSize (Str->str) - sizeof (UINT16));\r
+\r
+    Str->str = ReallocatePool (\r
+                Str->str,\r
+                StrSize (Str->str),\r
+                strsize\r
+                );\r
+    ASSERT (Str->str != NULL);\r
+  }\r
+\r
+  Str->maxlen = MAX_CHAR * sizeof (UINT16);\r
+  if (strsize < Str->maxlen) {\r
+    StrCat (Str->str, AppendStr);\r
+    Str->len = strsize - sizeof (UINT16);\r
+  }\r
+\r
+  gBS->FreePool (AppendStr);\r
+  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) {\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
+VOID\r
+DevPathPci (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  PCI_DEVICE_PATH *Pci;\r
+\r
+  Pci = DevPath;\r
+  CatPrint (Str, L"Pci(%x|%x)", (UINTN) Pci->Device, (UINTN) Pci->Function);\r
+}\r
+\r
+VOID\r
+DevPathPccard (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  PCCARD_DEVICE_PATH  *Pccard;\r
+\r
+  Pccard = DevPath;\r
+  CatPrint (Str, L"Pcmcia(Function%x)", (UINTN) Pccard->FunctionNumber);\r
+}\r
+\r
+VOID\r
+DevPathMemMap (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  MEMMAP_DEVICE_PATH  *MemMap;\r
+\r
+  MemMap = DevPath;\r
+  CatPrint (\r
+    Str,\r
+    L"MemMap(%d:%lx-%lx)",\r
+    MemMap->MemoryType,\r
+    MemMap->StartingAddress,\r
+    MemMap->EndingAddress\r
+    );\r
+}\r
+\r
+VOID\r
+DevPathController (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  CONTROLLER_DEVICE_PATH  *Controller;\r
+\r
+  Controller = DevPath;\r
+  CatPrint (Str, L"Ctrl(%d)", (UINTN) Controller->ControllerNumber);\r
+}\r
+\r
+\r
+/**\r
+  Convert Vendor device path to device name\r
+\r
+  @param  Str      The buffer store device name\r
+  @param  DevPath  Pointer to vendor device path\r
+\r
+  @return When it return, the device name have been stored in *Str.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+DevPathVendor (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  VENDOR_DEVICE_PATH  *Vendor;\r
+  CHAR16              *Type;\r
+  UINTN               DataLength;\r
+  UINTN               Index;\r
+  UINT32              FlowControlMap;\r
+\r
+  UINT16              Info;\r
+\r
+  Vendor  = DevPath;\r
+\r
+  switch (DevicePathType (&Vendor->Header)) {\r
+  case HARDWARE_DEVICE_PATH:\r
+    Type = L"Hw";\r
+// bugbug: nt 32 specific definition\r
+#if 0\r
+    //\r
+    // If the device is a winntbus device, we will give it a readable device name.\r
+    //\r
+    if (CompareGuid (&Vendor->Guid, &mEfiWinNtThunkProtocolGuid)) {\r
+      CatPrint (Str, L"%s", L"WinNtBus");\r
+      return ;\r
+    } else if (CompareGuid (&Vendor->Guid, &mEfiWinNtGopGuid)) {\r
+      CatPrint (Str, L"%s", L"GOP");\r
+      return ;\r
+    } else if (CompareGuid (&Vendor->Guid, &mEfiWinNtSerialPortGuid)) {\r
+      CatPrint (Str, L"%s", L"Serial");\r
+      return ;\r
+    }\r
+#endif\r
+    break;\r
+\r
+  case MESSAGING_DEVICE_PATH:\r
+    Type = L"Msg";\r
+    if (CompareGuid (&Vendor->Guid, &gEfiPcAnsiGuid)) {\r
+      CatPrint (Str, L"VenPcAnsi()");\r
+      return ;\r
+    } else if (CompareGuid (&Vendor->Guid, &gEfiVT100Guid)) {\r
+      CatPrint (Str, L"VenVt100()");\r
+      return ;\r
+    } else if (CompareGuid (&Vendor->Guid, &gEfiVT100PlusGuid)) {\r
+      CatPrint (Str, L"VenVt100Plus()");\r
+      return ;\r
+    } else if (CompareGuid (&Vendor->Guid, &gEfiVTUTF8Guid)) {\r
+      CatPrint (Str, L"VenUft8()");\r
+      return ;\r
+    } else if (CompareGuid (&Vendor->Guid, &mEfiDevicePathMessagingUartFlowControlGuid)) {\r
+      FlowControlMap = (((UART_FLOW_CONTROL_DEVICE_PATH *) Vendor)->FlowControlMap);\r
+      switch (FlowControlMap & 0x00000003) {\r
+      case 0:\r
+        CatPrint (Str, L"UartFlowCtrl(%s)", L"None");\r
+        break;\r
+\r
+      case 1:\r
+        CatPrint (Str, L"UartFlowCtrl(%s)", L"Hardware");\r
+        break;\r
+\r
+      case 2:\r
+        CatPrint (Str, L"UartFlowCtrl(%s)", L"XonXoff");\r
+        break;\r
+\r
+      default:\r
+        break;\r
+      }\r
+\r
+      return ;\r
+\r
+    } else if (CompareGuid (&Vendor->Guid, &mEfiDevicePathMessagingSASGuid)) {\r
+      CatPrint (\r
+        Str,\r
+        L"SAS(%lx,%lx,%x,",\r
+        ((SAS_DEVICE_PATH *) Vendor)->SasAddress,\r
+        ((SAS_DEVICE_PATH *) Vendor)->Lun,\r
+        ((SAS_DEVICE_PATH *) Vendor)->RelativeTargetPort\r
+        );\r
+      Info = (((SAS_DEVICE_PATH *) Vendor)->DeviceTopology);\r
+      if ((Info & 0x0f) == 0) {\r
+        CatPrint (Str, L"NoTopology,0,0,0,");\r
+      } else if (((Info & 0x0f) == 1) || ((Info & 0x0f) == 2)) {\r
+        CatPrint (\r
+          Str,\r
+          L"%s,%s,%s,",\r
+          (Info & (0x1 << 4)) ? L"SATA" : L"SAS",\r
+          (Info & (0x1 << 5)) ? L"External" : L"Internal",\r
+          (Info & (0x1 << 6)) ? L"Expanded" : L"Direct"\r
+          );\r
+        if ((Info & 0x0f) == 1) {\r
+          CatPrint (Str, L"0,");\r
+        } else {\r
+          CatPrint (Str, L"%x,", (UINTN) ((Info >> 8) & 0xff));\r
+        }\r
+      } else {\r
+        CatPrint (Str, L"0,0,0,0,");\r
+      }\r
+\r
+      CatPrint (Str, L"%x)", (UINTN) ((SAS_DEVICE_PATH *) Vendor)->Reserved);\r
+      return ;\r
+\r
+    } else if (CompareGuid (&Vendor->Guid, &gEfiDebugPortProtocolGuid)) {\r
+      CatPrint (Str, L"DebugPort()");\r
+      return ;\r
+    }\r
+    break;\r
+\r
+  case MEDIA_DEVICE_PATH:\r
+    Type = L"Media";\r
+    break;\r
+\r
+  default:\r
+    Type = L"?";\r
+    break;\r
+  }\r
+\r
+  CatPrint (Str, L"Ven%s(%g", Type, &Vendor->Guid);\r
+  DataLength = DevicePathNodeLength (&Vendor->Header) - sizeof (VENDOR_DEVICE_PATH);\r
+  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
+    }\r
+  }\r
+  CatPrint (Str, L")");\r
+}\r
+\r
+\r
+VOID\r
+DevPathAcpi (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  ACPI_HID_DEVICE_PATH  *Acpi;\r
+\r
+  Acpi = DevPath;\r
+  if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
+    CatPrint (Str, L"Acpi(PNP%04x,%x)", (UINTN)  EISA_ID_TO_NUM (Acpi->HID), (UINTN) Acpi->UID);\r
+  } else {\r
+    CatPrint (Str, L"Acpi(%08x,%x)", (UINTN) Acpi->HID, (UINTN) Acpi->UID);\r
+  }\r
+}\r
+\r
+VOID\r
+DevPathExtendedAcpi (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  ACPI_EXTENDED_HID_DEVICE_PATH   *ExtendedAcpi;\r
+  //\r
+  // Index for HID, UID and CID strings, 0 for non-exist\r
+  //\r
+  UINT16                          HIDSTRIdx;\r
+  UINT16                          UIDSTRIdx;\r
+  UINT16                          CIDSTRIdx;\r
+  UINT16                          Index;\r
+  UINT16                          Length;\r
+  UINT16                          Anchor;\r
+  CHAR8                           *AsChar8Array;\r
+\r
+  ASSERT (Str != NULL);\r
+  ASSERT (DevPath != NULL);\r
+\r
+  HIDSTRIdx    = 0;\r
+  UIDSTRIdx    = 0;\r
+  CIDSTRIdx    = 0;\r
+  ExtendedAcpi = DevPath;\r
+  Length       = (UINT16) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) ExtendedAcpi);\r
+\r
+  ASSERT (Length >= 19);\r
+  AsChar8Array = (CHAR8 *) ExtendedAcpi;\r
+\r
+  //\r
+  // find HIDSTR\r
+  //\r
+  Anchor = 16;\r
+  for (Index = Anchor; Index < Length && AsChar8Array[Index]; Index++) {\r
+    ;\r
+  }\r
+  if (Index > Anchor) {\r
+    HIDSTRIdx = Anchor;\r
+  }\r
+  //\r
+  // find UIDSTR\r
+  //\r
+  Anchor = (UINT16) (Index + 1);\r
+  for (Index = Anchor; Index < Length && AsChar8Array[Index]; Index++) {\r
+    ;\r
+  }\r
+  if (Index > Anchor) {\r
+    UIDSTRIdx = Anchor;\r
+  }\r
+  //\r
+  // find CIDSTR\r
+  //\r
+  Anchor = (UINT16) (Index + 1);\r
+  for (Index = Anchor; Index < Length && AsChar8Array[Index]; Index++) {\r
+    ;\r
+  }\r
+  if (Index > Anchor) {\r
+    CIDSTRIdx = Anchor;\r
+  }\r
+\r
+  if (HIDSTRIdx == 0 && CIDSTRIdx == 0 && ExtendedAcpi->UID == 0) {\r
+    CatPrint (Str, L"AcpiExp(");\r
+    if ((ExtendedAcpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
+      CatPrint (Str, L"PNP%04x,", (UINTN) EISA_ID_TO_NUM (ExtendedAcpi->HID));\r
+    } else {\r
+      CatPrint (Str, L"%08x,", (UINTN) ExtendedAcpi->HID);\r
+    }\r
+    if ((ExtendedAcpi->CID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
+      CatPrint (Str, L"PNP%04x,", (UINTN)  EISA_ID_TO_NUM (ExtendedAcpi->CID));\r
+    } else {\r
+      CatPrint (Str, L"%08x,", (UINTN)  ExtendedAcpi->CID);\r
+    }\r
+    if (UIDSTRIdx != 0) {\r
+      CatPrint (Str, L"%a)", AsChar8Array + UIDSTRIdx);\r
+    } else {\r
+      CatPrint (Str, L"\"\")");\r
+    }\r
+  } else {\r
+    CatPrint (Str, L"AcpiEx(");\r
+    if ((ExtendedAcpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
+      CatPrint (Str, L"PNP%04x,", (UINTN)  EISA_ID_TO_NUM (ExtendedAcpi->HID));\r
+    } else {\r
+      CatPrint (Str, L"%08x,", (UINTN) ExtendedAcpi->HID);\r
+    }\r
+    if ((ExtendedAcpi->CID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
+      CatPrint (Str, L"PNP%04x,", (UINTN) EISA_ID_TO_NUM (ExtendedAcpi->CID));\r
+    } else {\r
+      CatPrint (Str, L"%08x,", (UINTN) ExtendedAcpi->CID);\r
+    }\r
+    CatPrint (Str, L"%x,", (UINTN) ExtendedAcpi->UID);\r
+\r
+    if (HIDSTRIdx != 0) {\r
+      CatPrint (Str, L"%a,", AsChar8Array + HIDSTRIdx);\r
+    } else {\r
+      CatPrint (Str, L"\"\",");\r
+    }\r
+    if (CIDSTRIdx != 0) {\r
+      CatPrint (Str, L"%a,", AsChar8Array + CIDSTRIdx);\r
+    } else {\r
+      CatPrint (Str, L"\"\",");\r
+    }\r
+    if (UIDSTRIdx != 0) {\r
+      CatPrint (Str, L"%a)", AsChar8Array + UIDSTRIdx);\r
+    } else {\r
+      CatPrint (Str, L"\"\")");\r
+    }\r
+  }\r
+\r
+}\r
+\r
+VOID\r
+DevPathAdrAcpi (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  ACPI_ADR_DEVICE_PATH    *AcpiAdr;\r
+  UINT16                  Index;\r
+  UINT16                  Length;\r
+  UINT16                  AdditionalAdrCount;\r
+\r
+  AcpiAdr            = DevPath;\r
+  Length             = (UINT16) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) AcpiAdr);\r
+  AdditionalAdrCount = (UINT16) ((Length - 8) / 4);\r
+\r
+  CatPrint (Str, L"AcpiAdr(%x", (UINTN) AcpiAdr->ADR);\r
+  for (Index = 0; Index < AdditionalAdrCount; Index++) {\r
+    CatPrint (Str, L",%x", (UINTN) *(UINT32 *) ((UINT8 *) AcpiAdr + 8 + Index * 4));\r
+  }\r
+  CatPrint (Str, L")");\r
+}\r
+\r
+VOID\r
+DevPathAtapi (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  ATAPI_DEVICE_PATH *Atapi;\r
+\r
+  Atapi = DevPath;\r
+  CatPrint (\r
+    Str,\r
+    L"Ata(%s,%s)",\r
+    Atapi->PrimarySecondary ? L"Secondary" : L"Primary",\r
+    Atapi->SlaveMaster ? L"Slave" : L"Master"\r
+    );\r
+}\r
+\r
+VOID\r
+DevPathScsi (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  SCSI_DEVICE_PATH  *Scsi;\r
+\r
+  Scsi = DevPath;\r
+  CatPrint (Str, L"Scsi(Pun%x,Lun%x)", (UINTN) Scsi->Pun, (UINTN) Scsi->Lun);\r
+}\r
+\r
+VOID\r
+DevPathFibre (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  FIBRECHANNEL_DEVICE_PATH  *Fibre;\r
+\r
+  Fibre = DevPath;\r
+  CatPrint (Str, L"Fibre(Wwn%lx,Lun%x)", Fibre->WWN, Fibre->Lun);\r
+}\r
+\r
+VOID\r
+DevPath1394 (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  F1394_DEVICE_PATH *F1394;\r
+\r
+  F1394 = DevPath;\r
+  CatPrint (Str, L"1394(%g)", &F1394->Guid);\r
+}\r
+\r
+VOID\r
+DevPathUsb (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  USB_DEVICE_PATH *Usb;\r
+\r
+  Usb = DevPath;\r
+  CatPrint (Str, L"Usb(%x,%x)", (UINTN) Usb->ParentPortNumber, (UINTN) Usb->InterfaceNumber);\r
+}\r
+\r
+VOID\r
+DevPathUsbWWID (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  USB_WWID_DEVICE_PATH  *UsbWWId;\r
+\r
+  UsbWWId = DevPath;\r
+  CatPrint (\r
+    Str,\r
+    L"UsbWwid(%x,%x,%x,\"WWID\")",\r
+    (UINTN) UsbWWId->VendorId,\r
+    (UINTN) UsbWWId->ProductId,\r
+    (UINTN) UsbWWId->InterfaceNumber\r
+    );\r
+}\r
+\r
+VOID\r
+DevPathLogicalUnit (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;\r
+\r
+  LogicalUnit = DevPath;\r
+  CatPrint (Str, L"Unit(%x)", (UINTN) LogicalUnit->Lun);\r
+}\r
+\r
+VOID\r
+DevPathUsbClass (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  USB_CLASS_DEVICE_PATH *UsbClass;\r
+\r
+  UsbClass = DevPath;\r
+  CatPrint (\r
+    Str,\r
+    L"Usb Class(%x,%x,%x,%x,%x)",\r
+    (UINTN) UsbClass->VendorId,\r
+    (UINTN) UsbClass->ProductId,\r
+    (UINTN) UsbClass->DeviceClass,\r
+    (UINTN) UsbClass->DeviceSubClass,\r
+    (UINTN) UsbClass->DeviceProtocol\r
+    );\r
+}\r
+\r
+VOID\r
+DevPathSata (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  SATA_DEVICE_PATH *Sata;\r
+\r
+  Sata = DevPath;\r
+  CatPrint (\r
+    Str,\r
+    L"Sata(%x,%x,%x)",\r
+    (UINTN) Sata->HBAPortNumber,\r
+    (UINTN) Sata->PortMultiplierPortNumber,\r
+    (UINTN) Sata->Lun\r
+    );\r
+}\r
+\r
+VOID\r
+DevPathI2O (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  I2O_DEVICE_PATH *I2O;\r
+\r
+  I2O = DevPath;\r
+  CatPrint (Str, L"I2O(%x)", (UINTN) I2O->Tid);\r
+}\r
+\r
+VOID\r
+DevPathMacAddr (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  MAC_ADDR_DEVICE_PATH  *MAC;\r
+  UINTN                 HwAddressSize;\r
+  UINTN                 Index;\r
+\r
+  MAC           = DevPath;\r
+\r
+  HwAddressSize = sizeof (EFI_MAC_ADDRESS);\r
+  if (MAC->IfType == 0x01 || MAC->IfType == 0x00) {\r
+    HwAddressSize = 6;\r
+  }\r
+\r
+  CatPrint (Str, L"Mac(");\r
+\r
+  for (Index = 0; Index < HwAddressSize; Index++) {\r
+    CatPrint (Str, L"%02x", (UINTN) MAC->MacAddress.Addr[Index]);\r
+  }\r
+\r
+  CatPrint (Str, L")");\r
+}\r
+\r
+VOID\r
+DevPathIPv4 (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  IPv4_DEVICE_PATH  *IP;\r
+\r
+  IP = DevPath;\r
+  CatPrint (\r
+    Str,\r
+    L"IPv4(%d.%d.%d.%d:%d)",\r
+    (UINTN) IP->RemoteIpAddress.Addr[0],\r
+    (UINTN) IP->RemoteIpAddress.Addr[1],\r
+    (UINTN) IP->RemoteIpAddress.Addr[2],\r
+    (UINTN) IP->RemoteIpAddress.Addr[3],\r
+    (UINTN) IP->RemotePort\r
+    );\r
+}\r
+\r
+VOID\r
+DevPathIPv6 (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  IPv6_DEVICE_PATH  *IP;\r
+\r
+  IP = DevPath;\r
+  CatPrint (\r
+    Str,\r
+    L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",\r
+    (UINTN) IP->RemoteIpAddress.Addr[0],\r
+    (UINTN) IP->RemoteIpAddress.Addr[1],\r
+    (UINTN) IP->RemoteIpAddress.Addr[2],\r
+    (UINTN) IP->RemoteIpAddress.Addr[3],\r
+    (UINTN) IP->RemoteIpAddress.Addr[4],\r
+    (UINTN) IP->RemoteIpAddress.Addr[5],\r
+    (UINTN) IP->RemoteIpAddress.Addr[6],\r
+    (UINTN) IP->RemoteIpAddress.Addr[7],\r
+    (UINTN) IP->RemoteIpAddress.Addr[8],\r
+    (UINTN) IP->RemoteIpAddress.Addr[9],\r
+    (UINTN) IP->RemoteIpAddress.Addr[10],\r
+    (UINTN) IP->RemoteIpAddress.Addr[11],\r
+    (UINTN) IP->RemoteIpAddress.Addr[12],\r
+    (UINTN) IP->RemoteIpAddress.Addr[13],\r
+    (UINTN) IP->RemoteIpAddress.Addr[14],\r
+    (UINTN) IP->RemoteIpAddress.Addr[15]\r
+    );\r
+}\r
+\r
+VOID\r
+DevPathInfiniBand (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  INFINIBAND_DEVICE_PATH  *InfiniBand;\r
+\r
+  InfiniBand = DevPath;\r
+  CatPrint (\r
+    Str,\r
+    L"Infiniband(%x,%g,%lx,%lx,%lx)",\r
+    (UINTN) InfiniBand->ResourceFlags,\r
+    InfiniBand->PortGid,\r
+    InfiniBand->ServiceId,\r
+    InfiniBand->TargetPortId,\r
+    InfiniBand->DeviceId\r
+    );\r
+}\r
+\r
+VOID\r
+DevPathUart (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  UART_DEVICE_PATH  *Uart;\r
+  CHAR8             Parity;\r
+\r
+  Uart = DevPath;\r
+  switch (Uart->Parity) {\r
+  case 0:\r
+    Parity = 'D';\r
+    break;\r
+\r
+  case 1:\r
+    Parity = 'N';\r
+    break;\r
+\r
+  case 2:\r
+    Parity = 'E';\r
+    break;\r
+\r
+  case 3:\r
+    Parity = 'O';\r
+    break;\r
+\r
+  case 4:\r
+    Parity = 'M';\r
+    break;\r
+\r
+  case 5:\r
+    Parity = 'S';\r
+    break;\r
+\r
+  default:\r
+    Parity = 'x';\r
+    break;\r
+  }\r
+\r
+  if (Uart->BaudRate == 0) {\r
+    CatPrint (Str, L"Uart(DEFAULT,%c,", Parity);\r
+  } else {\r
+    CatPrint (Str, L"Uart(%d,%c,", Uart->BaudRate, Parity);\r
+  }\r
+\r
+  if (Uart->DataBits == 0) {\r
+    CatPrint (Str, L"D,");\r
+  } else {\r
+    CatPrint (Str, L"%d,", (UINTN) Uart->DataBits);\r
+  }\r
+\r
+  switch (Uart->StopBits) {\r
+  case 0:\r
+    CatPrint (Str, L"D)");\r
+    break;\r
+\r
+  case 1:\r
+    CatPrint (Str, L"1)");\r
+    break;\r
+\r
+  case 2:\r
+    CatPrint (Str, L"1.5)");\r
+    break;\r
+\r
+  case 3:\r
+    CatPrint (Str, L"2)");\r
+    break;\r
+\r
+  default:\r
+    CatPrint (Str, L"x)");\r
+    break;\r
+  }\r
+}\r
+\r
+VOID\r
+DevPathiSCSI (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  ISCSI_DEVICE_PATH_WITH_NAME *iSCSI;\r
+  UINT16                      Options;\r
+\r
+  ASSERT (Str != NULL);\r
+  ASSERT (DevPath != NULL);\r
+\r
+  iSCSI = DevPath;\r
+  CatPrint (\r
+    Str,\r
+    L"iSCSI(%s,%x,%lx,",\r
+    iSCSI->iSCSITargetName,\r
+    iSCSI->TargetPortalGroupTag,\r
+    iSCSI->Lun\r
+    );\r
+\r
+  Options = iSCSI->LoginOption;\r
+  CatPrint (Str, L"%s,", ((Options >> 1) & 0x0001) ? L"CRC32C" : L"None");\r
+  CatPrint (Str, L"%s,", ((Options >> 3) & 0x0001) ? L"CRC32C" : L"None");\r
+  if ((Options >> 11) & 0x0001) {\r
+    CatPrint (Str, L"%s,", L"None");\r
+  } else if ((Options >> 12) & 0x0001) {\r
+    CatPrint (Str, L"%s,", L"CHAP_UNI");\r
+  } else {\r
+    CatPrint (Str, L"%s,", L"CHAP_BI");\r
+\r
+  }\r
+\r
+  CatPrint (Str, L"%s)", (iSCSI->NetworkProtocol == 0) ? L"TCP" : L"reserved");\r
+}\r
+\r
+VOID\r
+DevPathHardDrive (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  HARDDRIVE_DEVICE_PATH *Hd;\r
+\r
+  Hd = DevPath;\r
+  switch (Hd->SignatureType) {\r
+  case SIGNATURE_TYPE_MBR:\r
+    CatPrint (\r
+      Str,\r
+      L"HD(Part%d,Sig%08x)",\r
+      (UINTN) Hd->PartitionNumber,\r
+      (UINTN) *((UINT32 *) (&(Hd->Signature[0])))\r
+      );\r
+    break;\r
+\r
+  case SIGNATURE_TYPE_GUID:\r
+    CatPrint (\r
+      Str,\r
+      L"HD(Part%d,Sig%g)",\r
+      (UINTN) Hd->PartitionNumber,\r
+      (EFI_GUID *) &(Hd->Signature[0])\r
+      );\r
+    break;\r
+\r
+  default:\r
+    CatPrint (\r
+      Str,\r
+      L"HD(Part%d,MBRType=%02x,SigType=%02x)",\r
+      (UINTN) Hd->PartitionNumber,\r
+      (UINTN) Hd->MBRType,\r
+      (UINTN) Hd->SignatureType\r
+      );\r
+    break;\r
+  }\r
+}\r
+\r
+VOID\r
+DevPathCDROM (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  CDROM_DEVICE_PATH *Cd;\r
+\r
+  Cd = DevPath;\r
+  CatPrint (Str, L"CDROM(Entry%x)", (UINTN) Cd->BootEntry);\r
+}\r
+\r
+VOID\r
+DevPathFilePath (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  FILEPATH_DEVICE_PATH  *Fp;\r
+\r
+  Fp = DevPath;\r
+  CatPrint (Str, L"%s", Fp->PathName);\r
+}\r
+\r
+VOID\r
+DevPathMediaProtocol (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  MEDIA_PROTOCOL_DEVICE_PATH  *MediaProt;\r
+\r
+  MediaProt = DevPath;\r
+  CatPrint (Str, L"Media(%g)", &MediaProt->Protocol);\r
+}\r
+\r
+VOID\r
+DevPathFvFilePath (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFilePath;\r
+\r
+  FvFilePath = DevPath;\r
+  CatPrint (Str, L"%g", &FvFilePath->FvFileName);\r
+}\r
+\r
+VOID\r
+DevPathBssBss (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  BBS_BBS_DEVICE_PATH *Bbs;\r
+  CHAR16              *Type;\r
+\r
+  Bbs = DevPath;\r
+  switch (Bbs->DeviceType) {\r
+  case BBS_TYPE_FLOPPY:\r
+    Type = L"Floppy";\r
+    break;\r
+\r
+  case BBS_TYPE_HARDDRIVE:\r
+    Type = L"Harddrive";\r
+    break;\r
+\r
+  case BBS_TYPE_CDROM:\r
+    Type = L"CDROM";\r
+    break;\r
+\r
+  case BBS_TYPE_PCMCIA:\r
+    Type = L"PCMCIA";\r
+    break;\r
+\r
+  case BBS_TYPE_USB:\r
+    Type = L"Usb";\r
+    break;\r
+\r
+  case BBS_TYPE_EMBEDDED_NETWORK:\r
+    Type = L"Net";\r
+    break;\r
+\r
+  case BBS_TYPE_BEV:\r
+    Type = L"BEV";\r
+    break;\r
+\r
+  default:\r
+    Type = L"?";\r
+    break;\r
+  }\r
+  CatPrint (Str, L"Legacy-%s", Type);\r
+}\r
+\r
+VOID\r
+DevPathEndInstance (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  CatPrint (Str, L",");\r
+}\r
+\r
+VOID\r
+DevPathNodeUnknown (\r
+  IN OUT POOL_PRINT       *Str,\r
+  IN VOID                 *DevPath\r
+  )\r
+{\r
+  CatPrint (Str, L"?");\r
+}\r
+\r
+DEVICE_PATH_STRING_TABLE  DevPathTable[] = {\r
+  HARDWARE_DEVICE_PATH,\r
+  HW_PCI_DP,\r
+  DevPathPci,\r
+  HARDWARE_DEVICE_PATH,\r
+  HW_PCCARD_DP,\r
+  DevPathPccard,\r
+  HARDWARE_DEVICE_PATH,\r
+  HW_MEMMAP_DP,\r
+  DevPathMemMap,\r
+  HARDWARE_DEVICE_PATH,\r
+  HW_VENDOR_DP,\r
+  DevPathVendor,\r
+  HARDWARE_DEVICE_PATH,\r
+  HW_CONTROLLER_DP,\r
+  DevPathController,\r
+  ACPI_DEVICE_PATH,\r
+  ACPI_DP,\r
+  DevPathAcpi,\r
+  ACPI_DEVICE_PATH,\r
+  ACPI_EXTENDED_DP,\r
+  DevPathExtendedAcpi,\r
+  ACPI_DEVICE_PATH,\r
+  ACPI_ADR_DP,\r
+  DevPathAdrAcpi,\r
+  MESSAGING_DEVICE_PATH,\r
+  MSG_ATAPI_DP,\r
+  DevPathAtapi,\r
+  MESSAGING_DEVICE_PATH,\r
+  MSG_SCSI_DP,\r
+  DevPathScsi,\r
+  MESSAGING_DEVICE_PATH,\r
+  MSG_FIBRECHANNEL_DP,\r
+  DevPathFibre,\r
+  MESSAGING_DEVICE_PATH,\r
+  MSG_1394_DP,\r
+  DevPath1394,\r
+  MESSAGING_DEVICE_PATH,\r
+  MSG_USB_DP,\r
+  DevPathUsb,\r
+  MESSAGING_DEVICE_PATH,\r
+  MSG_USB_WWID_DP,\r
+  DevPathUsbWWID,\r
+  MESSAGING_DEVICE_PATH,\r
+  MSG_DEVICE_LOGICAL_UNIT_DP,\r
+  DevPathLogicalUnit,\r
+  MESSAGING_DEVICE_PATH,\r
+  MSG_USB_CLASS_DP,\r
+  DevPathUsbClass,\r
+  MESSAGING_DEVICE_PATH,\r
+  MSG_SATA_DP,\r
+  DevPathSata,\r
+  MESSAGING_DEVICE_PATH,\r
+  MSG_I2O_DP,\r
+  DevPathI2O,\r
+  MESSAGING_DEVICE_PATH,\r
+  MSG_MAC_ADDR_DP,\r
+  DevPathMacAddr,\r
+  MESSAGING_DEVICE_PATH,\r
+  MSG_IPv4_DP,\r
+  DevPathIPv4,\r
+  MESSAGING_DEVICE_PATH,\r
+  MSG_IPv6_DP,\r
+  DevPathIPv6,\r
+  MESSAGING_DEVICE_PATH,\r
+  MSG_INFINIBAND_DP,\r
+  DevPathInfiniBand,\r
+  MESSAGING_DEVICE_PATH,\r
+  MSG_UART_DP,\r
+  DevPathUart,\r
+  MESSAGING_DEVICE_PATH,\r
+  MSG_VENDOR_DP,\r
+  DevPathVendor,\r
+  MESSAGING_DEVICE_PATH,\r
+  MSG_ISCSI_DP,\r
+  DevPathiSCSI,\r
+  MEDIA_DEVICE_PATH,\r
+  MEDIA_HARDDRIVE_DP,\r
+  DevPathHardDrive,\r
+  MEDIA_DEVICE_PATH,\r
+  MEDIA_CDROM_DP,\r
+  DevPathCDROM,\r
+  MEDIA_DEVICE_PATH,\r
+  MEDIA_VENDOR_DP,\r
+  DevPathVendor,\r
+  MEDIA_DEVICE_PATH,\r
+  MEDIA_FILEPATH_DP,\r
+  DevPathFilePath,\r
+  MEDIA_DEVICE_PATH,\r
+  MEDIA_PROTOCOL_DP,\r
+  DevPathMediaProtocol,\r
+  MEDIA_DEVICE_PATH,\r
+  MEDIA_PIWG_FW_FILE_DP,\r
+  DevPathFvFilePath,\r
+  BBS_DEVICE_PATH,\r
+  BBS_BBS_DP,\r
+  DevPathBssBss,\r
+  END_DEVICE_PATH_TYPE,\r
+  END_INSTANCE_DEVICE_PATH_SUBTYPE,\r
+  DevPathEndInstance,\r
+  0,\r
+  0,\r
+  NULL\r
+};\r
+\r
+\r
+/**\r
+  This function converts an input device structure to a Unicode string.\r
+\r
+  @param DevPath                  A pointer to the device path structure.\r
+\r
+  @return A new allocated Unicode string that represents the device path.\r
+\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+DevicePathToStr (\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *DevPath\r
+  )\r
+{\r
+  POOL_PRINT                Str;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevPathNode;\r
+  VOID (*DumpNode) (POOL_PRINT *, VOID *);\r
+\r
+  UINTN Index;\r
+  UINTN NewSize;\r
+\r
+  EFI_STATUS                       Status;\r
+  CHAR16                           *ToText;\r
+  EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DevPathToText;\r
+\r
+  ZeroMem (&Str, sizeof (Str));\r
+\r
+  if (DevPath == NULL) {\r
+    goto Done;\r
+  }\r
+\r
+  Status = gBS->LocateProtocol (\r
+                  &gEfiDevicePathToTextProtocolGuid,\r
+                  NULL,\r
+                  (VOID **) &DevPathToText\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+    ToText = DevPathToText->ConvertDevicePathToText (\r
+                              DevPath,\r
+                              FALSE,\r
+                              TRUE\r
+                              );\r
+    ASSERT (ToText != NULL);\r
+    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
+  DevPathNode = DevPath;\r
+  while (!IsDevicePathEnd (DevPathNode)) {\r
+    //\r
+    // Find the handler to dump this device path node\r
+    //\r
+    DumpNode = NULL;\r
+    for (Index = 0; DevPathTable[Index].Function; Index += 1) {\r
+\r
+      if (DevicePathType (DevPathNode) == DevPathTable[Index].Type &&\r
+          DevicePathSubType (DevPathNode) == DevPathTable[Index].SubType\r
+          ) {\r
+        DumpNode = DevPathTable[Index].Function;\r
+        break;\r
+      }\r
+    }\r
+    //\r
+    // If not found, use a generic function\r
+    //\r
+    if (!DumpNode) {\r
+      DumpNode = DevPathNodeUnknown;\r
+    }\r
+    //\r
+    //  Put a path seperator in if needed\r
+    //\r
+    if (Str.len && DumpNode != DevPathEndInstance) {\r
+      CatPrint (&Str, L"/");\r
+    }\r
+    //\r
+    // Print this node of the device path\r
+    //\r
+    DumpNode (&Str, DevPathNode);\r
+\r
+    //\r
+    // Next device path node\r
+    //\r
+    DevPathNode = NextDevicePathNode (DevPathNode);\r
+  }\r
+  //\r
+  // Shrink pool used for string allocation\r
+  //\r
+  gBS->FreePool (DevPath);\r
+\r
+Done:\r
+  NewSize = (Str.len + 1) * sizeof (CHAR16);\r
+  Str.str = ReallocatePool (Str.str, NewSize, NewSize);\r
+  ASSERT (Str.str != NULL);\r
+  Str.str[Str.len] = 0;\r
+  return Str.str;\r
+}\r
+\r
+\r
+/**\r
+  Function creates a device path data structure that identically matches the\r
+  device path passed in.\r
+\r
+  @param  DevPath  A pointer to a device path data structure.\r
+\r
+  @return The new copy of DevPath is created to identically match the input.\r
+  @return Otherwise, NULL is returned.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+LibDuplicateDevicePathInstance (\r
+  IN EFI_DEVICE_PATH_PROTOCOL  *DevPath\r
+  )\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *NewDevPath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePathInst;\r
+  EFI_DEVICE_PATH_PROTOCOL  *Temp;\r
+  UINTN                     Size;\r
+\r
+  //\r
+  // get the size of an instance from the input\r
+  //\r
+  Temp            = DevPath;\r
+  DevicePathInst  = GetNextDevicePathInstance (&Temp, &Size);\r
+\r
+  //\r
+  // Make a copy\r
+  //\r
+  NewDevPath = NULL;\r
+  if (Size) {\r
+    NewDevPath = AllocateZeroPool (Size);\r
+    ASSERT (NewDevPath != NULL);\r
+  }\r
+\r
+  if (NewDevPath) {\r
+    CopyMem (NewDevPath, DevicePathInst, Size);\r
+  }\r
+\r
+  return NewDevPath;\r
+}\r