Print to StdErr or ConOut defined in EFI_SYSTEM_TABLE\r
\r
Copyright (c) 2007, Intel Corporation<BR>\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
+ 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
+ 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
- Internal function which prints a formatted Unicode string to the console output device \r
+#include "UefiLibInternal.h"\r
+\r
+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
+ Internal function which prints a formatted Unicode string to the console output device\r
specified by Console\r
\r
- This function prints a formatted Unicode string to the console output device \r
- specified by Console and returns the number of Unicode characters that printed \r
- to it. If the length of the formatted Unicode string is greater than PcdUefiLibMaxPrintBufferSize, \r
+ This function prints a formatted Unicode string to the console output device\r
+ specified by Console and returns the number of Unicode characters that printed\r
+ to it. If the length of the formatted Unicode string is greater than PcdUefiLibMaxPrintBufferSize,\r
then only the first PcdUefiLibMaxPrintBufferSize characters are sent to Console.\r
+ If Format is NULL, then ASSERT().\r
+ If Format is not aligned on a 16-bit boundary, then ASSERT().\r
\r
@param Format Null-terminated Unicode format string.\r
@param Console The output console.\r
@param Marker VA_LIST marker for the variable argument list.\r
\r
- If Format is NULL, then ASSERT().\r
- If Format is not aligned on a 16-bit boundary, then ASSERT().\r
-\r
+ @return The number of Unicode characters in the produced\r
+ output buffer not including the Null-terminator.\r
**/\r
-\r
-STATIC\r
UINTN\r
InternalPrint (\r
- IN CONST CHAR16 *Format,\r
- IN EFI_SIMPLE_TEXT_OUT_PROTOCOL *Console,\r
- IN VA_LIST Marker\r
+ IN CONST CHAR16 *Format,\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console,\r
+ IN VA_LIST Marker\r
)\r
{\r
UINTN Return;\r
UINTN BufferSize;\r
\r
ASSERT (Format != NULL);\r
- ASSERT (((UINTN) Format & 0x01) == 0);\r
+ ASSERT (((UINTN) Format & BIT0) == 0);\r
\r
BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);\r
- \r
+\r
Buffer = (CHAR16 *) AllocatePool(BufferSize);\r
ASSERT (Buffer != NULL);\r
\r
Return = UnicodeVSPrint (Buffer, BufferSize, Format, Marker);\r
\r
- if (Console != NULL) {\r
+ if (Console != NULL && Return > 0) {\r
//\r
- // To be extra safe make sure ConOut has been initialized\r
+ // To be extra safe make sure Console has been initialized\r
//\r
Console->OutputString (Console, Buffer);\r
}\r
\r
FreePool (Buffer);\r
\r
- return Return; \r
+ return Return;\r
}\r
\r
-/** \r
- Prints a formatted Unicode string to the console output device specified by \r
+/**\r
+ Prints a formatted Unicode string to the console output device specified by\r
ConOut defined in the EFI_SYSTEM_TABLE.\r
\r
- This function prints a formatted Unicode string to the console output device \r
- specified by ConOut in EFI_SYSTEM_TABLE and returns the number of Unicode \r
- characters that printed to ConOut. If the length of the formatted Unicode \r
- string is greater than PcdUefiLibMaxPrintBufferSize, then only the first \r
+ This function prints a formatted Unicode string to the console output device\r
+ specified by ConOut in EFI_SYSTEM_TABLE and returns the number of Unicode\r
+ characters that printed to ConOut. If the length of the formatted Unicode\r
+ string is greater than PcdUefiLibMaxPrintBufferSize, then only the first\r
PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.\r
-\r
- @param Format Null-terminated Unicode format string.\r
- @param ... VARARG list consumed to process Format.\r
If Format is NULL, then ASSERT().\r
If Format is not aligned on a 16-bit boundary, then ASSERT().\r
\r
+ @param Format Null-terminated Unicode format string.\r
+ @param ... Variable argument list whose contents are accessed based \r
+ on the format string specified by Format.\r
+ \r
+ @return The number of Unicode characters in the produced\r
+ output buffer not including the Null-terminator.\r
+\r
**/\r
UINTN\r
EFIAPI\r
return Return;\r
}\r
\r
-/** \r
- Prints a formatted Unicode string to the console output device specified by \r
+/**\r
+ Prints a formatted Unicode string to the console output device specified by\r
StdErr defined in the EFI_SYSTEM_TABLE.\r
\r
- This function prints a formatted Unicode string to the console output device \r
- specified by StdErr in EFI_SYSTEM_TABLE and returns the number of Unicode \r
- characters that printed to StdErr. If the length of the formatted Unicode \r
- string is greater than PcdUefiLibMaxPrintBufferSize, then only the first \r
+ This function prints a formatted Unicode string to the console output device\r
+ specified by StdErr in EFI_SYSTEM_TABLE and returns the number of Unicode\r
+ characters that printed to StdErr. If the length of the formatted Unicode\r
+ string is greater than PcdUefiLibMaxPrintBufferSize, then only the first\r
PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.\r
-\r
- @param Format Null-terminated Unicode format string.\r
- @param ... VARARG list consumed to process Format.\r
If Format is NULL, then ASSERT().\r
If Format is not aligned on a 16-bit boundary, then ASSERT().\r
\r
-**/\r
+ @param Format Null-terminated Unicode format string.\r
+ @param ... Variable argument list whose contents are accessed based \r
+ on the format string specified by Format.\r
\r
+ @return The number of Unicode characters in the produced\r
+ output buffer not including the Null-terminator.\r
+**/\r
UINTN\r
EFIAPI\r
ErrorPrint (\r
}\r
\r
\r
-/** \r
- Internal function which prints a formatted ASCII string to the console output device \r
+/**\r
+ Internal function which prints a formatted ASCII string to the console output device\r
specified by Console\r
\r
- This function prints a formatted ASCII string to the console output device \r
- specified by Console and returns the number of ASCII characters that printed \r
- to it. If the length of the formatted ASCII string is greater than PcdUefiLibMaxPrintBufferSize, \r
+ This function prints a formatted ASCII string to the console output device\r
+ specified by Console and returns the number of ASCII characters that printed\r
+ to it. If the length of the formatted ASCII string is greater than PcdUefiLibMaxPrintBufferSize,\r
then only the first PcdUefiLibMaxPrintBufferSize characters are sent to Console.\r
\r
+ If Format is NULL, then ASSERT().\r
+\r
@param Format Null-terminated ASCII format string.\r
@param Console The output console.\r
@param Marker VA_LIST marker for the variable argument list.\r
- \r
- If Format is NULL, then ASSERT().\r
- \r
-**/\r
\r
-STATIC\r
+ @return The number of Unicode characters in the produced\r
+ output buffer not including the Null-terminator.\r
+\r
+**/\r
UINTN\r
AsciiInternalPrint (\r
- IN CONST CHAR8 *Format,\r
- IN EFI_SIMPLE_TEXT_OUT_PROTOCOL *Console,\r
- IN VA_LIST Marker\r
+ IN CONST CHAR8 *Format,\r
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console,\r
+ IN VA_LIST Marker\r
)\r
{\r
UINTN Return;\r
ASSERT (Format != NULL);\r
\r
BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);\r
- \r
+\r
Buffer = (CHAR16 *) AllocatePool(BufferSize);\r
ASSERT (Buffer != NULL);\r
\r
\r
if (Console != NULL) {\r
//\r
- // To be extra safe make sure ConOut has been initialized\r
+ // To be extra safe make sure Console has been initialized\r
//\r
Console->OutputString (Console, Buffer);\r
}\r
\r
FreePool (Buffer);\r
\r
- return Return; \r
+ return Return;\r
}\r
\r
-/** \r
- Prints a formatted ASCII string to the console output device specified by \r
+/**\r
+ Prints a formatted ASCII string to the console output device specified by\r
ConOut defined in the EFI_SYSTEM_TABLE.\r
\r
- This function prints a formatted ASCII string to the console output device \r
- specified by ConOut in EFI_SYSTEM_TABLE and returns the number of ASCII \r
- characters that printed to ConOut. If the length of the formatted ASCII \r
- string is greater than PcdUefiLibMaxPrintBufferSize, then only the first \r
+ This function prints a formatted ASCII string to the console output device\r
+ specified by ConOut in EFI_SYSTEM_TABLE and returns the number of ASCII\r
+ characters that printed to ConOut. If the length of the formatted ASCII\r
+ string is greater than PcdUefiLibMaxPrintBufferSize, then only the first\r
PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.\r
+ If Format is NULL, then ASSERT().\r
\r
@param Format Null-terminated ASCII format string.\r
- @param ... VARARG list consumed to process Format.\r
- If Format is NULL, then ASSERT().\r
- If Format is not aligned on a 16-bit boundary, then ASSERT().\r
+ @param ... Variable argument list whose contents are accessed based \r
+ on the format string specified by Format.\r
+ \r
+ @return The number of Ascii characters in the produced\r
+ output buffer not including the Null-terminator.\r
\r
**/\r
UINTN\r
{\r
VA_LIST Marker;\r
UINTN Return;\r
-\r
+ ASSERT (Format != NULL);\r
+ \r
VA_START (Marker, Format);\r
\r
Return = AsciiInternalPrint( Format, gST->ConOut, Marker);\r
return Return;\r
}\r
\r
-/** \r
- Prints a formatted ASCII string to the console output device specified by \r
+/**\r
+ Prints a formatted ASCII string to the console output device specified by\r
StdErr defined in the EFI_SYSTEM_TABLE.\r
\r
- This function prints a formatted ASCII string to the console output device \r
- specified by StdErr in EFI_SYSTEM_TABLE and returns the number of ASCII \r
- characters that printed to StdErr. If the length of the formatted ASCII \r
- string is greater than PcdUefiLibMaxPrintBufferSize, then only the first \r
+ This function prints a formatted ASCII string to the console output device\r
+ specified by StdErr in EFI_SYSTEM_TABLE and returns the number of ASCII\r
+ characters that printed to StdErr. If the length of the formatted ASCII\r
+ string is greater than PcdUefiLibMaxPrintBufferSize, then only the first\r
PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.\r
+ If Format is NULL, then ASSERT().\r
\r
@param Format Null-terminated ASCII format string.\r
- @param ... VARARG list consumed to process Format.\r
- If Format is NULL, then ASSERT().\r
- If Format is not aligned on a 16-bit boundary, then ASSERT().\r
+ @param ... Variable argument list whose contents are accessed based \r
+ on the format string specified by Format.\r
+ \r
+ @return The number of Ascii characters in the produced output\r
+ buffer not including the Null-terminator.\r
\r
**/\r
UINTN\r
VA_LIST Marker;\r
UINTN Return;\r
\r
+ ASSERT (Format != NULL);\r
+ \r
VA_START (Marker, Format);\r
\r
Return = AsciiInternalPrint( Format, gST->StdErr, Marker);\r
return Return;\r
}\r
\r
+/**\r
+ Internal function to print a formatted Unicode string to a graphics console device specified by \r
+ ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates.\r
+\r
+ This function prints a formatted Unicode string to the graphics console device \r
+ specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of \r
+ Unicode characters printed. The EFI_HII_FONT_PROTOCOL is used to convert the \r
+ string to a bitmap using the glyphs registered with the \r
+ HII database. No wrapping is performed, so any portions of the string the fall\r
+ outside the active display region will not be displayed.\r
+\r
+ If a graphics console device is not associated with the ConsoleOutputHandle \r
+ defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.\r
+ If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no \r
+ string is printed, and 0 is returned.\r
+\r
+ @param X X coordinate to print the string.\r
+ @param Y Y coordinate to print the string.\r
+ @param ForeGround The forground color of the string being printed. This is\r
+ an optional parameter that may be NULL. If it is NULL,\r
+ then the foreground color of the current ConOut device\r
+ in the EFI_SYSTEM_TABLE is used.\r
+ @param BackGround The background color of the string being printed. This is\r
+ an optional parameter that may be NULL. If it is NULL, \r
+ then the background color of the current ConOut device\r
+ in the EFI_SYSTEM_TABLE is used.\r
+ @param Buffer Null-terminated Unicode formatted string.\r
+ @param PrintNum The number of Unicode formatted string to be printed.\r
+\r
+ @return Number of Unicode Characters printed. Zero means no any character \r
+ displayed successfully.\r
+\r
+**/\r
+UINTN\r
+InternalPrintGraphic (\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 *Buffer,\r
+ IN UINTN PrintNum\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN Index;\r
+ CHAR16 *UnicodeWeight;\r
+ UINT32 HorizontalResolution;\r
+ UINT32 VerticalResolution;\r
+ UINT32 ColorDepth;\r
+ UINT32 RefreshRate;\r
+ UINTN LineBufferLen;\r
+ EFI_HII_FONT_PROTOCOL *HiiFont;\r
+ EFI_IMAGE_OUTPUT *Blt;\r
+ EFI_FONT_DISPLAY_INFO FontInfo;\r
+ EFI_HII_ROW_INFO *RowInfoArray;\r
+ UINTN RowInfoArraySize;\r
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
+ EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Sto;\r
+ EFI_HANDLE ConsoleHandle;\r
+\r
+ HorizontalResolution = 0;\r
+ VerticalResolution = 0;\r
+ Blt = NULL;\r
+\r
+ ConsoleHandle = gST->ConsoleOutHandle;\r
+\r
+ Status = gBS->HandleProtocol (\r
+ ConsoleHandle,\r
+ &gEfiGraphicsOutputProtocolGuid,\r
+ (VOID **) &GraphicsOutput\r
+ );\r
+\r
+ UgaDraw = NULL;\r
+ if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {\r
+ //\r
+ // If no GOP available, try to open UGA Draw protocol if supported.\r
+ //\r
+ GraphicsOutput = NULL;\r
+\r
+ Status = gBS->HandleProtocol (\r
+ ConsoleHandle,\r
+ &gEfiUgaDrawProtocolGuid,\r
+ (VOID **) &UgaDraw\r
+ );\r
+ }\r
+ if (EFI_ERROR (Status)) {\r
+ return 0;\r
+ }\r
+\r
+ Status = gBS->HandleProtocol (\r
+ ConsoleHandle,\r
+ &gEfiSimpleTextOutProtocolGuid,\r
+ (VOID **) &Sto\r
+ );\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return 0;\r
+ }\r
+\r
+ if (GraphicsOutput != NULL) {\r
+ HorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution;\r
+ VerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution;\r
+ } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {\r
+ UgaDraw->GetMode (UgaDraw, &HorizontalResolution, &VerticalResolution, &ColorDepth, &RefreshRate);\r
+ } else {\r
+ Status = EFI_UNSUPPORTED;\r
+ goto Error;\r
+ }\r
+\r
+ ASSERT ((HorizontalResolution != 0) && (VerticalResolution !=0));\r
+\r
+ Status = gBS->LocateProtocol (&gEfiHiiFontProtocolGuid, NULL, (VOID **) &HiiFont);\r
+ if (EFI_ERROR (Status)) {\r
+ goto Error;\r
+ }\r
+\r
+ UnicodeWeight = 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
+ 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) * PrintNum > LineBufferLen) {\r
+ Status = EFI_INVALID_PARAMETER;\r
+ goto Error;\r
+ }\r
+\r
+ Blt = (EFI_IMAGE_OUTPUT *) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT));\r
+ ASSERT (Blt != NULL);\r
+\r
+ Blt->Width = (UINT16) (HorizontalResolution);\r
+ Blt->Height = (UINT16) (VerticalResolution);\r
+\r
+ ZeroMem (&FontInfo, sizeof (EFI_FONT_DISPLAY_INFO));\r
+\r
+ if (Foreground != NULL) {\r
+ CopyMem (&FontInfo.ForegroundColor, Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
+ } else {\r
+ CopyMem (\r
+ &FontInfo.ForegroundColor,\r
+ &mEfiColors[Sto->Mode->Attribute & 0x0f],\r
+ sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
+ );\r
+ }\r
+ if (Background != NULL) {\r
+ CopyMem (&FontInfo.BackgroundColor, Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
+ } else {\r
+ CopyMem (\r
+ &FontInfo.BackgroundColor,\r
+ &mEfiColors[Sto->Mode->Attribute >> 4],\r
+ sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
+ );\r
+ }\r
+\r
+ if (GraphicsOutput != NULL) {\r
+ Blt->Image.Screen = GraphicsOutput;\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 if (FeaturePcdGet (PcdUgaConsumeSupport)) {\r
+ ASSERT (UgaDraw!= NULL);\r
+\r
+ Blt->Image.Bitmap = AllocateZeroPool (Blt->Width * Blt->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
+ ASSERT (Blt->Image.Bitmap != NULL);\r
+\r
+ RowInfoArray = NULL;\r
+ //\r
+ // StringToImage only support blt'ing image to device using GOP protocol. If GOP is not supported in this platform,\r
+ // we ask StringToImage to print the string to blt buffer, then blt to device using UgaDraw.\r
+ //\r
+ Status = HiiFont->StringToImage (\r
+ HiiFont,\r
+ EFI_HII_IGNORE_IF_NO_GLYPH,\r
+ Buffer,\r
+ &FontInfo,\r
+ &Blt,\r
+ X,\r
+ Y,\r
+ &RowInfoArray,\r
+ &RowInfoArraySize,\r
+ NULL\r
+ );\r
+\r
+ if (!EFI_ERROR (Status)) {\r
+ ASSERT (RowInfoArray != NULL);\r
+ //\r
+ // Line breaks are handled by caller of DrawUnicodeWeightAtCursorN, so the updated parameter RowInfoArraySize by StringToImage will\r
+ // always be 1 or 0 (if there is no valid Unicode Char can be printed). ASSERT here to make sure.\r
+ //\r
+ ASSERT (RowInfoArraySize <= 1);\r
+\r
+ Status = UgaDraw->Blt (\r
+ UgaDraw,\r
+ (EFI_UGA_PIXEL *) Blt->Image.Bitmap,\r
+ EfiUgaBltBufferToVideo,\r
+ X,\r
+ Y,\r
+ X,\r
+ Y,\r
+ RowInfoArray[0].LineWidth,\r
+ RowInfoArray[0].LineHeight,\r
+ Blt->Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
+ );\r
+ }\r
+\r
+ FreePool (RowInfoArray);\r
+ FreePool (Blt->Image.Bitmap);\r
+\r
+ } else {\r
+ Status = EFI_UNSUPPORTED;\r
+ }\r
+\r
+ FreePool (Blt);\r
+\r
+Error:\r
+ if (EFI_ERROR (Status)) {\r
+ return 0;\r
+ } else {\r
+ return PrintNum;\r
+ }\r
+}\r
+\r
+/**\r
+ Prints a formatted Unicode string to a graphics console device specified by \r
+ ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates.\r
+\r
+ This function prints a formatted Unicode string to the graphics console device \r
+ specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of \r
+ Unicode characters printed. If the length of the formatted Unicode string is\r
+ greater than PcdUefiLibMaxPrintBufferSize, then only the first \r
+ PcdUefiLibMaxPrintBufferSize characters are printed. The EFI_HII_FONT_PROTOCOL\r
+ is used to convert the string to a bitmap using the glyphs registered with the \r
+ HII database. No wrapping is performed, so any portions of the string the fall\r
+ outside the active display region will not be displayed.\r
+\r
+ If a graphics console device is not associated with the ConsoleOutputHandle \r
+ defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.\r
+ If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no \r
+ string is printed, and 0 is returned.\r
+ If Format is NULL, then ASSERT().\r
+ If Format is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+ @param X X coordinate to print the string.\r
+ @param Y Y coordinate to print the string.\r
+ @param ForeGround The forground color of the string being printed. This is\r
+ an optional parameter that may be NULL. If it is NULL,\r
+ then the foreground color of the current ConOut device\r
+ in the EFI_SYSTEM_TABLE is used.\r
+ @param BackGround The background color of the string being printed. This is\r
+ an optional parameter that may be NULL. If it is NULL, \r
+ then the background color of the current ConOut device\r
+ in the EFI_SYSTEM_TABLE is used.\r
+ @param Format Null-terminated Unicode format string. See Print Library \r
+ for the supported format string syntax.\r
+ @param ... Variable argument list whose contents are accessed based on \r
+ the format string specified by Format. \r
+\r
+ @return The number of characters printed.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\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 CONST CHAR16 *Format,\r
+ ...\r
+ )\r
+{\r
+ VA_LIST Marker;\r
+ CHAR16 *Buffer;\r
+ UINTN BufferSize;\r
+ UINTN PrintNum;\r
+ UINTN ReturnNum;\r
+\r
+ ASSERT (Format != NULL);\r
+ ASSERT (((UINTN) Format & BIT0) == 0);\r
+\r
+ VA_START (Marker, Format);\r
+\r
+ BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);\r
+\r
+ Buffer = (CHAR16 *) AllocatePool (BufferSize);\r
+ ASSERT (Buffer != NULL);\r
+ \r
+ PrintNum = UnicodeVSPrint (Buffer, BufferSize, Format, Marker);\r
+\r
+ ReturnNum = InternalPrintGraphic (X, Y, ForeGround, BackGround, Buffer, PrintNum);\r
+\r
+ FreePool (Buffer);\r
+\r
+ return ReturnNum;\r
+}\r
+\r
+/**\r
+ Prints a formatted ASCII string to a graphics console device specified by \r
+ ConsoleOutputHandle defined in the EFI_SYSTEM_TABLE at the given (X,Y) coordinates.\r
+\r
+ This function prints a formatted ASCII string to the graphics console device \r
+ specified by ConsoleOutputHandle in EFI_SYSTEM_TABLE and returns the number of \r
+ Unicode characters printed. If the length of the formatted ASCII string is\r
+ greater than PcdUefiLibMaxPrintBufferSize, then only the first \r
+ PcdUefiLibMaxPrintBufferSize characters are printed. The EFI_HII_FONT_PROTOCOL\r
+ is used to convert the string to a bitmap using the glyphs registered with the \r
+ HII database. No wrapping is performed, so any portions of the string the fall\r
+ outside the active display region will not be displayed.\r
+\r
+ If a graphics console device is not associated with the ConsoleOutputHandle \r
+ defined in the EFI_SYSTEM_TABLE then no string is printed, and 0 is returned.\r
+ If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no \r
+ string is printed, and 0 is returned.\r
+ If Format is NULL, then ASSERT().\r
+\r
+ @param X X coordinate to print the string.\r
+ @param Y Y coordinate to print the string.\r
+ @param ForeGround The forground color of the string being printed. This is\r
+ an optional parameter that may be NULL. If it is NULL,\r
+ then the foreground color of the current ConOut device\r
+ in the EFI_SYSTEM_TABLE is used.\r
+ @param BackGround The background color of the string being printed. This is\r
+ an optional parameter that may be NULL. If it is NULL, \r
+ then the background color of the current ConOut device\r
+ in the EFI_SYSTEM_TABLE is used.\r
+ @param Format Null-terminated ASCII format string. See Print Library \r
+ for the supported format string syntax.\r
+ @param ... Variable argument list whose contents are accessed based on \r
+ the format string specified by Format. \r
+\r
+ @return The number of characters printed.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiPrintXY (\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 CONST CHAR8 *Format,\r
+ ...\r
+ )\r
+{\r
+ VA_LIST Marker;\r
+ CHAR16 *Buffer;\r
+ UINTN BufferSize;\r
+ UINTN PrintNum;\r
+ UINTN ReturnNum;\r
+\r
+ ASSERT (Format != NULL);\r
+\r
+ VA_START (Marker, Format);\r
+\r
+ BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);\r
+\r
+ Buffer = (CHAR16 *) AllocatePool (BufferSize);\r
+ ASSERT (Buffer != NULL);\r
+ \r
+ PrintNum = UnicodeSPrintAsciiFormat (Buffer, BufferSize, Format, Marker);\r
+\r
+ ReturnNum = InternalPrintGraphic (X, Y, ForeGround, BackGround, Buffer, PrintNum);\r
+\r
+ FreePool (Buffer);\r
+ \r
+ return ReturnNum;\r
+}\r
+\r