]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Enahance 'dh' command to add more protocols decoding support
authorTapan Shah <tapandshah@hpe.com>
Fri, 22 Apr 2016 16:32:26 +0000 (09:32 -0700)
committerJaben Carsey <jaben.carsey@intel.com>
Mon, 25 Apr 2016 16:08:06 +0000 (09:08 -0700)
Adding EdidDiscovered, EdidActive protocol decode support a in 'dh' command.
Extending GraphicsOutput protocol decoding to list all supported GOP resolutions.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Tapan Shah <tapandshah@hpe.com>
Reviewed-by: Samer El-Haj-Mahmoud <elhaj@hpe.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
ShellPkg/Include/Library/ShellCommandLib.h
ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h
ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni
ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.h

index 0dd66c2fbc3a725787f11a27c59d5b18521a48a5..e3bb6e016475e84bc92effc8e2905dc806c2d80e 100644 (file)
@@ -4,8 +4,9 @@
   This library is for use ONLY by shell commands linked into the shell application.\r
   This library will not funciton if it is used for UEFI Shell 2.0 Applications.\r
 \r
-  (C) Copyright 2013-2014 Hewlett-Packard Development Company, L.P.<BR>\r
   Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
+  (C) Copyright 2013-2014 Hewlett-Packard Development Company, L.P.<BR>
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -701,4 +702,21 @@ DumpHex (
   IN VOID         *UserData\r
   );\r
 \r
+/**
+  Dump HEX data into buffer.
+   
+  @param[in] Buffer     HEX data to be dumped in Buffer.
+  @param[in] Indent     How many spaces to indent the output.
+  @param[in] Offset     The offset of the printing.
+  @param[in] DataSize   The size in bytes of UserData.
+  @param[in] UserData   The data to print out.
+**/
+CHAR16*
+CatSDumpHex (
+  IN CHAR16  *Buffer,
+  IN UINTN   Indent,
+  IN UINTN   Offset,
+  IN UINTN   DataSize,
+  IN VOID    *UserData
+  );
 #endif //_SHELL_COMMAND_LIB_\r
index 14e7a9fa45ed6ea619060eca3be6444663cb8d71..efafe6f5350dd61759c3677dff9c0a9056e23b6f 100644 (file)
@@ -244,11 +244,15 @@ GraphicsOutputProtocolDumpInformation(
   IN CONST BOOLEAN    Verbose\r
   )\r
 {\r
-  EFI_GRAPHICS_OUTPUT_PROTOCOL      *GraphicsOutput;\r
-  EFI_STATUS                        Status;\r
-  CHAR16                            *RetVal;\r
-  CHAR16                            *Temp;\r
-  CHAR16                            *Fmt;\r
+  EFI_GRAPHICS_OUTPUT_PROTOCOL          *GraphicsOutput;
+  EFI_STATUS                            Status;
+  CHAR16                                *RetVal;
+  CHAR16                                *Temp;
+  CHAR16                                *Fmt;
+  CHAR16                                *TempRetVal;
+  UINTN                                 GopInfoSize;
+  UINT32                                Mode;
+  EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  *GopInfo;
 \r
   if (!Verbose) {\r
     return (CatSPrint(NULL, L"GraphicsOutput"));\r
@@ -295,6 +299,41 @@ GraphicsOutputProtocolDumpInformation(
              GraphicsOutput->Mode->Info->PixelFormat!=PixelBitMask?0:GraphicsOutput->Mode->Info->PixelInformation.BlueMask\r
              );\r
 \r
+  SHELL_FREE_NON_NULL (Temp);
+  
+  Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN (STR_GOP_RES_LIST_MAIN), NULL);
+
+  TempRetVal = CatSPrint (RetVal, Temp);
+  SHELL_FREE_NON_NULL (RetVal);
+  RetVal = TempRetVal;
+  SHELL_FREE_NON_NULL (Temp);
+
+  Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN (STR_GOP_RES_LIST_ENTRY), NULL);
+
+  for (Mode = 0; Mode < GraphicsOutput->Mode->MaxMode; Mode++) {
+    Status = GraphicsOutput->QueryMode (
+                               GraphicsOutput,
+                               Mode,
+                               &GopInfoSize,
+                               &GopInfo
+                               );
+    if (EFI_ERROR (Status)) {
+      continue;
+    }
+
+    TempRetVal = CatSPrint (
+                   RetVal,
+                   Temp,
+                   Mode,
+                   GopInfo->HorizontalResolution,
+                   GopInfo->VerticalResolution
+                   );
+
+    SHELL_FREE_NON_NULL (GopInfo);
+    SHELL_FREE_NON_NULL (RetVal);
+    RetVal = TempRetVal;
+  }
+
   SHELL_FREE_NON_NULL(Temp);\r
   SHELL_FREE_NON_NULL(Fmt);\r
 \r
@@ -302,6 +341,134 @@ GraphicsOutputProtocolDumpInformation(
 }\r
 \r
 /**\r
+  Function to dump information about EDID Discovered Protocol.
+
+  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*
+EFIAPI
+EdidDiscoveredProtocolDumpInformation (
+  IN CONST EFI_HANDLE TheHandle,
+  IN CONST BOOLEAN    Verbose
+  )
+{
+  EFI_EDID_DISCOVERED_PROTOCOL          *EdidDiscovered;
+  EFI_STATUS                            Status;
+  CHAR16                                *RetVal;
+  CHAR16                                *Temp;
+  CHAR16                                *TempRetVal;
+
+  if (!Verbose) {
+    return (CatSPrint(NULL, L"EDIDDiscovered"));
+  }
+
+  Status = gBS->OpenProtocol (
+                  TheHandle,
+                  &gEfiEdidDiscoveredProtocolGuid,
+                  (VOID**)&EdidDiscovered,
+                  NULL,
+                  NULL,
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL
+                  );
+
+  if (EFI_ERROR (Status)) {
+    return NULL;
+  }
+
+  Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_EDID_DISCOVERED_MAIN), NULL);
+  if (Temp == NULL) {
+    return NULL;
+  }
+
+  RetVal = CatSPrint (NULL, Temp, EdidDiscovered->SizeOfEdid);
+  SHELL_FREE_NON_NULL (Temp);
+
+  if(EdidDiscovered->SizeOfEdid != 0) {
+    Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_EDID_DISCOVERED_DATA), NULL);
+    if (Temp == NULL) {
+      SHELL_FREE_NON_NULL (RetVal);
+      return NULL;
+    }
+    TempRetVal = CatSPrint (RetVal, Temp);
+    SHELL_FREE_NON_NULL (RetVal);
+    RetVal = TempRetVal;
+
+    TempRetVal = CatSDumpHex (RetVal, 7, 0, EdidDiscovered->SizeOfEdid, EdidDiscovered->Edid);
+    RetVal = TempRetVal;
+  }
+  return RetVal;
+}
+
+/**
+  Function to dump information about EDID Active Protocol.
+
+  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*
+EFIAPI
+EdidActiveProtocolDumpInformation (
+  IN CONST EFI_HANDLE TheHandle,
+  IN CONST BOOLEAN    Verbose
+  )
+{
+  EFI_EDID_ACTIVE_PROTOCOL  *EdidActive;
+  EFI_STATUS                Status;
+  CHAR16                    *RetVal;
+  CHAR16                    *Temp;
+  CHAR16                    *TempRetVal;
+
+  if (!Verbose) {
+    return (CatSPrint(NULL, L"EDIDActive"));
+  }
+
+  Status = gBS->OpenProtocol (
+                  TheHandle,
+                  &gEfiEdidActiveProtocolGuid,
+                  (VOID**)&EdidActive,
+                  NULL,
+                  NULL,
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL
+                  );
+
+  if (EFI_ERROR (Status)) {
+    return NULL;
+  }
+
+  Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_EDID_ACTIVE_MAIN), NULL);
+  if (Temp == NULL) {
+    return NULL;
+  }
+
+  RetVal = CatSPrint (NULL, Temp, EdidActive->SizeOfEdid);
+  SHELL_FREE_NON_NULL (Temp);
+
+  if(EdidActive->SizeOfEdid != 0) {
+    Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN(STR_EDID_ACTIVE_DATA), NULL);
+    if (Temp == NULL) {
+      SHELL_FREE_NON_NULL (RetVal);
+      return NULL;
+    }
+    TempRetVal = CatSPrint (RetVal, Temp);
+    SHELL_FREE_NON_NULL (RetVal);
+    RetVal = TempRetVal;
+
+    TempRetVal = CatSDumpHex (RetVal, 7, 0, EdidActive->SizeOfEdid, EdidActive->Edid);
+    RetVal = TempRetVal;
+  }
+  return RetVal;
+}
+
+/**
   Function to dump information about PciRootBridgeIo.\r
 \r
   This will allocate the return buffer from boot services pool.\r
@@ -1294,8 +1461,8 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = {
   {STRING_TOKEN(STR_ABS_POINTER),           &gEfiAbsolutePointerProtocolGuid,                 NULL},\r
   {STRING_TOKEN(STR_SERIAL_IO),             &gEfiSerialIoProtocolGuid,                        NULL},\r
   {STRING_TOKEN(STR_GRAPHICS_OUTPUT),       &gEfiGraphicsOutputProtocolGuid,                  GraphicsOutputProtocolDumpInformation},\r
-  {STRING_TOKEN(STR_EDID_DISCOVERED),       &gEfiEdidDiscoveredProtocolGuid,                  NULL},\r
-  {STRING_TOKEN(STR_EDID_ACTIVE),           &gEfiEdidActiveProtocolGuid,                      NULL},\r
+  {STRING_TOKEN(STR_EDID_DISCOVERED),       &gEfiEdidDiscoveredProtocolGuid,                  EdidDiscoveredProtocolDumpInformation},
+  {STRING_TOKEN(STR_EDID_ACTIVE),           &gEfiEdidActiveProtocolGuid,                      EdidActiveProtocolDumpInformation},
   {STRING_TOKEN(STR_EDID_OVERRIDE),         &gEfiEdidOverrideProtocolGuid,                    NULL},\r
   {STRING_TOKEN(STR_CON_IN),                &gEfiConsoleInDeviceGuid,                         NULL},\r
   {STRING_TOKEN(STR_CON_OUT),               &gEfiConsoleOutDeviceGuid,                        NULL},\r
index 6f2ca50922a02fd05e4c248f7fac366ba4e7085b..f53cfb91081accda0985b8f8e4b7030dfee4035c 100644 (file)
@@ -1,8 +1,9 @@
 /** @file\r
   Provides interface to advanced shell functionality for parsing both handle and protocol database.\r
 \r
-  (C) Copyright 2013-2016 Hewlett-Packard Development Company, L.P.<BR>\r
   Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>\r
+  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
+  (C) Copyright 2013-2016 Hewlett-Packard Development Company, L.P.<BR>
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
 #include <Library/HiiLib.h>\r
 #include <Library/ShellLib.h>\r
 #include <Library/SortLib.h>\r
+#include <Library/ShellCommandLib.h>
 \r
 #define   EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V1   1\r
 #define   EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION_V2   2\r
index 0cb2fa874651902f9aa355544c624a7f97b2e0f8..c5ea60d6562fbd2e5b3b358264c7f3b8b12ac1f5 100644 (file)
                                                   "         GreenMask.......: %%H0x%08x%%N\r\n"\r
                                                   "         BlueMask........: %%H0x%08x%%N\r\n"\r
 \r
+#string STR_GOP_RES_LIST_MAIN     #language en-US "     Supported Resolution List\r\n"
+#string STR_GOP_RES_LIST_ENTRY    #language en-US "       Resolution[%%H%d%%N]:\r\n"
+                                                  "         Res Hor.........: %%H0x%08x%%N\r\n"
+                                                  "         Res Ver.........: %%H0x%08x%%N\r\n"
+
+#string STR_EDID_DISCOVERED_MAIN  #language en-US "     EDID Discovered Size : %%H0x%08x%%N\r\n"
+#string STR_EDID_DISCOVERED_DATA  #language en-US "     EDID Discovered Data :\r\n"
+#string STR_EDID_ACTIVE_MAIN      #language en-US "     EDID Active Size : %%H0x%08x%%N\r\n"
+#string STR_EDID_ACTIVE_DATA      #language en-US "     EDID Active Data :\r\n"
 \r
 #string STR_GET_SUPP_TYPES_FAILED         #language en-US "Unable to get supported types - %%H%r%%N\r\n"\r
 #string STR_SUPP_TYPE_HEADER              #language en-US "  Supported Information Types: \r\n"\r
index 92a88d18a065b95b98631e91061418792fe13c0c..48e4d4af0dca77301b278888918be9ed622482bc 100644 (file)
@@ -1,8 +1,10 @@
 /** @file\r
   Provides interface to shell internal functions for shell commands.\r
 \r
-  (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>\r
   Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
+  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
+
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -1742,3 +1744,60 @@ DumpHex (
     DataSize -= Size;\r
   }\r
 }\r
+
+/**
+  Dump HEX data into buffer.
+   
+  @param[in] Buffer     HEX data to be dumped in Buffer.
+  @param[in] Indent     How many spaces to indent the output.
+  @param[in] Offset     The offset of the printing.
+  @param[in] DataSize   The size in bytes of UserData.
+  @param[in] UserData   The data to print out.
+**/
+CHAR16*
+CatSDumpHex (
+  IN CHAR16  *Buffer,
+  IN UINTN   Indent,
+  IN UINTN   Offset,
+  IN UINTN   DataSize,
+  IN VOID    *UserData
+  )
+{
+  UINT8   *Data;
+  UINT8   TempByte;
+  UINTN   Size;
+  UINTN   Index;
+  CHAR8   Val[50];
+  CHAR8   Str[20];
+  CHAR16  *RetVal;
+  CHAR16  *TempRetVal;
+
+  Data = UserData;
+  RetVal = Buffer;
+  while (DataSize != 0) {
+    Size = 16;
+    if (Size > DataSize) {
+      Size = DataSize;
+    }
+
+    for (Index = 0; Index < Size; Index += 1) {
+      TempByte            = Data[Index];
+      Val[Index * 3 + 0]  = Hex[TempByte >> 4];
+      Val[Index * 3 + 1]  = Hex[TempByte & 0xF];
+      Val[Index * 3 + 2]  = (CHAR8) ((Index == 7) ? '-' : ' ');
+      Str[Index]          = (CHAR8) ((TempByte < ' ' || TempByte > 'z') ? '.' : TempByte);
+    }
+
+    Val[Index * 3]  = 0;
+    Str[Index]      = 0;
+    TempRetVal = CatSPrint (RetVal, L"%*a%08X: %-48a *%a*\r\n", Indent, "", Offset, Val, Str);
+    SHELL_FREE_NON_NULL (RetVal);
+    RetVal = TempRetVal;
+
+    Data += Size;
+    Offset += Size;
+    DataSize -= Size;
+  }
+
+  return RetVal;
+}
index 1cfda2cf2d5a75d3681821212f4d0bcfc3237f1f..a096a12098f306ce98fe6264c1e08739cacd872a 100644 (file)
@@ -2,6 +2,7 @@
   Provides interface to shell internal functions for shell commands.\r
 \r
   Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved. <BR>\r
+  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -43,6 +44,7 @@
 #include <Library/ShellLib.h>\r
 #include <Library/HiiLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiLib.h>
 \r
 typedef struct{\r
   LIST_ENTRY                  Link;\r