]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
Update the comments for function 'ConvertPixelFormat' in UefiHandleParsingLib.c to...
[mirror_edk2.git] / ShellPkg / Library / UefiHandleParsingLib / UefiHandleParsingLib.c
index 6f4dd91ccad2d841c96f7dc277b83860473f3dca..e1fdab3215ac43289dc0b78b36395a8dd73cf2de 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 Hewlett-Packard Development Company, L.P.\r
+  Copyright (c) 2013 - 2014, Hewlett-Packard Development Company, L.P.\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
@@ -56,6 +56,33 @@ ConvertMemoryType (
   return (RetVal);\r
 }\r
 \r
+/**\r
+  Function to translate the EFI_GRAPHICS_PIXEL_FORMAT into a string.\r
+\r
+  @param[in] Fmt     The format type.\r
+\r
+  @retval               A string representation of the type allocated from BS Pool.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+ConvertPixelFormat (\r
+  IN CONST EFI_GRAPHICS_PIXEL_FORMAT Fmt\r
+  )\r
+{\r
+  CHAR16 *RetVal;\r
+  RetVal = NULL;\r
+\r
+  switch (Fmt) {\r
+  case PixelRedGreenBlueReserved8BitPerColor: StrnCatGrow(&RetVal, NULL, L"PixelRedGreenBlueReserved8BitPerColor", 0);  break;\r
+  case PixelBlueGreenRedReserved8BitPerColor: StrnCatGrow(&RetVal, NULL, L"PixelBlueGreenRedReserved8BitPerColor", 0);  break;\r
+  case PixelBitMask:                          StrnCatGrow(&RetVal, NULL, L"PixelBitMask", 0);                           break;\r
+  case PixelBltOnly:                          StrnCatGrow(&RetVal, NULL, L"PixelBltOnly", 0);                           break;\r
+  case PixelFormatMax:                        StrnCatGrow(&RetVal, NULL, L"PixelFormatMax", 0);                         break;\r
+  default: ASSERT(FALSE);\r
+  }\r
+  return (RetVal);\r
+}\r
+\r
 /**\r
   Constructor for the library.\r
 \r
@@ -177,6 +204,81 @@ LoadedImageProtocolDumpInformation(
   return RetVal;\r
 }\r
 \r
+/**\r
+  Function to dump information about GOP.\r
+\r
+  This will allocate the return buffer from boot services pool.\r
+\r
+  @param[in] TheHandle      The handle that has LoadedImage 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
+GraphicsOutputProtocolDumpInformation(\r
+  IN CONST EFI_HANDLE TheHandle,\r
+  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
+\r
+  if (!Verbose) {\r
+    return (CatSPrint(NULL, L"GraphicsOutput"));\r
+  }\r
+\r
+  Temp = HiiGetString(mHandleParsingHiiHandle, STRING_TOKEN(STR_GOP_DUMP_MAIN), NULL);\r
+  RetVal = AllocateZeroPool (PcdGet16 (PcdShellPrintBufferSize));\r
+  if (Temp == NULL || RetVal == NULL) {\r
+    SHELL_FREE_NON_NULL(Temp);\r
+    SHELL_FREE_NON_NULL(RetVal);\r
+    return NULL;\r
+  }\r
+\r
+  Status = gBS->OpenProtocol (\r
+                TheHandle,\r
+                &gEfiGraphicsOutputProtocolGuid,\r
+                (VOID**)&GraphicsOutput,\r
+                gImageHandle,\r
+                NULL,\r
+                EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+               );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    SHELL_FREE_NON_NULL (Temp);\r
+    SHELL_FREE_NON_NULL (RetVal);\r
+    return NULL;\r
+  }\r
+\r
+  Fmt = ConvertPixelFormat(GraphicsOutput->Mode->Info->PixelFormat);\r
+\r
+  RetVal = CatSPrint(RetVal,\r
+                      Temp,\r
+                      GraphicsOutput->Mode->MaxMode,\r
+                      GraphicsOutput->Mode->Mode,\r
+                      GraphicsOutput->Mode->FrameBufferBase,\r
+                      (UINT64)GraphicsOutput->Mode->FrameBufferSize,\r
+                      (UINT64)GraphicsOutput->Mode->SizeOfInfo,\r
+                      GraphicsOutput->Mode->Info->Version,\r
+                      GraphicsOutput->Mode->Info->HorizontalResolution,\r
+                      GraphicsOutput->Mode->Info->VerticalResolution,\r
+                      Fmt,\r
+                      GraphicsOutput->Mode->Info->PixelsPerScanLine,\r
+                      GraphicsOutput->Mode->Info->PixelFormat!=PixelBitMask?0:GraphicsOutput->Mode->Info->PixelInformation.RedMask,\r
+                      GraphicsOutput->Mode->Info->PixelFormat!=PixelBitMask?0:GraphicsOutput->Mode->Info->PixelInformation.GreenMask,\r
+                      GraphicsOutput->Mode->Info->PixelFormat!=PixelBitMask?0:GraphicsOutput->Mode->Info->PixelInformation.BlueMask\r
+                      );\r
+  \r
+  SHELL_FREE_NON_NULL(Temp);\r
+  SHELL_FREE_NON_NULL(Fmt);\r
+\r
+  return RetVal;\r
+}\r
+\r
 /**\r
   Function to dump information about PciRootBridgeIo.\r
 \r
@@ -503,7 +605,7 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = {
   {STRING_TOKEN(STR_SIM_POINTER),           &gEfiSimplePointerProtocolGuid,                   NULL},\r
   {STRING_TOKEN(STR_ABS_POINTER),           &gEfiAbsolutePointerProtocolGuid,                 NULL},\r
   {STRING_TOKEN(STR_SERIAL_IO),             &gEfiSerialIoProtocolGuid,                        NULL},\r
-  {STRING_TOKEN(STR_GRAPHICS_OUTPUT),       &gEfiGraphicsOutputProtocolGuid,                  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_OVERRIDE),         &gEfiEdidOverrideProtocolGuid,                    NULL},\r
@@ -640,6 +742,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
 \r
 //\r
 // PI Spec ones\r