X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ShellPkg%2FLibrary%2FUefiShellCommandLib%2FConsistMapping.c;h=a42a045d52d48341f1ed43c27a100d15f5fe6d26;hb=cc4c331207b6556e1aaae2b603e7024d775da812;hp=a009609ffc27e08f727fce96f64ec2c5217bbed5;hpb=531733377ac25083c7a54067a5330fb59f79bdfd;p=mirror_edk2.git diff --git a/ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c b/ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c index a009609ffc..a42a045d52 100644 --- a/ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c +++ b/ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c @@ -14,6 +14,7 @@ #include "UefiShellCommandLib.h" #include #include +#include typedef enum { MTDTypeUnknown, @@ -575,6 +576,9 @@ DevPathSerialVendor ( { VENDOR_DEVICE_PATH *Vendor; SAS_DEVICE_PATH *Sas; + UINTN TargetNameLength; + UINTN Index; + CHAR16 *Buffer; if (DevicePathNode == NULL || MappingItem == NULL) { return; @@ -589,6 +593,32 @@ DevPathSerialVendor ( AppendCSDNum (MappingItem, Sas->Lun); AppendCSDNum (MappingItem, Sas->DeviceTopology); AppendCSDNum (MappingItem, Sas->RelativeTargetPort); + } else { + TargetNameLength = MIN(DevicePathNodeLength (DevicePathNode) - sizeof (VENDOR_DEVICE_PATH), PcdGet32(PcdShellVendorExtendedDecode)); + if (TargetNameLength != 0) { + // + // String is 2 chars per data byte, plus NULL terminator + // + Buffer = AllocateZeroPool (((TargetNameLength * 2) + 1) * sizeof(CHAR16)); + ASSERT(Buffer != NULL); + if (Buffer == NULL) { + return; + } + + // + // Build the string data + // + for (Index = 0; Index < TargetNameLength; Index++) { + Buffer = CatSPrint (Buffer, L"%02x", *((UINT8*)Vendor + sizeof (VENDOR_DEVICE_PATH) + Index)); + } + + // + // Append the new data block + // + AppendCSDStr (MappingItem, Buffer); + + FreePool(Buffer); + } } } @@ -651,13 +681,6 @@ DevPathSerialIScsi ( IN DEVICE_CONSIST_MAPPING_INFO *MappingItem ) { -///@todo make this a PCD -// -// As Csd of ISCSI node is quite long, we comment -// the code below to keep the consistent mapping -// short. Uncomment if you really need it. -// -/* ISCSI_DEVICE_PATH *IScsi; UINT8 *IScsiTargetName; CHAR16 *TargetName; @@ -667,24 +690,25 @@ DevPathSerialIScsi ( ASSERT(DevicePathNode != NULL); ASSERT(MappingItem != NULL); - IScsi = (ISCSI_DEVICE_PATH *) DevicePathNode; - AppendCSDNum (MappingItem, IScsi->NetworkProtocol); - AppendCSDNum (MappingItem, IScsi->LoginOption); - AppendCSDNum (MappingItem, IScsi->Lun); - AppendCSDNum (MappingItem, IScsi->TargetPortalGroupTag); - TargetNameLength = DevicePathNodeLength (DevicePathNode) - sizeof (ISCSI_DEVICE_PATH); - if (TargetNameLength > 0) { - TargetName = AllocateZeroPool ((TargetNameLength + 1) * sizeof (CHAR16)); - if (TargetName != NULL) { - IScsiTargetName = (UINT8 *) (IScsi + 1); - for (Index = 0; Index < TargetNameLength; Index++) { - TargetName[Index] = (CHAR16) IScsiTargetName[Index]; + if (PcdGetBool(PcdShellDecodeIScsiMapNames)) { + IScsi = (ISCSI_DEVICE_PATH *) DevicePathNode; + AppendCSDNum (MappingItem, IScsi->NetworkProtocol); + AppendCSDNum (MappingItem, IScsi->LoginOption); + AppendCSDNum (MappingItem, IScsi->Lun); + AppendCSDNum (MappingItem, IScsi->TargetPortalGroupTag); + TargetNameLength = DevicePathNodeLength (DevicePathNode) - sizeof (ISCSI_DEVICE_PATH); + if (TargetNameLength > 0) { + TargetName = AllocateZeroPool ((TargetNameLength + 1) * sizeof (CHAR16)); + if (TargetName != NULL) { + IScsiTargetName = (UINT8 *) (IScsi + 1); + for (Index = 0; Index < TargetNameLength; Index++) { + TargetName[Index] = (CHAR16) IScsiTargetName[Index]; + } + AppendCSDStr (MappingItem, TargetName); + FreePool (TargetName); } - AppendCSDStr (MappingItem, TargetName); - FreePool (TargetName); } } - */ } /**