]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Library/GraphicsLib/Graphics.c
Add some function/header comments.
[mirror_edk2.git] / IntelFrameworkModulePkg / Library / GraphicsLib / Graphics.c
index 605a240bf2b57fe166e4cabe1790eb1253173145..f75963e712351b17db623c3ada1ca99f747ba80f 100644 (file)
@@ -5,53 +5,62 @@
           when Tiano graphics format is supported.\r
 \r
 \r
-Copyright (c) 2006, Intel Corporation                                                         \r
-All rights reserved. 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
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. 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
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
 **/\r
 \r
-//\r
-// Include common header file for this module.\r
-//\r
-#include "CommonHeader.h"\r
 \r
-EFI_STATUS\r
-GetGraphicsBitMapFromFV (\r
-  IN  EFI_GUID      *FileNameGuid,\r
-  OUT VOID          **Image,\r
-  OUT UINTN         *ImageSize\r
-  )\r
-/*++\r
+#include <PiDxe.h>\r
+\r
+#include <Protocol/SimpleTextOut.h>\r
+#include <Protocol/OEMBadging.h>\r
+#include <Protocol/ConsoleControl.h>\r
+#include <Protocol/GraphicsOutput.h>\r
+#include <Protocol/FirmwareVolume2.h>\r
+#include <Protocol/UgaDraw.h>\r
+#include <Protocol/FrameworkHii.h>\r
+\r
+#include <Guid/Bmp.h>\r
 \r
-Routine Description:\r
+#include <Library/GraphicsLib.h>\r
+#include <Library/PrintLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/PcdLib.h>\r
 \r
+/**\r
   Return the graphics image file named FileNameGuid into Image and return it's\r
   size in ImageSize. All Firmware Volumes (FV) in the system are searched for the\r
   file name.\r
 \r
-Arguments:\r
+  @param FileNameGuid  - File Name of graphics file in the FV(s).\r
 \r
-  FileNameGuid  - File Name of graphics file in the FV(s).\r
+  @param Image         - Pointer to pointer to return graphics image.  If NULL, a\r
+                         buffer will be allocated.\r
 \r
-  Image         - Pointer to pointer to return graphics image.  If NULL, a \r
-                  buffer will be allocated.\r
+  @param ImageSize     - Size of the graphics Image in bytes. Zero if no image found.\r
 \r
-  ImageSize     - Size of the graphics Image in bytes. Zero if no image found.\r
+  @retval EFI_SUCCESS          - Image and ImageSize are valid.\r
+  @retval EFI_BUFFER_TOO_SMALL - Image not big enough. ImageSize has required size\r
+  @retval EFI_NOT_FOUND        - FileNameGuid not found\r
 \r
+**/\r
 \r
-Returns: \r
-\r
-  EFI_SUCCESS          - Image and ImageSize are valid. \r
-  EFI_BUFFER_TOO_SMALL - Image not big enough. ImageSize has required size\r
-  EFI_NOT_FOUND        - FileNameGuid not found\r
-\r
---*/\r
+EFI_STATUS\r
+GetGraphicsBitMapFromFV (\r
+  IN  EFI_GUID      *FileNameGuid,\r
+  OUT VOID          **Image,\r
+  OUT UINTN         *ImageSize\r
+  )\r
 {\r
   EFI_STATUS                    Status;\r
   UINTN                         FvProtocolCount;\r
@@ -104,48 +113,42 @@ Returns:
   return EFI_NOT_FOUND;\r
 }\r
 \r
-STATIC\r
-EFI_STATUS\r
-ConvertBmpToGopBlt (\r
-  IN  VOID      *BmpImage,\r
-  IN  UINTN     BmpImageSize,\r
-  IN OUT VOID   **GopBlt,\r
-  IN OUT UINTN  *GopBltSize,\r
-  OUT UINTN     *PixelHeight,\r
-  OUT UINTN     *PixelWidth\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Convert a *.BMP graphics image to a UGA blt buffer. If a NULL UgaBlt buffer\r
-  is passed in a UgaBlt buffer will be allocated by this routine. If a UgaBlt\r
+/**\r
+  Convert a *.BMP graphics image to a GOP/UGA blt buffer. If a NULL Blt buffer\r
+  is passed in a GopBlt buffer will be allocated by this routine. If a GopBlt\r
   buffer is passed in it will be used if it is big enough.\r
 \r
-Arguments:\r
-\r
-  BmpImage      - Pointer to BMP file\r
+  @param BmpImage      - Pointer to BMP file\r
 \r
-  BmpImageSize  - Number of bytes in BmpImage\r
+  @param BmpImageSize  - Number of bytes in BmpImage\r
 \r
-  UgaBlt        - Buffer containing UGA version of BmpImage.\r
+  @param GopBlt        - Buffer containing GOP version of BmpImage.\r
 \r
-  UgaBltSize    - Size of UgaBlt in bytes.\r
+  @param GopBltSize    - Size of GopBlt in bytes.\r
 \r
-  PixelHeight   - Height of UgaBlt/BmpImage in pixels\r
+  @param PixelHeight   - Height of GopBlt/BmpImage in pixels\r
 \r
-  PixelWidth    - Width of UgaBlt/BmpImage in pixels\r
+  @param PixelWidth    - Width of GopBlt/BmpImage in pixels\r
 \r
 \r
-Returns: \r
+  @retval EFI_SUCCESS           - GopBlt and GopBltSize are returned.\r
+  @retval EFI_UNSUPPORTED       - BmpImage is not a valid *.BMP image\r
+  @retval EFI_BUFFER_TOO_SMALL  - The passed in GopBlt buffer is not big enough.\r
+                                  GopBltSize will contain the required size.\r
+  @retval EFI_OUT_OF_RESOURCES  - No enough buffer to allocate\r
 \r
-  EFI_SUCCESS           - UgaBlt and UgaBltSize are returned. \r
-  EFI_UNSUPPORTED       - BmpImage is not a valid *.BMP image\r
-  EFI_BUFFER_TOO_SMALL  - The passed in UgaBlt buffer is not big enough.\r
-                          UgaBltSize will contain the required size.\r
-  EFI_OUT_OF_RESOURCES  - No enough buffer to allocate\r
+**/\r
+STATIC\r
+EFI_STATUS\r
+ConvertBmpToGopBlt (\r
+  IN  VOID      *BmpImage,\r
+  IN  UINTN     BmpImageSize,\r
+  IN OUT VOID   **GopBlt,\r
+  IN OUT UINTN  *GopBltSize,\r
+  OUT UINTN     *PixelHeight,\r
+  OUT UINTN     *PixelWidth\r
+  )\r
 \r
---*/\r
 {\r
   UINT8             *Image;\r
   UINT8             *ImageHeader;\r
@@ -159,7 +162,7 @@ Returns:
   UINTN             Width;\r
   UINTN             ImageIndex;\r
   BOOLEAN           IsAllocated;\r
-  \r
+\r
   BmpHeader = (BMP_IMAGE_HEADER *) BmpImage;\r
   if (BmpHeader->CharB != 'B' || BmpHeader->CharM != 'M') {\r
     return EFI_UNSUPPORTED;\r
@@ -223,7 +226,7 @@ Returns:
         Blt --;\r
         Width --;\r
         break;\r
-      \r
+\r
       case 4:\r
         //\r
         // Convert BMP Palette to 24-bit color\r
@@ -280,30 +283,23 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
-\r
-EFI_STATUS\r
-LockKeyboards (\r
-  IN  CHAR16    *Password\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Use Console Control Protocol to lock the Console In Spliter virtual handle. \r
+/**\r
+  Use Console Control Protocol to lock the Console In Spliter virtual handle.\r
   This is the ConInHandle and ConIn handle in the EFI system table. All key\r
   presses will be ignored until the Password is typed in. The only way to\r
   disable the password is to type it in to a ConIn device.\r
 \r
-Arguments:\r
-  Password - Password used to lock ConIn device\r
-\r
+  @param  Password - Password used to lock ConIn device\r
 \r
-Returns: \r
-\r
-  EFI_SUCCESS     - ConsoleControl has been flipped to graphics and logo\r
+  @retval EFI_SUCCESS     - ConsoleControl has been flipped to graphics and logo\r
                           displayed.\r
-  EFI_UNSUPPORTED - Logo not found\r
+  @retval EFI_UNSUPPORTED - Logo not found\r
 \r
---*/\r
+**/\r
+EFI_STATUS\r
+LockKeyboards (\r
+  IN  CHAR16    *Password\r
+  )\r
 {\r
   EFI_STATUS                    Status;\r
   EFI_CONSOLE_CONTROL_PROTOCOL  *ConsoleControl;\r
@@ -317,30 +313,22 @@ Returns:
   return Status;\r
 }\r
 \r
-\r
-EFI_STATUS\r
-EnableQuietBoot (\r
-  IN  EFI_GUID  *LogoFile\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
+/**\r
   Use Console Control to turn off UGA based Simple Text Out consoles from going\r
   to the UGA device. Put up LogoFile on every UGA device that is a console\r
 \r
-Arguments:\r
-\r
-  LogoFile - File name of logo to display on the center of the screen.\r
-\r
+  @param LogoFile - File name of logo to display on the center of the screen.\r
 \r
-Returns: \r
+  @retval EFI_SUCCESS           - ConsoleControl has been flipped to graphics and logo\r
+                                  displayed.\r
+  @retval EFI_UNSUPPORTED       - Logo not found\r
 \r
-  EFI_SUCCESS           - ConsoleControl has been flipped to graphics and logo\r
-                          displayed.\r
-  EFI_UNSUPPORTED       - Logo not found\r
+**/\r
+EFI_STATUS\r
+EnableQuietBoot (\r
+  IN  EFI_GUID  *LogoFile\r
+  )\r
 \r
---*/\r
 {\r
   EFI_STATUS                    Status;\r
   EFI_CONSOLE_CONTROL_PROTOCOL  *ConsoleControl;\r
@@ -374,16 +362,16 @@ Returns:
   //\r
   // Try to open GOP first\r
   //\r
-  Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiGraphicsOutputProtocolGuid, (VOID **) &GraphicsOutput); \r
-  if (EFI_ERROR(Status)) {\r
+  Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiGraphicsOutputProtocolGuid, (VOID **) &GraphicsOutput);\r
+  if (EFI_ERROR(Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {\r
     GraphicsOutput = NULL;\r
     //\r
     // Open GOP failed, try to open UGA\r
     //\r
     Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiUgaDrawProtocolGuid, (VOID **) &UgaDraw);\r
-    if (EFI_ERROR (Status)) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
+  }\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
   }\r
 \r
   Badging = NULL;\r
@@ -394,11 +382,13 @@ Returns:
   if (GraphicsOutput != NULL) {\r
     SizeOfX = GraphicsOutput->Mode->Info->HorizontalResolution;\r
     SizeOfY = GraphicsOutput->Mode->Info->VerticalResolution;\r
-  } else {\r
+  } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {\r
     Status = UgaDraw->GetMode (UgaDraw, &SizeOfX, &SizeOfY, &ColorDepth, &RefreshRate);\r
     if (EFI_ERROR (Status)) {\r
       return EFI_UNSUPPORTED;\r
     }\r
+  } else {\r
+    return EFI_UNSUPPORTED;\r
   }\r
 \r
   Instance = 0;\r
@@ -524,7 +514,7 @@ Returns:
                             Height,\r
                             Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
                             );\r
-      } else {\r
+      } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {\r
         Status = UgaDraw->Blt (\r
                             UgaDraw,\r
                             (EFI_UGA_PIXEL *) Blt,\r
@@ -537,6 +527,8 @@ Returns:
                             Height,\r
                             Width * sizeof (EFI_UGA_PIXEL)\r
                             );\r
+      } else {\r
+        Status = EFI_UNSUPPORTED;\r
       }\r
     }\r
 \r
@@ -551,28 +543,18 @@ Returns:
   return Status;\r
 }\r
 \r
+/**\r
+  Use Console Control to turn on GOP/UGA based Simple Text Out consoles. The GOP/UGA\r
+  Simple Text Out screens will now be synced up with all non GOP/UGA output devices\r
 \r
+  @retval EFI_SUCCESS           - GOP/UGA devices are back in text mode and synced up.\r
+  @retval EFI_UNSUPPORTED       - Logo not found\r
+**/\r
 EFI_STATUS\r
 DisableQuietBoot (\r
   VOID\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Use Console Control to turn on UGA based Simple Text Out consoles. The UGA \r
-  Simple Text Out screens will now be synced up with all non UGA output devices\r
-\r
-Arguments:\r
-\r
-  NONE\r
 \r
-Returns: \r
-\r
-  EFI_SUCCESS           - UGA devices are back in text mode and synced up.\r
-  EFI_UNSUPPORTED       - Logo not found\r
-\r
---*/\r
 {\r
   EFI_STATUS                    Status;\r
   EFI_CONSOLE_CONTROL_PROTOCOL  *ConsoleControl;\r
@@ -604,6 +586,32 @@ static EFI_GRAPHICS_OUTPUT_BLT_PIXEL mEfiColors[16] = {
   { 0xff, 0xff, 0xff, 0x00 }\r
 };\r
 \r
+/**\r
+  Display string worker for: Print, PrintAt, IPrint, IPrintAt\r
+\r
+  @param GraphicsOutput  - Graphics output protocol interface\r
+\r
+  @param UgaDraw         - UGA draw protocol interface\r
+\r
+  @param Sto             - Simple text out protocol interface\r
+\r
+  @param X               - X coordinate to start printing\r
+\r
+  @param Y               - Y coordinate to start printing\r
+\r
+  @param Foreground      - Foreground color\r
+\r
+  @param Background      - Background color\r
+\r
+  @param fmt             - Format string\r
+\r
+  @param args            - Print arguments\r
+\r
+\r
+  @retval EFI_SUCCESS             -  success\r
+  @retval EFI_OUT_OF_RESOURCES    -  out of resources\r
+\r
+**/\r
 STATIC\r
 UINTN\r
 _IPrint (\r
@@ -617,54 +625,25 @@ _IPrint (
   IN CHAR16                           *fmt,\r
   IN VA_LIST                          args\r
   )\r
-/*++\r
-\r
-Routine Description:\r
 \r
-  Display string worker for: Print, PrintAt, IPrint, IPrintAt\r
-\r
-Arguments:\r
-\r
-  GraphicsOutput  - Graphics output protocol interface\r
-  \r
-  UgaDraw         - UGA draw protocol interface\r
-  \r
-  Sto             - Simple text out protocol interface\r
-  \r
-  X               - X coordinate to start printing\r
-  \r
-  Y               - Y coordinate to start printing\r
-  \r
-  Foreground      - Foreground color\r
-  \r
-  Background      - Background color\r
-  \r
-  fmt             - Format string\r
-  \r
-  args            - Print arguments\r
-\r
-Returns: \r
-\r
-  EFI_SUCCESS             -  success\r
-  EFI_OUT_OF_RESOURCES    -  out of resources\r
-\r
---*/\r
 {\r
-  VOID              *Buffer;\r
-  EFI_STATUS        Status;\r
-  UINT16            GlyphWidth;\r
-  UINT32            GlyphStatus;\r
-  UINT16            StringIndex;\r
-  UINTN             Index;\r
-  CHAR16            *UnicodeWeight;\r
-  EFI_NARROW_GLYPH  *Glyph;\r
-  EFI_HII_PROTOCOL  *Hii;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL     *LineBuffer;\r
-  UINT32            HorizontalResolution;\r
-  UINT32            VerticalResolution;\r
-  UINT32            ColorDepth;\r
-  UINT32            RefreshRate;\r
-  UINTN             BufferGlyphWidth;\r
+  VOID                           *Buffer;\r
+  EFI_STATUS                     Status;\r
+  UINT16                         GlyphWidth;\r
+  UINT32                         GlyphStatus;\r
+  UINT16                         StringIndex;\r
+  UINTN                          Index;\r
+  CHAR16                         *UnicodeWeight;\r
+  EFI_NARROW_GLYPH               *Glyph;\r
+  EFI_HII_PROTOCOL               *Hii;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  *LineBuffer;\r
+  UINT32                         HorizontalResolution;\r
+  UINT32                         VerticalResolution;\r
+  UINT32                         ColorDepth;\r
+  UINT32                         RefreshRate;\r
+  UINTN                          BufferLen;\r
+  UINTN                          LineBufferLen;\r
+  UINTN                          BufferGlyphWidth;\r
 \r
   GlyphStatus = 0;\r
 \r
@@ -675,18 +654,20 @@ Returns:
   if (Buffer == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
-  \r
+\r
   if (GraphicsOutput != NULL) {\r
     HorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution;\r
     VerticalResolution   = GraphicsOutput->Mode->Info->VerticalResolution;\r
-  } else {\r
+  } else if (FeaturePcdGet (PcdUgaConsumeSupport))  {\r
     //\r
     // Get the current mode information from the UGA Draw Protocol\r
     //\r
     UgaDraw->GetMode (UgaDraw, &HorizontalResolution, &VerticalResolution, &ColorDepth, &RefreshRate);\r
   }\r
+  ASSERT ((HorizontalResolution != 0) && (VerticalResolution !=0));\r
 \r
-  LineBuffer = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * HorizontalResolution * GLYPH_WIDTH * GLYPH_HEIGHT);\r
+  LineBufferLen = sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * HorizontalResolution * GLYPH_HEIGHT;\r
+  LineBuffer = AllocatePool (LineBufferLen);\r
   if (LineBuffer == NULL) {\r
     gBS->FreePool (Buffer);\r
     return EFI_OUT_OF_RESOURCES;\r
@@ -709,7 +690,14 @@ Returns:
     }\r
   }\r
 \r
-  for (Index = 0; Index < StrLen (Buffer); Index++) {\r
+  BufferLen = StrLen (Buffer);\r
+\r
+  if (GLYPH_WIDTH * GLYPH_HEIGHT * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * BufferLen > LineBufferLen) {\r
+     Status = EFI_INVALID_PARAMETER;\r
+     goto Error;\r
+  }\r
+\r
+  for (Index = 0; Index < BufferLen; Index++) {\r
     StringIndex = (UINT16) Index;\r
     Status      = Hii->GetGlyph (Hii, UnicodeWeight, &StringIndex, (UINT8 **) &Glyph, &GlyphWidth, &GlyphStatus);\r
     if (EFI_ERROR (Status)) {\r
@@ -722,7 +710,7 @@ Returns:
                       (UINT8 *) Glyph,\r
                       mEfiColors[Sto->Mode->Attribute & 0x0f],\r
                       mEfiColors[Sto->Mode->Attribute >> 4],\r
-                      StrLen (Buffer),\r
+                      BufferLen,\r
                       GlyphWidth,\r
                       GLYPH_HEIGHT,\r
                       &LineBuffer[Index * GLYPH_WIDTH]\r
@@ -733,7 +721,7 @@ Returns:
                       (UINT8 *) Glyph,\r
                       *Foreground,\r
                       *Background,\r
-                      StrLen (Buffer),\r
+                      BufferLen,\r
                       GlyphWidth,\r
                       GLYPH_HEIGHT,\r
                       &LineBuffer[Index * GLYPH_WIDTH]\r
@@ -744,7 +732,7 @@ Returns:
   //\r
   // Blt a character to the screen\r
   //\r
-  BufferGlyphWidth = GLYPH_WIDTH * StrLen (Buffer);\r
+  BufferGlyphWidth = GLYPH_WIDTH * BufferLen;\r
   if (GraphicsOutput != NULL) {\r
     Status = GraphicsOutput->Blt (\r
                         GraphicsOutput,\r
@@ -758,7 +746,7 @@ Returns:
                         GLYPH_HEIGHT,\r
                         BufferGlyphWidth * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
                         );\r
-  } else {\r
+  } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {\r
     Status = UgaDraw->Blt (\r
                         UgaDraw,\r
                         (EFI_UGA_PIXEL *) (UINTN) LineBuffer,\r
@@ -771,6 +759,8 @@ Returns:
                         GLYPH_HEIGHT,\r
                         BufferGlyphWidth * sizeof (EFI_UGA_PIXEL)\r
                         );\r
+  } else {\r
+    Status = EFI_UNSUPPORTED;\r
   }\r
 \r
 Error:\r
@@ -779,7 +769,25 @@ Error:
   return Status;\r
 }\r
 \r
+/**\r
+  Prints a formatted unicode string to the default console\r
+\r
+  @param X           - X coordinate to start printing\r
+\r
+  @param Y           - Y coordinate to start printing\r
+\r
+  @param ForeGround  - Foreground color\r
+\r
+  @param BackGround  - Background color\r
+\r
+  @param Fmt         - Format string\r
+\r
+  @param ...         - Print arguments\r
+\r
+\r
+  @retval Length of string printed to the console\r
 \r
+**/\r
 UINTN\r
 PrintXY (\r
   IN UINTN                            X,\r
@@ -789,31 +797,6 @@ PrintXY (
   IN CHAR16                           *Fmt,\r
   ...\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    Prints a formatted unicode string to the default console\r
-\r
-Arguments:\r
-\r
-    X           - X coordinate to start printing\r
-    \r
-    Y           - Y coordinate to start printing\r
-    \r
-    ForeGround  - Foreground color\r
-    \r
-    BackGround  - Background color\r
-\r
-    Fmt         - Format string\r
-\r
-    ...         - Print arguments\r
-\r
-Returns:\r
-\r
-    Length of string printed to the console\r
-\r
---*/\r
 {\r
   EFI_HANDLE                    Handle;\r
 \r
@@ -835,7 +818,7 @@ Returns:
                   (VOID **) &GraphicsOutput\r
                   );\r
 \r
-  if (EFI_ERROR (Status)) {\r
+  if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {\r
     GraphicsOutput = NULL;\r
 \r
     Status = gBS->HandleProtocol (\r
@@ -843,10 +826,10 @@ Returns:
                     &gEfiUgaDrawProtocolGuid,\r
                     (VOID **) &UgaDraw\r
                     );\r
+  }\r
 \r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
   }\r
 \r
   Status = gBS->HandleProtocol (\r
@@ -861,3 +844,4 @@ Returns:
 \r
   return _IPrint (GraphicsOutput, UgaDraw, Sto, X, Y, ForeGround, BackGround, Fmt, Args);\r
 }\r
+\r