Support new format of IPv4 device path node, FibreEx and PcieRoot device path node in DevicepathDxe driver.

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
This commit is contained in:
niruiyu 2011-09-05 04:51:51 +00:00
parent 09e1962905
commit e9b3cd557f
3 changed files with 264 additions and 164 deletions

View File

@ -1,7 +1,7 @@
/** @file /** @file
Definition for Device Path Utilities driver Definition for Device Path Utilities driver
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -31,9 +31,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/DevicePathLib.h> #include <Library/DevicePathLib.h>
#include <Library/PcdLib.h> #include <Library/PcdLib.h>
#define MAX_CHAR 480
#define IS_COMMA(a) ((a) == L',') #define IS_COMMA(a) ((a) == L',')
#define IS_HYPHEN(a) ((a) == L'-') #define IS_HYPHEN(a) ((a) == L'-')
#define IS_DOT(a) ((a) == L'.') #define IS_DOT(a) ((a) == L'.')
@ -55,8 +52,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
// //
typedef struct { typedef struct {
CHAR16 *Str; CHAR16 *Str;
UINTN Len; UINTN Length;
UINTN MaxLen; UINTN Capacity;
} POOL_PRINT; } POOL_PRINT;
typedef typedef

View File

@ -970,6 +970,22 @@ DevPathFromTextPciRoot (
return ConvertFromTextAcpi (TextDeviceNode, 0x0a03); return ConvertFromTextAcpi (TextDeviceNode, 0x0a03);
} }
/**
Converts a text device path node to PCIE root device path structure.
@param TextDeviceNode The input Text device path node.
@return A pointer to the newly-created PCIE root device path structure.
**/
EFI_DEVICE_PATH_PROTOCOL *
DevPathFromTextPcieRoot (
IN CHAR16 *TextDeviceNode
)
{
return ConvertFromTextAcpi (TextDeviceNode, 0x0a08);
}
/** /**
Converts a text device path node to Floppy device path structure. Converts a text device path node to Floppy device path structure.
@ -1282,6 +1298,41 @@ DevPathFromTextFibre (
return (EFI_DEVICE_PATH_PROTOCOL *) Fibre; return (EFI_DEVICE_PATH_PROTOCOL *) Fibre;
} }
/**
Converts a text device path node to FibreEx device path structure.
@param TextDeviceNode The input Text device path node.
@return A pointer to the newly-created FibreEx device path structure.
**/
EFI_DEVICE_PATH_PROTOCOL *
DevPathFromTextFibreEx (
IN CHAR16 *TextDeviceNode
)
{
CHAR16 *WWNStr;
CHAR16 *LunStr;
FIBRECHANNELEX_DEVICE_PATH *FibreEx;
WWNStr = GetNextParamStr (&TextDeviceNode);
LunStr = GetNextParamStr (&TextDeviceNode);
FibreEx = (FIBRECHANNELEX_DEVICE_PATH *) CreateDeviceNode (
MESSAGING_DEVICE_PATH,
MSG_FIBRECHANNELEX_DP,
(UINT16) sizeof (FIBRECHANNELEX_DEVICE_PATH)
);
FibreEx->Reserved = 0;
Strtoi64 (WWNStr, (UINT64 *) (&FibreEx->WWN));
Strtoi64 (LunStr, (UINT64 *) (&FibreEx->Lun));
*(UINT64 *) (&FibreEx->WWN) = SwapBytes64 (*(UINT64 *) (&FibreEx->WWN));
*(UINT64 *) (&FibreEx->Lun) = SwapBytes64 (*(UINT64 *) (&FibreEx->Lun));
return (EFI_DEVICE_PATH_PROTOCOL *) FibreEx;
}
/** /**
Converts a text device path node to 1394 device path structure. Converts a text device path node to 1394 device path structure.
@ -1736,12 +1787,16 @@ DevPathFromTextIPv4 (
CHAR16 *ProtocolStr; CHAR16 *ProtocolStr;
CHAR16 *TypeStr; CHAR16 *TypeStr;
CHAR16 *LocalIPStr; CHAR16 *LocalIPStr;
CHAR16 *GatewayIPStr;
CHAR16 *SubnetMaskStr;
IPv4_DEVICE_PATH *IPv4; IPv4_DEVICE_PATH *IPv4;
RemoteIPStr = GetNextParamStr (&TextDeviceNode); RemoteIPStr = GetNextParamStr (&TextDeviceNode);
ProtocolStr = GetNextParamStr (&TextDeviceNode); ProtocolStr = GetNextParamStr (&TextDeviceNode);
TypeStr = GetNextParamStr (&TextDeviceNode); TypeStr = GetNextParamStr (&TextDeviceNode);
LocalIPStr = GetNextParamStr (&TextDeviceNode); LocalIPStr = GetNextParamStr (&TextDeviceNode);
GatewayIPStr = GetNextParamStr (&TextDeviceNode);
SubnetMaskStr = GetNextParamStr (&TextDeviceNode);
IPv4 = (IPv4_DEVICE_PATH *) CreateDeviceNode ( IPv4 = (IPv4_DEVICE_PATH *) CreateDeviceNode (
MESSAGING_DEVICE_PATH, MESSAGING_DEVICE_PATH,
MSG_IPv4_DP, MSG_IPv4_DP,
@ -1757,6 +1812,13 @@ DevPathFromTextIPv4 (
} }
StrToIPv4Addr (&LocalIPStr, &IPv4->LocalIpAddress); StrToIPv4Addr (&LocalIPStr, &IPv4->LocalIpAddress);
if (!IS_NULL (*GatewayIPStr) && !IS_NULL (*SubnetMaskStr)) {
StrToIPv4Addr (&GatewayIPStr, &IPv4->GatewayIpAddress);
StrToIPv4Addr (&SubnetMaskStr, &IPv4->SubnetMask);
} else {
ZeroMem (&IPv4->GatewayIpAddress, sizeof (IPv4->GatewayIpAddress));
ZeroMem (&IPv4->SubnetMask, sizeof (IPv4->SubnetMask));
}
IPv4->LocalPort = 0; IPv4->LocalPort = 0;
IPv4->RemotePort = 0; IPv4->RemotePort = 0;
@ -2810,6 +2872,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE DevPathFromTextTable[]
{L"Ctrl", DevPathFromTextCtrl}, {L"Ctrl", DevPathFromTextCtrl},
{L"Acpi", DevPathFromTextAcpi}, {L"Acpi", DevPathFromTextAcpi},
{L"PciRoot", DevPathFromTextPciRoot}, {L"PciRoot", DevPathFromTextPciRoot},
{L"PcieRoot", DevPathFromTextPcieRoot},
{L"Floppy", DevPathFromTextFloppy}, {L"Floppy", DevPathFromTextFloppy},
{L"Keyboard", DevPathFromTextKeyboard}, {L"Keyboard", DevPathFromTextKeyboard},
{L"Serial", DevPathFromTextSerial}, {L"Serial", DevPathFromTextSerial},
@ -2820,6 +2883,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE DevPathFromTextTable[]
{L"Ata", DevPathFromTextAta}, {L"Ata", DevPathFromTextAta},
{L"Scsi", DevPathFromTextScsi}, {L"Scsi", DevPathFromTextScsi},
{L"Fibre", DevPathFromTextFibre}, {L"Fibre", DevPathFromTextFibre},
{L"FibreEx", DevPathFromTextFibreEx},
{L"I1394", DevPathFromText1394}, {L"I1394", DevPathFromText1394},
{L"USB", DevPathFromTextUsb}, {L"USB", DevPathFromTextUsb},
{L"I2O", DevPathFromTextI2O}, {L"I2O", DevPathFromTextI2O},

View File

@ -37,36 +37,32 @@ CatPrint (
) )
{ {
UINT16 *AppendStr; UINT16 *AppendStr;
UINTN AppendCount;
VA_LIST Args; VA_LIST Args;
UINTN Size;
AppendStr = AllocateZeroPool (0x1000); AppendStr = AllocateZeroPool (0x1000);
if (AppendStr == NULL) { ASSERT (AppendStr != NULL);
return Str->Str;
}
VA_START (Args, Fmt); VA_START (Args, Fmt);
UnicodeVSPrint (AppendStr, 0x1000, Fmt, Args); AppendCount = UnicodeVSPrint (AppendStr, 0x1000, Fmt, Args);
VA_END (Args); VA_END (Args);
if (NULL == Str->Str) {
Size = StrSize (AppendStr); if (Str->Length + AppendCount * sizeof (CHAR16) > Str->Capacity) {
Str->Str = AllocateZeroPool (Size); Str->Capacity = Str->Length + (AppendCount + 1) * sizeof (CHAR16) * 2;
ASSERT (Str->Str != NULL);
} else {
Size = StrSize (AppendStr) - sizeof (UINT16);
Size = Size + StrSize (Str->Str);
Str->Str = ReallocatePool ( Str->Str = ReallocatePool (
StrSize (Str->Str), Str->Length,
Size, Str->Capacity,
Str->Str Str->Str
); );
ASSERT (Str->Str != NULL); ASSERT (Str->Str != NULL);
} }
Str->MaxLen = MAX_CHAR * sizeof (UINT16); if (Str->Length == 0) {
if (Size < Str->MaxLen) { StrCpy (Str->Str, AppendStr);
Str->Length = (AppendCount + 1) * sizeof (CHAR16);
} else {
StrCat (Str->Str, AppendStr); StrCat (Str->Str, AppendStr);
Str->Len = Size - sizeof (UINT16); Str->Length += AppendCount * sizeof (CHAR16);
} }
FreePool (AppendStr); FreePool (AppendStr);
@ -97,7 +93,7 @@ DevPathToTextPci (
PCI_DEVICE_PATH *Pci; PCI_DEVICE_PATH *Pci;
Pci = DevPath; Pci = DevPath;
CatPrint (Str, L"Pci(0x%x,0x%x)", (UINTN) Pci->Device, (UINTN) Pci->Function); CatPrint (Str, L"Pci(0x%x,0x%x)", Pci->Device, Pci->Function);
} }
/** /**
@ -124,7 +120,7 @@ DevPathToTextPccard (
PCCARD_DEVICE_PATH *Pccard; PCCARD_DEVICE_PATH *Pccard;
Pccard = DevPath; Pccard = DevPath;
CatPrint (Str, L"PcCard(0x%x)", (UINTN) Pccard->FunctionNumber); CatPrint (Str, L"PcCard(0x%x)", Pccard->FunctionNumber);
} }
/** /**
@ -154,7 +150,7 @@ DevPathToTextMemMap (
CatPrint ( CatPrint (
Str, Str,
L"MemoryMapped(0x%x,0x%lx,0x%lx)", L"MemoryMapped(0x%x,0x%lx,0x%lx)",
(UINTN) MemMap->MemoryType, MemMap->MemoryType,
MemMap->StartingAddress, MemMap->StartingAddress,
MemMap->EndingAddress MemMap->EndingAddress
); );
@ -235,7 +231,7 @@ DevPathToTextVendor (
L"SAS(0x%lx,0x%lx,0x%x,", L"SAS(0x%lx,0x%lx,0x%x,",
((SAS_DEVICE_PATH *) Vendor)->SasAddress, ((SAS_DEVICE_PATH *) Vendor)->SasAddress,
((SAS_DEVICE_PATH *) Vendor)->Lun, ((SAS_DEVICE_PATH *) Vendor)->Lun,
(UINTN) ((SAS_DEVICE_PATH *) Vendor)->RelativeTargetPort ((SAS_DEVICE_PATH *) Vendor)->RelativeTargetPort
); );
Info = (((SAS_DEVICE_PATH *) Vendor)->DeviceTopology); Info = (((SAS_DEVICE_PATH *) Vendor)->DeviceTopology);
if ((Info & 0x0f) == 0) { if ((Info & 0x0f) == 0) {
@ -251,13 +247,13 @@ DevPathToTextVendor (
if ((Info & 0x0f) == 1) { if ((Info & 0x0f) == 1) {
CatPrint (Str, L"0,"); CatPrint (Str, L"0,");
} else { } else {
CatPrint (Str, L"0x%x,",(UINTN) (Info >> 8) & 0xff); CatPrint (Str, L"0x%x,", (Info >> 8) & 0xff);
} }
} else { } else {
CatPrint (Str, L"0,0,0,0,"); CatPrint (Str, L"0,0,0,0,");
} }
CatPrint (Str, L"0x%x)", (UINTN) ((SAS_DEVICE_PATH *) Vendor)->Reserved); CatPrint (Str, L"0x%x)", ((SAS_DEVICE_PATH *) Vendor)->Reserved);
return ; return ;
} else if (CompareGuid (&Vendor->Guid, &gEfiDebugPortProtocolGuid)) { } else if (CompareGuid (&Vendor->Guid, &gEfiDebugPortProtocolGuid)) {
CatPrint (Str, L"DebugPort()"); CatPrint (Str, L"DebugPort()");
@ -280,7 +276,7 @@ DevPathToTextVendor (
if (DataLength != 0) { if (DataLength != 0) {
CatPrint (Str, L","); CatPrint (Str, L",");
for (Index = 0; Index < DataLength; Index++) { for (Index = 0; Index < DataLength; Index++) {
CatPrint (Str, L"%02x", (UINTN) ((VENDOR_DEVICE_PATH_WITH_DATA *) Vendor)->VendorDefinedData[Index]); CatPrint (Str, L"%02x", ((VENDOR_DEVICE_PATH_WITH_DATA *) Vendor)->VendorDefinedData[Index]);
} }
} }
@ -314,7 +310,7 @@ DevPathToTextController (
CatPrint ( CatPrint (
Str, Str,
L"Ctrl(0x%x)", L"Ctrl(0x%x)",
(UINTN) Controller->ControllerNumber Controller->ControllerNumber
); );
} }
@ -345,31 +341,35 @@ DevPathToTextAcpi (
if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) { if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {
switch (EISA_ID_TO_NUM (Acpi->HID)) { switch (EISA_ID_TO_NUM (Acpi->HID)) {
case 0x0a03: case 0x0a03:
CatPrint (Str, L"PciRoot(0x%x)", (UINTN) Acpi->UID); CatPrint (Str, L"PciRoot(0x%x)", Acpi->UID);
break;
case 0x0a08:
CatPrint (Str, L"PcieRoot(0x%x)", Acpi->UID);
break; break;
case 0x0604: case 0x0604:
CatPrint (Str, L"Floppy(0x%x)", (UINTN) Acpi->UID); CatPrint (Str, L"Floppy(0x%x)", Acpi->UID);
break; break;
case 0x0301: case 0x0301:
CatPrint (Str, L"Keyboard(0x%x)", (UINTN) Acpi->UID); CatPrint (Str, L"Keyboard(0x%x)", Acpi->UID);
break; break;
case 0x0501: case 0x0501:
CatPrint (Str, L"Serial(0x%x)", (UINTN) Acpi->UID); CatPrint (Str, L"Serial(0x%x)", Acpi->UID);
break; break;
case 0x0401: case 0x0401:
CatPrint (Str, L"ParallelPort(0x%x)", (UINTN) Acpi->UID); CatPrint (Str, L"ParallelPort(0x%x)", Acpi->UID);
break; break;
default: default:
CatPrint (Str, L"Acpi(PNP%04x,0x%x)", (UINTN) EISA_ID_TO_NUM (Acpi->HID), (UINTN) Acpi->UID); CatPrint (Str, L"Acpi(PNP%04x,0x%x)", EISA_ID_TO_NUM (Acpi->HID), Acpi->UID);
break; break;
} }
} else { } else {
CatPrint (Str, L"Acpi(0x%08x,0x%x)", (UINTN) Acpi->HID, (UINTN) Acpi->UID); CatPrint (Str, L"Acpi(0x%08x,0x%x)", Acpi->HID, Acpi->UID);
} }
} }
@ -465,7 +465,7 @@ DevPathToTextAcpiEx (
if (AcpiEx->UID == 0) { if (AcpiEx->UID == 0) {
CatPrint (Str, L"%a,", UIDStr); CatPrint (Str, L"%a,", UIDStr);
} else { } else {
CatPrint (Str, L"0x%x,", (UINTN) AcpiEx->UID); CatPrint (Str, L"0x%x,", AcpiEx->UID);
} }
if (AcpiEx->CID == 0) { if (AcpiEx->CID == 0) {
@ -479,7 +479,7 @@ DevPathToTextAcpiEx (
L"AcpiEx(%s,%s,0x%x,%a,%a,%a)", L"AcpiEx(%s,%s,0x%x,%a,%a,%a)",
HIDText, HIDText,
CIDText, CIDText,
(UINTN) AcpiEx->UID, AcpiEx->UID,
HIDStr, HIDStr,
CIDStr, CIDStr,
UIDStr UIDStr
@ -518,9 +518,9 @@ DevPathToTextAcpiAdr (
Length = (UINT16) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) AcpiAdr); Length = (UINT16) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) AcpiAdr);
AdditionalAdrCount = (UINT16) ((Length - 8) / 4); AdditionalAdrCount = (UINT16) ((Length - 8) / 4);
CatPrint (Str, L"AcpiAdr(0x%x", (UINTN) AcpiAdr->ADR); CatPrint (Str, L"AcpiAdr(0x%x", AcpiAdr->ADR);
for (Index = 0; Index < AdditionalAdrCount; Index++) { for (Index = 0; Index < AdditionalAdrCount; Index++) {
CatPrint (Str, L",0x%x", (UINTN) *(UINT32 *) ((UINT8 *) AcpiAdr + 8 + Index * 4)); CatPrint (Str, L",0x%x", *(UINT32 *) ((UINT8 *) AcpiAdr + 8 + Index * 4));
} }
CatPrint (Str, L")"); CatPrint (Str, L")");
} }
@ -551,14 +551,14 @@ DevPathToTextAtapi (
Atapi = DevPath; Atapi = DevPath;
if (DisplayOnly) { if (DisplayOnly) {
CatPrint (Str, L"Ata(0x%x)", (UINTN) Atapi->Lun); CatPrint (Str, L"Ata(0x%x)", Atapi->Lun);
} else { } else {
CatPrint ( CatPrint (
Str, Str,
L"Ata(%s,%s,0x%x)", L"Ata(%s,%s,0x%x)",
(Atapi->PrimarySecondary == 1) ? L"Secondary" : L"Primary", (Atapi->PrimarySecondary == 1) ? L"Secondary" : L"Primary",
(Atapi->SlaveMaster == 1) ? L"Slave" : L"Master", (Atapi->SlaveMaster == 1) ? L"Slave" : L"Master",
(UINTN) Atapi->Lun Atapi->Lun
); );
} }
} }
@ -587,7 +587,7 @@ DevPathToTextScsi (
SCSI_DEVICE_PATH *Scsi; SCSI_DEVICE_PATH *Scsi;
Scsi = DevPath; Scsi = DevPath;
CatPrint (Str, L"Scsi(0x%x,0x%x)", (UINTN) Scsi->Pun, (UINTN) Scsi->Lun); CatPrint (Str, L"Scsi(0x%x,0x%x)", Scsi->Pun, Scsi->Lun);
} }
/** /**
@ -617,6 +617,42 @@ DevPathToTextFibre (
CatPrint (Str, L"Fibre(0x%lx,0x%lx)", Fibre->WWN, Fibre->Lun); CatPrint (Str, L"Fibre(0x%lx,0x%lx)", Fibre->WWN, Fibre->Lun);
} }
/**
Converts a FibreEx device path structure to its string representative.
@param Str The string representative of input device.
@param DevPath The input device path structure.
@param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
of the display node is used, where applicable. If DisplayOnly
is FALSE, then the longer text representation of the display node
is used.
@param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
representation for a device node can be used, where applicable.
**/
VOID
DevPathToTextFibreEx (
IN OUT POOL_PRINT *Str,
IN VOID *DevPath,
IN BOOLEAN DisplayOnly,
IN BOOLEAN AllowShortcuts
)
{
FIBRECHANNELEX_DEVICE_PATH *FibreEx;
UINTN Index;
FibreEx = DevPath;
CatPrint (Str, L"FibreEx(0x");
for (Index = 0; Index < sizeof (FibreEx->WWN) / sizeof (FibreEx->WWN[0]); Index++) {
CatPrint (Str, L"%02x", FibreEx->WWN[Index]);
}
CatPrint (Str, L",0x");
for (Index = 0; Index < sizeof (FibreEx->Lun) / sizeof (FibreEx->Lun[0]); Index++) {
CatPrint (Str, L"%02x", FibreEx->Lun[Index]);
}
CatPrint (Str, L")");
}
/** /**
Converts a 1394 device path structure to its string representative. Converts a 1394 device path structure to its string representative.
@ -717,9 +753,9 @@ DevPathToTextUsbWWID (
CatPrint ( CatPrint (
Str, Str,
L"UsbWwid(0x%x,0x%x,0x%x,\"%s\")", L"UsbWwid(0x%x,0x%x,0x%x,\"%s\")",
(UINTN) UsbWWId->VendorId, UsbWWId->VendorId,
(UINTN) UsbWWId->ProductId, UsbWWId->ProductId,
(UINTN) UsbWWId->InterfaceNumber, UsbWWId->InterfaceNumber,
SerialNumberStr SerialNumberStr
); );
} }
@ -748,7 +784,7 @@ DevPathToTextLogicalUnit (
DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit; DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit;
LogicalUnit = DevPath; LogicalUnit = DevPath;
CatPrint (Str, L"Unit(0x%x)", (UINTN) LogicalUnit->Lun); CatPrint (Str, L"Unit(0x%x)", LogicalUnit->Lun);
} }
/** /**
@ -837,10 +873,10 @@ DevPathToTextUsbClass (
CatPrint ( CatPrint (
Str, Str,
L"(0x%x,0x%x,0x%x,0x%x)", L"(0x%x,0x%x,0x%x,0x%x)",
(UINTN) UsbClass->VendorId, UsbClass->VendorId,
(UINTN) UsbClass->ProductId, UsbClass->ProductId,
(UINTN) UsbClass->DeviceSubClass, UsbClass->DeviceSubClass,
(UINTN) UsbClass->DeviceProtocol UsbClass->DeviceProtocol
); );
return; return;
} }
@ -850,27 +886,27 @@ DevPathToTextUsbClass (
CatPrint ( CatPrint (
Str, Str,
L"UsbDeviceFirmwareUpdate(0x%x,0x%x,0x%x)", L"UsbDeviceFirmwareUpdate(0x%x,0x%x,0x%x)",
(UINTN) UsbClass->VendorId, UsbClass->VendorId,
(UINTN) UsbClass->ProductId, UsbClass->ProductId,
(UINTN) UsbClass->DeviceProtocol UsbClass->DeviceProtocol
); );
return; return;
} else if (UsbClass->DeviceSubClass == USB_SUBCLASS_IRDA_BRIDGE) { } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_IRDA_BRIDGE) {
CatPrint ( CatPrint (
Str, Str,
L"UsbIrdaBridge(0x%x,0x%x,0x%x)", L"UsbIrdaBridge(0x%x,0x%x,0x%x)",
(UINTN) UsbClass->VendorId, UsbClass->VendorId,
(UINTN) UsbClass->ProductId, UsbClass->ProductId,
(UINTN) UsbClass->DeviceProtocol UsbClass->DeviceProtocol
); );
return; return;
} else if (UsbClass->DeviceSubClass == USB_SUBCLASS_TEST) { } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_TEST) {
CatPrint ( CatPrint (
Str, Str,
L"UsbTestAndMeasurement(0x%x,0x%x,0x%x)", L"UsbTestAndMeasurement(0x%x,0x%x,0x%x)",
(UINTN) UsbClass->VendorId, UsbClass->VendorId,
(UINTN) UsbClass->ProductId, UsbClass->ProductId,
(UINTN) UsbClass->DeviceProtocol UsbClass->DeviceProtocol
); );
return; return;
} }
@ -879,11 +915,11 @@ DevPathToTextUsbClass (
CatPrint ( CatPrint (
Str, Str,
L"UsbClass(0x%x,0x%x,0x%x,0x%x,0x%x)", L"UsbClass(0x%x,0x%x,0x%x,0x%x,0x%x)",
(UINTN) UsbClass->VendorId, UsbClass->VendorId,
(UINTN) UsbClass->ProductId, UsbClass->ProductId,
(UINTN) UsbClass->DeviceClass, UsbClass->DeviceClass,
(UINTN) UsbClass->DeviceSubClass, UsbClass->DeviceSubClass,
(UINTN) UsbClass->DeviceProtocol UsbClass->DeviceProtocol
); );
} }
@ -915,16 +951,16 @@ DevPathToTextSata (
CatPrint ( CatPrint (
Str, Str,
L"Sata(0x%x,0x%x)", L"Sata(0x%x,0x%x)",
(UINTN) Sata->HBAPortNumber, Sata->HBAPortNumber,
(UINTN) Sata->Lun Sata->Lun
); );
} else { } else {
CatPrint ( CatPrint (
Str, Str,
L"Sata(0x%x,0x%x,0x%x)", L"Sata(0x%x,0x%x,0x%x)",
(UINTN) Sata->HBAPortNumber, Sata->HBAPortNumber,
(UINTN) Sata->PortMultiplierPortNumber, Sata->PortMultiplierPortNumber,
(UINTN) Sata->Lun Sata->Lun
); );
} }
} }
@ -953,7 +989,7 @@ DevPathToTextI2O (
I2O_DEVICE_PATH *I2ODevPath; I2O_DEVICE_PATH *I2ODevPath;
I2ODevPath = DevPath; I2ODevPath = DevPath;
CatPrint (Str, L"I2O(0x%x)", (UINTN) I2ODevPath->Tid); CatPrint (Str, L"I2O(0x%x)", I2ODevPath->Tid);
} }
/** /**
@ -991,10 +1027,10 @@ DevPathToTextMacAddr (
CatPrint (Str, L"MAC("); CatPrint (Str, L"MAC(");
for (Index = 0; Index < HwAddressSize; Index++) { for (Index = 0; Index < HwAddressSize; Index++) {
CatPrint (Str, L"%02x", (UINTN) MacDevPath->MacAddress.Addr[Index]); CatPrint (Str, L"%02x", MacDevPath->MacAddress.Addr[Index]);
} }
CatPrint (Str, L",0x%x)", (UINTN) MacDevPath->IfType); CatPrint (Str, L",0x%x)", MacDevPath->IfType);
} }
/** /**
@ -1047,10 +1083,10 @@ DevPathToTextIPv4 (
CatPrint ( CatPrint (
Str, Str,
L"IPv4(%d.%d.%d.%d)", L"IPv4(%d.%d.%d.%d)",
(UINTN) IPDevPath->RemoteIpAddress.Addr[0], IPDevPath->RemoteIpAddress.Addr[0],
(UINTN) IPDevPath->RemoteIpAddress.Addr[1], IPDevPath->RemoteIpAddress.Addr[1],
(UINTN) IPDevPath->RemoteIpAddress.Addr[2], IPDevPath->RemoteIpAddress.Addr[2],
(UINTN) IPDevPath->RemoteIpAddress.Addr[3] IPDevPath->RemoteIpAddress.Addr[3]
); );
return ; return ;
} }
@ -1058,10 +1094,10 @@ DevPathToTextIPv4 (
CatPrint ( CatPrint (
Str, Str,
L"IPv4(%d.%d.%d.%d,", L"IPv4(%d.%d.%d.%d,",
(UINTN) IPDevPath->RemoteIpAddress.Addr[0], IPDevPath->RemoteIpAddress.Addr[0],
(UINTN) IPDevPath->RemoteIpAddress.Addr[1], IPDevPath->RemoteIpAddress.Addr[1],
(UINTN) IPDevPath->RemoteIpAddress.Addr[2], IPDevPath->RemoteIpAddress.Addr[2],
(UINTN) IPDevPath->RemoteIpAddress.Addr[3] IPDevPath->RemoteIpAddress.Addr[3]
); );
CatNetworkProtocol ( CatNetworkProtocol (
@ -1071,13 +1107,28 @@ DevPathToTextIPv4 (
CatPrint ( CatPrint (
Str, Str,
L",%s,%d.%d.%d.%d)", L",%s,%d.%d.%d.%d",
IPDevPath->StaticIpAddress ? L"Static" : L"DHCP", IPDevPath->StaticIpAddress ? L"Static" : L"DHCP",
(UINTN) IPDevPath->LocalIpAddress.Addr[0], IPDevPath->LocalIpAddress.Addr[0],
(UINTN) IPDevPath->LocalIpAddress.Addr[1], IPDevPath->LocalIpAddress.Addr[1],
(UINTN) IPDevPath->LocalIpAddress.Addr[2], IPDevPath->LocalIpAddress.Addr[2],
(UINTN) IPDevPath->LocalIpAddress.Addr[3] IPDevPath->LocalIpAddress.Addr[3]
); );
if (DevicePathNodeLength (IPDevPath) == sizeof (IPv4_DEVICE_PATH)) {
CatPrint (
Str,
L",%d.%d.%d.%d,%d.%d.%d.%d",
IPDevPath->GatewayIpAddress.Addr[0],
IPDevPath->GatewayIpAddress.Addr[1],
IPDevPath->GatewayIpAddress.Addr[2],
IPDevPath->GatewayIpAddress.Addr[3],
IPDevPath->SubnetMask.Addr[0],
IPDevPath->SubnetMask.Addr[1],
IPDevPath->SubnetMask.Addr[2],
IPDevPath->SubnetMask.Addr[3]
);
}
CatPrint (Str, L")");
} }
/** /**
@ -1108,22 +1159,22 @@ DevPathToTextIPv6 (
CatPrint ( CatPrint (
Str, Str,
L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)", L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",
(UINTN) IPDevPath->RemoteIpAddress.Addr[0], IPDevPath->RemoteIpAddress.Addr[0],
(UINTN) IPDevPath->RemoteIpAddress.Addr[1], IPDevPath->RemoteIpAddress.Addr[1],
(UINTN) IPDevPath->RemoteIpAddress.Addr[2], IPDevPath->RemoteIpAddress.Addr[2],
(UINTN) IPDevPath->RemoteIpAddress.Addr[3], IPDevPath->RemoteIpAddress.Addr[3],
(UINTN) IPDevPath->RemoteIpAddress.Addr[4], IPDevPath->RemoteIpAddress.Addr[4],
(UINTN) IPDevPath->RemoteIpAddress.Addr[5], IPDevPath->RemoteIpAddress.Addr[5],
(UINTN) IPDevPath->RemoteIpAddress.Addr[6], IPDevPath->RemoteIpAddress.Addr[6],
(UINTN) IPDevPath->RemoteIpAddress.Addr[7], IPDevPath->RemoteIpAddress.Addr[7],
(UINTN) IPDevPath->RemoteIpAddress.Addr[8], IPDevPath->RemoteIpAddress.Addr[8],
(UINTN) IPDevPath->RemoteIpAddress.Addr[9], IPDevPath->RemoteIpAddress.Addr[9],
(UINTN) IPDevPath->RemoteIpAddress.Addr[10], IPDevPath->RemoteIpAddress.Addr[10],
(UINTN) IPDevPath->RemoteIpAddress.Addr[11], IPDevPath->RemoteIpAddress.Addr[11],
(UINTN) IPDevPath->RemoteIpAddress.Addr[12], IPDevPath->RemoteIpAddress.Addr[12],
(UINTN) IPDevPath->RemoteIpAddress.Addr[13], IPDevPath->RemoteIpAddress.Addr[13],
(UINTN) IPDevPath->RemoteIpAddress.Addr[14], IPDevPath->RemoteIpAddress.Addr[14],
(UINTN) IPDevPath->RemoteIpAddress.Addr[15] IPDevPath->RemoteIpAddress.Addr[15]
); );
return ; return ;
} }
@ -1131,22 +1182,22 @@ DevPathToTextIPv6 (
CatPrint ( CatPrint (
Str, Str,
L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x,", L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x,",
(UINTN) IPDevPath->RemoteIpAddress.Addr[0], IPDevPath->RemoteIpAddress.Addr[0],
(UINTN) IPDevPath->RemoteIpAddress.Addr[1], IPDevPath->RemoteIpAddress.Addr[1],
(UINTN) IPDevPath->RemoteIpAddress.Addr[2], IPDevPath->RemoteIpAddress.Addr[2],
(UINTN) IPDevPath->RemoteIpAddress.Addr[3], IPDevPath->RemoteIpAddress.Addr[3],
(UINTN) IPDevPath->RemoteIpAddress.Addr[4], IPDevPath->RemoteIpAddress.Addr[4],
(UINTN) IPDevPath->RemoteIpAddress.Addr[5], IPDevPath->RemoteIpAddress.Addr[5],
(UINTN) IPDevPath->RemoteIpAddress.Addr[6], IPDevPath->RemoteIpAddress.Addr[6],
(UINTN) IPDevPath->RemoteIpAddress.Addr[7], IPDevPath->RemoteIpAddress.Addr[7],
(UINTN) IPDevPath->RemoteIpAddress.Addr[8], IPDevPath->RemoteIpAddress.Addr[8],
(UINTN) IPDevPath->RemoteIpAddress.Addr[9], IPDevPath->RemoteIpAddress.Addr[9],
(UINTN) IPDevPath->RemoteIpAddress.Addr[10], IPDevPath->RemoteIpAddress.Addr[10],
(UINTN) IPDevPath->RemoteIpAddress.Addr[11], IPDevPath->RemoteIpAddress.Addr[11],
(UINTN) IPDevPath->RemoteIpAddress.Addr[12], IPDevPath->RemoteIpAddress.Addr[12],
(UINTN) IPDevPath->RemoteIpAddress.Addr[13], IPDevPath->RemoteIpAddress.Addr[13],
(UINTN) IPDevPath->RemoteIpAddress.Addr[14], IPDevPath->RemoteIpAddress.Addr[14],
(UINTN) IPDevPath->RemoteIpAddress.Addr[15] IPDevPath->RemoteIpAddress.Addr[15]
); );
CatNetworkProtocol ( CatNetworkProtocol (
@ -1158,22 +1209,22 @@ DevPathToTextIPv6 (
Str, Str,
L",%s,%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)", L",%s,%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",
IPDevPath->StaticIpAddress ? L"Static" : L"DHCP", IPDevPath->StaticIpAddress ? L"Static" : L"DHCP",
(UINTN) IPDevPath->LocalIpAddress.Addr[0], IPDevPath->LocalIpAddress.Addr[0],
(UINTN) IPDevPath->LocalIpAddress.Addr[1], IPDevPath->LocalIpAddress.Addr[1],
(UINTN) IPDevPath->LocalIpAddress.Addr[2], IPDevPath->LocalIpAddress.Addr[2],
(UINTN) IPDevPath->LocalIpAddress.Addr[3], IPDevPath->LocalIpAddress.Addr[3],
(UINTN) IPDevPath->LocalIpAddress.Addr[4], IPDevPath->LocalIpAddress.Addr[4],
(UINTN) IPDevPath->LocalIpAddress.Addr[5], IPDevPath->LocalIpAddress.Addr[5],
(UINTN) IPDevPath->LocalIpAddress.Addr[6], IPDevPath->LocalIpAddress.Addr[6],
(UINTN) IPDevPath->LocalIpAddress.Addr[7], IPDevPath->LocalIpAddress.Addr[7],
(UINTN) IPDevPath->LocalIpAddress.Addr[8], IPDevPath->LocalIpAddress.Addr[8],
(UINTN) IPDevPath->LocalIpAddress.Addr[9], IPDevPath->LocalIpAddress.Addr[9],
(UINTN) IPDevPath->LocalIpAddress.Addr[10], IPDevPath->LocalIpAddress.Addr[10],
(UINTN) IPDevPath->LocalIpAddress.Addr[11], IPDevPath->LocalIpAddress.Addr[11],
(UINTN) IPDevPath->LocalIpAddress.Addr[12], IPDevPath->LocalIpAddress.Addr[12],
(UINTN) IPDevPath->LocalIpAddress.Addr[13], IPDevPath->LocalIpAddress.Addr[13],
(UINTN) IPDevPath->LocalIpAddress.Addr[14], IPDevPath->LocalIpAddress.Addr[14],
(UINTN) IPDevPath->LocalIpAddress.Addr[15] IPDevPath->LocalIpAddress.Addr[15]
); );
} }
@ -1204,7 +1255,7 @@ DevPathToTextInfiniBand (
CatPrint ( CatPrint (
Str, Str,
L"Infiniband(0x%x,%g,0x%lx,0x%lx,0x%lx)", L"Infiniband(0x%x,%g,0x%lx,0x%lx,0x%lx)",
(UINTN) InfiniBand->ResourceFlags, InfiniBand->ResourceFlags,
InfiniBand->PortGid, InfiniBand->PortGid,
InfiniBand->ServiceId, InfiniBand->ServiceId,
InfiniBand->TargetPortId, InfiniBand->TargetPortId,
@ -1276,7 +1327,7 @@ DevPathToTextUart (
if (Uart->DataBits == 0) { if (Uart->DataBits == 0) {
CatPrint (Str, L"DEFAULT,"); CatPrint (Str, L"DEFAULT,");
} else { } else {
CatPrint (Str, L"%d,", (UINTN) Uart->DataBits); CatPrint (Str, L"%d,", Uart->DataBits);
} }
CatPrint (Str, L"%c,", Parity); CatPrint (Str, L"%c,", Parity);
@ -1333,7 +1384,7 @@ DevPathToTextiSCSI (
Str, Str,
L"iSCSI(%a,0x%x,0x%lx,", L"iSCSI(%a,0x%x,0x%lx,",
ISCSIDevPath->TargetName, ISCSIDevPath->TargetName,
(UINTN) ISCSIDevPath->TargetPortalGroupTag, ISCSIDevPath->TargetPortalGroupTag,
ISCSIDevPath->Lun ISCSIDevPath->Lun
); );
@ -1376,7 +1427,7 @@ DevPathToTextVlan (
VLAN_DEVICE_PATH *Vlan; VLAN_DEVICE_PATH *Vlan;
Vlan = DevPath; Vlan = DevPath;
CatPrint (Str, L"Vlan(%d)", (UINTN) Vlan->VlanId); CatPrint (Str, L"Vlan(%d)", Vlan->VlanId);
} }
/** /**
@ -1408,9 +1459,9 @@ DevPathToTextHardDrive (
CatPrint ( CatPrint (
Str, Str,
L"HD(%d,%s,0x%08x,", L"HD(%d,%s,0x%08x,",
(UINTN) Hd->PartitionNumber, Hd->PartitionNumber,
L"MBR", L"MBR",
(UINTN) *((UINT32 *) (&(Hd->Signature[0]))) *((UINT32 *) (&(Hd->Signature[0])))
); );
break; break;
@ -1418,7 +1469,7 @@ DevPathToTextHardDrive (
CatPrint ( CatPrint (
Str, Str,
L"HD(%d,%s,%g,", L"HD(%d,%s,%g,",
(UINTN) Hd->PartitionNumber, Hd->PartitionNumber,
L"GPT", L"GPT",
(EFI_GUID *) &(Hd->Signature[0]) (EFI_GUID *) &(Hd->Signature[0])
); );
@ -1428,8 +1479,8 @@ DevPathToTextHardDrive (
CatPrint ( CatPrint (
Str, Str,
L"HD(%d,%d,0,", L"HD(%d,%d,0,",
(UINTN) Hd->PartitionNumber, Hd->PartitionNumber,
(UINTN) Hd->SignatureType Hd->SignatureType
); );
break; break;
} }
@ -1462,11 +1513,11 @@ DevPathToTextCDROM (
Cd = DevPath; Cd = DevPath;
if (DisplayOnly) { if (DisplayOnly) {
CatPrint (Str, L"CDROM(0x%x)", (UINTN) Cd->BootEntry); CatPrint (Str, L"CDROM(0x%x)", Cd->BootEntry);
return ; return ;
} }
CatPrint (Str, L"CDROM(0x%x,0x%lx,0x%lx)", (UINTN) Cd->BootEntry, Cd->PartitionStart, Cd->PartitionSize); CatPrint (Str, L"CDROM(0x%x,0x%lx,0x%lx)", Cd->BootEntry, Cd->PartitionStart, Cd->PartitionSize);
} }
/** /**
@ -1667,7 +1718,7 @@ DevPathToTextBBS (
if (Type != NULL) { if (Type != NULL) {
CatPrint (Str, L"BBS(%s,%a", Type, Bbs->String); CatPrint (Str, L"BBS(%s,%a", Type, Bbs->String);
} else { } else {
CatPrint (Str, L"BBS(0x%x,%a", (UINTN) Bbs->DeviceType, Bbs->String); CatPrint (Str, L"BBS(0x%x,%a", Bbs->DeviceType, Bbs->String);
} }
if (DisplayOnly) { if (DisplayOnly) {
@ -1675,7 +1726,7 @@ DevPathToTextBBS (
return ; return ;
} }
CatPrint (Str, L",0x%x)", (UINTN) Bbs->StatusFlag); CatPrint (Str, L",0x%x)", Bbs->StatusFlag);
} }
/** /**
@ -1738,6 +1789,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE DevPathToTextTable
{MESSAGING_DEVICE_PATH, MSG_ATAPI_DP, DevPathToTextAtapi}, {MESSAGING_DEVICE_PATH, MSG_ATAPI_DP, DevPathToTextAtapi},
{MESSAGING_DEVICE_PATH, MSG_SCSI_DP, DevPathToTextScsi}, {MESSAGING_DEVICE_PATH, MSG_SCSI_DP, DevPathToTextScsi},
{MESSAGING_DEVICE_PATH, MSG_FIBRECHANNEL_DP, DevPathToTextFibre}, {MESSAGING_DEVICE_PATH, MSG_FIBRECHANNEL_DP, DevPathToTextFibre},
{MESSAGING_DEVICE_PATH, MSG_FIBRECHANNELEX_DP, DevPathToTextFibreEx},
{MESSAGING_DEVICE_PATH, MSG_1394_DP, DevPathToText1394}, {MESSAGING_DEVICE_PATH, MSG_1394_DP, DevPathToText1394},
{MESSAGING_DEVICE_PATH, MSG_USB_DP, DevPathToTextUsb}, {MESSAGING_DEVICE_PATH, MSG_USB_DP, DevPathToTextUsb},
{MESSAGING_DEVICE_PATH, MSG_USB_WWID_DP, DevPathToTextUsbWWID}, {MESSAGING_DEVICE_PATH, MSG_USB_WWID_DP, DevPathToTextUsbWWID},
@ -1791,7 +1843,6 @@ ConvertDeviceNodeToText (
{ {
POOL_PRINT Str; POOL_PRINT Str;
UINTN Index; UINTN Index;
UINTN NewSize;
VOID (*DumpNode)(POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN); VOID (*DumpNode)(POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);
if (DeviceNode == NULL) { if (DeviceNode == NULL) {
@ -1824,13 +1875,6 @@ ConvertDeviceNodeToText (
// //
DumpNode (&Str, (VOID *) DeviceNode, DisplayOnly, AllowShortcuts); DumpNode (&Str, (VOID *) DeviceNode, DisplayOnly, AllowShortcuts);
//
// Shrink pool used for string allocation
//
NewSize = (Str.Len + 1) * sizeof (CHAR16);
Str.Str = ReallocatePool (NewSize, NewSize, Str.Str);
ASSERT (Str.Str != NULL);
Str.Str[Str.Len] = 0;
return Str.Str; return Str.Str;
} }
@ -1861,7 +1905,6 @@ ConvertDevicePathToText (
EFI_DEVICE_PATH_PROTOCOL *DevPathNode; EFI_DEVICE_PATH_PROTOCOL *DevPathNode;
EFI_DEVICE_PATH_PROTOCOL *AlignedDevPathNode; EFI_DEVICE_PATH_PROTOCOL *AlignedDevPathNode;
UINTN Index; UINTN Index;
UINTN NewSize;
VOID (*DumpNode) (POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN); VOID (*DumpNode) (POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN);
if (DevicePath == NULL) { if (DevicePath == NULL) {
@ -1897,8 +1940,8 @@ ConvertDevicePathToText (
// //
// Put a path separator in if needed // Put a path separator in if needed
// //
if ((Str.Len != 0) && DumpNode != DevPathToTextEndInstance) { if ((Str.Length != 0) && (DumpNode != DevPathToTextEndInstance)) {
if (*(Str.Str + Str.Len / sizeof (CHAR16) - 1) != L',') { if (*(Str.Str + Str.Length / sizeof (CHAR16) - 1) != L',') {
CatPrint (&Str, L"/"); CatPrint (&Str, L"/");
} }
} }
@ -1916,9 +1959,5 @@ ConvertDevicePathToText (
DevPathNode = NextDevicePathNode (DevPathNode); DevPathNode = NextDevicePathNode (DevPathNode);
} }
NewSize = (Str.Len + 1) * sizeof (CHAR16);
Str.Str = ReallocatePool (NewSize, NewSize, Str.Str);
ASSERT (Str.Str != NULL);
Str.Str[Str.Len] = 0;
return Str.Str; return Str.Str;
} }