]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
ShellPkg: Update Shell DH command to display more info.
[mirror_edk2.git] / ShellPkg / Library / UefiHandleParsingLib / UefiHandleParsingLib.c
index 4921f2816d0840c4e6c67cfc9fc3a6ecb1bba15f..9c6cf61af5ce917e64eaa7700edb9673e45465a9 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Provides interface to advanced shell functionality for parsing both handle and protocol database.\r
 \r
-  Copyright (c) 2013 - 2014, Hewlett-Packard Development Company, L.P.\r
+  Copyright (c) 2013 - 2014, Hewlett-Packard Development Company, L.P.<BR>\r
   Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -581,6 +581,167 @@ DevicePathProtocolDumpInformation(
   return (Temp);\r
 }\r
 \r
+/**\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
 //\r
 // Put the information on the NT32 protocol GUIDs here so we are not dependant on the Nt32Pkg\r
 //\r
@@ -713,6 +874,8 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = {
   {STRING_TOKEN(STR_GPT_NBR),               &gEfiPartTypeLegacyMbrGuid,                       NULL},\r
   {STRING_TOKEN(STR_DRIVER_CONFIG),         &gEfiDriverConfigurationProtocolGuid,             NULL},\r
   {STRING_TOKEN(STR_DRIVER_CONFIG2),        &gEfiDriverConfiguration2ProtocolGuid,            NULL},\r
+  {STRING_TOKEN(STR_ISA_IO),                &gEfiIsaIoProtocolGuid,                           NULL},\r
+  {STRING_TOKEN(STR_ISA_ACPI),              &gEfiIsaAcpiProtocolGuid,                         NULL},\r
 \r
 //\r
 // the ones under this are GUID identified structs, not protocols\r
@@ -770,7 +933,7 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = {
 // UEFI 2.4\r
 //\r
   {STRING_TOKEN(STR_DISK_IO2),              &gEfiDiskIo2ProtocolGuid,                         NULL},\r
-  {STRING_TOKEN(STR_ADAPTER_INFO),          &gEfiAdapterInformationProtocolGuid,              NULL},\r
+  {STRING_TOKEN(STR_ADAPTER_INFO),          &gEfiAdapterInformationProtocolGuid,              AdapterInformationDumpInformation},\r
 \r
 //\r
 // PI Spec ones\r