]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Print.c
EdkCompatibilityPkg: Remove EdkCompatibilityPkg
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / Dxe / GraphicsLite / Print.c
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Print.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Print.c
deleted file mode 100644 (file)
index 1492e53..0000000
+++ /dev/null
@@ -1,528 +0,0 @@
-/*++\r
-\r
-Copyright (c) 2004 - 2012, 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
-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
-Module Name:\r
-\r
-  Print.c\r
-\r
-Abstract:\r
-\r
-  Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very\r
-  simple implemenation of SPrint() and Print() to support debug. \r
-\r
-  You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a \r
-  time. This makes the implementation very simple.\r
-\r
-  VSPrint, Print, SPrint format specification has the follwoing form\r
-\r
-  %[flags][width]type\r
-\r
-  flags:\r
-    '-' - Left justify\r
-    '+' - Prefix a sign\r
-    ' ' - Prefix a blank\r
-    ',' - Place commas in numberss\r
-    '0' - Prefix for width with zeros\r
-    'l' - UINT64\r
-    'L' - UINT64\r
-\r
-  width:\r
-    '*' - Get width from a UINTN argumnet from the argument list\r
-    Decimal number that represents width of print\r
-\r
-  type:\r
-    'X' - argument is a UINTN hex number, prefix '0'\r
-    'x' - argument is a hex number\r
-    'd' - argument is a decimal number\r
-    'a' - argument is an ascii string \r
-    'S','s' - argument is an Unicode string\r
-    'g' - argument is a pointer to an EFI_GUID\r
-    't' - argument is a pointer to an EFI_TIME structure\r
-    'c' - argument is an ascii character\r
-    'r' - argument is EFI_STATUS\r
-    '%' - Print a %\r
-\r
---*/\r
-\r
-#include "Tiano.h"\r
-#include "EfiDriverLib.h"\r
-#include "TianoCommon.h"\r
-#include "EfiCommonLib.h"\r
-#include "PrintWidth.h"\r
-#include "EfiPrintLib.h"\r
-#include "Print.h"\r
-#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)\r
-#include EFI_PROTOCOL_DEFINITION (HiiFont)\r
-#else\r
-#include EFI_PROTOCOL_DEFINITION (Hii)\r
-#endif\r
-\r
-static EFI_GRAPHICS_OUTPUT_BLT_PIXEL  mEfiColors[16] = {\r
-  {0x00, 0x00, 0x00, 0x00},\r
-  {0x98, 0x00, 0x00, 0x00},\r
-  {0x00, 0x98, 0x00, 0x00},\r
-  {0x98, 0x98, 0x00, 0x00},\r
-  {0x00, 0x00, 0x98, 0x00},\r
-  {0x98, 0x00, 0x98, 0x00},\r
-  {0x00, 0x98, 0x98, 0x00},\r
-  {0x98, 0x98, 0x98, 0x00},\r
-  {0x10, 0x10, 0x10, 0x00},\r
-  {0xff, 0x10, 0x10, 0x00},\r
-  {0x10, 0xff, 0x10, 0x00},\r
-  {0xff, 0xff, 0x10, 0x00},\r
-  {0x10, 0x10, 0xff, 0x00},\r
-  {0xf0, 0x10, 0xff, 0x00},\r
-  {0x10, 0xff, 0xff, 0x00},\r
-  {0xff, 0xff, 0xff, 0x00},\r
-};\r
-\r
-\r
-UINTN\r
-_IPrint (\r
-  IN EFI_GRAPHICS_OUTPUT_PROTOCOL     *GraphicsOutput,\r
-  IN EFI_UGA_DRAW_PROTOCOL            *UgaDraw,\r
-  IN EFI_SIMPLE_TEXT_OUT_PROTOCOL     *Sto,\r
-  IN UINTN                            X,\r
-  IN UINTN                            Y,\r
-  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL    *Foreground,\r
-  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL    *Background,\r
-  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
-  Length of string printed to the console\r
-\r
---*/\r
-{\r
-  VOID                           *Buffer;\r
-  EFI_STATUS                     Status;\r
-  UINTN                          Index;\r
-  CHAR16                         *UnicodeWeight;\r
-  UINT32                         HorizontalResolution;\r
-  UINT32                         VerticalResolution;\r
-  UINT32                         ColorDepth;\r
-  UINT32                         RefreshRate;\r
-  UINTN                          BufferLen;\r
-  UINTN                          LineBufferLen;\r
-#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)\r
-  EFI_HII_FONT_PROTOCOL          *HiiFont;\r
-  EFI_IMAGE_OUTPUT               *Blt;\r
-  EFI_FONT_DISPLAY_INFO          *FontInfo;  \r
-#else\r
-  EFI_HII_PROTOCOL               *Hii;\r
-  UINT16                         GlyphWidth;\r
-  UINT32                         GlyphStatus;\r
-  UINT16                         StringIndex;\r
-  EFI_NARROW_GLYPH               *Glyph;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  *LineBuffer;\r
-#endif\r
-\r
-  //\r
-  // For now, allocate an arbitrarily long buffer\r
-  //\r
-  BufferLen = 0;\r
-  Buffer = EfiLibAllocateZeroPool (0x10000);\r
-  if (Buffer == NULL) {\r
-    return 0;\r
-  }\r
-\r
-  if (GraphicsOutput != NULL) {\r
-    HorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution;\r
-    VerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution;\r
-  } else {\r
-    UgaDraw->GetMode (UgaDraw, &HorizontalResolution, &VerticalResolution, &ColorDepth, &RefreshRate);\r
-  }\r
-  ASSERT ((HorizontalResolution != 0) && (VerticalResolution !=0));\r
-  \r
-#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)\r
-  Blt      = NULL;\r
-  FontInfo = NULL;\r
-  ASSERT (GraphicsOutput != NULL);\r
-  Status = gBS->LocateProtocol (&gEfiHiiFontProtocolGuid, NULL, (VOID **) &HiiFont);\r
-  if (EFI_ERROR (Status)) {\r
-    goto Error;\r
-  }  \r
-#else  \r
-  LineBuffer = NULL;\r
-  Status = gBS->LocateProtocol (&gEfiHiiProtocolGuid, NULL, (VOID**)&Hii);\r
-  if (EFI_ERROR (Status)) {\r
-    goto Error;\r
-  }\r
-  LineBufferLen = sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * HorizontalResolution * GLYPH_HEIGHT;\r
-  LineBuffer = EfiLibAllocatePool (LineBufferLen);\r
-  if (LineBuffer == NULL) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto Error;\r
-  }  \r
-#endif\r
-\r
-  VSPrint (Buffer, 0x10000, fmt, args);\r
-  \r
-  UnicodeWeight = (CHAR16 *) Buffer;\r
-\r
-  for (Index = 0; UnicodeWeight[Index] != 0; Index++) {\r
-    if (UnicodeWeight[Index] == CHAR_BACKSPACE ||\r
-        UnicodeWeight[Index] == CHAR_LINEFEED  ||\r
-        UnicodeWeight[Index] == CHAR_CARRIAGE_RETURN) {\r
-      UnicodeWeight[Index] = 0;\r
-    }\r
-  }\r
-\r
-  BufferLen = EfiStrLen (Buffer);\r
-\r
-#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)\r
-  LineBufferLen = sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * HorizontalResolution * EFI_GLYPH_HEIGHT;\r
-  if (EFI_GLYPH_WIDTH * EFI_GLYPH_HEIGHT * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * BufferLen > LineBufferLen) {\r
-     Status = EFI_INVALID_PARAMETER;\r
-     goto Error;\r
-  }\r
-\r
-  Blt = (EFI_IMAGE_OUTPUT *) EfiLibAllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT));\r
-  if (Blt == NULL) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto Error;\r
-  }\r
-\r
-  Blt->Width        = (UINT16) (HorizontalResolution);\r
-  Blt->Height       = (UINT16) (VerticalResolution);\r
-  Blt->Image.Screen = GraphicsOutput;\r
-   \r
-  FontInfo = (EFI_FONT_DISPLAY_INFO *) EfiLibAllocateZeroPool (sizeof (EFI_FONT_DISPLAY_INFO));\r
-  if (FontInfo == NULL) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto Error;\r
-  }\r
-  if (Foreground != NULL) {\r
-    EfiCopyMem (&FontInfo->ForegroundColor, Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
-  } else {\r
-    EfiCopyMem (\r
-      &FontInfo->ForegroundColor, \r
-      &mEfiColors[Sto->Mode->Attribute & 0x0f], \r
-      sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
-      );\r
-  }\r
-  if (Background != NULL) {\r
-    EfiCopyMem (&FontInfo->BackgroundColor, Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
-  } else {\r
-    EfiCopyMem (\r
-      &FontInfo->BackgroundColor, \r
-      &mEfiColors[Sto->Mode->Attribute >> 4], \r
-      sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
-      );\r
-  }\r
-\r
-  Status = HiiFont->StringToImage (\r
-                       HiiFont,\r
-                       EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_DIRECT_TO_SCREEN,\r
-                       Buffer,\r
-                       FontInfo,\r
-                       &Blt,\r
-                       X,\r
-                       Y,\r
-                       NULL,\r
-                       NULL,\r
-                       NULL\r
-                       );\r
-  \r
-#else\r
-  GlyphStatus = 0;\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
-      goto Error;\r
-    }\r
-\r
-    if (Foreground == NULL || Background == NULL) {\r
-      Status = Hii->GlyphToBlt (\r
-                      Hii,\r
-                      (UINT8 *) Glyph,\r
-                      mEfiColors[Sto->Mode->Attribute & 0x0f],\r
-                      mEfiColors[Sto->Mode->Attribute >> 4],\r
-                      BufferLen,\r
-                      GlyphWidth,\r
-                      GLYPH_HEIGHT,\r
-                      &LineBuffer[Index * GLYPH_WIDTH]\r
-                      );\r
-    } else {\r
-      Status = Hii->GlyphToBlt (\r
-                      Hii,\r
-                      (UINT8 *) Glyph,\r
-                      *Foreground,\r
-                      *Background,\r
-                      BufferLen,\r
-                      GlyphWidth,\r
-                      GLYPH_HEIGHT,\r
-                      &LineBuffer[Index * GLYPH_WIDTH]\r
-                      );\r
-    }\r
-  }\r
-\r
-  //\r
-  // Blt a character to the screen\r
-  //\r
-  if (GraphicsOutput != NULL) {\r
-    Status = GraphicsOutput->Blt (\r
-                        GraphicsOutput,\r
-                        LineBuffer,\r
-                        EfiBltBufferToVideo,\r
-                        0,\r
-                        0,\r
-                        X,\r
-                        Y,\r
-                        GLYPH_WIDTH * BufferLen,\r
-                        GLYPH_HEIGHT,\r
-                        GLYPH_WIDTH * BufferLen * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
-                        );\r
-  } else {\r
-    Status = UgaDraw->Blt (\r
-                        UgaDraw,\r
-                        (EFI_UGA_PIXEL *) LineBuffer,\r
-                        EfiUgaBltBufferToVideo,\r
-                        0,\r
-                        0,\r
-                        X,\r
-                        Y,\r
-                        GLYPH_WIDTH * BufferLen,\r
-                        GLYPH_HEIGHT,\r
-                        GLYPH_WIDTH * BufferLen * sizeof (EFI_UGA_PIXEL)\r
-                        );\r
-  }\r
-\r
-#endif\r
-\r
-Error:\r
-#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)\r
-  EfiLibSafeFreePool (Blt);\r
-  EfiLibSafeFreePool (FontInfo);\r
-#else\r
-  EfiLibSafeFreePool (LineBuffer);\r
-#endif  \r
-  gBS->FreePool (Buffer);\r
-  \r
-  if (EFI_ERROR (Status)) {\r
-    return 0;\r
-  }\r
-\r
-  return BufferLen;\r
-}\r
-\r
-\r
-UINTN\r
-PrintXY (\r
-  IN UINTN                            X,\r
-  IN UINTN                            Y,\r
-  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL    *ForeGround, OPTIONAL\r
-  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL    *BackGround, OPTIONAL\r
-  IN CHAR_W                           *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
-  EFI_GRAPHICS_OUTPUT_PROTOCOL  *GraphicsOutput;\r
-  EFI_UGA_DRAW_PROTOCOL         *UgaDraw;\r
-  EFI_SIMPLE_TEXT_OUT_PROTOCOL  *Sto;\r
-  EFI_STATUS                    Status;\r
-  VA_LIST                       Args;\r
-  UINTN                         LengthOfPrinted;\r
-\r
-  Handle = gST->ConsoleOutHandle;\r
-\r
-  GraphicsOutput = NULL;\r
-  UgaDraw = NULL;\r
-  Status = gBS->HandleProtocol (\r
-                  Handle,\r
-                  &gEfiGraphicsOutputProtocolGuid,\r
-                  (VOID **) &GraphicsOutput\r
-                  );\r
-\r
-  if (EFI_ERROR (Status) || (GraphicsOutput == NULL)) {\r
-    GraphicsOutput = NULL;\r
-\r
-    Status = gBS->HandleProtocol (\r
-                    Handle,\r
-                    &gEfiUgaDrawProtocolGuid,\r
-                    (VOID **) &UgaDraw\r
-                    );\r
-\r
-    if (EFI_ERROR (Status) || (UgaDraw == NULL)) {\r
-      return 0;\r
-    }\r
-  }\r
-\r
-  Sto = NULL;\r
-  Status = gBS->HandleProtocol (\r
-                  Handle,\r
-                  &gEfiSimpleTextOutProtocolGuid,\r
-                  (VOID **) &Sto\r
-                  );\r
-\r
-  if (EFI_ERROR (Status) || (Sto == NULL)) {\r
-    return 0;\r
-  }\r
-\r
-  VA_START (Args, Fmt);\r
-  LengthOfPrinted = _IPrint (GraphicsOutput, UgaDraw, Sto, X, Y, ForeGround, BackGround, Fmt, Args);\r
-  VA_END (Args);\r
-  return LengthOfPrinted;\r
-}\r
-\r
-\r
-UINTN\r
-SPrint (\r
-  OUT CHAR_W        *Buffer,\r
-  IN  UINTN         BufferSize,\r
-  IN  CONST CHAR_W  *Format,\r
-  ...\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  SPrint function to process format and place the results in Buffer.\r
-\r
-Arguments:\r
-\r
-  Buffer     - Wide char buffer to print the results of the parsing of Format into.\r
-\r
-  BufferSize - Maximum number of characters to put into buffer. Zero means no \r
-               limit.\r
-\r
-  Format - Format string see file header for more details.\r
-\r
-  ...    - Vararg list consumed by processing Format.\r
-\r
-Returns: \r
-\r
-  Number of characters printed.\r
-\r
---*/\r
-{\r
-  UINTN   Return;\r
-  VA_LIST Marker;\r
-\r
-  VA_START (Marker, Format);\r
-  Return = VSPrint (Buffer, BufferSize, Format, Marker);\r
-  VA_END (Marker);\r
-\r
-  return Return;\r
-}\r
-\r
-UINTN\r
-EFIAPI\r
-VSPrint (\r
-  OUT CHAR_W        *StartOfBuffer,\r
-  IN  UINTN         BufferSize,\r
-  IN  CONST CHAR_W  *FormatString,\r
-  IN  VA_LIST       Marker\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  VSPrint function to process format and place the results in Buffer. Since a \r
-  VA_LIST is used this rountine allows the nesting of Vararg routines. Thus \r
-  this is the main print working routine\r
-\r
-Arguments:\r
-\r
-  StartOfBuffer - Unicode buffer to print the results of the parsing of Format into.\r
-\r
-  BufferSize    - Maximum number of characters to put into buffer. Zero means \r
-                  no limit.\r
-\r
-  FormatString  - Unicode format string see file header for more details.\r
-\r
-  Marker        - Vararg list consumed by processing Format.\r
-\r
-Returns: \r
-\r
-  Number of characters printed.\r
-\r
---*/\r
-{\r
-  EFI_STATUS          Status;\r
-  EFI_PRINT_PROTOCOL  *PrintProtocol;\r
-\r
-  Status = gBS->LocateProtocol (\r
-                  &gEfiPrintProtocolGuid,\r
-                  NULL,\r
-                  (VOID **) &PrintProtocol\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return 0;\r
-  } else {\r
-    return PrintProtocol->VSPrint (\r
-                            StartOfBuffer,\r
-                            BufferSize,\r
-                            FormatString,\r
-                            Marker\r
-                            );\r
-  }\r
-}\r