CHAR16 * ConsistMappingGenMappingName ( EFI_DEVICE_PATH_PROTOCOL *DevicePath, EFI_DEVICE_PATH_PROTOCOL **HIDevicePathTable ) { POOL_PRINT Str; DEVICE_CONSIST_MAPPING_INFO MappingInfo; EFI_DEVICE_PATH_PROTOCOL *HIDevicePath; UINTN Index; UINTN NewSize; HIDevicePath = GetHIDevicePath (DevicePath); if (HIDevicePath == NULL) { return NULL; } for (Index = 0; HIDevicePathTable[Index] != NULL; Index++) { if (DevicePathCompare (HIDevicePathTable[Index], HIDevicePath) == 0) { break; } } FreePool (HIDevicePath); if (HIDevicePathTable[Index] == NULL) { return NULL; } MappingInfo.HI = Index; MappingInfo.MTD = MTDTypeUnknown; MappingInfo.Digital = FALSE; GetDeviceConsistMappingInfo (&MappingInfo, DevicePath); SetMem (&Str, sizeof (Str), 0); for (Index = 0; mMTDName[Index].MTDType != MTDTypeEnd; Index++) { if (MappingInfo.MTD == mMTDName[Index].MTDType) { break; } } if (mMTDName[Index].MTDType != MTDTypeEnd) { CatPrint (&Str, L"%s", mMTDName[Index].Name); } CatPrint (&Str, L"%d", (UINTN) MappingInfo.HI); if (MappingInfo.CSD.str != NULL) { CatPrint (&Str, L"%s", MappingInfo.CSD.str); FreePool (MappingInfo.CSD.str); } NewSize = (Str.len + 1) * sizeof (CHAR16); Str.str = ReallocatePool (Str.str, NewSize, NewSize); Str.str[Str.len] = 0; return Str.str; }
EFIAPI ShellCommandConsistMappingGenMappingName ( IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN EFI_DEVICE_PATH_PROTOCOL **Table ) { POOL_PRINT Str; DEVICE_CONSIST_MAPPING_INFO MappingInfo; EFI_DEVICE_PATH_PROTOCOL *HIDevicePath; UINTN Index; UINTN NewSize; ASSERT(DevicePath != NULL); ASSERT(Table != NULL); HIDevicePath = GetHIDevicePath (DevicePath); if (HIDevicePath == NULL) { return NULL; } for (Index = 0; Table[Index] != NULL; Index++) { if (DevicePathCompare (&Table[Index], &HIDevicePath) == 0) { break; } } FreePool (HIDevicePath); if (Table[Index] == NULL) { return NULL; } MappingInfo.Hi = Index; MappingInfo.Mtd = MTDTypeUnknown; MappingInfo.Digital = FALSE; GetDeviceConsistMappingInfo (&MappingInfo, DevicePath); SetMem (&Str, sizeof (Str), 0); for (Index = 0; mMTDName[Index].MTDType != MTDTypeEnd; Index++) { if (MappingInfo.Mtd == mMTDName[Index].MTDType) { break; } } if (mMTDName[Index].MTDType != MTDTypeEnd) { CatPrint (&Str, L"%s", mMTDName[Index].Name); } CatPrint (&Str, L"%d", (UINTN) MappingInfo.Hi); if (MappingInfo.Csd.Str != NULL) { CatPrint (&Str, L"%s", MappingInfo.Csd.Str); FreePool (MappingInfo.Csd.Str); } if (Str.Str != NULL) { CatPrint (&Str, L":"); } NewSize = (Str.Len + 1) * sizeof (CHAR16); Str.Str = ReallocatePool (Str.Len, NewSize, Str.Str); if (Str.Str == NULL) { return (NULL); } Str.Str[Str.Len] = CHAR_NULL; return Str.Str; }