+/**\r
+ Function to dump information about EfiAdapterInformation 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
+AdapterInformationDumpInformation (\r
+ IN CONST EFI_HANDLE TheHandle,\r
+ IN CONST BOOLEAN Verbose\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_ADAPTER_INFORMATION_PROTOCOL *EfiAdptrInfoProtocol;\r
+ UINTN InfoTypesBufferCount;\r
+ UINTN GuidIndex;\r
+ EFI_GUID *InfoTypesBuffer;\r
+ CHAR16 *GuidStr;\r
+ CHAR16 *TempStr;\r
+ CHAR16 *RetVal;\r
+ VOID *InformationBlock;\r
+ UINTN InformationBlockSize;\r
+ \r
+ if (!Verbose) {\r
+ return (CatSPrint(NULL, L"AdapterInfo"));\r
+ }\r
+\r
+ //\r
+ // Allocate print buffer to store data\r
+ //\r
+ RetVal = AllocateZeroPool (PcdGet16(PcdShellPrintBufferSize));\r
+ if (RetVal == NULL) {\r
+ return NULL;\r
+ }\r
+\r
+ Status = gBS->OpenProtocol (\r
+ (EFI_HANDLE) (TheHandle),\r
+ &gEfiAdapterInformationProtocolGuid,\r
+ (VOID **) &EfiAdptrInfoProtocol,\r
+ NULL,\r
+ NULL,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ SHELL_FREE_NON_NULL (RetVal);\r
+ return NULL;\r
+ }\r
+\r
+ //\r
+ // Get a list of supported information types for this instance of the protocol.\r
+ //\r
+ Status = EfiAdptrInfoProtocol->GetSupportedTypes (\r
+ EfiAdptrInfoProtocol,\r
+ &InfoTypesBuffer, \r
+ &InfoTypesBufferCount\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GET_SUPP_TYPES_FAILED), NULL);\r
+ RetVal = CatSPrint (RetVal, TempStr, Status);\r
+ } else {\r
+ TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_SUPP_TYPE_HEADER), NULL);\r
+ RetVal = CatSPrint (RetVal, TempStr);\r
+ SHELL_FREE_NON_NULL (TempStr);\r
+\r
+ for (GuidIndex = 0; GuidIndex < InfoTypesBufferCount; GuidIndex++) {\r
+ TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GUID_NUMBER), NULL);\r
+ RetVal = CatSPrint (RetVal, TempStr, (GuidIndex + 1), InfoTypesBuffer[GuidIndex]);\r
+ SHELL_FREE_NON_NULL (TempStr);\r
+\r
+ TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GUID_STRING), NULL);\r
+\r
+ if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoMediaStateGuid)) {\r
+ RetVal = CatSPrint (RetVal, TempStr, L"gEfiAdapterInfoMediaStateGuid");\r
+ } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoNetworkBootGuid)) {\r
+ RetVal = CatSPrint (RetVal, TempStr, L"gEfiAdapterInfoNetworkBootGuid");\r
+ } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoSanMacAddressGuid)) {\r
+ RetVal = CatSPrint (RetVal, TempStr, L"gEfiAdapterInfoSanMacAddressGuid");\r
+ } else {\r
+\r
+ GuidStr = GetStringNameFromGuid (&InfoTypesBuffer[GuidIndex], NULL);\r
+ \r
+ if (GuidStr != NULL) {\r
+ if (StrCmp(GuidStr, L"UnknownDevice") == 0) {\r
+ RetVal = CatSPrint (RetVal, TempStr, L"UnknownInfoType");\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
+ RetVal = CatSPrint (RetVal, TempStr, GuidStr);\r
+ SHELL_FREE_NON_NULL(GuidStr);\r
+ }\r
+ }\r
+ }\r
+ \r
+ SHELL_FREE_NON_NULL (TempStr);\r
+\r
+ Status = EfiAdptrInfoProtocol->GetInformation (\r
+ EfiAdptrInfoProtocol,\r
+ &InfoTypesBuffer[GuidIndex],\r
+ &InformationBlock,\r
+ &InformationBlockSize\r
+ );\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_GETINFO_FAILED), NULL);\r
+ RetVal = CatSPrint (RetVal, TempStr, Status);\r
+ } else {\r
+ if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoMediaStateGuid)) {\r
+ TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_MEDIA_STATE), NULL);\r
+ RetVal = CatSPrint (\r
+ RetVal,\r
+ TempStr,\r
+ ((EFI_ADAPTER_INFO_MEDIA_STATE *)InformationBlock)->MediaState,\r
+ ((EFI_ADAPTER_INFO_MEDIA_STATE *)InformationBlock)->MediaState\r
+ );\r
+ } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoNetworkBootGuid)) {\r
+ TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_NETWORK_BOOT_INFO), NULL);\r
+ RetVal = CatSPrint (\r
+ RetVal,\r
+ TempStr,\r
+ ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv4BootCapablity,\r
+ ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv6BootCapablity, \r
+ ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->FCoeBootCapablity, \r
+ ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->OffloadCapability, \r
+ ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiMpioCapability, \r
+ ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv4Boot, \r
+ ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->iScsiIpv6Boot,\r
+ ((EFI_ADAPTER_INFO_NETWORK_BOOT *)InformationBlock)->FCoeBoot\r
+ );\r
+ } else if (CompareGuid (&InfoTypesBuffer[GuidIndex], &gEfiAdapterInfoSanMacAddressGuid) == TRUE) { \r
+ TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_SAN_MAC_ADDRESS_INFO), NULL);\r
+ RetVal = CatSPrint (\r
+ RetVal,\r
+ TempStr,\r
+ ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[0], \r
+ ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[1], \r
+ ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[2],\r
+ ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[3], \r
+ ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[4], \r
+ ((EFI_ADAPTER_INFO_SAN_MAC_ADDRESS *)InformationBlock)->SanMacAddress.Addr[5]\r
+ ); \r
+ } else {\r
+ TempStr = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_UNKNOWN_INFO_TYPE), NULL);\r
+ RetVal = CatSPrint (RetVal, TempStr, &InfoTypesBuffer[GuidIndex]);\r
+ }\r
+ }\r
+ SHELL_FREE_NON_NULL (TempStr);\r
+ SHELL_FREE_NON_NULL (InformationBlock);\r
+ }\r
+ }\r
+\r
+ return RetVal;\r
+}\r