X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdePkg%2FLibrary%2FUefiDevicePathLib%2FDevicePathToText.c;h=dd90dfa58e829995ab46ef93ed6119f64604c7b2;hb=2f88bd3a1296c522317f1c21377876de63de5be7;hp=363830bd32caf96e76ab1df9e090008fc50a4b82;hpb=0cd35d739ea8c0096af0db7d920010593db5779f;p=mirror_edk2.git diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c index 363830bd32..dd90dfa58e 100644 --- a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c +++ b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c @@ -2,14 +2,8 @@ DevicePathToText protocol as defined in the UEFI 2.0 specification. (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
-Copyright (c) 2013 - 2015, 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. +Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -32,29 +26,32 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. CHAR16 * EFIAPI UefiDevicePathLibCatPrint ( - IN OUT POOL_PRINT *Str, - IN CHAR16 *Fmt, + IN OUT POOL_PRINT *Str, + IN CHAR16 *Fmt, ... ) { - UINTN Count; - VA_LIST Args; + UINTN Count; + VA_LIST Args; VA_START (Args, Fmt); Count = SPrintLength (Fmt, Args); + VA_END (Args); if ((Str->Count + (Count + 1)) * sizeof (CHAR16) > Str->Capacity) { Str->Capacity = (Str->Count + (Count + 1) * 2) * sizeof (CHAR16); - Str->Str = ReallocatePool ( - Str->Count * sizeof (CHAR16), - Str->Capacity, - Str->Str - ); + Str->Str = ReallocatePool ( + Str->Count * sizeof (CHAR16), + Str->Capacity, + Str->Str + ); ASSERT (Str->Str != NULL); } + + VA_START (Args, Fmt); UnicodeVSPrint (&Str->Str[Str->Count], Str->Capacity - Str->Count * sizeof (CHAR16), Fmt, Args); Str->Count += Count; - + VA_END (Args); return Str->Str; } @@ -80,7 +77,7 @@ DevPathToTextPci ( IN BOOLEAN AllowShortcuts ) { - PCI_DEVICE_PATH *Pci; + PCI_DEVICE_PATH *Pci; Pci = DevPath; UefiDevicePathLibCatPrint (Str, L"Pci(0x%x,0x%x)", Pci->Device, Pci->Function); @@ -174,94 +171,95 @@ DevPathToTextVendor ( UINT32 FlowControlMap; UINT16 Info; - Vendor = (VENDOR_DEVICE_PATH *) DevPath; + Vendor = (VENDOR_DEVICE_PATH *)DevPath; switch (DevicePathType (&Vendor->Header)) { - case HARDWARE_DEVICE_PATH: - Type = L"Hw"; - break; - - case MESSAGING_DEVICE_PATH: - Type = L"Msg"; - if (AllowShortcuts) { - if (CompareGuid (&Vendor->Guid, &gEfiPcAnsiGuid)) { - UefiDevicePathLibCatPrint (Str, L"VenPcAnsi()"); - return ; - } else if (CompareGuid (&Vendor->Guid, &gEfiVT100Guid)) { - UefiDevicePathLibCatPrint (Str, L"VenVt100()"); - return ; - } else if (CompareGuid (&Vendor->Guid, &gEfiVT100PlusGuid)) { - UefiDevicePathLibCatPrint (Str, L"VenVt100Plus()"); - return ; - } else if (CompareGuid (&Vendor->Guid, &gEfiVTUTF8Guid)) { - UefiDevicePathLibCatPrint (Str, L"VenUft8()"); - return ; - } else if (CompareGuid (&Vendor->Guid, &gEfiUartDevicePathGuid)) { - FlowControlMap = (((UART_FLOW_CONTROL_DEVICE_PATH *) Vendor)->FlowControlMap); - switch (FlowControlMap & 0x00000003) { - case 0: - UefiDevicePathLibCatPrint (Str, L"UartFlowCtrl(%s)", L"None"); - break; - - case 1: - UefiDevicePathLibCatPrint (Str, L"UartFlowCtrl(%s)", L"Hardware"); - break; - - case 2: - UefiDevicePathLibCatPrint (Str, L"UartFlowCtrl(%s)", L"XonXoff"); - break; - - default: - break; - } + case HARDWARE_DEVICE_PATH: + Type = L"Hw"; + break; - return ; - } else if (CompareGuid (&Vendor->Guid, &gEfiSasDevicePathGuid)) { - UefiDevicePathLibCatPrint ( - Str, - L"SAS(0x%lx,0x%lx,0x%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) && ((Info & BIT7) == 0)) { - UefiDevicePathLibCatPrint (Str, L"NoTopology,0,0,0,"); - } else if (((Info & 0x0f) <= 2) && ((Info & BIT7) == 0)) { + case MESSAGING_DEVICE_PATH: + Type = L"Msg"; + if (AllowShortcuts) { + if (CompareGuid (&Vendor->Guid, &gEfiPcAnsiGuid)) { + UefiDevicePathLibCatPrint (Str, L"VenPcAnsi()"); + return; + } else if (CompareGuid (&Vendor->Guid, &gEfiVT100Guid)) { + UefiDevicePathLibCatPrint (Str, L"VenVt100()"); + return; + } else if (CompareGuid (&Vendor->Guid, &gEfiVT100PlusGuid)) { + UefiDevicePathLibCatPrint (Str, L"VenVt100Plus()"); + return; + } else if (CompareGuid (&Vendor->Guid, &gEfiVTUTF8Guid)) { + UefiDevicePathLibCatPrint (Str, L"VenUtf8()"); + return; + } else if (CompareGuid (&Vendor->Guid, &gEfiUartDevicePathGuid)) { + FlowControlMap = (((UART_FLOW_CONTROL_DEVICE_PATH *)Vendor)->FlowControlMap); + switch (FlowControlMap & 0x00000003) { + case 0: + UefiDevicePathLibCatPrint (Str, L"UartFlowCtrl(%s)", L"None"); + break; + + case 1: + UefiDevicePathLibCatPrint (Str, L"UartFlowCtrl(%s)", L"Hardware"); + break; + + case 2: + UefiDevicePathLibCatPrint (Str, L"UartFlowCtrl(%s)", L"XonXoff"); + break; + + default: + break; + } + + return; + } else if (CompareGuid (&Vendor->Guid, &gEfiSasDevicePathGuid)) { UefiDevicePathLibCatPrint ( Str, - L"%s,%s,%s,", - ((Info & BIT4) != 0) ? L"SATA" : L"SAS", - ((Info & BIT5) != 0) ? L"External" : L"Internal", - ((Info & BIT6) != 0) ? L"Expanded" : L"Direct" + L"SAS(0x%lx,0x%lx,0x%x,", + ((SAS_DEVICE_PATH *)Vendor)->SasAddress, + ((SAS_DEVICE_PATH *)Vendor)->Lun, + ((SAS_DEVICE_PATH *)Vendor)->RelativeTargetPort ); - if ((Info & 0x0f) == 1) { - UefiDevicePathLibCatPrint (Str, L"0,"); + Info = (((SAS_DEVICE_PATH *)Vendor)->DeviceTopology); + if (((Info & 0x0f) == 0) && ((Info & BIT7) == 0)) { + UefiDevicePathLibCatPrint (Str, L"NoTopology,0,0,0,"); + } else if (((Info & 0x0f) <= 2) && ((Info & BIT7) == 0)) { + UefiDevicePathLibCatPrint ( + Str, + L"%s,%s,%s,", + ((Info & BIT4) != 0) ? L"SATA" : L"SAS", + ((Info & BIT5) != 0) ? L"External" : L"Internal", + ((Info & BIT6) != 0) ? L"Expanded" : L"Direct" + ); + if ((Info & 0x0f) == 1) { + UefiDevicePathLibCatPrint (Str, L"0,"); + } else { + // + // Value 0x0 thru 0xFF -> Drive 1 thru Drive 256 + // + UefiDevicePathLibCatPrint (Str, L"0x%x,", ((Info >> 8) & 0xff) + 1); + } } else { - // - // Value 0x0 thru 0xFF -> Drive 1 thru Drive 256 - // - UefiDevicePathLibCatPrint (Str, L"0x%x,", ((Info >> 8) & 0xff) + 1); + UefiDevicePathLibCatPrint (Str, L"0x%x,0,0,0,", Info); } - } else { - UefiDevicePathLibCatPrint (Str, L"0x%x,0,0,0,", Info); - } - UefiDevicePathLibCatPrint (Str, L"0x%x)", ((SAS_DEVICE_PATH *) Vendor)->Reserved); - return ; - } else if (CompareGuid (&Vendor->Guid, &gEfiDebugPortProtocolGuid)) { - UefiDevicePathLibCatPrint (Str, L"DebugPort()"); - return ; + UefiDevicePathLibCatPrint (Str, L"0x%x)", ((SAS_DEVICE_PATH *)Vendor)->Reserved); + return; + } else if (CompareGuid (&Vendor->Guid, &gEfiDebugPortProtocolGuid)) { + UefiDevicePathLibCatPrint (Str, L"DebugPort()"); + return; + } } - } - break; - case MEDIA_DEVICE_PATH: - Type = L"Media"; - break; + break; + + case MEDIA_DEVICE_PATH: + Type = L"Media"; + break; - default: - Type = L"?"; - break; + default: + Type = L"?"; + break; } DataLength = DevicePathNodeLength (&Vendor->Header) - sizeof (VENDOR_DEVICE_PATH); @@ -269,7 +267,7 @@ DevPathToTextVendor ( if (DataLength != 0) { UefiDevicePathLibCatPrint (Str, L","); for (Index = 0; Index < DataLength; Index++) { - UefiDevicePathLibCatPrint (Str, L"%02x", ((VENDOR_DEVICE_PATH_WITH_DATA *) Vendor)->VendorDefinedData[Index]); + UefiDevicePathLibCatPrint (Str, L"%02x", ((VENDOR_DEVICE_PATH_WITH_DATA *)Vendor)->VendorDefinedData[Index]); } } @@ -328,14 +326,14 @@ DevPathToTextBmc ( IN BOOLEAN AllowShortcuts ) { - BMC_DEVICE_PATH *Bmc; + BMC_DEVICE_PATH *Bmc; Bmc = DevPath; UefiDevicePathLibCatPrint ( Str, L"BMC(0x%x,0x%lx)", Bmc->InterfaceType, - ReadUnaligned64 ((UINT64 *) (&Bmc->BaseAddress)) + ReadUnaligned64 ((UINT64 *)(&Bmc->BaseAddress)) ); } @@ -365,33 +363,33 @@ DevPathToTextAcpi ( Acpi = DevPath; if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) { switch (EISA_ID_TO_NUM (Acpi->HID)) { - case 0x0a03: - UefiDevicePathLibCatPrint (Str, L"PciRoot(0x%x)", Acpi->UID); - break; + case 0x0a03: + UefiDevicePathLibCatPrint (Str, L"PciRoot(0x%x)", Acpi->UID); + break; - case 0x0a08: - UefiDevicePathLibCatPrint (Str, L"PcieRoot(0x%x)", Acpi->UID); - break; + case 0x0a08: + UefiDevicePathLibCatPrint (Str, L"PcieRoot(0x%x)", Acpi->UID); + break; - case 0x0604: - UefiDevicePathLibCatPrint (Str, L"Floppy(0x%x)", Acpi->UID); - break; + case 0x0604: + UefiDevicePathLibCatPrint (Str, L"Floppy(0x%x)", Acpi->UID); + break; - case 0x0301: - UefiDevicePathLibCatPrint (Str, L"Keyboard(0x%x)", Acpi->UID); - break; + case 0x0301: + UefiDevicePathLibCatPrint (Str, L"Keyboard(0x%x)", Acpi->UID); + break; - case 0x0501: - UefiDevicePathLibCatPrint (Str, L"Serial(0x%x)", Acpi->UID); - break; + case 0x0501: + UefiDevicePathLibCatPrint (Str, L"Serial(0x%x)", Acpi->UID); + break; - case 0x0401: - UefiDevicePathLibCatPrint (Str, L"ParallelPort(0x%x)", Acpi->UID); - break; + case 0x0401: + UefiDevicePathLibCatPrint (Str, L"ParallelPort(0x%x)", Acpi->UID); + break; - default: - UefiDevicePathLibCatPrint (Str, L"Acpi(PNP%04x,0x%x)", EISA_ID_TO_NUM (Acpi->HID), Acpi->UID); - break; + default: + UefiDevicePathLibCatPrint (Str, L"Acpi(PNP%04x,0x%x)", EISA_ID_TO_NUM (Acpi->HID), Acpi->UID); + break; } } else { UefiDevicePathLibCatPrint (Str, L"Acpi(0x%08x,0x%x)", Acpi->HID, Acpi->UID); @@ -427,13 +425,37 @@ DevPathToTextAcpiEx ( CHAR16 CIDText[11]; AcpiEx = DevPath; - HIDStr = (CHAR8 *) (((UINT8 *) AcpiEx) + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH)); + HIDStr = (CHAR8 *)(((UINT8 *)AcpiEx) + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH)); UIDStr = HIDStr + AsciiStrLen (HIDStr) + 1; CIDStr = UIDStr + AsciiStrLen (UIDStr) + 1; + if (DisplayOnly) { + if ((EISA_ID_TO_NUM (AcpiEx->HID) == 0x0A03) || + ((EISA_ID_TO_NUM (AcpiEx->CID) == 0x0A03) && (EISA_ID_TO_NUM (AcpiEx->HID) != 0x0A08))) + { + if (AcpiEx->UID == 0) { + UefiDevicePathLibCatPrint (Str, L"PciRoot(%a)", UIDStr); + } else { + UefiDevicePathLibCatPrint (Str, L"PciRoot(0x%x)", AcpiEx->UID); + } + + return; + } + + if ((EISA_ID_TO_NUM (AcpiEx->HID) == 0x0A08) || (EISA_ID_TO_NUM (AcpiEx->CID) == 0x0A08)) { + if (AcpiEx->UID == 0) { + UefiDevicePathLibCatPrint (Str, L"PcieRoot(%a)", UIDStr); + } else { + UefiDevicePathLibCatPrint (Str, L"PcieRoot(0x%x)", AcpiEx->UID); + } + + return; + } + } + // // Converts EISA identification to string. - // + // UnicodeSPrint ( HIDText, sizeof (HIDText), @@ -453,19 +475,28 @@ DevPathToTextAcpiEx ( (AcpiEx->CID >> 16) & 0xFFFF ); - if ((*HIDStr == '\0') && (*CIDStr == '\0') && (AcpiEx->UID == 0)) { + if ((*HIDStr == '\0') && (*CIDStr == '\0') && (*UIDStr != '\0')) { // // use AcpiExp() // - UefiDevicePathLibCatPrint ( - Str, - L"AcpiExp(%s,%s,%a)", - HIDText, - CIDText, - UIDStr - ); + if (AcpiEx->CID == 0) { + UefiDevicePathLibCatPrint ( + Str, + L"AcpiExp(%s,0,%a)", + HIDText, + UIDStr + ); + } else { + UefiDevicePathLibCatPrint ( + Str, + L"AcpiExp(%s,%s,%a)", + HIDText, + CIDText, + UIDStr + ); + } } else { - if (AllowShortcuts) { + if (DisplayOnly) { // // display only // @@ -475,16 +506,16 @@ DevPathToTextAcpiEx ( UefiDevicePathLibCatPrint (Str, L"AcpiEx(%s,", HIDText); } - if (AcpiEx->UID == 0) { - UefiDevicePathLibCatPrint (Str, L"%a,", UIDStr); + if (AcpiEx->CID == 0) { + UefiDevicePathLibCatPrint (Str, L"%a,", CIDStr); } else { - UefiDevicePathLibCatPrint (Str, L"0x%x,", AcpiEx->UID); + UefiDevicePathLibCatPrint (Str, L"%s,", CIDText); } - if (AcpiEx->CID == 0) { - UefiDevicePathLibCatPrint (Str, L"%a)", CIDStr); + if (AcpiEx->UID == 0) { + UefiDevicePathLibCatPrint (Str, L"%a)", UIDStr); } else { - UefiDevicePathLibCatPrint (Str, L"%s)", CIDText); + UefiDevicePathLibCatPrint (Str, L"0x%x)", AcpiEx->UID); } } else { UefiDevicePathLibCatPrint ( @@ -522,19 +553,20 @@ DevPathToTextAcpiAdr ( IN BOOLEAN AllowShortcuts ) { - ACPI_ADR_DEVICE_PATH *AcpiAdr; - UINT16 Index; - UINT16 Length; - UINT16 AdditionalAdrCount; + 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); + Length = (UINT16)DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *)AcpiAdr); + AdditionalAdrCount = (UINT16)((Length - 8) / 4); UefiDevicePathLibCatPrint (Str, L"AcpiAdr(0x%x", AcpiAdr->ADR); for (Index = 0; Index < AdditionalAdrCount; Index++) { - UefiDevicePathLibCatPrint (Str, L",0x%x", *(UINT32 *) ((UINT8 *) AcpiAdr + 8 + Index * 4)); + UefiDevicePathLibCatPrint (Str, L",0x%x", *(UINT32 *)((UINT8 *)AcpiAdr + 8 + Index * 4)); } + UefiDevicePathLibCatPrint (Str, L")"); } @@ -559,7 +591,7 @@ DevPathToTextAtapi ( IN BOOLEAN AllowShortcuts ) { - ATAPI_DEVICE_PATH *Atapi; + ATAPI_DEVICE_PATH *Atapi; Atapi = DevPath; @@ -659,10 +691,12 @@ DevPathToTextFibreEx ( for (Index = 0; Index < sizeof (FibreEx->WWN) / sizeof (FibreEx->WWN[0]); Index++) { UefiDevicePathLibCatPrint (Str, L"%02x", FibreEx->WWN[Index]); } + UefiDevicePathLibCatPrint (Str, L",0x"); for (Index = 0; Index < sizeof (FibreEx->Lun) / sizeof (FibreEx->Lun[0]); Index++) { UefiDevicePathLibCatPrint (Str, L"%02x", FibreEx->Lun[Index]); } + UefiDevicePathLibCatPrint (Str, L")"); } @@ -696,10 +730,12 @@ DevPathToTextSasEx ( for (Index = 0; Index < sizeof (SasEx->SasAddress) / sizeof (SasEx->SasAddress[0]); Index++) { UefiDevicePathLibCatPrint (Str, L"%02x", SasEx->SasAddress[Index]); } + UefiDevicePathLibCatPrint (Str, L",0x"); for (Index = 0; Index < sizeof (SasEx->Lun) / sizeof (SasEx->Lun[0]); Index++) { UefiDevicePathLibCatPrint (Str, L"%02x", SasEx->Lun[Index]); } + UefiDevicePathLibCatPrint (Str, L",0x%x,", SasEx->RelativeTargetPort); if (((SasEx->DeviceTopology & 0x0f) == 0) && ((SasEx->DeviceTopology & BIT7) == 0)) { @@ -725,8 +761,7 @@ DevPathToTextSasEx ( } UefiDevicePathLibCatPrint (Str, L")"); - return ; - + return; } /** @@ -750,17 +785,23 @@ DevPathToTextNVMe ( IN BOOLEAN AllowShortcuts ) { - NVME_NAMESPACE_DEVICE_PATH *Nvme; - UINT8 *Uuid; + NVME_NAMESPACE_DEVICE_PATH *Nvme; + UINT8 *Uuid; Nvme = DevPath; - Uuid = (UINT8 *) &Nvme->NamespaceUuid; + Uuid = (UINT8 *)&Nvme->NamespaceUuid; UefiDevicePathLibCatPrint ( Str, L"NVMe(0x%x,%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x)", Nvme->NamespaceId, - Uuid[7], Uuid[6], Uuid[5], Uuid[4], - Uuid[3], Uuid[2], Uuid[1], Uuid[0] + Uuid[7], + Uuid[6], + Uuid[5], + Uuid[4], + Uuid[3], + Uuid[2], + Uuid[1], + Uuid[0] ); } @@ -812,7 +853,7 @@ DevPathToTextSd ( IN BOOLEAN AllowShortcuts ) { - SD_DEVICE_PATH *Sd; + SD_DEVICE_PATH *Sd; Sd = DevPath; UefiDevicePathLibCatPrint ( @@ -822,6 +863,37 @@ DevPathToTextSd ( ); } +/** + Converts a EMMC (Embedded MMC) 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 +DevPathToTextEmmc ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath, + IN BOOLEAN DisplayOnly, + IN BOOLEAN AllowShortcuts + ) +{ + EMMC_DEVICE_PATH *Emmc; + + Emmc = DevPath; + UefiDevicePathLibCatPrint ( + Str, + L"eMMC(0x%x)", + Emmc->SlotNumber + ); +} + /** Converts a 1394 device path structure to its string representative. @@ -843,7 +915,7 @@ DevPathToText1394 ( IN BOOLEAN AllowShortcuts ) { - F1394_DEVICE_PATH *F1394DevPath; + F1394_DEVICE_PATH *F1394DevPath; F1394DevPath = DevPath; // @@ -873,7 +945,7 @@ DevPathToTextUsb ( IN BOOLEAN AllowShortcuts ) { - USB_DEVICE_PATH *Usb; + USB_DEVICE_PATH *Usb; Usb = DevPath; UefiDevicePathLibCatPrint (Str, L"USB(0x%x,0x%x)", Usb->ParentPortNumber, Usb->InterfaceNumber); @@ -907,15 +979,15 @@ DevPathToTextUsbWWID ( UsbWWId = DevPath; - SerialNumberStr = (CHAR16 *) ((UINT8 *) UsbWWId + sizeof (USB_WWID_DEVICE_PATH)); - Length = (UINT16) ((DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) UsbWWId) - sizeof (USB_WWID_DEVICE_PATH)) / sizeof (CHAR16)); - if (SerialNumberStr [Length - 1] != 0) { + SerialNumberStr = (CHAR16 *)((UINT8 *)UsbWWId + sizeof (USB_WWID_DEVICE_PATH)); + Length = (UINT16)((DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *)UsbWWId) - sizeof (USB_WWID_DEVICE_PATH)) / sizeof (CHAR16)); + if ((Length >= 1) && (SerialNumberStr[Length - 1] != 0)) { // // In case no NULL terminator in SerialNumber, create a new one with NULL terminator // NewStr = AllocateCopyPool ((Length + 1) * sizeof (CHAR16), SerialNumberStr); ASSERT (NewStr != NULL); - NewStr [Length] = 0; + NewStr[Length] = 0; SerialNumberStr = NewStr; } @@ -950,7 +1022,7 @@ DevPathToTextLogicalUnit ( IN BOOLEAN AllowShortcuts ) { - DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit; + DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit; LogicalUnit = DevPath; UefiDevicePathLibCatPrint (Str, L"Unit(0x%x)", LogicalUnit->Lun); @@ -977,65 +1049,64 @@ DevPathToTextUsbClass ( IN BOOLEAN AllowShortcuts ) { - USB_CLASS_DEVICE_PATH *UsbClass; - BOOLEAN IsKnownSubClass; - + USB_CLASS_DEVICE_PATH *UsbClass; + BOOLEAN IsKnownSubClass; UsbClass = DevPath; IsKnownSubClass = TRUE; switch (UsbClass->DeviceClass) { - case USB_CLASS_AUDIO: - UefiDevicePathLibCatPrint (Str, L"UsbAudio"); - break; + case USB_CLASS_AUDIO: + UefiDevicePathLibCatPrint (Str, L"UsbAudio"); + break; - case USB_CLASS_CDCCONTROL: - UefiDevicePathLibCatPrint (Str, L"UsbCDCControl"); - break; + case USB_CLASS_CDCCONTROL: + UefiDevicePathLibCatPrint (Str, L"UsbCDCControl"); + break; - case USB_CLASS_HID: - UefiDevicePathLibCatPrint (Str, L"UsbHID"); - break; + case USB_CLASS_HID: + UefiDevicePathLibCatPrint (Str, L"UsbHID"); + break; - case USB_CLASS_IMAGE: - UefiDevicePathLibCatPrint (Str, L"UsbImage"); - break; + case USB_CLASS_IMAGE: + UefiDevicePathLibCatPrint (Str, L"UsbImage"); + break; - case USB_CLASS_PRINTER: - UefiDevicePathLibCatPrint (Str, L"UsbPrinter"); - break; + case USB_CLASS_PRINTER: + UefiDevicePathLibCatPrint (Str, L"UsbPrinter"); + break; - case USB_CLASS_MASS_STORAGE: - UefiDevicePathLibCatPrint (Str, L"UsbMassStorage"); - break; + case USB_CLASS_MASS_STORAGE: + UefiDevicePathLibCatPrint (Str, L"UsbMassStorage"); + break; - case USB_CLASS_HUB: - UefiDevicePathLibCatPrint (Str, L"UsbHub"); - break; + case USB_CLASS_HUB: + UefiDevicePathLibCatPrint (Str, L"UsbHub"); + break; - case USB_CLASS_CDCDATA: - UefiDevicePathLibCatPrint (Str, L"UsbCDCData"); - break; + case USB_CLASS_CDCDATA: + UefiDevicePathLibCatPrint (Str, L"UsbCDCData"); + break; - case USB_CLASS_SMART_CARD: - UefiDevicePathLibCatPrint (Str, L"UsbSmartCard"); - break; + case USB_CLASS_SMART_CARD: + UefiDevicePathLibCatPrint (Str, L"UsbSmartCard"); + break; - case USB_CLASS_VIDEO: - UefiDevicePathLibCatPrint (Str, L"UsbVideo"); - break; + case USB_CLASS_VIDEO: + UefiDevicePathLibCatPrint (Str, L"UsbVideo"); + break; - case USB_CLASS_DIAGNOSTIC: - UefiDevicePathLibCatPrint (Str, L"UsbDiagnostic"); - break; + case USB_CLASS_DIAGNOSTIC: + UefiDevicePathLibCatPrint (Str, L"UsbDiagnostic"); + break; - case USB_CLASS_WIRELESS: - UefiDevicePathLibCatPrint (Str, L"UsbWireless"); - break; + case USB_CLASS_WIRELESS: + UefiDevicePathLibCatPrint (Str, L"UsbWireless"); + break; - default: - IsKnownSubClass = FALSE; - break; + default: + IsKnownSubClass = FALSE; + break; } if (IsKnownSubClass) { @@ -1113,7 +1184,7 @@ DevPathToTextSata ( IN BOOLEAN AllowShortcuts ) { - SATA_DEVICE_PATH *Sata; + SATA_DEVICE_PATH *Sata; Sata = DevPath; UefiDevicePathLibCatPrint ( @@ -1146,7 +1217,7 @@ DevPathToTextI2O ( IN BOOLEAN AllowShortcuts ) { - I2O_DEVICE_PATH *I2ODevPath; + I2O_DEVICE_PATH *I2ODevPath; I2ODevPath = DevPath; UefiDevicePathLibCatPrint (Str, L"I2O(0x%x)", I2ODevPath->Tid); @@ -1180,7 +1251,7 @@ DevPathToTextMacAddr ( MacDevPath = DevPath; HwAddressSize = sizeof (EFI_MAC_ADDRESS); - if (MacDevPath->IfType == 0x01 || MacDevPath->IfType == 0x00) { + if ((MacDevPath->IfType == 0x01) || (MacDevPath->IfType == 0x00)) { HwAddressSize = 6; } @@ -1223,8 +1294,8 @@ CatNetworkProtocol ( **/ VOID CatIPv4Address ( - IN OUT POOL_PRINT *Str, - IN EFI_IPv4_ADDRESS *Address + IN OUT POOL_PRINT *Str, + IN EFI_IPv4_ADDRESS *Address ) { UefiDevicePathLibCatPrint (Str, L"%d.%d.%d.%d", Address->Addr[0], Address->Addr[1], Address->Addr[2], Address->Addr[3]); @@ -1238,21 +1309,30 @@ CatIPv4Address ( **/ VOID CatIPv6Address ( - IN OUT POOL_PRINT *Str, - IN EFI_IPv6_ADDRESS *Address + IN OUT POOL_PRINT *Str, + IN EFI_IPv6_ADDRESS *Address ) { UefiDevicePathLibCatPrint ( - Str, L"%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x", - Address->Addr[0], Address->Addr[1], - Address->Addr[2], Address->Addr[3], - Address->Addr[4], Address->Addr[5], - Address->Addr[6], Address->Addr[7], - Address->Addr[8], Address->Addr[9], - Address->Addr[10], Address->Addr[11], - Address->Addr[12], Address->Addr[13], - Address->Addr[14], Address->Addr[15] - ); + Str, + L"%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x", + Address->Addr[0], + Address->Addr[1], + Address->Addr[2], + Address->Addr[3], + Address->Addr[4], + Address->Addr[5], + Address->Addr[6], + Address->Addr[7], + Address->Addr[8], + Address->Addr[9], + Address->Addr[10], + Address->Addr[11], + Address->Addr[12], + Address->Addr[13], + Address->Addr[14], + Address->Addr[15] + ); } /** @@ -1284,7 +1364,7 @@ DevPathToTextIPv4 ( if (DisplayOnly) { UefiDevicePathLibCatPrint (Str, L")"); - return ; + return; } UefiDevicePathLibCatPrint (Str, L","); @@ -1298,6 +1378,7 @@ DevPathToTextIPv4 ( UefiDevicePathLibCatPrint (Str, L","); CatIPv4Address (Str, &IPDevPath->SubnetMask); } + UefiDevicePathLibCatPrint (Str, L")"); } @@ -1329,9 +1410,9 @@ DevPathToTextIPv6 ( CatIPv6Address (Str, &IPDevPath->RemoteIpAddress); if (DisplayOnly) { UefiDevicePathLibCatPrint (Str, L")"); - return ; + return; } - + UefiDevicePathLibCatPrint (Str, L","); CatNetworkProtocol (Str, IPDevPath->Protocol); @@ -1353,6 +1434,7 @@ DevPathToTextIPv6 ( UefiDevicePathLibCatPrint (Str, L",0x%x,", IPDevPath->PrefixLength); CatIPv6Address (Str, &IPDevPath->GatewayIpAddress); } + UefiDevicePathLibCatPrint (Str, L")"); } @@ -1417,33 +1499,33 @@ DevPathToTextUart ( Uart = DevPath; switch (Uart->Parity) { - case 0: - Parity = 'D'; - break; + case 0: + Parity = 'D'; + break; - case 1: - Parity = 'N'; - break; + case 1: + Parity = 'N'; + break; - case 2: - Parity = 'E'; - break; + case 2: + Parity = 'E'; + break; - case 3: - Parity = 'O'; - break; + case 3: + Parity = 'O'; + break; - case 4: - Parity = 'M'; - break; + case 4: + Parity = 'M'; + break; - case 5: - Parity = 'S'; - break; + case 5: + Parity = 'S'; + break; - default: - Parity = 'x'; - break; + default: + Parity = 'x'; + break; } if (Uart->BaudRate == 0) { @@ -1461,25 +1543,25 @@ DevPathToTextUart ( UefiDevicePathLibCatPrint (Str, L"%c,", Parity); switch (Uart->StopBits) { - case 0: - UefiDevicePathLibCatPrint (Str, L"D)"); - break; + case 0: + UefiDevicePathLibCatPrint (Str, L"D)"); + break; - case 1: - UefiDevicePathLibCatPrint (Str, L"1)"); - break; + case 1: + UefiDevicePathLibCatPrint (Str, L"1)"); + break; - case 2: - UefiDevicePathLibCatPrint (Str, L"1.5)"); - break; + case 2: + UefiDevicePathLibCatPrint (Str, L"1.5)"); + break; - case 3: - UefiDevicePathLibCatPrint (Str, L"2)"); - break; + case 3: + UefiDevicePathLibCatPrint (Str, L"2)"); + break; - default: - UefiDevicePathLibCatPrint (Str, L"x)"); - break; + default: + UefiDevicePathLibCatPrint (Str, L"x)"); + break; } } @@ -1504,20 +1586,23 @@ DevPathToTextiSCSI ( IN BOOLEAN AllowShortcuts ) { - ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath; - UINT16 Options; + ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath; + UINT16 Options; + UINTN Index; ISCSIDevPath = DevPath; UefiDevicePathLibCatPrint ( Str, - L"iSCSI(%a,0x%x,0x%lx,", + L"iSCSI(%a,0x%x,0x", ISCSIDevPath->TargetName, - ISCSIDevPath->TargetPortalGroupTag, - ISCSIDevPath->Lun + ISCSIDevPath->TargetPortalGroupTag ); + for (Index = 0; Index < sizeof (ISCSIDevPath->Lun) / sizeof (UINT8); Index++) { + UefiDevicePathLibCatPrint (Str, L"%02x", ((UINT8 *)&ISCSIDevPath->Lun)[Index]); + } Options = ISCSIDevPath->LoginOption; - UefiDevicePathLibCatPrint (Str, L"%s,", (((Options >> 1) & 0x0001) != 0) ? L"CRC32C" : L"None"); + UefiDevicePathLibCatPrint (Str, L",%s,", (((Options >> 1) & 0x0001) != 0) ? L"CRC32C" : L"None"); UefiDevicePathLibCatPrint (Str, L"%s,", (((Options >> 3) & 0x0001) != 0) ? L"CRC32C" : L"None"); if (((Options >> 11) & 0x0001) != 0) { UefiDevicePathLibCatPrint (Str, L"%s,", L"None"); @@ -1525,7 +1610,6 @@ DevPathToTextiSCSI ( UefiDevicePathLibCatPrint (Str, L"%s,", L"CHAP_UNI"); } else { UefiDevicePathLibCatPrint (Str, L"%s,", L"CHAP_BI"); - } UefiDevicePathLibCatPrint (Str, L"%s)", (ISCSIDevPath->NetworkProtocol == 0) ? L"TCP" : L"reserved"); @@ -1585,12 +1669,12 @@ DevPathToTextBluetooth ( UefiDevicePathLibCatPrint ( Str, L"Bluetooth(%02x%02x%02x%02x%02x%02x)", - Bluetooth->BD_ADDR.Address[5], - Bluetooth->BD_ADDR.Address[4], - Bluetooth->BD_ADDR.Address[3], - Bluetooth->BD_ADDR.Address[2], + Bluetooth->BD_ADDR.Address[0], Bluetooth->BD_ADDR.Address[1], - Bluetooth->BD_ADDR.Address[0] + Bluetooth->BD_ADDR.Address[2], + Bluetooth->BD_ADDR.Address[3], + Bluetooth->BD_ADDR.Address[4], + Bluetooth->BD_ADDR.Address[5] ); } @@ -1615,8 +1699,8 @@ DevPathToTextWiFi ( IN BOOLEAN AllowShortcuts ) { - WIFI_DEVICE_PATH *WiFi; - UINT8 SSId[33]; + WIFI_DEVICE_PATH *WiFi; + UINT8 SSId[33]; WiFi = DevPath; @@ -1626,6 +1710,88 @@ DevPathToTextWiFi ( UefiDevicePathLibCatPrint (Str, L"Wi-Fi(%a)", SSId); } +/** + Converts a Bluetooth 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 +DevPathToTextBluetoothLE ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath, + IN BOOLEAN DisplayOnly, + IN BOOLEAN AllowShortcuts + ) +{ + BLUETOOTH_LE_DEVICE_PATH *BluetoothLE; + + BluetoothLE = DevPath; + UefiDevicePathLibCatPrint ( + Str, + L"BluetoothLE(%02x%02x%02x%02x%02x%02x,0x%02x)", + BluetoothLE->Address.Address[0], + BluetoothLE->Address.Address[1], + BluetoothLE->Address.Address[2], + BluetoothLE->Address.Address[3], + BluetoothLE->Address.Address[4], + BluetoothLE->Address.Address[5], + BluetoothLE->Address.Type + ); +} + +/** + Converts a DNS 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 +DevPathToTextDns ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath, + IN BOOLEAN DisplayOnly, + IN BOOLEAN AllowShortcuts + ) +{ + DNS_DEVICE_PATH *DnsDevPath; + UINT32 DnsServerIpCount; + UINT32 DnsServerIpIndex; + + DnsDevPath = DevPath; + DnsServerIpCount = (UINT32)(DevicePathNodeLength (DnsDevPath) - sizeof (EFI_DEVICE_PATH_PROTOCOL) - sizeof (DnsDevPath->IsIPv6)) / sizeof (EFI_IP_ADDRESS); + + UefiDevicePathLibCatPrint (Str, L"Dns("); + + for (DnsServerIpIndex = 0; DnsServerIpIndex < DnsServerIpCount; DnsServerIpIndex++) { + if (DnsDevPath->IsIPv6 == 0x00) { + CatIPv4Address (Str, &(DnsDevPath->DnsServerIp[DnsServerIpIndex].v4)); + } else { + CatIPv6Address (Str, &(DnsDevPath->DnsServerIp[DnsServerIpIndex].v6)); + } + + if (DnsServerIpIndex < DnsServerIpCount - 1) { + UefiDevicePathLibCatPrint (Str, L","); + } + } + + UefiDevicePathLibCatPrint (Str, L")"); +} + /** Converts a URI device path structure to its string representative. @@ -1647,16 +1813,16 @@ DevPathToTextUri ( IN BOOLEAN AllowShortcuts ) { - URI_DEVICE_PATH *Uri; - UINTN UriLength; - CHAR8 *UriStr; + URI_DEVICE_PATH *Uri; + UINTN UriLength; + CHAR8 *UriStr; // // Uri in the device path may not be null terminated. // Uri = DevPath; UriLength = DevicePathNodeLength (Uri) - sizeof (URI_DEVICE_PATH); - UriStr = AllocatePool (UriLength + 1); + UriStr = AllocatePool (UriLength + 1); ASSERT (UriStr != NULL); CopyMem (UriStr, Uri->Uri, UriLength); @@ -1686,38 +1852,38 @@ DevPathToTextHardDrive ( IN BOOLEAN AllowShortcuts ) { - HARDDRIVE_DEVICE_PATH *Hd; + HARDDRIVE_DEVICE_PATH *Hd; Hd = DevPath; switch (Hd->SignatureType) { - case SIGNATURE_TYPE_MBR: - UefiDevicePathLibCatPrint ( - Str, - L"HD(%d,%s,0x%08x,", - Hd->PartitionNumber, - L"MBR", - *((UINT32 *) (&(Hd->Signature[0]))) - ); - break; + case SIGNATURE_TYPE_MBR: + UefiDevicePathLibCatPrint ( + Str, + L"HD(%d,%s,0x%08x,", + Hd->PartitionNumber, + L"MBR", + *((UINT32 *)(&(Hd->Signature[0]))) + ); + break; - case SIGNATURE_TYPE_GUID: - UefiDevicePathLibCatPrint ( - Str, - L"HD(%d,%s,%g,", - Hd->PartitionNumber, - L"GPT", - (EFI_GUID *) &(Hd->Signature[0]) - ); - break; + case SIGNATURE_TYPE_GUID: + UefiDevicePathLibCatPrint ( + Str, + L"HD(%d,%s,%g,", + Hd->PartitionNumber, + L"GPT", + (EFI_GUID *)&(Hd->Signature[0]) + ); + break; - default: - UefiDevicePathLibCatPrint ( - Str, - L"HD(%d,%d,0,", - Hd->PartitionNumber, - Hd->SignatureType - ); - break; + default: + UefiDevicePathLibCatPrint ( + Str, + L"HD(%d,%d,0,", + Hd->PartitionNumber, + Hd->SignatureType + ); + break; } UefiDevicePathLibCatPrint (Str, L"0x%lx,0x%lx)", Hd->PartitionStart, Hd->PartitionSize); @@ -1744,12 +1910,12 @@ DevPathToTextCDROM ( IN BOOLEAN AllowShortcuts ) { - CDROM_DEVICE_PATH *Cd; + CDROM_DEVICE_PATH *Cd; Cd = DevPath; if (DisplayOnly) { UefiDevicePathLibCatPrint (Str, L"CDROM(0x%x)", Cd->BootEntry); - return ; + return; } UefiDevicePathLibCatPrint (Str, L"CDROM(0x%x,0x%lx,0x%lx)", Cd->BootEntry, Cd->PartitionStart, Cd->PartitionSize); @@ -1878,13 +2044,13 @@ DevPathToTextFvFile ( **/ VOID DevPathRelativeOffsetRange ( - IN OUT POOL_PRINT *Str, - IN VOID *DevPath, - IN BOOLEAN DisplayOnly, - IN BOOLEAN AllowShortcuts + IN OUT POOL_PRINT *Str, + IN VOID *DevPath, + IN BOOLEAN DisplayOnly, + IN BOOLEAN AllowShortcuts ) { - MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset; + MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset; Offset = DevPath; UefiDevicePathLibCatPrint ( @@ -1910,13 +2076,13 @@ DevPathRelativeOffsetRange ( **/ VOID DevPathToTextRamDisk ( - IN OUT POOL_PRINT *Str, - IN VOID *DevPath, - IN BOOLEAN DisplayOnly, - IN BOOLEAN AllowShortcuts + IN OUT POOL_PRINT *Str, + IN VOID *DevPath, + IN BOOLEAN DisplayOnly, + IN BOOLEAN AllowShortcuts ) { - MEDIA_RAM_DISK_DEVICE_PATH *RamDisk; + MEDIA_RAM_DISK_DEVICE_PATH *RamDisk; RamDisk = DevPath; @@ -1985,38 +2151,38 @@ DevPathToTextBBS ( IN BOOLEAN AllowShortcuts ) { - BBS_BBS_DEVICE_PATH *Bbs; - CHAR16 *Type; + BBS_BBS_DEVICE_PATH *Bbs; + CHAR16 *Type; Bbs = DevPath; switch (Bbs->DeviceType) { - case BBS_TYPE_FLOPPY: - Type = L"Floppy"; - break; + case BBS_TYPE_FLOPPY: + Type = L"Floppy"; + break; - case BBS_TYPE_HARDDRIVE: - Type = L"HD"; - break; + case BBS_TYPE_HARDDRIVE: + Type = L"HD"; + break; - case BBS_TYPE_CDROM: - Type = L"CDROM"; - break; + case BBS_TYPE_CDROM: + Type = L"CDROM"; + break; - case BBS_TYPE_PCMCIA: - Type = L"PCMCIA"; - break; + case BBS_TYPE_PCMCIA: + Type = L"PCMCIA"; + break; - case BBS_TYPE_USB: - Type = L"USB"; - break; + case BBS_TYPE_USB: + Type = L"USB"; + break; - case BBS_TYPE_EMBEDDED_NETWORK: - Type = L"Network"; - break; + case BBS_TYPE_EMBEDDED_NETWORK: + Type = L"Network"; + break; - default: - Type = NULL; - break; + default: + Type = NULL; + break; } if (Type != NULL) { @@ -2027,7 +2193,7 @@ DevPathToTextBBS ( if (DisplayOnly) { UefiDevicePathLibCatPrint (Str, L")"); - return ; + return; } UefiDevicePathLibCatPrint (Str, L",0x%x)", Bbs->StatusFlag); @@ -2057,13 +2223,13 @@ DevPathToTextEndInstance ( UefiDevicePathLibCatPrint (Str, L","); } -GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_GENERIC_TABLE mUefiDevicePathLibToTextTableGeneric[] = { - {HARDWARE_DEVICE_PATH, L"HardwarePath" }, - {ACPI_DEVICE_PATH, L"AcpiPath" }, - {MESSAGING_DEVICE_PATH, L"Msg" }, - {MEDIA_DEVICE_PATH, L"MediaPath" }, - {BBS_DEVICE_PATH, L"BbsPath" }, - {0, NULL} +GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_GENERIC_TABLE mUefiDevicePathLibToTextTableGeneric[] = { + { HARDWARE_DEVICE_PATH, L"HardwarePath" }, + { ACPI_DEVICE_PATH, L"AcpiPath" }, + { MESSAGING_DEVICE_PATH, L"Msg" }, + { MEDIA_DEVICE_PATH, L"MediaPath" }, + { BBS_DEVICE_PATH, L"BbsPath" }, + { 0, NULL } }; /** @@ -2087,8 +2253,8 @@ DevPathToTextNodeGeneric ( IN BOOLEAN AllowShortcuts ) { - EFI_DEVICE_PATH_PROTOCOL *Node; - UINTN Index; + EFI_DEVICE_PATH_PROTOCOL *Node; + UINTN Index; Node = DevPath; @@ -2113,62 +2279,65 @@ DevPathToTextNodeGeneric ( Index = sizeof (EFI_DEVICE_PATH_PROTOCOL); if (Index < DevicePathNodeLength (Node)) { UefiDevicePathLibCatPrint (Str, L","); - for (; Index < DevicePathNodeLength (Node); Index++) { - UefiDevicePathLibCatPrint (Str, L"%02x", ((UINT8 *) Node)[Index]); + for ( ; Index < DevicePathNodeLength (Node); Index++) { + UefiDevicePathLibCatPrint (Str, L"%02x", ((UINT8 *)Node)[Index]); } } UefiDevicePathLibCatPrint (Str, L")"); } -GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE mUefiDevicePathLibToTextTable[] = { - {HARDWARE_DEVICE_PATH, HW_PCI_DP, DevPathToTextPci }, - {HARDWARE_DEVICE_PATH, HW_PCCARD_DP, DevPathToTextPccard }, - {HARDWARE_DEVICE_PATH, HW_MEMMAP_DP, DevPathToTextMemMap }, - {HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DevPathToTextVendor }, - {HARDWARE_DEVICE_PATH, HW_CONTROLLER_DP, DevPathToTextController }, - {HARDWARE_DEVICE_PATH, HW_BMC_DP, DevPathToTextBmc }, - {ACPI_DEVICE_PATH, ACPI_DP, DevPathToTextAcpi }, - {ACPI_DEVICE_PATH, ACPI_EXTENDED_DP, DevPathToTextAcpiEx }, - {ACPI_DEVICE_PATH, ACPI_ADR_DP, DevPathToTextAcpiAdr }, - {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_SASEX_DP, DevPathToTextSasEx }, - {MESSAGING_DEVICE_PATH, MSG_NVME_NAMESPACE_DP, DevPathToTextNVMe }, - {MESSAGING_DEVICE_PATH, MSG_UFS_DP, DevPathToTextUfs }, - {MESSAGING_DEVICE_PATH, MSG_SD_DP, DevPathToTextSd }, - {MESSAGING_DEVICE_PATH, MSG_1394_DP, DevPathToText1394 }, - {MESSAGING_DEVICE_PATH, MSG_USB_DP, DevPathToTextUsb }, - {MESSAGING_DEVICE_PATH, MSG_USB_WWID_DP, DevPathToTextUsbWWID }, - {MESSAGING_DEVICE_PATH, MSG_DEVICE_LOGICAL_UNIT_DP, DevPathToTextLogicalUnit }, - {MESSAGING_DEVICE_PATH, MSG_USB_CLASS_DP, DevPathToTextUsbClass }, - {MESSAGING_DEVICE_PATH, MSG_SATA_DP, DevPathToTextSata }, - {MESSAGING_DEVICE_PATH, MSG_I2O_DP, DevPathToTextI2O }, - {MESSAGING_DEVICE_PATH, MSG_MAC_ADDR_DP, DevPathToTextMacAddr }, - {MESSAGING_DEVICE_PATH, MSG_IPv4_DP, DevPathToTextIPv4 }, - {MESSAGING_DEVICE_PATH, MSG_IPv6_DP, DevPathToTextIPv6 }, - {MESSAGING_DEVICE_PATH, MSG_INFINIBAND_DP, DevPathToTextInfiniBand }, - {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 }, - {MESSAGING_DEVICE_PATH, MSG_URI_DP, DevPathToTextUri }, - {MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_DP, DevPathToTextBluetooth }, - {MESSAGING_DEVICE_PATH, MSG_WIFI_DP, DevPathToTextWiFi }, - {MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, DevPathToTextHardDrive }, - {MEDIA_DEVICE_PATH, MEDIA_CDROM_DP, DevPathToTextCDROM }, - {MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP, DevPathToTextVendor }, - {MEDIA_DEVICE_PATH, MEDIA_PROTOCOL_DP, DevPathToTextMediaProtocol }, - {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 }, - {MEDIA_DEVICE_PATH, MEDIA_RAM_DISK_DP, DevPathToTextRamDisk }, - {BBS_DEVICE_PATH, BBS_BBS_DP, DevPathToTextBBS }, - {END_DEVICE_PATH_TYPE, END_INSTANCE_DEVICE_PATH_SUBTYPE, DevPathToTextEndInstance }, - {0, 0, NULL} +GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE mUefiDevicePathLibToTextTable[] = { + { HARDWARE_DEVICE_PATH, HW_PCI_DP, DevPathToTextPci }, + { HARDWARE_DEVICE_PATH, HW_PCCARD_DP, DevPathToTextPccard }, + { HARDWARE_DEVICE_PATH, HW_MEMMAP_DP, DevPathToTextMemMap }, + { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DevPathToTextVendor }, + { HARDWARE_DEVICE_PATH, HW_CONTROLLER_DP, DevPathToTextController }, + { HARDWARE_DEVICE_PATH, HW_BMC_DP, DevPathToTextBmc }, + { ACPI_DEVICE_PATH, ACPI_DP, DevPathToTextAcpi }, + { ACPI_DEVICE_PATH, ACPI_EXTENDED_DP, DevPathToTextAcpiEx }, + { ACPI_DEVICE_PATH, ACPI_ADR_DP, DevPathToTextAcpiAdr }, + { 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_SASEX_DP, DevPathToTextSasEx }, + { MESSAGING_DEVICE_PATH, MSG_NVME_NAMESPACE_DP, DevPathToTextNVMe }, + { MESSAGING_DEVICE_PATH, MSG_UFS_DP, DevPathToTextUfs }, + { MESSAGING_DEVICE_PATH, MSG_SD_DP, DevPathToTextSd }, + { MESSAGING_DEVICE_PATH, MSG_EMMC_DP, DevPathToTextEmmc }, + { MESSAGING_DEVICE_PATH, MSG_1394_DP, DevPathToText1394 }, + { MESSAGING_DEVICE_PATH, MSG_USB_DP, DevPathToTextUsb }, + { MESSAGING_DEVICE_PATH, MSG_USB_WWID_DP, DevPathToTextUsbWWID }, + { MESSAGING_DEVICE_PATH, MSG_DEVICE_LOGICAL_UNIT_DP, DevPathToTextLogicalUnit }, + { MESSAGING_DEVICE_PATH, MSG_USB_CLASS_DP, DevPathToTextUsbClass }, + { MESSAGING_DEVICE_PATH, MSG_SATA_DP, DevPathToTextSata }, + { MESSAGING_DEVICE_PATH, MSG_I2O_DP, DevPathToTextI2O }, + { MESSAGING_DEVICE_PATH, MSG_MAC_ADDR_DP, DevPathToTextMacAddr }, + { MESSAGING_DEVICE_PATH, MSG_IPv4_DP, DevPathToTextIPv4 }, + { MESSAGING_DEVICE_PATH, MSG_IPv6_DP, DevPathToTextIPv6 }, + { MESSAGING_DEVICE_PATH, MSG_INFINIBAND_DP, DevPathToTextInfiniBand }, + { 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 }, + { MESSAGING_DEVICE_PATH, MSG_DNS_DP, DevPathToTextDns }, + { MESSAGING_DEVICE_PATH, MSG_URI_DP, DevPathToTextUri }, + { MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_DP, DevPathToTextBluetooth }, + { MESSAGING_DEVICE_PATH, MSG_WIFI_DP, DevPathToTextWiFi }, + { MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_LE_DP, DevPathToTextBluetoothLE }, + { MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, DevPathToTextHardDrive }, + { MEDIA_DEVICE_PATH, MEDIA_CDROM_DP, DevPathToTextCDROM }, + { MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP, DevPathToTextVendor }, + { MEDIA_DEVICE_PATH, MEDIA_PROTOCOL_DP, DevPathToTextMediaProtocol }, + { 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 }, + { MEDIA_DEVICE_PATH, MEDIA_RAM_DISK_DP, DevPathToTextRamDisk }, + { BBS_DEVICE_PATH, BBS_BBS_DP, DevPathToTextBBS }, + { END_DEVICE_PATH_TYPE, END_INSTANCE_DEVICE_PATH_SUBTYPE, DevPathToTextEndInstance }, + { 0, 0, NULL } }; /** @@ -2194,9 +2363,9 @@ UefiDevicePathLibConvertDeviceNodeToText ( IN BOOLEAN AllowShortcuts ) { - POOL_PRINT Str; - UINTN Index; - DEVICE_PATH_TO_TEXT ToText; + POOL_PRINT Str; + UINTN Index; + DEVICE_PATH_TO_TEXT ToText; if (DeviceNode == NULL) { return NULL; @@ -2210,9 +2379,10 @@ UefiDevicePathLibConvertDeviceNodeToText ( // ToText = DevPathToTextNodeGeneric; for (Index = 0; mUefiDevicePathLibToTextTable[Index].Function != NULL; Index++) { - if (DevicePathType (DeviceNode) == mUefiDevicePathLibToTextTable[Index].Type && - DevicePathSubType (DeviceNode) == mUefiDevicePathLibToTextTable[Index].SubType - ) { + if ((DevicePathType (DeviceNode) == mUefiDevicePathLibToTextTable[Index].Type) && + (DevicePathSubType (DeviceNode) == mUefiDevicePathLibToTextTable[Index].SubType) + ) + { ToText = mUefiDevicePathLibToTextTable[Index].Function; break; } @@ -2221,7 +2391,7 @@ UefiDevicePathLibConvertDeviceNodeToText ( // // Print this node // - ToText (&Str, (VOID *) DeviceNode, DisplayOnly, AllowShortcuts); + ToText (&Str, (VOID *)DeviceNode, DisplayOnly, AllowShortcuts); ASSERT (Str.Str != NULL); return Str.Str; @@ -2245,16 +2415,16 @@ UefiDevicePathLibConvertDeviceNodeToText ( CHAR16 * EFIAPI UefiDevicePathLibConvertDevicePathToText ( - IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, - IN BOOLEAN DisplayOnly, - IN BOOLEAN AllowShortcuts + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, + IN BOOLEAN DisplayOnly, + IN BOOLEAN AllowShortcuts ) { - POOL_PRINT Str; - EFI_DEVICE_PATH_PROTOCOL *Node; - EFI_DEVICE_PATH_PROTOCOL *AlignedNode; - UINTN Index; - DEVICE_PATH_TO_TEXT ToText; + POOL_PRINT Str; + EFI_DEVICE_PATH_PROTOCOL *Node; + EFI_DEVICE_PATH_PROTOCOL *AlignedNode; + UINTN Index; + DEVICE_PATH_TO_TEXT ToText; if (DevicePath == NULL) { return NULL; @@ -2265,7 +2435,7 @@ UefiDevicePathLibConvertDevicePathToText ( // // Process each device path node // - Node = (EFI_DEVICE_PATH_PROTOCOL *) DevicePath; + Node = (EFI_DEVICE_PATH_PROTOCOL *)DevicePath; while (!IsDevicePathEnd (Node)) { // // Find the handler to dump this device path node @@ -2273,14 +2443,15 @@ UefiDevicePathLibConvertDevicePathToText ( // ToText = DevPathToTextNodeGeneric; for (Index = 0; mUefiDevicePathLibToTextTable[Index].Function != NULL; Index += 1) { - - if (DevicePathType (Node) == mUefiDevicePathLibToTextTable[Index].Type && - DevicePathSubType (Node) == mUefiDevicePathLibToTextTable[Index].SubType - ) { + if ((DevicePathType (Node) == mUefiDevicePathLibToTextTable[Index].Type) && + (DevicePathSubType (Node) == mUefiDevicePathLibToTextTable[Index].SubType) + ) + { ToText = mUefiDevicePathLibToTextTable[Index].Function; break; } } + // // Put a path separator in if needed // @@ -2289,14 +2460,14 @@ UefiDevicePathLibConvertDevicePathToText ( UefiDevicePathLibCatPrint (&Str, L"/"); } } - + AlignedNode = AllocateCopyPool (DevicePathNodeLength (Node), Node); // // Print this node of the device path // ToText (&Str, AlignedNode, DisplayOnly, AllowShortcuts); FreePool (AlignedNode); - + // // Next device path node //