Mde UEFI library API implementation.\r
Print to StdErr or ConOut defined in EFI_SYSTEM_TABLE\r
\r
- Copyright (c) 2007 - 2008, Intel Corporation<BR>\r
- All rights reserved. This program and the accompanying materials\r
+ Copyright (c) 2007 - 2009, 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
+ 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
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 Format A Null-terminated Unicode format string.\r
@param Console The output console.\r
- @param Marker VA_LIST marker for the variable argument list.\r
+ @param Marker A VA_LIST marker for the variable argument list.\r
\r
@return The number of Unicode characters in the produced\r
- output buffer not including the Null-terminator.\r
+ output buffer, not including the Null-terminator.\r
**/\r
UINTN\r
InternalPrint (\r
IN VA_LIST Marker\r
)\r
{\r
- UINTN Return;\r
- CHAR16 *Buffer;\r
- UINTN BufferSize;\r
+ EFI_STATUS Status;\r
+ UINTN Return;\r
+ CHAR16 *Buffer;\r
+ UINTN BufferSize;\r
\r
ASSERT (Format != NULL);\r
ASSERT (((UINTN) Format & BIT0) == 0);\r
+ ASSERT (Console != NULL);\r
\r
BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);\r
\r
//\r
// To be extra safe make sure Console has been initialized\r
//\r
- Console->OutputString (Console, Buffer);\r
+ Status = Console->OutputString (Console, Buffer);\r
+ if (EFI_ERROR (Status)) {\r
+ Return = 0;\r
+ }\r
}\r
\r
FreePool (Buffer);\r
PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.\r
If Format is NULL, then ASSERT().\r
If Format is not aligned on a 16-bit boundary, then ASSERT().\r
+ If gST->ConOut is NULL, then ASSERT().\r
\r
- @param Format Null-terminated Unicode format string.\r
- @param ... Variable argument list whose contents are accessed based \r
+ @param Format A Null-terminated Unicode format string.\r
+ @param ... A Variable argument list whose contents are accessed based \r
on the format string specified by Format.\r
\r
- @return Number of Unicode characters printed to ConOut.\r
+ @return The number of Unicode characters printed to ConOut.\r
\r
**/\r
UINTN\r
PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.\r
If Format is NULL, then ASSERT().\r
If Format is not aligned on a 16-bit boundary, then ASSERT().\r
+ If gST->StdErr is NULL, then ASSERT().\r
\r
- @param Format Null-terminated Unicode format string.\r
+ @param Format A 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 Number of Unicode characters printed to StdErr.\r
+ @return The number of Unicode characters printed to StdErr.\r
\r
**/\r
UINTN\r
\r
If Format is NULL, then ASSERT().\r
\r
- @param Format Null-terminated ASCII format string.\r
+ @param Format A Null-terminated ASCII format string.\r
@param Console The output console.\r
@param Marker VA_LIST marker for the variable argument list.\r
\r
IN VA_LIST Marker\r
)\r
{\r
- UINTN Return;\r
- CHAR16 *Buffer;\r
- UINTN BufferSize;\r
+ EFI_STATUS Status;\r
+ UINTN Return;\r
+ CHAR16 *Buffer;\r
+ UINTN BufferSize;\r
\r
ASSERT (Format != NULL);\r
+ ASSERT (Console != NULL);\r
\r
BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);\r
\r
//\r
// To be extra safe make sure Console has been initialized\r
//\r
- Console->OutputString (Console, Buffer);\r
+ Status = Console->OutputString (Console, Buffer);\r
+ if (EFI_ERROR (Status)) {\r
+ Return = 0;\r
+ }\r
}\r
\r
FreePool (Buffer);\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
+ If gST->ConOut is NULL, then ASSERT().\r
\r
- @param Format Null-terminated ASCII format string.\r
+ @param Format A Null-terminated ASCII format string.\r
@param ... Variable argument list whose contents are accessed based \r
on the format string specified by Format.\r
\r
- @return Number of ASCII characters printed to ConOut.\r
+ @return The number of ASCII characters printed to ConOut.\r
\r
**/\r
UINTN\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
+ If gST->StdErr is NULL, then ASSERT().\r
\r
- @param Format Null-terminated ASCII format string.\r
+ @param Format A Null-terminated ASCII format string.\r
@param ... Variable argument list whose contents are accessed based \r
on the format string specified by Format.\r
\r
- @return Number of ASCII characters printed to ConErr.\r
+ @return The number of ASCII characters printed to ConErr.\r
\r
**/\r
UINTN\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 PointX X coordinate to print the string.\r
- @param PointY Y coordinate to print the string.\r
+ @param PointX An X coordinate to print the string.\r
+ @param PointY A Y coordinate to print the string.\r
@param Foreground The foreground 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
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 Buffer A 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
+ @return The number of Unicode Characters printed. Zero means no any character\r
displayed successfully.\r
\r
**/\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_UGA_DRAW_PROTOCOL *UgaDraw;\r
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Sto;\r
EFI_HANDLE ConsoleHandle;\r
+ UINTN Width;\r
+ UINTN Height;\r
+ UINTN Delta;\r
\r
HorizontalResolution = 0;\r
VerticalResolution = 0;\r
Blt = NULL;\r
+ RowInfoArray = NULL;\r
\r
ConsoleHandle = gST->ConsoleOutHandle;\r
+ \r
+ ASSERT( ConsoleHandle != NULL);\r
\r
Status = gBS->HandleProtocol (\r
ConsoleHandle,\r
);\r
}\r
if (EFI_ERROR (Status)) {\r
- return 0;\r
+ goto Error;\r
}\r
\r
Status = gBS->HandleProtocol (\r
);\r
\r
if (EFI_ERROR (Status)) {\r
- return 0;\r
+ goto Error;\r
}\r
\r
if (GraphicsOutput != NULL) {\r
} else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {\r
UgaDraw->GetMode (UgaDraw, &HorizontalResolution, &VerticalResolution, &ColorDepth, &RefreshRate);\r
} else {\r
- Status = EFI_UNSUPPORTED;\r
goto Error;\r
}\r
\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
\r
Status = HiiFont->StringToImage (\r
HiiFont,\r
- EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_DIRECT_TO_SCREEN,\r
+ EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_OUT_FLAG_CLIP |\r
+ EFI_HII_OUT_FLAG_CLIP_CLEAN_X | EFI_HII_OUT_FLAG_CLIP_CLEAN_Y |\r
+ EFI_HII_IGNORE_LINE_BREAK | EFI_HII_DIRECT_TO_SCREEN,\r
Buffer,\r
&FontInfo,\r
&Blt,\r
PointX,\r
PointY,\r
- NULL,\r
- NULL,\r
+ &RowInfoArray,\r
+ &RowInfoArraySize,\r
NULL\r
);\r
+ if (EFI_ERROR (Status)) {\r
+ goto Error;\r
+ }\r
\r
} else if (FeaturePcdGet (PcdUgaConsumeSupport)) {\r
ASSERT (UgaDraw!= NULL);\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
+ EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_OUT_FLAG_CLIP |\r
+ EFI_HII_OUT_FLAG_CLIP_CLEAN_X | EFI_HII_OUT_FLAG_CLIP_CLEAN_Y |\r
+ EFI_HII_IGNORE_LINE_BREAK,\r
Buffer,\r
&FontInfo,\r
&Blt,\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
+ // Explicit Line break characters are ignored, 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
+ if (RowInfoArraySize != 0) {\r
+ Width = RowInfoArray[0].LineWidth;\r
+ Height = RowInfoArray[0].LineHeight;\r
+ Delta = Blt->Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);\r
+ } else {\r
+ Width = 0;\r
+ Height = 0;\r
+ Delta = 0;\r
+ }\r
Status = UgaDraw->Blt (\r
UgaDraw,\r
(EFI_UGA_PIXEL *) Blt->Image.Bitmap,\r
PointY,\r
PointX,\r
PointY,\r
- RowInfoArray[0].LineWidth,\r
- RowInfoArray[0].LineHeight,\r
- Blt->Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
+ Width,\r
+ Height,\r
+ Delta\r
);\r
+ } else {\r
+ goto Error;\r
}\r
-\r
- FreePool (RowInfoArray);\r
FreePool (Blt->Image.Bitmap);\r
-\r
} else {\r
- Status = EFI_UNSUPPORTED;\r
+ goto Error;\r
+ }\r
+ //\r
+ // Calculate the number of actual printed characters\r
+ //\r
+ if (RowInfoArraySize != 0) {\r
+ PrintNum = RowInfoArray[0].EndIndex - RowInfoArray[0].StartIndex + 1;\r
+ } else {\r
+ PrintNum = 0;\r
}\r
\r
+ FreePool (RowInfoArray);\r
FreePool (Blt);\r
+ return PrintNum;\r
\r
Error:\r
- if (EFI_ERROR (Status)) {\r
- return 0;\r
- } else {\r
- return PrintNum;\r
+ if (Blt != NULL) {\r
+ FreePool (Blt);\r
}\r
+ return 0;\r
}\r
\r
/**\r
Unicode characters displayed, not including partial characters that may be clipped \r
by the right edge of the display. If the length of the formatted Unicode string is\r
greater than PcdUefiLibMaxPrintBufferSize, then at most 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
+ PcdUefiLibMaxPrintBufferSize characters are printed.The EFI_HII_FONT_PROTOCOL\r
+ StringToImage() service is used to convert the string to a bitmap using the glyphs \r
+ registered with the HII database. No wrapping is performed, so any portions of the \r
+ string the fall outside the active display region will not be displayed. Please see \r
+ Section 27.2.6 of the UEFI Specification for a description of the supported string\r
+ format including the set of control codes supported by the StringToImage() service.\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
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
+ If gST->ConsoleOutputHandle is NULL, then ASSERT().\r
\r
- @param PointX X coordinate to print the string.\r
- @param PointY Y coordinate to print the string.\r
+ @param PointX An X coordinate to print the string.\r
+ @param PointY A Y coordinate to print the string.\r
@param ForeGround The foreground 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
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
+ @param Format A 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
+ @param ... A Variable argument list whose contents are accessed based on \r
the format string specified by Format. \r
\r
@return The number of Unicode characters printed.\r
ASCII characters displayed, not including partial characters that may be clipped \r
by the right edge of the display. If the length of the formatted ASCII string is\r
greater than PcdUefiLibMaxPrintBufferSize, then at most 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
+ PcdUefiLibMaxPrintBufferSize characters are printed.The EFI_HII_FONT_PROTOCOL\r
+ StringToImage() service is used to convert the string to a bitmap using the glyphs \r
+ registered with the HII database. No wrapping is performed, so any portions of the \r
+ string the fall outside the active display region will not be displayed. Please see \r
+ Section 27.2.6 of the UEFI Specification for a description of the supported string\r
+ format including the set of control codes supported by the StringToImage() service.\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 gST->ConsoleOutputHandle is NULL, then ASSERT().\r
\r
- @param PointX X coordinate to print the string.\r
- @param PointY Y coordinate to print the string.\r
+ @param PointX An X coordinate to print the string.\r
+ @param PointY A Y coordinate to print the string.\r
@param ForeGround The foreground 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
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
+ @param Format A 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