/** @file\r
Provides interface to advanced shell functionality for parsing both handle and protocol database.\r
\r
- Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.<BR>\r
(C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>\r
(C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r
This program and the accompanying materials\r
\r
#include "UefiHandleParsingLib.h"\r
#include "IndustryStandard/Acpi10.h"\r
+#include "IndustryStandard/Pci.h"\r
+#include <PiDxe.h>\r
+#include <Protocol/FirmwareVolume2.h>\r
\r
EFI_HANDLE mHandleParsingHiiHandle = NULL;\r
HANDLE_INDEX_LIST mHandleList = {{{NULL,NULL},0,0},0};\r
-GUID_INFO_BLOCK *GuidList;\r
-UINTN GuidListCount;\r
+GUID_INFO_BLOCK *mGuidList;\r
+UINTN mGuidListCount;\r
+\r
+/**\r
+ Function to find the file name associated with a LoadedImageProtocol.\r
+\r
+ @param[in] LoadedImage An instance of LoadedImageProtocol.\r
+\r
+ @retval A string representation of the file name associated\r
+ with LoadedImage, or NULL if no name can be found.\r
+**/\r
+CHAR16*\r
+FindLoadedImageFileName (\r
+ IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage\r
+ )\r
+{\r
+ EFI_GUID *NameGuid;\r
+ EFI_STATUS Status;\r
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;\r
+ VOID *Buffer;\r
+ UINTN BufferSize;\r
+ UINT32 AuthenticationStatus;\r
+\r
+ if ((LoadedImage == NULL) || (LoadedImage->FilePath == NULL)) {\r
+ return NULL;\r
+ }\r
+\r
+ NameGuid = EfiGetNameGuidFromFwVolDevicePathNode((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)LoadedImage->FilePath);\r
+\r
+ if (NameGuid == NULL) {\r
+ return NULL;\r
+ }\r
+\r
+ //\r
+ // Get the FirmwareVolume2Protocol of the device handle that this image was loaded from.\r
+ //\r
+ Status = gBS->HandleProtocol (LoadedImage->DeviceHandle, &gEfiFirmwareVolume2ProtocolGuid, (VOID**) &Fv);\r
+\r
+ //\r
+ // FirmwareVolume2Protocol is PI, and is not required to be available.\r
+ //\r
+ if (EFI_ERROR (Status)) {\r
+ return NULL;\r
+ }\r
+\r
+ //\r
+ // Read the user interface section of the image.\r
+ //\r
+ Buffer = NULL;\r
+ Status = Fv->ReadSection(Fv, NameGuid, EFI_SECTION_USER_INTERFACE, 0, &Buffer, &BufferSize, &AuthenticationStatus);\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return NULL;\r
+ }\r
+\r
+ //\r
+ // ReadSection returns just the section data, without any section header. For\r
+ // a user interface section, the only data is the file name.\r
+ //\r
+ return Buffer;\r
+}\r
+\r
/**\r
Function to translate the EFI_MEMORY_TYPE into a string.\r
\r
IN EFI_SYSTEM_TABLE *SystemTable\r
)\r
{\r
- GuidListCount = 0;\r
- GuidList = NULL;\r
+ mGuidListCount = 0;\r
+ mGuidList = NULL;\r
\r
//\r
// Do nothing with mHandleParsingHiiHandle. Initialize HII as needed.\r
{\r
UINTN LoopCount;\r
\r
- for (LoopCount = 0; GuidList != NULL && LoopCount < GuidListCount; LoopCount++) {\r
- SHELL_FREE_NON_NULL(GuidList[LoopCount].GuidId);\r
+ for (LoopCount = 0; mGuidList != NULL && LoopCount < mGuidListCount; LoopCount++) {\r
+ SHELL_FREE_NON_NULL(mGuidList[LoopCount].GuidId);\r
}\r
\r
- SHELL_FREE_NON_NULL(GuidList);\r
+ SHELL_FREE_NON_NULL(mGuidList);\r
if (mHandleParsingHiiHandle != NULL) {\r
HiiRemovePackages(mHandleParsingHiiHandle);\r
}\r
EFI_STATUS Status;\r
CHAR16 *RetVal;\r
CHAR16 *Temp;\r
+ CHAR16 *FileName;\r
+ CHAR8 *PdbFileName;\r
+ CHAR16 *FilePath;\r
CHAR16 *CodeType;\r
CHAR16 *DataType;\r
\r
- if (!Verbose) {\r
- return (CatSPrint(NULL, L"LoadedImage"));\r
- }\r
-\r
- HandleParsingHiiInit();\r
-\r
- Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_LI_DUMP_MAIN), NULL);\r
- if (Temp == NULL) {\r
- return NULL;\r
- }\r
-\r
Status = gBS->OpenProtocol (\r
TheHandle,\r
&gEfiLoadedImageProtocolGuid,\r
);\r
\r
if (EFI_ERROR (Status)) {\r
- SHELL_FREE_NON_NULL (Temp);\r
return NULL;\r
}\r
\r
+ FileName = FindLoadedImageFileName(LoadedImage);\r
+ FilePath = ConvertDevicePathToText(LoadedImage->FilePath, TRUE, TRUE);\r
+ if (!Verbose) {\r
+ if (FileName == NULL) {\r
+ FileName = FilePath;\r
+ } else {\r
+ SHELL_FREE_NON_NULL(FilePath);\r
+ }\r
+ RetVal = CatSPrint(NULL, FileName);\r
+ SHELL_FREE_NON_NULL(FileName);\r
+ return RetVal;\r
+ }\r
+\r
+ HandleParsingHiiInit();\r
+ RetVal = NULL;\r
+ if (FileName != NULL) {\r
+ Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_LI_DUMP_NAME), NULL);\r
+\r
+ if (Temp != NULL) {\r
+ RetVal = CatSPrint(NULL, Temp, FileName);\r
+ }\r
+\r
+ SHELL_FREE_NON_NULL(Temp);\r
+ SHELL_FREE_NON_NULL(FileName);\r
+ }\r
+\r
+ Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_LI_DUMP_MAIN), NULL);\r
+ if (Temp == NULL) {\r
+ return NULL;\r
+ }\r
+ PdbFileName = PeCoffLoaderGetPdbPointer (LoadedImage->ImageBase);\r
DataType = ConvertMemoryType(LoadedImage->ImageDataType);\r
CodeType = ConvertMemoryType(LoadedImage->ImageCodeType);\r
\r
RetVal = CatSPrint(\r
- NULL,\r
+ RetVal,\r
Temp,\r
LoadedImage->Revision,\r
LoadedImage->ParentHandle,\r
LoadedImage->SystemTable,\r
LoadedImage->DeviceHandle,\r
- LoadedImage->FilePath,\r
+ FilePath,\r
+ PdbFileName,\r
LoadedImage->LoadOptionsSize,\r
LoadedImage->LoadOptions,\r
LoadedImage->ImageBase,\r
\r
\r
SHELL_FREE_NON_NULL(Temp);\r
+ SHELL_FREE_NON_NULL(FilePath);\r
SHELL_FREE_NON_NULL(CodeType);\r
SHELL_FREE_NON_NULL(DataType);\r
\r
return (Temp);\r
}\r
\r
+/**\r
+ Function to dump protocol information.\r
+\r
+ This will allocate the return buffer from boot services pool.\r
+\r
+ @param[in] TheHandle The handle that has the protocol installed.\r
+ @param[in] Verbose TRUE for additional information, FALSE otherwise.\r
+ @param[in] Protocol The protocol is needed to dump.\r
+\r
+ @retval A pointer to a string containing the information.\r
+**/\r
+STATIC CHAR16*\r
+EFIAPI\r
+DevicePathProtocolDumpInformationEx (\r
+ IN CONST EFI_HANDLE TheHandle,\r
+ IN CONST BOOLEAN Verbose,\r
+ IN EFI_GUID *Protocol\r
+)\r
+{\r
+ EFI_DEVICE_PATH_PROTOCOL *DevPath;\r
+ CHAR16 *DevPathStr;\r
+ CHAR16 *DevPathStrTemp;\r
+ UINTN Size;\r
+ EFI_STATUS Status;\r
+ DevPathStr = NULL;\r
+ DevPathStrTemp = NULL;\r
+ Status = gBS->OpenProtocol(TheHandle, Protocol, (VOID**)&DevPath, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);\r
+ if (!EFI_ERROR(Status)) {\r
+ DevPathStr = ConvertDevicePathToShortText (DevPath, Verbose, 30);\r
+ if (Verbose) {\r
+ Size = StrSize(DevPathStr) + sizeof(CHAR16) * 2;\r
+ DevPathStrTemp = AllocateZeroPool (Size);\r
+ if (DevPathStrTemp != NULL) {\r
+ StrnCatS (DevPathStrTemp, Size/sizeof(CHAR16), L" ", 2);\r
+ StrnCatS (DevPathStrTemp, Size/sizeof(CHAR16), DevPathStr, StrLen (DevPathStr));\r
+ }\r
+ FreePool (DevPathStr);\r
+ DevPathStr = DevPathStrTemp;\r
+ }\r
+ gBS->CloseProtocol(TheHandle, Protocol, gImageHandle, NULL);\r
+ }\r
+ return DevPathStr;\r
+}\r
+\r
/**\r
Function to dump information about DevicePath protocol.\r
\r
IN CONST BOOLEAN Verbose\r
)\r
{\r
- EFI_DEVICE_PATH_PROTOCOL *DevPath;\r
- CHAR16 *Temp;\r
- EFI_STATUS Status;\r
- Temp = NULL;\r
-\r
- Status = gBS->OpenProtocol(TheHandle, &gEfiDevicePathProtocolGuid, (VOID**)&DevPath, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);\r
- if (!EFI_ERROR(Status)) {\r
- Temp = ConvertDevicePathToShortText (DevPath, Verbose, 30);\r
- gBS->CloseProtocol(TheHandle, &gEfiDevicePathProtocolGuid, gImageHandle, NULL);\r
- }\r
- return (Temp);\r
+ return DevicePathProtocolDumpInformationEx (TheHandle, Verbose, &gEfiDevicePathProtocolGuid);\r
}\r
\r
/**\r
IN CONST BOOLEAN Verbose\r
)\r
{\r
- EFI_DEVICE_PATH_PROTOCOL *DevPath;\r
- CHAR16 *Temp;\r
- EFI_STATUS Status;\r
- Temp = NULL;\r
+ return DevicePathProtocolDumpInformationEx (TheHandle, Verbose, &gEfiLoadedImageDevicePathProtocolGuid);\r
+}\r
\r
- Status = gBS->OpenProtocol(TheHandle, &gEfiLoadedImageDevicePathProtocolGuid, (VOID**)&DevPath, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);\r
- if (!EFI_ERROR(Status)) {\r
- Temp = ConvertDevicePathToShortText (DevPath, Verbose, 30);\r
- gBS->CloseProtocol(TheHandle, &gEfiDevicePathProtocolGuid, gImageHandle, NULL);\r
+/**\r
+ Function to dump information about BusSpecificDriverOverride protocol.\r
+\r
+ This will allocate the return buffer from boot services pool.\r
+\r
+ @param[in] TheHandle The handle that has the protocol installed.\r
+ @param[in] Verbose TRUE for additional information, FALSE otherwise.\r
+\r
+ @retval A pointer to a string containing the information.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+BusSpecificDriverOverrideProtocolDumpInformation (\r
+ IN CONST EFI_HANDLE TheHandle,\r
+ IN CONST BOOLEAN Verbose\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ CHAR16 *GetString;\r
+ CHAR16 *RetVal;\r
+ CHAR16 *TempRetVal;\r
+ EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL *BusSpecificDriverOverride;\r
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;\r
+ EFI_HANDLE ImageHandle;\r
+ UINTN Size;\r
+\r
+ if (!Verbose) {\r
+ return NULL;\r
}\r
- return (Temp);\r
+ Size = 0;\r
+ GetString = NULL;\r
+ RetVal = NULL;\r
+ TempRetVal = NULL;\r
+ ImageHandle = 0;\r
+\r
+ Status = gBS->OpenProtocol (\r
+ TheHandle,\r
+ &gEfiBusSpecificDriverOverrideProtocolGuid,\r
+ (VOID**)&BusSpecificDriverOverride,\r
+ gImageHandle,\r
+ NULL,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return NULL;\r
+ }\r
+ HandleParsingHiiInit ();\r
+ GetString = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_BSDO_DUMP_MAIN), NULL);\r
+ if (GetString == NULL) {\r
+ return NULL;\r
+ }\r
+ do {\r
+ Status = BusSpecificDriverOverride->GetDriver (\r
+ BusSpecificDriverOverride,\r
+ &ImageHandle\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ Status = gBS->HandleProtocol (\r
+ ImageHandle,\r
+ &gEfiLoadedImageProtocolGuid,\r
+ (VOID **) &LoadedImage\r
+ );\r
+ if(!EFI_ERROR (Status)) {\r
+ TempRetVal = CatSPrint (\r
+ TempRetVal,\r
+ GetString,\r
+ ConvertHandleToHandleIndex (ImageHandle),\r
+ ConvertDevicePathToText (LoadedImage->FilePath, TRUE, TRUE)\r
+ );\r
+ StrnCatGrow (&RetVal, &Size, TempRetVal, 0);\r
+ SHELL_FREE_NON_NULL (TempRetVal);\r
+ }\r
+ }\r
+ } while (!EFI_ERROR (Status));\r
+\r
+ SHELL_FREE_NON_NULL (GetString);\r
+ return RetVal;\r
+}\r
+\r
+/**\r
+ Function to dump information about BlockIo protocol.\r
+\r
+ This will allocate the return buffer from boot services pool.\r
+\r
+ @param[in] TheHandle The handle that has the protocol installed.\r
+ @param[in] Verbose TRUE for additional information, FALSE otherwise.\r
+\r
+ @retval A pointer to a string containing the information.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+BlockIoProtocolDumpInformation (\r
+ IN CONST EFI_HANDLE TheHandle,\r
+ IN CONST BOOLEAN Verbose\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
+ EFI_BLOCK_IO_MEDIA *BlockMedia;\r
+ CHAR16 *GetString;\r
+ CHAR16 *RetVal;\r
+\r
+ if (!Verbose) {\r
+ return NULL;\r
+ }\r
+ GetString = NULL;\r
+ RetVal = NULL;\r
+\r
+ Status = gBS->OpenProtocol (\r
+ TheHandle,\r
+ &gEfiBlockIoProtocolGuid,\r
+ (VOID**)&BlockIo,\r
+ gImageHandle,\r
+ NULL,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return NULL;\r
+ }\r
+ BlockMedia = BlockIo->Media;\r
+ //\r
+ // Per spec:\r
+ // The function (ReadBlocks) must return EFI_NO_MEDIA or\r
+ // EFI_MEDIA_CHANGED even if LBA, BufferSize, or Buffer are invalid so the caller can probe\r
+ // for changes in media state.\r
+ //\r
+ BlockIo->ReadBlocks (\r
+ BlockIo,\r
+ BlockIo->Media->MediaId,\r
+ 0,\r
+ 0,\r
+ NULL\r
+ );\r
+\r
+ HandleParsingHiiInit ();\r
+ GetString = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_BLOCKIO_INFO), NULL);\r
+ if (GetString == NULL) {\r
+ return NULL;\r
+ }\r
+ RetVal = CatSPrint (\r
+ RetVal,\r
+ GetString,\r
+ BlockMedia->RemovableMedia ? L"Removable " : L"Fixed ",\r
+ BlockMedia->MediaPresent ? L"" : L"not-present ",\r
+ BlockMedia->MediaId,\r
+ BlockMedia->BlockSize,\r
+ BlockMedia->LastBlock,\r
+ MultU64x32 (BlockMedia->LastBlock + 1, BlockMedia->BlockSize),\r
+ BlockMedia->LogicalPartition ? L"partition" : L"raw",\r
+ BlockMedia->ReadOnly ? L"ro" : L"rw",\r
+ BlockMedia->WriteCaching ? L"cached" : L"!cached"\r
+ );\r
+\r
+ SHELL_FREE_NON_NULL (GetString);\r
+ return RetVal;\r
+}\r
+\r
+/**\r
+ Function to dump information about DebugSupport Protocol.\r
+\r
+ @param[in] TheHandle The handle that has the protocol installed.\r
+ @param[in] Verbose TRUE for additional information, FALSE otherwise.\r
+\r
+ @retval A pointer to a string containing the information.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+DebugSupportProtocolDumpInformation (\r
+ IN CONST EFI_HANDLE TheHandle,\r
+ IN CONST BOOLEAN Verbose\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_DEBUG_SUPPORT_PROTOCOL *DebugSupport;\r
+ CHAR16 *GetString;\r
+ CHAR16 *RetVal;\r
+\r
+ if (!Verbose) {\r
+ return NULL;\r
+ }\r
+ GetString = NULL;\r
+ RetVal = NULL;\r
+ Status = gBS->OpenProtocol (\r
+ TheHandle,\r
+ &gEfiDebugSupportProtocolGuid,\r
+ (VOID**)&DebugSupport,\r
+ gImageHandle,\r
+ NULL,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return NULL;\r
+ }\r
+ HandleParsingHiiInit ();\r
+ GetString = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_DEBUGSUPPORT_INFO), NULL);\r
+ if (GetString == NULL) {\r
+ return NULL;\r
+ }\r
+ //\r
+ // Dump Debug support info\r
+ //\r
+ switch (DebugSupport->Isa) {\r
+ case (IsaIa32):\r
+ RetVal = CatSPrint (RetVal, GetString, L"IA-32");\r
+ break;\r
+ case (IsaIpf):\r
+ RetVal = CatSPrint (RetVal, GetString, L"IPF");\r
+ break;\r
+ case (IsaEbc):\r
+ RetVal = CatSPrint (RetVal, GetString, L"EBC");\r
+ break;\r
+ default:\r
+ SHELL_FREE_NON_NULL (GetString);\r
+ GetString = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_DEBUGSUPPORT_UNKNOWN), NULL);\r
+ RetVal = GetString != NULL ? CatSPrint (RetVal, GetString, DebugSupport->Isa) : NULL;\r
+ break;\r
+ }\r
+\r
+ SHELL_FREE_NON_NULL (GetString);\r
+ return RetVal;\r
+}\r
+\r
+/**\r
+ Function to dump information about PciIoProtocol.\r
+\r
+ This will allocate the return buffer from boot services pool.\r
+\r
+ @param[in] TheHandle The handle that has PciRootBridgeIo installed.\r
+ @param[in] Verbose TRUE for additional information, FALSE otherwise.\r
+\r
+ @retval A poitner to a string containing the information.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+PciIoProtocolDumpInformation (\r
+ IN CONST EFI_HANDLE TheHandle,\r
+ IN CONST BOOLEAN Verbose\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_PCI_IO_PROTOCOL *PciIo;\r
+ PCI_TYPE00 Pci;\r
+ UINTN Segment;\r
+ UINTN Bus;\r
+ UINTN Device;\r
+ UINTN Function;\r
+ UINTN Index;\r
+ CHAR16 *GetString;\r
+ CHAR16 *TempRetVal;\r
+ CHAR16 *RetVal;\r
+\r
+ if (!Verbose) {\r
+ return (NULL);\r
+ }\r
+ RetVal = NULL;\r
+ GetString = NULL;\r
+ TempRetVal = NULL;\r
+ Status = gBS->OpenProtocol (\r
+ TheHandle,\r
+ &gEfiPciIoProtocolGuid,\r
+ (VOID**)&PciIo,\r
+ gImageHandle,\r
+ NULL,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+\r
+ if (EFI_ERROR(Status)) {\r
+ return NULL;\r
+ }\r
+ PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0, sizeof (Pci), &Pci);\r
+ PciIo->GetLocation (PciIo, &Segment, &Bus, &Device, &Function);\r
+ HandleParsingHiiInit ();\r
+ GetString = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_PCIIO_DUMP_MAIN), NULL);\r
+ if (GetString == NULL) {\r
+ return NULL;\r
+ }\r
+ RetVal = CatSPrint (\r
+ NULL,\r
+ GetString,\r
+ Segment,\r
+ Bus,\r
+ Device,\r
+ Function,\r
+ PciIo->RomSize,\r
+ PciIo->RomImage,\r
+ Pci.Hdr.VendorId,\r
+ Pci.Hdr.DeviceId,\r
+ Pci.Hdr.ClassCode[0],\r
+ Pci.Hdr.ClassCode[1],\r
+ Pci.Hdr.ClassCode[2]\r
+ );\r
+ for (Index = 0; Index < sizeof (Pci); Index ++) {\r
+ if ((Index % 0x10) == 0) {\r
+ TempRetVal = CatSPrint (RetVal, L"\r\n %02x", *((UINT8 *) (&Pci) + Index));\r
+ } else {\r
+ TempRetVal = CatSPrint (RetVal, L"%02x", *((UINT8 *) (&Pci) + Index));\r
+ }\r
+ FreePool (RetVal);\r
+ RetVal = TempRetVal;\r
+ TempRetVal = NULL;\r
+ }\r
+\r
+ FreePool(GetString);\r
+ return RetVal;\r
+}\r
+\r
+/**\r
+ Function to dump information about UsbIoProtocol.\r
+\r
+ This will allocate the return buffer from boot services pool.\r
+\r
+ @param[in] TheHandle The handle that has PciRootBridgeIo installed.\r
+ @param[in] Verbose TRUE for additional information, FALSE otherwise.\r
+\r
+ @retval A poitner to a string containing the information.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+UsbIoProtocolDumpInformation (\r
+ IN CONST EFI_HANDLE TheHandle,\r
+ IN CONST BOOLEAN Verbose\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_USB_IO_PROTOCOL *UsbIo;\r
+ EFI_USB_INTERFACE_DESCRIPTOR InterfaceDesc;\r
+ CHAR16 *GetString;\r
+ CHAR16 *RetVal;\r
+\r
+ if (!Verbose) {\r
+ return (NULL);\r
+ }\r
+ RetVal = NULL;\r
+ GetString = NULL;\r
+ Status = gBS->OpenProtocol (\r
+ TheHandle,\r
+ &gEfiUsbIoProtocolGuid,\r
+ (VOID**)&UsbIo,\r
+ gImageHandle,\r
+ NULL,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+\r
+ if (EFI_ERROR(Status)) {\r
+ return NULL;\r
+ }\r
+ UsbIo->UsbGetInterfaceDescriptor (UsbIo, &InterfaceDesc);\r
+ HandleParsingHiiInit ();\r
+ GetString = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_USBIO_DUMP_MAIN), NULL);\r
+ if (GetString == NULL) {\r
+ return NULL;\r
+ }\r
+ RetVal = CatSPrint (\r
+ NULL,\r
+ GetString,\r
+ InterfaceDesc.InterfaceNumber,\r
+ InterfaceDesc.InterfaceClass,\r
+ InterfaceDesc.InterfaceSubClass,\r
+ InterfaceDesc.InterfaceProtocol\r
+ );\r
+\r
+ FreePool (GetString);\r
+ return RetVal;\r
}\r
\r
/**\r
} else {\r
\r
GuidStr = GetStringNameFromGuid (&InfoTypesBuffer[GuidIndex], NULL);\r
+ if (GuidStr == NULL) {\r
+ TempRetVal = CatSPrint (RetVal, TempStr, L"UnknownInfoType");\r
+ SHELL_FREE_NON_NULL (RetVal);\r
+ RetVal = TempRetVal;\r
\r
- if (GuidStr != NULL) {\r
- if (StrCmp(GuidStr, L"UnknownDevice") == 0) {\r
- TempRetVal = CatSPrint (RetVal, TempStr, L"UnknownInfoType");\r
- SHELL_FREE_NON_NULL (RetVal);\r
- RetVal = TempRetVal;\r
-\r
- SHELL_FREE_NON_NULL (TempStr);\r
- SHELL_FREE_NON_NULL(GuidStr);\r
- //\r
- // So that we never have to pass this UnknownInfoType to the parsing function "GetInformation" service of AIP\r
- //\r
- continue;\r
- } else {\r
- TempRetVal = CatSPrint (RetVal, TempStr, GuidStr);\r
- SHELL_FREE_NON_NULL (RetVal);\r
- RetVal = TempRetVal;\r
- SHELL_FREE_NON_NULL(GuidStr);\r
- }\r
+ SHELL_FREE_NON_NULL (TempStr);\r
+ SHELL_FREE_NON_NULL(GuidStr);\r
+ //\r
+ // So that we never have to pass this UnknownInfoType to the parsing function "GetInformation" service of AIP\r
+ //\r
+ continue;\r
+ } else {\r
+ TempRetVal = CatSPrint (RetVal, TempStr, GuidStr);\r
+ SHELL_FREE_NON_NULL (RetVal);\r
+ RetVal = TempRetVal;\r
+ SHELL_FREE_NON_NULL(GuidStr);\r
}\r
}\r
\r
{STRING_TOKEN(STR_WINNT_THUNK), (EFI_GUID*)&WinNtThunkProtocolGuid, NULL},\r
{STRING_TOKEN(STR_WINNT_DRIVER_IO), (EFI_GUID*)&WinNtIoProtocolGuid, NULL},\r
{STRING_TOKEN(STR_WINNT_SERIAL_PORT), (EFI_GUID*)&WinNtSerialPortGuid, NULL},\r
- {STRING_TOKEN(STR_UNKNOWN_DEVICE), NULL, NULL},\r
+ {0, NULL, NULL},\r
};\r
\r
STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = {\r
{STRING_TOKEN(STR_DEVICE_PATH_VTUTF8), &gEfiVTUTF8Guid, NULL},\r
{STRING_TOKEN(STR_DRIVER_BINDING), &gEfiDriverBindingProtocolGuid, NULL},\r
{STRING_TOKEN(STR_PLATFORM_OVERRIDE), &gEfiPlatformDriverOverrideProtocolGuid, NULL},\r
- {STRING_TOKEN(STR_BUS_OVERRIDE), &gEfiBusSpecificDriverOverrideProtocolGuid, NULL},\r
+ {STRING_TOKEN(STR_BUS_OVERRIDE), &gEfiBusSpecificDriverOverrideProtocolGuid, BusSpecificDriverOverrideProtocolDumpInformation},\r
{STRING_TOKEN(STR_DRIVER_DIAG), &gEfiDriverDiagnosticsProtocolGuid, NULL},\r
{STRING_TOKEN(STR_DRIVER_DIAG2), &gEfiDriverDiagnostics2ProtocolGuid, NULL},\r
{STRING_TOKEN(STR_DRIVER_CN), &gEfiComponentNameProtocolGuid, NULL},\r
{STRING_TOKEN(STR_SIMPLE_FILE_SYS), &gEfiSimpleFileSystemProtocolGuid, NULL},\r
{STRING_TOKEN(STR_TAPE_IO), &gEfiTapeIoProtocolGuid, NULL},\r
{STRING_TOKEN(STR_DISK_IO), &gEfiDiskIoProtocolGuid, NULL},\r
- {STRING_TOKEN(STR_BLK_IO), &gEfiBlockIoProtocolGuid, NULL},\r
+ {STRING_TOKEN(STR_BLK_IO), &gEfiBlockIoProtocolGuid, BlockIoProtocolDumpInformation},\r
{STRING_TOKEN(STR_UC), &gEfiUnicodeCollationProtocolGuid, NULL},\r
{STRING_TOKEN(STR_UC2), &gEfiUnicodeCollation2ProtocolGuid, NULL},\r
{STRING_TOKEN(STR_PCIRB_IO), &gEfiPciRootBridgeIoProtocolGuid, PciRootBridgeIoDumpInformation},\r
- {STRING_TOKEN(STR_PCI_IO), &gEfiPciIoProtocolGuid, NULL},\r
+ {STRING_TOKEN(STR_PCI_IO), &gEfiPciIoProtocolGuid, PciIoProtocolDumpInformation},\r
{STRING_TOKEN(STR_SCSI_PT), &gEfiScsiPassThruProtocolGuid, NULL},\r
{STRING_TOKEN(STR_SCSI_IO), &gEfiScsiIoProtocolGuid, NULL},\r
{STRING_TOKEN(STR_SCSI_PT_EXT), &gEfiExtScsiPassThruProtocolGuid, NULL},\r
{STRING_TOKEN(STR_ISCSI), &gEfiIScsiInitiatorNameProtocolGuid, NULL},\r
- {STRING_TOKEN(STR_USB_IO), &gEfiUsbIoProtocolGuid, NULL},\r
+ {STRING_TOKEN(STR_USB_IO), &gEfiUsbIoProtocolGuid, UsbIoProtocolDumpInformation},\r
{STRING_TOKEN(STR_USB_HC), &gEfiUsbHcProtocolGuid, NULL},\r
{STRING_TOKEN(STR_USB_HC2), &gEfiUsb2HcProtocolGuid, NULL},\r
- {STRING_TOKEN(STR_DEBUG_SUPPORT), &gEfiDebugSupportProtocolGuid, NULL},\r
+ {STRING_TOKEN(STR_DEBUG_SUPPORT), &gEfiDebugSupportProtocolGuid, DebugSupportProtocolDumpInformation},\r
{STRING_TOKEN(STR_DEBUG_PORT), &gEfiDebugPortProtocolGuid, NULL},\r
{STRING_TOKEN(STR_DECOMPRESS), &gEfiDecompressProtocolGuid, NULL},\r
{STRING_TOKEN(STR_ACPI_TABLE), &gEfiAcpiTableProtocolGuid, NULL},\r
//\r
// terminator\r
//\r
- {STRING_TOKEN(STR_UNKNOWN_DEVICE), NULL, NULL},\r
+ {0, NULL, NULL},\r
};\r
\r
/**\r
\r
ASSERT(Guid != NULL);\r
\r
- for (LoopCount = 0, ListWalker = GuidList; GuidList != NULL && LoopCount < GuidListCount; LoopCount++, ListWalker++) {\r
+ for (LoopCount = 0, ListWalker = mGuidList; mGuidList != NULL && LoopCount < mGuidListCount; LoopCount++, ListWalker++) {\r
if (CompareGuid(ListWalker->GuidId, Guid)) {\r
return (ListWalker);\r
}\r
ASSERT(Guid != NULL);\r
ASSERT(NameID != 0);\r
\r
- GuidList = ReallocatePool(GuidListCount * sizeof(GUID_INFO_BLOCK), GuidListCount+1 * sizeof(GUID_INFO_BLOCK), GuidList);\r
- if (GuidList == NULL) {\r
- GuidListCount = 0;\r
+ mGuidList = ReallocatePool(mGuidListCount * sizeof(GUID_INFO_BLOCK), mGuidListCount+1 * sizeof(GUID_INFO_BLOCK), mGuidList);\r
+ if (mGuidList == NULL) {\r
+ mGuidListCount = 0;\r
return (EFI_OUT_OF_RESOURCES);\r
}\r
- GuidListCount++;\r
+ mGuidListCount++;\r
\r
- GuidList[GuidListCount - 1].GuidId = AllocateCopyPool(sizeof(EFI_GUID), Guid);\r
- GuidList[GuidListCount - 1].StringId = NameID;\r
- GuidList[GuidListCount - 1].DumpInfo = DumpFunc;\r
+ mGuidList[mGuidListCount - 1].GuidId = AllocateCopyPool(sizeof(EFI_GUID), Guid);\r
+ mGuidList[mGuidListCount - 1].StringId = NameID;\r
+ mGuidList[mGuidListCount - 1].DumpInfo = DumpFunc;\r
\r
- if (GuidList[GuidListCount - 1].GuidId == NULL) {\r
+ if (mGuidList[mGuidListCount - 1].GuidId == NULL) {\r
return (EFI_OUT_OF_RESOURCES);\r
}\r
\r
HandleParsingHiiInit();\r
\r
Id = InternalShellGetNodeFromGuid(Guid);\r
- return (HiiGetString(mHandleParsingHiiHandle, Id==NULL?STRING_TOKEN(STR_UNKNOWN_DEVICE):Id->StringId, Lang));\r
+ if (Id == NULL) {\r
+ return NULL;\r
+ }\r
+ return HiiGetString (mHandleParsingHiiHandle, Id->StringId, Lang);\r
}\r
\r
/**\r
}\r
}\r
\r
- for (LoopCount = 0, ListWalker = GuidList; GuidList != NULL && LoopCount < GuidListCount; LoopCount++, ListWalker++) {\r
+ for (LoopCount = 0, ListWalker = mGuidList; mGuidList != NULL && LoopCount < mGuidListCount; LoopCount++, ListWalker++) {\r
String = HiiGetString(mHandleParsingHiiHandle, ListWalker->StringId, Lang);\r
if (Name != NULL && String != NULL && StringNoCaseCompare (&Name, &String) == 0) {\r
*Guid = ListWalker->GuidId;\r
// Verify that LinkWalker->TheHandle is valid handle\r
//\r
Status = gBS->ProtocolsPerHandle(ListWalker->TheHandle, &ProtocolBuffer, &ProtocolCount);\r
- if (EFI_ERROR (Status)) {\r
+ if (!EFI_ERROR (Status)) {\r
+ FreePool (ProtocolBuffer);\r
+ } else {\r
//\r
// TheHandle is not valid, so do not add to handle list\r
//\r
\r
return (HandleList);\r
}\r
+\r
+/**\r
+ Return all supported GUIDs.\r
+\r
+ @param[out] Guids The buffer to return all supported GUIDs.\r
+ @param[in, out] Count On input, the count of GUIDs the buffer can hold,\r
+ On output, the count of GUIDs to return.\r
+\r
+ @retval EFI_INVALID_PARAMETER Count is NULL.\r
+ @retval EFI_BUFFER_TOO_SMALL Buffer is not enough to hold all GUIDs.\r
+ @retval EFI_SUCCESS GUIDs are returned successfully.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GetAllMappingGuids (\r
+ OUT EFI_GUID *Guids,\r
+ IN OUT UINTN *Count\r
+ )\r
+{\r
+ UINTN GuidCount;\r
+ UINTN NtGuidCount;\r
+ UINTN Index;\r
+\r
+ if (Count == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ NtGuidCount = 0;\r
+ if (PcdGetBool (PcdShellIncludeNtGuids)) {\r
+ NtGuidCount = ARRAY_SIZE (mGuidStringListNT) - 1;\r
+ }\r
+ GuidCount = ARRAY_SIZE (mGuidStringList) - 1;\r
+\r
+ if (*Count < NtGuidCount + GuidCount + mGuidListCount) {\r
+ *Count = NtGuidCount + GuidCount + mGuidListCount;\r
+ return EFI_BUFFER_TOO_SMALL;\r
+ }\r
+\r
+ for (Index = 0; Index < NtGuidCount; Index++) {\r
+ CopyGuid (&Guids[Index], mGuidStringListNT[Index].GuidId);\r
+ }\r
+\r
+ for (Index = 0; Index < GuidCount; Index++) {\r
+ CopyGuid (&Guids[NtGuidCount + Index], mGuidStringList[Index].GuidId);\r
+ }\r
+\r
+ for (Index = 0; Index < mGuidListCount; Index++) {\r
+ CopyGuid (&Guids[NtGuidCount + GuidCount + Index], mGuidList[Index].GuidId);\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r