From 59febea1f5390c9cc2b3199f1a0be7c39f7bb203 Mon Sep 17 00:00:00 2001 From: Samer El-Haj-Mahmoud Date: Tue, 25 Nov 2014 22:41:30 +0000 Subject: [PATCH] ShellPkg: Update Shell DH command to display more info. Decode for gEfiAdapterInformationProtocolGuid and added GUIDs for gEfiIsaIoProtocolGuid and gEfiIsaAcpiProtocolGuid protocols. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Samer El-Haj-Mahmoud Reviewed-by: jaben carsey git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16445 6f19259b-4bc3-4df7-8a09-765794883524 --- .../UefiHandleParsingLib.c | 167 +++++++++++++++++- .../UefiHandleParsingLib.h | 4 +- .../UefiHandleParsingLib.inf | 9 +- .../UefiHandleParsingLib.uni | Bin 29662 -> 33030 bytes 4 files changed, 176 insertions(+), 4 deletions(-) diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c index 4921f2816d..9c6cf61af5 100644 --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c @@ -1,7 +1,7 @@ /** @file Provides interface to advanced shell functionality for parsing both handle and protocol database. - Copyright (c) 2013 - 2014, Hewlett-Packard Development Company, L.P. + Copyright (c) 2013 - 2014, Hewlett-Packard Development Company, L.P.
Copyright (c) 2010 - 2014, 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 @@ -581,6 +581,167 @@ DevicePathProtocolDumpInformation( return (Temp); } +/** + Function to dump information about EfiAdapterInformation Protocol. + + @param[in] TheHandle The handle that has the protocol installed. + @param[in] Verbose TRUE for additional information, FALSE otherwise. + + @retval A pointer to a string containing the information. +**/ +CHAR16* +EFIAPI +AdapterInformationDumpInformation ( + IN CONST EFI_HANDLE TheHandle, + IN CONST BOOLEAN Verbose + ) +{ + EFI_STATUS Status; + EFI_ADAPTER_INFORMATION_PROTOCOL *EfiAdptrInfoProtocol; + UINTN InfoTypesBufferCount; + UINTN GuidIndex; + EFI_GUID *InfoTypesBuffer; + CHAR16 *GuidStr; + CHAR16 *TempStr; + CHAR16 *RetVal; + VOID *InformationBlock; + UINTN InformationBlockSize; + + if (!Verbose) { + return (CatSPrint(NULL, L"AdapterInfo")); + } + + // + // Allocate print buffer to store data + // + RetVal = AllocateZeroPool (PcdGet16(PcdShellPrintBufferSize)); + if (RetVal == NULL) { + return NULL; + } + + Status = gBS->OpenProtocol ( + (EFI_HANDLE) (TheHandle), + &gEfiAdapterInformationProtocolGuid, + (VOID **) &EfiAdptrInfoProtocol, + NULL, + NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); + + if (EFI_ERROR (Status)) { + SHELL_FREE_NON_NULL (RetVal); + return NULL; + } + + // + // Get a list of supported information types for this instance of the protocol. + // + Status = EfiAdptrInfoProtocol->GetSupportedTypes ( + EfiAdptrInfoProtocol, + &InfoTypesBuffer, + &InfoTypesBufferCount + ); + if (EFI_ERROR (Status)) { + TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GET_SUPP_TYPES_FAILED), NULL); + RetVal = CatSPrint (RetVal, TempStr, Status); + } else { + TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_SUPP_TYPE_HEADER), NULL); + RetVal = CatSPrint (RetVal, TempStr); + SHELL_FREE_NON_NULL (TempStr); + + for (GuidIndex = 0; GuidIndex < InfoTypesBufferCount; GuidIndex++) { + TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GUID_NUMBER), NULL); + RetVal = CatSPrint (RetVal, TempStr, (GuidIndex + 1), InfoTypesBuffer[GuidIndex]); + SHELL_FREE_NON_NULL (TempStr); + + TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GUID_STRING), NULL); + + if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoMediaStateGuid)) { + RetVal = CatSPrint (RetVal, TempStr, L"gEfiAdapterInfoMediaStateGuid"); + } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoNetworkBootGuid)) { + RetVal = CatSPrint (RetVal, TempStr, L"gEfiAdapterInfoNetworkBootGuid"); + } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoSanMacAddressGuid)) { + RetVal = CatSPrint (RetVal, TempStr, L"gEfiAdapterInfoSanMacAddressGuid"); + } else { + + GuidStr = GetStringNameFromGuid (&InfoTypesBuffer[GuidIndex], NULL); + + if (GuidStr != NULL) { + if (StrCmp(GuidStr, L"UnknownDevice") == 0) { + RetVal = CatSPrint (RetVal, TempStr, L"UnknownInfoType"); + + SHELL_FREE_NON_NULL (TempStr); + SHELL_FREE_NON_NULL(GuidStr); + // + // So that we never have to pass this UnknownInfoType to the parsing function "GetInformation" service of AIP + // + continue; + } else { + RetVal = CatSPrint (RetVal, TempStr, GuidStr); + SHELL_FREE_NON_NULL(GuidStr); + } + } + } + + SHELL_FREE_NON_NULL (TempStr); + + Status = EfiAdptrInfoProtocol->GetInformation ( + EfiAdptrInfoProtocol, + &InfoTypesBuffer[GuidIndex], + &InformationBlock, + &InformationBlockSize + ); + + if (EFI_ERROR (Status)) { + TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GETINFO_FAILED), NULL); + RetVal = CatSPrint (RetVal, TempStr, Status); + } else { + if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoMediaStateGuid)) { + TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_MEDIA_STATE), NULL); + RetVal = CatSPrint ( + RetVal, + TempStr, + ((EFI_ADAPTER_INFO_MEDIA_STATE *)InformationBlock)->MediaState, + ((EFI_ADAPTER_INFO_MEDIA_STATE *)InformationBlock)->MediaState + ); + } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoNetworkBootGuid)) { + TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_NETWORK_BOOT_INFO), NULL); + RetVal = CatSPrint ( + RetVal, + TempStr, + ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv4BootCapablity, + ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv6BootCapablity, + ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->FCoeBootCapablity, + ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->OffloadCapability, + ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiMpioCapability, + ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv4Boot, + ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv6Boot, + ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->FCoeBoot + ); + } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoSanMacAddressGuid) == TRUE) { + TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_SAN_MAC_ADDRESS_INFO), NULL); + RetVal = CatSPrint ( + RetVal, + TempStr, + ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[0], + ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[1], + ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[2], + ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[3], + ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[4], + ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[5] + ); + } else { + TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_UNKNOWN_INFO_TYPE), NULL); + RetVal = CatSPrint (RetVal, TempStr, &InfoTypesBuffer[GuidIndex]); + } + } + SHELL_FREE_NON_NULL (TempStr); + SHELL_FREE_NON_NULL (InformationBlock); + } + } + + return RetVal; +} // // Put the information on the NT32 protocol GUIDs here so we are not dependant on the Nt32Pkg // @@ -713,6 +874,8 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = { {STRING_TOKEN(STR_GPT_NBR), &gEfiPartTypeLegacyMbrGuid, NULL}, {STRING_TOKEN(STR_DRIVER_CONFIG), &gEfiDriverConfigurationProtocolGuid, NULL}, {STRING_TOKEN(STR_DRIVER_CONFIG2), &gEfiDriverConfiguration2ProtocolGuid, NULL}, + {STRING_TOKEN(STR_ISA_IO), &gEfiIsaIoProtocolGuid, NULL}, + {STRING_TOKEN(STR_ISA_ACPI), &gEfiIsaAcpiProtocolGuid, NULL}, // // the ones under this are GUID identified structs, not protocols @@ -770,7 +933,7 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = { // UEFI 2.4 // {STRING_TOKEN(STR_DISK_IO2), &gEfiDiskIo2ProtocolGuid, NULL}, - {STRING_TOKEN(STR_ADAPTER_INFO), &gEfiAdapterInformationProtocolGuid, NULL}, + {STRING_TOKEN(STR_ADAPTER_INFO), &gEfiAdapterInformationProtocolGuid, AdapterInformationDumpInformation}, // // PI Spec ones diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h index c1735a64ae..ba6e152d3b 100644 --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h @@ -1,7 +1,7 @@ /** @file Provides interface to advanced shell functionality for parsing both handle and protocol database. - Copyright (c) 2013 - 2014, Hewlett-Packard Development Company, L.P. + Copyright (c) 2013 - 2014, Hewlett-Packard Development Company, L.P.
Copyright (c) 2011 - 2014, 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 @@ -135,6 +135,8 @@ #include #include #include +#include +#include #include #include diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf index 6c30552503..dc97876667 100644 --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf @@ -1,6 +1,6 @@ ## @file # Provides interface to advanced shell functionality for parsing both handle and protocol database. -# Copyright (c) 2013 - 2014, Hewlett-Packard Development Company, L.P. +# Copyright (c) 2013 - 2014, Hewlett-Packard Development Company, L.P.
# Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
# # This program and the accompanying materials @@ -36,6 +36,7 @@ MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec ShellPkg/ShellPkg.dec + IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec [LibraryClasses] UefiBootServicesTableLib @@ -172,6 +173,9 @@ gEfiIdeControllerInitProtocolGuid ##UNDEFINED gEfiDiskIo2ProtocolGuid ##UNDEFINED gEfiAdapterInformationProtocolGuid ##UNDEFINED + gEfiIsaIoProtocolGuid ##UNDEFINED + gEfiIsaAcpiProtocolGuid ##UNDEFINED + gEfiShellDynamicCommandProtocolGuid ##UNDEFINED [Guids] gEfiFileInfoGuid ##CONSUMES @@ -188,6 +192,9 @@ gEfiPartTypeSystemPartGuid ##UNDEFINED gEfiPartTypeLegacyMbrGuid ##UNDEFINED gHandleParsingHiiGuid ##UNDEFINED + gEfiAdapterInfoMediaStateGuid ##SOMETIMES CONSUMES + gEfiAdapterInfoNetworkBootGuid ##SOMETIMES CONSUMES + gEfiAdapterInfoSanMacAddressGuid ##SOMETIMES CONSUMES [Pcd.common] gEfiShellPkgTokenSpaceGuid.PcdShellPrintBufferSize ##CONSUMES diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni index 36acfb10b215ead20b26216c051c82aabb437318..364fd9c4835b4f2a9f37272c14b20f9d507679d4 100644 GIT binary patch delta 1370 zcmbVMT~8B16g?^tK^v-sER7HrOj9v2Aq0IuquGAYHrlOrOH?RsO1Iz|+-+zz*7%|i zKCAN!c+hA00|xyeBs}@3{sYf!yKZX>Q8SsHncchRo_p@Sv;Xbbo7czRejL1xI10G2 z`(daq?yro`rjbGsCJZd&4u{Fp1Fk8)F|h;QqPf_D=vCVT8mS@rAn<~GlxXc;l$Z&3pFO{+PYvWVBZcQ4b=r+k`LA;u{DZZA@ zogkbz*ous(q~}8}LKQztv9UC%XK8Oj=Pt(p<)3#GS@C)0)P*!@*(9_2+qvcKbgYpO zF%T6yv(uviia{R*BI;sCkBG1`e>xx^7vJ3oiJx!jMk8vJ|3j&ACLx@MXS8KFI7}^@ z-!?q0p3tU2iZ0&-jyhEu&B+9ikw!<7ora>=J*kLVW*P@3%EtFICpu1y^Ey9Oyx0y4U4(;;cGU5>ZlMh%ltjV0xeyR1`>p?ampI7 zd2ae5wlixnv&}A?3Xy!AtN)3!M87VBJc@-%CavKmwJ)DMHQyj}ml0SUvDh8a_$ck- z=!+xuX~mVJ8Zvi*F1=WX@=*euE}eyDDxtsstF7wMe}%dM3j__2DaYEVRnHf2hoQBI4EFI&Cd>Z-PIbC}0-Hh&cVwv$(d z-s*5sTnvu{t>#@&Uj2WHT$J_yvWQ3YtRlv8?blZRoe`r==QXrRAD$ORAY+NKpjDQ( d#FDX8m{^AwoWm5q;Mqcn?@K(-AcSFW{sIhF5Ox3n delta 61 acmZo`V!HR7al*2V>o|%Hcp11DNWlPWVh1Gv