ShellPkg: Allow for LoadedImageProtocol information to be verbosely exported for commands like "dh"
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jaben Carsey <Jaben.carsey@intel.com> Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15352 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
Provides interface to advanced shell functionality for parsing both handle and protocol database.
|
Provides interface to advanced shell functionality for parsing both handle and protocol database.
|
||||||
|
|
||||||
Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
|
Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
|
||||||
Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2010 - 2014, 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
|
||||||
@ -19,6 +19,43 @@
|
|||||||
EFI_HANDLE mHandleParsingHiiHandle;
|
EFI_HANDLE mHandleParsingHiiHandle;
|
||||||
HANDLE_INDEX_LIST mHandleList = {{{NULL,NULL},0,0},0};
|
HANDLE_INDEX_LIST mHandleList = {{{NULL,NULL},0,0},0};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Function to translate the EFI_MEMORY_TYPE into a string.
|
||||||
|
|
||||||
|
@param[in] Memory The memory type.
|
||||||
|
|
||||||
|
@retval A string representation of the type allocated from BS Pool.
|
||||||
|
**/
|
||||||
|
CHAR16*
|
||||||
|
EFIAPI
|
||||||
|
ConvertMemoryType (
|
||||||
|
IN CONST EFI_MEMORY_TYPE Memory
|
||||||
|
)
|
||||||
|
{
|
||||||
|
CHAR16 *RetVal;
|
||||||
|
RetVal = NULL;
|
||||||
|
|
||||||
|
switch (Memory) {
|
||||||
|
case EfiReservedMemoryType: StrnCatGrow(&RetVal, NULL, L"EfiReservedMemoryType", 0); break;
|
||||||
|
case EfiLoaderCode: StrnCatGrow(&RetVal, NULL, L"EfiLoaderCode", 0); break;
|
||||||
|
case EfiLoaderData: StrnCatGrow(&RetVal, NULL, L"EfiLoaderData", 0); break;
|
||||||
|
case EfiBootServicesCode: StrnCatGrow(&RetVal, NULL, L"EfiBootServicesCode", 0); break;
|
||||||
|
case EfiBootServicesData: StrnCatGrow(&RetVal, NULL, L"EfiBootServicesData", 0); break;
|
||||||
|
case EfiRuntimeServicesCode: StrnCatGrow(&RetVal, NULL, L"EfiRuntimeServicesCode", 0); break;
|
||||||
|
case EfiRuntimeServicesData: StrnCatGrow(&RetVal, NULL, L"EfiRuntimeServicesData", 0); break;
|
||||||
|
case EfiConventionalMemory: StrnCatGrow(&RetVal, NULL, L"EfiConventionalMemory", 0); break;
|
||||||
|
case EfiUnusableMemory: StrnCatGrow(&RetVal, NULL, L"EfiUnusableMemory", 0); break;
|
||||||
|
case EfiACPIReclaimMemory: StrnCatGrow(&RetVal, NULL, L"EfiACPIReclaimMemory", 0); break;
|
||||||
|
case EfiACPIMemoryNVS: StrnCatGrow(&RetVal, NULL, L"EfiACPIMemoryNVS", 0); break;
|
||||||
|
case EfiMemoryMappedIO: StrnCatGrow(&RetVal, NULL, L"EfiMemoryMappedIO", 0); break;
|
||||||
|
case EfiMemoryMappedIOPortSpace: StrnCatGrow(&RetVal, NULL, L"EfiMemoryMappedIOPortSpace", 0); break;
|
||||||
|
case EfiPalCode: StrnCatGrow(&RetVal, NULL, L"EfiPalCode", 0); break;
|
||||||
|
case EfiMaxMemoryType: StrnCatGrow(&RetVal, NULL, L"EfiMaxMemoryType", 0); break;
|
||||||
|
default: ASSERT(FALSE);
|
||||||
|
}
|
||||||
|
return (RetVal);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructor for the library.
|
Constructor for the library.
|
||||||
|
|
||||||
@ -63,7 +100,16 @@ HandleParsingLibDestructor (
|
|||||||
return (EFI_SUCCESS);
|
return (EFI_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
|
Function to dump information about LoadedImage.
|
||||||
|
|
||||||
|
This will allocate the return buffer from boot services pool.
|
||||||
|
|
||||||
|
@param[in] TheHandle The handle that has LoadedImage installed.
|
||||||
|
@param[in] Verbose TRUE for additional information, FALSE otherwise.
|
||||||
|
|
||||||
|
@retval A poitner to a string containing the information.
|
||||||
|
**/
|
||||||
CHAR16*
|
CHAR16*
|
||||||
EFIAPI
|
EFIAPI
|
||||||
LoadedImageProtocolDumpInformation(
|
LoadedImageProtocolDumpInformation(
|
||||||
@ -71,96 +117,59 @@ LoadedImageProtocolDumpInformation(
|
|||||||
IN CONST BOOLEAN Verbose
|
IN CONST BOOLEAN Verbose
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_LOADED_IMAGE_PROTOCOL *Image;
|
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_DEVICE_PATH_PROTOCOL *DevPath;
|
CHAR16 *RetVal;
|
||||||
EFI_DEVICE_PATH_PROTOCOL *DevPathNode;
|
CHAR16 *Temp;
|
||||||
VOID *Buffer;
|
CHAR16 *CodeType;
|
||||||
UINTN BufferSize;
|
CHAR16 *DataType;
|
||||||
UINT32 AuthenticationStatus;
|
|
||||||
EFI_GUID *NameGuid;
|
|
||||||
EFI_FIRMWARE_VOLUME_PROTOCOL *FV;
|
|
||||||
EFI_FIRMWARE_VOLUME2_PROTOCOL *FV2;
|
|
||||||
|
|
||||||
FV = NULL;
|
if (!Verbose) {
|
||||||
FV2 = NULL;
|
return (CatSPrint(NULL, L"LoadedImage"));
|
||||||
Buffer = NULL;
|
}
|
||||||
BufferSize = 0;
|
|
||||||
|
|
||||||
Status = HandleProtocol (
|
Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_LI_DUMP_MAIN), NULL);
|
||||||
TheHandle,
|
RetVal = AllocateZeroPool (PcdGet16 (PcdShellPrintBufferSize));
|
||||||
&gEfiLoadedImageProtocolGuid,
|
if (Temp == NULL || RetVal == NULL) {
|
||||||
&Image);
|
SHELL_FREE_NON_NULL(Temp);
|
||||||
ASSERT_EFI_ERROR(Status);
|
SHELL_FREE_NON_NULL(RetVal);
|
||||||
|
|
||||||
DevPath = UnpackDevicePath (Image->FilePath);
|
|
||||||
|
|
||||||
if (DevPath == NULL) {
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DevPathNode = DevPath;
|
Status = gBS->OpenProtocol (
|
||||||
|
TheHandle,
|
||||||
|
&gEfiLoadedImageProtocolGuid,
|
||||||
|
(VOID**)&LoadedImage,
|
||||||
|
gImageHandle,
|
||||||
|
NULL,
|
||||||
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||||
|
);
|
||||||
|
|
||||||
while (!IsDevicePathEnd (DevPathNode)) {
|
DataType = ConvertMemoryType(LoadedImage->ImageDataType);
|
||||||
//
|
CodeType = ConvertMemoryType(LoadedImage->ImageCodeType);
|
||||||
// Find the Fv File path
|
|
||||||
//
|
|
||||||
NameGuid = GetNameGuidFromFwVolDevicePathNode ((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)DevPathNode);
|
|
||||||
if (NameGuid != NULL) {
|
|
||||||
Status = BS->HandleProtocol (
|
|
||||||
Image->DeviceHandle,
|
|
||||||
&gEfiFirmwareVolumeProtocolGuid,
|
|
||||||
&FV
|
|
||||||
);
|
|
||||||
if (!EFI_ERROR (Status)) {
|
|
||||||
Status = FV->ReadSection (
|
|
||||||
FV,
|
|
||||||
NameGuid,
|
|
||||||
EFI_SECTION_USER_INTERFACE,
|
|
||||||
0,
|
|
||||||
&Buffer,
|
|
||||||
&BufferSize,
|
|
||||||
&AuthenticationStatus
|
|
||||||
);
|
|
||||||
if (!EFI_ERROR (Status)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Buffer = NULL;
|
RetVal = CatSPrint(RetVal,
|
||||||
} else {
|
Temp,
|
||||||
Status = BS->HandleProtocol (
|
LoadedImage->Revision,
|
||||||
Image->DeviceHandle,
|
LoadedImage->ParentHandle,
|
||||||
&gEfiFirmwareVolume2ProtocolGuid,
|
LoadedImage->SystemTable,
|
||||||
&FV2
|
LoadedImage->DeviceHandle,
|
||||||
);
|
LoadedImage->FilePath,
|
||||||
if (!EFI_ERROR (Status)) {
|
LoadedImage->LoadOptionsSize,
|
||||||
Status = FV2->ReadSection (
|
LoadedImage->LoadOptions,
|
||||||
FV2,
|
LoadedImage->ImageBase,
|
||||||
NameGuid,
|
LoadedImage->ImageSize,
|
||||||
EFI_SECTION_USER_INTERFACE,
|
CodeType,
|
||||||
0,
|
DataType,
|
||||||
&Buffer,
|
LoadedImage->Unload);
|
||||||
&BufferSize,
|
|
||||||
&AuthenticationStatus
|
|
||||||
);
|
|
||||||
if (!EFI_ERROR (Status)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Buffer = NULL;
|
|
||||||
}
|
SHELL_FREE_NON_NULL(Temp);
|
||||||
}
|
SHELL_FREE_NON_NULL(CodeType);
|
||||||
}
|
SHELL_FREE_NON_NULL(DataType);
|
||||||
//
|
|
||||||
// Next device path node
|
|
||||||
//
|
|
||||||
DevPathNode = NextDevicePathNode (DevPathNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
FreePool (DevPath);
|
return RetVal;
|
||||||
return Buffer;
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Function to dump information about PciRootBridgeIo.
|
Function to dump information about PciRootBridgeIo.
|
||||||
@ -463,7 +472,7 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringListNT[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = {
|
STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = {
|
||||||
{STRING_TOKEN(STR_LOADED_IMAGE), &gEfiLoadedImageProtocolGuid, NULL},
|
{STRING_TOKEN(STR_LOADED_IMAGE), &gEfiLoadedImageProtocolGuid, LoadedImageProtocolDumpInformation},
|
||||||
{STRING_TOKEN(STR_DEVICE_PATH), &gEfiDevicePathProtocolGuid, DevicePathProtocolDumpInformation},
|
{STRING_TOKEN(STR_DEVICE_PATH), &gEfiDevicePathProtocolGuid, DevicePathProtocolDumpInformation},
|
||||||
{STRING_TOKEN(STR_IMAGE_PATH), &gEfiLoadedImageDevicePathProtocolGuid, DevicePathProtocolDumpInformation},
|
{STRING_TOKEN(STR_IMAGE_PATH), &gEfiLoadedImageDevicePathProtocolGuid, DevicePathProtocolDumpInformation},
|
||||||
{STRING_TOKEN(STR_DEVICE_PATH_UTIL), &gEfiDevicePathUtilitiesProtocolGuid, NULL},
|
{STRING_TOKEN(STR_DEVICE_PATH_UTIL), &gEfiDevicePathUtilitiesProtocolGuid, NULL},
|
||||||
|
Binary file not shown.
Reference in New Issue
Block a user