X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FDevicePathDxe%2FDevicePathToText.c;h=d7cff207fe60181dd0ff12b5a04d20227c9c015d;hb=8f5e3a12a9dc5f5b782204ee655db6cb22e25ea5;hp=afa982afc4e9d4a3c1dee1a885973c5a640d57cb;hpb=186ca8b0cd473901fd0a6ce39d7f091383672799;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c b/MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c index afa982afc4..d7cff207fe 100644 --- a/MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c +++ b/MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c @@ -1,8 +1,8 @@ /** @file DevicePathToText protocol as defined in the UEFI 2.0 specification. -Copyright (c) 2006 - 2008, Intel Corporation.
-All rights reserved. This program and the accompanying materials +Copyright (c) 2006 - 2011, 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 @@ -29,6 +29,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ CHAR16 * +EFIAPI CatPrint ( IN OUT POOL_PRINT *Str, IN CHAR16 *Fmt, @@ -36,36 +37,32 @@ CatPrint ( ) { UINT16 *AppendStr; + UINTN AppendCount; VA_LIST Args; - UINTN Size; AppendStr = AllocateZeroPool (0x1000); - if (AppendStr == NULL) { - return Str->Str; - } + ASSERT (AppendStr != NULL); VA_START (Args, Fmt); - UnicodeVSPrint (AppendStr, 0x1000, Fmt, Args); + AppendCount = UnicodeVSPrint (AppendStr, 0x1000, Fmt, Args); VA_END (Args); - if (NULL == Str->Str) { - Size = StrSize (AppendStr); - Str->Str = AllocateZeroPool (Size); - ASSERT (Str->Str != NULL); - } else { - Size = StrSize (AppendStr) - sizeof (UINT16); - Size = Size + StrSize (Str->Str); + + if (Str->Length + AppendCount * sizeof (CHAR16) > Str->Capacity) { + Str->Capacity = Str->Length + (AppendCount + 1) * sizeof (CHAR16) * 2; Str->Str = ReallocatePool ( - StrSize (Str->Str), - Size, + Str->Length, + Str->Capacity, Str->Str ); ASSERT (Str->Str != NULL); } - Str->MaxLen = MAX_CHAR * sizeof (UINT16); - if (Size < Str->MaxLen) { + if (Str->Length == 0) { + StrCpy (Str->Str, AppendStr); + Str->Length = (AppendCount + 1) * sizeof (CHAR16); + } else { StrCat (Str->Str, AppendStr); - Str->Len = Size - sizeof (UINT16); + Str->Length += AppendCount * sizeof (CHAR16); } FreePool (AppendStr); @@ -96,7 +93,7 @@ DevPathToTextPci ( PCI_DEVICE_PATH *Pci; 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); } /** @@ -123,7 +120,7 @@ DevPathToTextPccard ( PCCARD_DEVICE_PATH *Pccard; Pccard = DevPath; - CatPrint (Str, L"PcCard(0x%x)", (UINTN) Pccard->FunctionNumber); + CatPrint (Str, L"PcCard(0x%x)", Pccard->FunctionNumber); } /** @@ -153,7 +150,7 @@ DevPathToTextMemMap ( CatPrint ( Str, L"MemoryMapped(0x%x,0x%lx,0x%lx)", - (UINTN) MemMap->MemoryType, + MemMap->MemoryType, MemMap->StartingAddress, MemMap->EndingAddress ); @@ -234,7 +231,7 @@ DevPathToTextVendor ( L"SAS(0x%lx,0x%lx,0x%x,", ((SAS_DEVICE_PATH *) Vendor)->SasAddress, ((SAS_DEVICE_PATH *) Vendor)->Lun, - (UINTN) ((SAS_DEVICE_PATH *) Vendor)->RelativeTargetPort + ((SAS_DEVICE_PATH *) Vendor)->RelativeTargetPort ); Info = (((SAS_DEVICE_PATH *) Vendor)->DeviceTopology); if ((Info & 0x0f) == 0) { @@ -250,13 +247,13 @@ DevPathToTextVendor ( if ((Info & 0x0f) == 1) { CatPrint (Str, L"0,"); } else { - CatPrint (Str, L"0x%x,",(UINTN) (Info >> 8) & 0xff); + CatPrint (Str, L"0x%x,", (Info >> 8) & 0xff); } } else { 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 ; } else if (CompareGuid (&Vendor->Guid, &gEfiDebugPortProtocolGuid)) { CatPrint (Str, L"DebugPort()"); @@ -279,7 +276,7 @@ DevPathToTextVendor ( 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"%02x", ((VENDOR_DEVICE_PATH_WITH_DATA *) Vendor)->VendorDefinedData[Index]); } } @@ -313,7 +310,7 @@ DevPathToTextController ( CatPrint ( Str, L"Ctrl(0x%x)", - (UINTN) Controller->ControllerNumber + Controller->ControllerNumber ); } @@ -344,31 +341,35 @@ DevPathToTextAcpi ( if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) { switch (EISA_ID_TO_NUM (Acpi->HID)) { 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; case 0x0604: - CatPrint (Str, L"Floppy(0x%x)", (UINTN) Acpi->UID); + CatPrint (Str, L"Floppy(0x%x)", Acpi->UID); break; case 0x0301: - CatPrint (Str, L"Keyboard(0x%x)", (UINTN) Acpi->UID); + CatPrint (Str, L"Keyboard(0x%x)", Acpi->UID); break; case 0x0501: - CatPrint (Str, L"Serial(0x%x)", (UINTN) Acpi->UID); + CatPrint (Str, L"Serial(0x%x)", Acpi->UID); break; case 0x0401: - CatPrint (Str, L"ParallelPort(0x%x)", (UINTN) Acpi->UID); + CatPrint (Str, L"ParallelPort(0x%x)", Acpi->UID); break; 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; } } 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); } } @@ -464,7 +465,7 @@ DevPathToTextAcpiEx ( if (AcpiEx->UID == 0) { CatPrint (Str, L"%a,", UIDStr); } else { - CatPrint (Str, L"0x%x,", (UINTN) AcpiEx->UID); + CatPrint (Str, L"0x%x,", AcpiEx->UID); } if (AcpiEx->CID == 0) { @@ -478,7 +479,7 @@ DevPathToTextAcpiEx ( L"AcpiEx(%s,%s,0x%x,%a,%a,%a)", HIDText, CIDText, - (UINTN) AcpiEx->UID, + AcpiEx->UID, HIDStr, CIDStr, UIDStr @@ -517,9 +518,9 @@ DevPathToTextAcpiAdr ( Length = (UINT16) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) AcpiAdr); 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++) { - 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")"); } @@ -550,14 +551,14 @@ DevPathToTextAtapi ( Atapi = DevPath; if (DisplayOnly) { - CatPrint (Str, L"Ata(0x%x)", (UINTN) Atapi->Lun); + CatPrint (Str, L"Ata(0x%x)", Atapi->Lun); } else { CatPrint ( Str, L"Ata(%s,%s,0x%x)", (Atapi->PrimarySecondary == 1) ? L"Secondary" : L"Primary", (Atapi->SlaveMaster == 1) ? L"Slave" : L"Master", - (UINTN) Atapi->Lun + Atapi->Lun ); } } @@ -586,7 +587,7 @@ DevPathToTextScsi ( SCSI_DEVICE_PATH *Scsi; 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); } /** @@ -616,6 +617,42 @@ DevPathToTextFibre ( 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. @@ -716,9 +753,9 @@ DevPathToTextUsbWWID ( CatPrint ( Str, L"UsbWwid(0x%x,0x%x,0x%x,\"%s\")", - (UINTN) UsbWWId->VendorId, - (UINTN) UsbWWId->ProductId, - (UINTN) UsbWWId->InterfaceNumber, + UsbWWId->VendorId, + UsbWWId->ProductId, + UsbWWId->InterfaceNumber, SerialNumberStr ); } @@ -747,7 +784,7 @@ DevPathToTextLogicalUnit ( DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit; LogicalUnit = DevPath; - CatPrint (Str, L"Unit(0x%x)", (UINTN) LogicalUnit->Lun); + CatPrint (Str, L"Unit(0x%x)", LogicalUnit->Lun); } /** @@ -836,10 +873,10 @@ DevPathToTextUsbClass ( CatPrint ( Str, L"(0x%x,0x%x,0x%x,0x%x)", - (UINTN) UsbClass->VendorId, - (UINTN) UsbClass->ProductId, - (UINTN) UsbClass->DeviceSubClass, - (UINTN) UsbClass->DeviceProtocol + UsbClass->VendorId, + UsbClass->ProductId, + UsbClass->DeviceSubClass, + UsbClass->DeviceProtocol ); return; } @@ -849,27 +886,27 @@ DevPathToTextUsbClass ( CatPrint ( Str, L"UsbDeviceFirmwareUpdate(0x%x,0x%x,0x%x)", - (UINTN) UsbClass->VendorId, - (UINTN) UsbClass->ProductId, - (UINTN) UsbClass->DeviceProtocol + UsbClass->VendorId, + UsbClass->ProductId, + UsbClass->DeviceProtocol ); return; } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_IRDA_BRIDGE) { CatPrint ( Str, L"UsbIrdaBridge(0x%x,0x%x,0x%x)", - (UINTN) UsbClass->VendorId, - (UINTN) UsbClass->ProductId, - (UINTN) UsbClass->DeviceProtocol + UsbClass->VendorId, + UsbClass->ProductId, + UsbClass->DeviceProtocol ); return; } else if (UsbClass->DeviceSubClass == USB_SUBCLASS_TEST) { CatPrint ( Str, L"UsbTestAndMeasurement(0x%x,0x%x,0x%x)", - (UINTN) UsbClass->VendorId, - (UINTN) UsbClass->ProductId, - (UINTN) UsbClass->DeviceProtocol + UsbClass->VendorId, + UsbClass->ProductId, + UsbClass->DeviceProtocol ); return; } @@ -878,11 +915,11 @@ DevPathToTextUsbClass ( CatPrint ( Str, L"UsbClass(0x%x,0x%x,0x%x,0x%x,0x%x)", - (UINTN) UsbClass->VendorId, - (UINTN) UsbClass->ProductId, - (UINTN) UsbClass->DeviceClass, - (UINTN) UsbClass->DeviceSubClass, - (UINTN) UsbClass->DeviceProtocol + UsbClass->VendorId, + UsbClass->ProductId, + UsbClass->DeviceClass, + UsbClass->DeviceSubClass, + UsbClass->DeviceProtocol ); } @@ -910,20 +947,20 @@ DevPathToTextSata ( SATA_DEVICE_PATH *Sata; Sata = DevPath; - if (Sata->PortMultiplierPortNumber & SATA_HBA_DIRECT_CONNECT_FLAG) { + if ((Sata->PortMultiplierPortNumber & SATA_HBA_DIRECT_CONNECT_FLAG) != 0) { CatPrint ( Str, L"Sata(0x%x,0x%x)", - (UINTN) Sata->HBAPortNumber, - (UINTN) Sata->Lun + Sata->HBAPortNumber, + Sata->Lun ); } else { CatPrint ( Str, L"Sata(0x%x,0x%x,0x%x)", - (UINTN) Sata->HBAPortNumber, - (UINTN) Sata->PortMultiplierPortNumber, - (UINTN) Sata->Lun + Sata->HBAPortNumber, + Sata->PortMultiplierPortNumber, + Sata->Lun ); } } @@ -952,7 +989,7 @@ DevPathToTextI2O ( I2O_DEVICE_PATH *I2ODevPath; I2ODevPath = DevPath; - CatPrint (Str, L"I2O(0x%x)", (UINTN) I2ODevPath->Tid); + CatPrint (Str, L"I2O(0x%x)", I2ODevPath->Tid); } /** @@ -990,10 +1027,32 @@ DevPathToTextMacAddr ( CatPrint (Str, L"MAC("); 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); +} + +/** + Converts network protocol string to its text representation. + + @param Str The string representative of input device. + @param Protocol The network protocol ID. + +**/ +VOID +CatNetworkProtocol ( + IN OUT POOL_PRINT *Str, + IN UINT16 Protocol + ) +{ + if (Protocol == RFC_1700_TCP_PROTOCOL) { + CatPrint (Str, L"TCP"); + } else if (Protocol == RFC_1700_UDP_PROTOCOL) { + CatPrint (Str, L"UDP"); + } else { + CatPrint (Str, L"0x%x", Protocol); + } } /** @@ -1024,28 +1083,52 @@ DevPathToTextIPv4 ( CatPrint ( Str, L"IPv4(%d.%d.%d.%d)", - (UINTN) IPDevPath->RemoteIpAddress.Addr[0], - (UINTN) IPDevPath->RemoteIpAddress.Addr[1], - (UINTN) IPDevPath->RemoteIpAddress.Addr[2], - (UINTN) IPDevPath->RemoteIpAddress.Addr[3] + IPDevPath->RemoteIpAddress.Addr[0], + IPDevPath->RemoteIpAddress.Addr[1], + IPDevPath->RemoteIpAddress.Addr[2], + IPDevPath->RemoteIpAddress.Addr[3] ); return ; } CatPrint ( Str, - L"IPv4(%d.%d.%d.%d,%s,%s,%d.%d.%d.%d)", - (UINTN) IPDevPath->RemoteIpAddress.Addr[0], - (UINTN) IPDevPath->RemoteIpAddress.Addr[1], - (UINTN) IPDevPath->RemoteIpAddress.Addr[2], - (UINTN) IPDevPath->RemoteIpAddress.Addr[3], - (IPDevPath->Protocol == 1) ? L"TCP" : L"UDP", + L"IPv4(%d.%d.%d.%d,", + IPDevPath->RemoteIpAddress.Addr[0], + IPDevPath->RemoteIpAddress.Addr[1], + IPDevPath->RemoteIpAddress.Addr[2], + IPDevPath->RemoteIpAddress.Addr[3] + ); + + CatNetworkProtocol ( + Str, + IPDevPath->Protocol + ); + + CatPrint ( + Str, + L",%s,%d.%d.%d.%d", IPDevPath->StaticIpAddress ? L"Static" : L"DHCP", - (UINTN) IPDevPath->LocalIpAddress.Addr[0], - (UINTN) IPDevPath->LocalIpAddress.Addr[1], - (UINTN) IPDevPath->LocalIpAddress.Addr[2], - (UINTN) IPDevPath->LocalIpAddress.Addr[3] + IPDevPath->LocalIpAddress.Addr[0], + IPDevPath->LocalIpAddress.Addr[1], + IPDevPath->LocalIpAddress.Addr[2], + 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")"); } /** @@ -1076,63 +1159,72 @@ DevPathToTextIPv6 ( CatPrint ( Str, L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)", - (UINTN) IPDevPath->RemoteIpAddress.Addr[0], - (UINTN) IPDevPath->RemoteIpAddress.Addr[1], - (UINTN) IPDevPath->RemoteIpAddress.Addr[2], - (UINTN) IPDevPath->RemoteIpAddress.Addr[3], - (UINTN) IPDevPath->RemoteIpAddress.Addr[4], - (UINTN) IPDevPath->RemoteIpAddress.Addr[5], - (UINTN) IPDevPath->RemoteIpAddress.Addr[6], - (UINTN) IPDevPath->RemoteIpAddress.Addr[7], - (UINTN) IPDevPath->RemoteIpAddress.Addr[8], - (UINTN) IPDevPath->RemoteIpAddress.Addr[9], - (UINTN) IPDevPath->RemoteIpAddress.Addr[10], - (UINTN) IPDevPath->RemoteIpAddress.Addr[11], - (UINTN) IPDevPath->RemoteIpAddress.Addr[12], - (UINTN) IPDevPath->RemoteIpAddress.Addr[13], - (UINTN) IPDevPath->RemoteIpAddress.Addr[14], - (UINTN) IPDevPath->RemoteIpAddress.Addr[15] + IPDevPath->RemoteIpAddress.Addr[0], + IPDevPath->RemoteIpAddress.Addr[1], + IPDevPath->RemoteIpAddress.Addr[2], + IPDevPath->RemoteIpAddress.Addr[3], + IPDevPath->RemoteIpAddress.Addr[4], + IPDevPath->RemoteIpAddress.Addr[5], + IPDevPath->RemoteIpAddress.Addr[6], + IPDevPath->RemoteIpAddress.Addr[7], + IPDevPath->RemoteIpAddress.Addr[8], + IPDevPath->RemoteIpAddress.Addr[9], + IPDevPath->RemoteIpAddress.Addr[10], + IPDevPath->RemoteIpAddress.Addr[11], + IPDevPath->RemoteIpAddress.Addr[12], + IPDevPath->RemoteIpAddress.Addr[13], + IPDevPath->RemoteIpAddress.Addr[14], + IPDevPath->RemoteIpAddress.Addr[15] ); return ; } CatPrint ( Str, - L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x,%s,%s,%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)", - (UINTN) IPDevPath->RemoteIpAddress.Addr[0], - (UINTN) IPDevPath->RemoteIpAddress.Addr[1], - (UINTN) IPDevPath->RemoteIpAddress.Addr[2], - (UINTN) IPDevPath->RemoteIpAddress.Addr[3], - (UINTN) IPDevPath->RemoteIpAddress.Addr[4], - (UINTN) IPDevPath->RemoteIpAddress.Addr[5], - (UINTN) IPDevPath->RemoteIpAddress.Addr[6], - (UINTN) IPDevPath->RemoteIpAddress.Addr[7], - (UINTN) IPDevPath->RemoteIpAddress.Addr[8], - (UINTN) IPDevPath->RemoteIpAddress.Addr[9], - (UINTN) IPDevPath->RemoteIpAddress.Addr[10], - (UINTN) IPDevPath->RemoteIpAddress.Addr[11], - (UINTN) IPDevPath->RemoteIpAddress.Addr[12], - (UINTN) IPDevPath->RemoteIpAddress.Addr[13], - (UINTN) IPDevPath->RemoteIpAddress.Addr[14], - (UINTN) IPDevPath->RemoteIpAddress.Addr[15], - (IPDevPath->Protocol == 1) ? L"TCP" : L"UDP", + L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x,", + IPDevPath->RemoteIpAddress.Addr[0], + IPDevPath->RemoteIpAddress.Addr[1], + IPDevPath->RemoteIpAddress.Addr[2], + IPDevPath->RemoteIpAddress.Addr[3], + IPDevPath->RemoteIpAddress.Addr[4], + IPDevPath->RemoteIpAddress.Addr[5], + IPDevPath->RemoteIpAddress.Addr[6], + IPDevPath->RemoteIpAddress.Addr[7], + IPDevPath->RemoteIpAddress.Addr[8], + IPDevPath->RemoteIpAddress.Addr[9], + IPDevPath->RemoteIpAddress.Addr[10], + IPDevPath->RemoteIpAddress.Addr[11], + IPDevPath->RemoteIpAddress.Addr[12], + IPDevPath->RemoteIpAddress.Addr[13], + IPDevPath->RemoteIpAddress.Addr[14], + IPDevPath->RemoteIpAddress.Addr[15] + ); + + CatNetworkProtocol ( + Str, + IPDevPath->Protocol + ); + + CatPrint ( + Str, + L",%s,%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)", IPDevPath->StaticIpAddress ? L"Static" : L"DHCP", - (UINTN) IPDevPath->LocalIpAddress.Addr[0], - (UINTN) IPDevPath->LocalIpAddress.Addr[1], - (UINTN) IPDevPath->LocalIpAddress.Addr[2], - (UINTN) IPDevPath->LocalIpAddress.Addr[3], - (UINTN) IPDevPath->LocalIpAddress.Addr[4], - (UINTN) IPDevPath->LocalIpAddress.Addr[5], - (UINTN) IPDevPath->LocalIpAddress.Addr[6], - (UINTN) IPDevPath->LocalIpAddress.Addr[7], - (UINTN) IPDevPath->LocalIpAddress.Addr[8], - (UINTN) IPDevPath->LocalIpAddress.Addr[9], - (UINTN) IPDevPath->LocalIpAddress.Addr[10], - (UINTN) IPDevPath->LocalIpAddress.Addr[11], - (UINTN) IPDevPath->LocalIpAddress.Addr[12], - (UINTN) IPDevPath->LocalIpAddress.Addr[13], - (UINTN) IPDevPath->LocalIpAddress.Addr[14], - (UINTN) IPDevPath->LocalIpAddress.Addr[15] + IPDevPath->LocalIpAddress.Addr[0], + IPDevPath->LocalIpAddress.Addr[1], + IPDevPath->LocalIpAddress.Addr[2], + IPDevPath->LocalIpAddress.Addr[3], + IPDevPath->LocalIpAddress.Addr[4], + IPDevPath->LocalIpAddress.Addr[5], + IPDevPath->LocalIpAddress.Addr[6], + IPDevPath->LocalIpAddress.Addr[7], + IPDevPath->LocalIpAddress.Addr[8], + IPDevPath->LocalIpAddress.Addr[9], + IPDevPath->LocalIpAddress.Addr[10], + IPDevPath->LocalIpAddress.Addr[11], + IPDevPath->LocalIpAddress.Addr[12], + IPDevPath->LocalIpAddress.Addr[13], + IPDevPath->LocalIpAddress.Addr[14], + IPDevPath->LocalIpAddress.Addr[15] ); } @@ -1163,7 +1255,7 @@ DevPathToTextInfiniBand ( CatPrint ( Str, L"Infiniband(0x%x,%g,0x%lx,0x%lx,0x%lx)", - (UINTN) InfiniBand->ResourceFlags, + InfiniBand->ResourceFlags, InfiniBand->PortGid, InfiniBand->ServiceId, InfiniBand->TargetPortId, @@ -1235,7 +1327,7 @@ DevPathToTextUart ( if (Uart->DataBits == 0) { CatPrint (Str, L"DEFAULT,"); } else { - CatPrint (Str, L"%d,", (UINTN) Uart->DataBits); + CatPrint (Str, L"%d,", Uart->DataBits); } CatPrint (Str, L"%c,", Parity); @@ -1291,8 +1383,8 @@ DevPathToTextiSCSI ( CatPrint ( Str, L"iSCSI(%a,0x%x,0x%lx,", - ISCSIDevPath->iSCSITargetName, - (UINTN) ISCSIDevPath->TargetPortalGroupTag, + ISCSIDevPath->TargetName, + ISCSIDevPath->TargetPortalGroupTag, ISCSIDevPath->Lun ); @@ -1311,6 +1403,33 @@ DevPathToTextiSCSI ( CatPrint (Str, L"%s)", (ISCSIDevPath->NetworkProtocol == 0) ? L"TCP" : L"reserved"); } +/** + Converts a VLAN 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 +DevPathToTextVlan ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath, + IN BOOLEAN DisplayOnly, + IN BOOLEAN AllowShortcuts + ) +{ + VLAN_DEVICE_PATH *Vlan; + + Vlan = DevPath; + CatPrint (Str, L"Vlan(%d)", Vlan->VlanId); +} + /** Converts a Hard drive device path structure to its string representative. @@ -1340,9 +1459,9 @@ DevPathToTextHardDrive ( CatPrint ( Str, L"HD(%d,%s,0x%08x,", - (UINTN) Hd->PartitionNumber, + Hd->PartitionNumber, L"MBR", - (UINTN) *((UINT32 *) (&(Hd->Signature[0]))) + *((UINT32 *) (&(Hd->Signature[0]))) ); break; @@ -1350,7 +1469,7 @@ DevPathToTextHardDrive ( CatPrint ( Str, L"HD(%d,%s,%g,", - (UINTN) Hd->PartitionNumber, + Hd->PartitionNumber, L"GPT", (EFI_GUID *) &(Hd->Signature[0]) ); @@ -1360,8 +1479,8 @@ DevPathToTextHardDrive ( CatPrint ( Str, L"HD(%d,%d,0,", - (UINTN) Hd->PartitionNumber, - (UINTN) Hd->SignatureType + Hd->PartitionNumber, + Hd->SignatureType ); break; } @@ -1394,11 +1513,11 @@ DevPathToTextCDROM ( Cd = DevPath; if (DisplayOnly) { - CatPrint (Str, L"CDROM(0x%x)", (UINTN) Cd->BootEntry); + CatPrint (Str, L"CDROM(0x%x)", Cd->BootEntry); 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); } /** @@ -1509,6 +1628,38 @@ DevPathToTextFvFile ( CatPrint (Str, L"FvFile(%g)", &FvFile->FvFileName); } +/** + Converts a Relative Offset 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 +DevPathRelativeOffsetRange ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath, + IN BOOLEAN DisplayOnly, + IN BOOLEAN AllowShortcuts + ) +{ + MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset; + + Offset = DevPath; + CatPrint ( + Str, + L"Offset(0x%lx,0x%lx)", + Offset->StartingOffset, + Offset->EndingOffset + ); +} + /** Converts a BIOS Boot Specification device path structure to its string representative. @@ -1567,7 +1718,7 @@ DevPathToTextBBS ( if (Type != NULL) { CatPrint (Str, L"BBS(%s,%a", Type, Bbs->String); } 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) { @@ -1575,7 +1726,7 @@ DevPathToTextBBS ( return ; } - CatPrint (Str, L",0x%x)", (UINTN) Bbs->StatusFlag); + CatPrint (Str, L",0x%x)", Bbs->StatusFlag); } /** @@ -1638,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_SCSI_DP, DevPathToTextScsi}, {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_USB_DP, DevPathToTextUsb}, {MESSAGING_DEVICE_PATH, MSG_USB_WWID_DP, DevPathToTextUsbWWID}, @@ -1652,6 +1804,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE DevPathToTextTable {MESSAGING_DEVICE_PATH, MSG_UART_DP, DevPathToTextUart}, {MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, DevPathToTextVendor}, {MESSAGING_DEVICE_PATH, MSG_ISCSI_DP, DevPathToTextiSCSI}, + {MESSAGING_DEVICE_PATH, MSG_VLAN_DP, DevPathToTextVlan}, {MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, DevPathToTextHardDrive}, {MEDIA_DEVICE_PATH, MEDIA_CDROM_DP, DevPathToTextCDROM}, {MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP, DevPathToTextVendor}, @@ -1659,6 +1812,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE DevPathToTextTable {MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP, DevPathToTextFilePath}, {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_VOL_DP, DevPathToTextFv}, {MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_FILE_DP, DevPathToTextFvFile}, + {MEDIA_DEVICE_PATH, MEDIA_RELATIVE_OFFSET_RANGE_DP, DevPathRelativeOffsetRange}, {BBS_DEVICE_PATH, BBS_BBS_DP, DevPathToTextBBS}, {END_DEVICE_PATH_TYPE, END_INSTANCE_DEVICE_PATH_SUBTYPE, DevPathToTextEndInstance}, {0, 0, NULL} @@ -1689,7 +1843,6 @@ ConvertDeviceNodeToText ( { POOL_PRINT Str; UINTN Index; - UINTN NewSize; VOID (*DumpNode)(POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN); if (DeviceNode == NULL) { @@ -1722,13 +1875,7 @@ ConvertDeviceNodeToText ( // 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; } @@ -1759,7 +1906,6 @@ ConvertDevicePathToText ( EFI_DEVICE_PATH_PROTOCOL *DevPathNode; EFI_DEVICE_PATH_PROTOCOL *AlignedDevPathNode; UINTN Index; - UINTN NewSize; VOID (*DumpNode) (POOL_PRINT *, VOID *, BOOLEAN, BOOLEAN); if (DevicePath == NULL) { @@ -1795,8 +1941,8 @@ ConvertDevicePathToText ( // // Put a path separator in if needed // - if ((Str.Len != 0) && DumpNode != DevPathToTextEndInstance) { - if (*(Str.Str + Str.Len / sizeof (CHAR16) - 1) != L',') { + if ((Str.Length != 0) && (DumpNode != DevPathToTextEndInstance)) { + if (*(Str.Str + Str.Length / sizeof (CHAR16) - 1) != L',') { CatPrint (&Str, L"/"); } } @@ -1814,9 +1960,9 @@ ConvertDevicePathToText ( 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; + if (Str.Str == NULL) { + return AllocateZeroPool (sizeof (CHAR16)); + } else { + return Str.Str; + } }