summaryrefslogtreecommitdiffstats
path: root/MdePkg/Library/UefiLib/UefiLibPrint.c
diff options
context:
space:
mode:
Diffstat (limited to 'MdePkg/Library/UefiLib/UefiLibPrint.c')
-rw-r--r--MdePkg/Library/UefiLib/UefiLibPrint.c257
1 files changed, 131 insertions, 126 deletions
diff --git a/MdePkg/Library/UefiLib/UefiLibPrint.c b/MdePkg/Library/UefiLib/UefiLibPrint.c
index 41db7bdfc3..39edeb7283 100644
--- a/MdePkg/Library/UefiLib/UefiLibPrint.c
+++ b/MdePkg/Library/UefiLib/UefiLibPrint.c
@@ -9,7 +9,7 @@
#include "UefiLibInternal.h"
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_GRAPHICS_OUTPUT_BLT_PIXEL mEfiColors[16] = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GRAPHICS_OUTPUT_BLT_PIXEL mEfiColors[16] = {
{ 0x00, 0x00, 0x00, 0x00 },
{ 0x98, 0x00, 0x00, 0x00 },
{ 0x00, 0x98, 0x00, 0x00 },
@@ -59,17 +59,17 @@ InternalPrint (
UINTN BufferSize;
ASSERT (Format != NULL);
- ASSERT (((UINTN) Format & BIT0) == 0);
+ ASSERT (((UINTN)Format & BIT0) == 0);
ASSERT (Console != NULL);
BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);
- Buffer = (CHAR16 *) AllocatePool(BufferSize);
+ Buffer = (CHAR16 *)AllocatePool (BufferSize);
ASSERT (Buffer != NULL);
Return = UnicodeVSPrint (Buffer, BufferSize, Format, Marker);
- if (Console != NULL && Return > 0) {
+ if ((Console != NULL) && (Return > 0)) {
//
// To be extra safe make sure Console has been initialized
//
@@ -111,8 +111,8 @@ Print (
...
)
{
- VA_LIST Marker;
- UINTN Return;
+ VA_LIST Marker;
+ UINTN Return;
VA_START (Marker, Format);
@@ -150,19 +150,18 @@ ErrorPrint (
...
)
{
- VA_LIST Marker;
- UINTN Return;
+ VA_LIST Marker;
+ UINTN Return;
VA_START (Marker, Format);
- Return = InternalPrint( Format, gST->StdErr, Marker);
+ Return = InternalPrint (Format, gST->StdErr, Marker);
VA_END (Marker);
return Return;
}
-
/**
Internal function which prints a formatted ASCII string to the console output device
specified by Console
@@ -199,7 +198,7 @@ AsciiInternalPrint (
BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);
- Buffer = (CHAR16 *) AllocatePool(BufferSize);
+ Buffer = (CHAR16 *)AllocatePool (BufferSize);
ASSERT (Buffer != NULL);
Return = UnicodeVSPrintAsciiFormat (Buffer, BufferSize, Format, Marker);
@@ -245,13 +244,14 @@ AsciiPrint (
...
)
{
- VA_LIST Marker;
- UINTN Return;
+ VA_LIST Marker;
+ UINTN Return;
+
ASSERT (Format != NULL);
VA_START (Marker, Format);
- Return = AsciiInternalPrint( Format, gST->ConOut, Marker);
+ Return = AsciiInternalPrint (Format, gST->ConOut, Marker);
VA_END (Marker);
@@ -284,14 +284,14 @@ AsciiErrorPrint (
...
)
{
- VA_LIST Marker;
- UINTN Return;
+ VA_LIST Marker;
+ UINTN Return;
ASSERT (Format != NULL);
VA_START (Marker, Format);
- Return = AsciiInternalPrint( Format, gST->StdErr, Marker);
+ Return = AsciiInternalPrint (Format, gST->StdErr, Marker);
VA_END (Marker);
@@ -333,45 +333,45 @@ AsciiErrorPrint (
**/
UINTN
InternalPrintGraphic (
- IN UINTN PointX,
- IN UINTN PointY,
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Foreground,
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Background,
- IN CHAR16 *Buffer,
- IN UINTN PrintNum
+ IN UINTN PointX,
+ IN UINTN PointY,
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Foreground,
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Background,
+ IN CHAR16 *Buffer,
+ IN UINTN PrintNum
)
{
- EFI_STATUS Status;
- UINT32 HorizontalResolution;
- UINT32 VerticalResolution;
- UINT32 ColorDepth;
- UINT32 RefreshRate;
- EFI_HII_FONT_PROTOCOL *HiiFont;
- EFI_IMAGE_OUTPUT *Blt;
- EFI_FONT_DISPLAY_INFO FontInfo;
- EFI_HII_ROW_INFO *RowInfoArray;
- UINTN RowInfoArraySize;
- EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
- EFI_UGA_DRAW_PROTOCOL *UgaDraw;
- EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Sto;
- EFI_HANDLE ConsoleHandle;
- UINTN Width;
- UINTN Height;
- UINTN Delta;
-
- HorizontalResolution = 0;
- VerticalResolution = 0;
- Blt = NULL;
- RowInfoArray = NULL;
+ EFI_STATUS Status;
+ UINT32 HorizontalResolution;
+ UINT32 VerticalResolution;
+ UINT32 ColorDepth;
+ UINT32 RefreshRate;
+ EFI_HII_FONT_PROTOCOL *HiiFont;
+ EFI_IMAGE_OUTPUT *Blt;
+ EFI_FONT_DISPLAY_INFO FontInfo;
+ EFI_HII_ROW_INFO *RowInfoArray;
+ UINTN RowInfoArraySize;
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
+ EFI_UGA_DRAW_PROTOCOL *UgaDraw;
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Sto;
+ EFI_HANDLE ConsoleHandle;
+ UINTN Width;
+ UINTN Height;
+ UINTN Delta;
+
+ HorizontalResolution = 0;
+ VerticalResolution = 0;
+ Blt = NULL;
+ RowInfoArray = NULL;
ConsoleHandle = gST->ConsoleOutHandle;
- ASSERT( ConsoleHandle != NULL);
+ ASSERT (ConsoleHandle != NULL);
Status = gBS->HandleProtocol (
ConsoleHandle,
&gEfiGraphicsOutputProtocolGuid,
- (VOID **) &GraphicsOutput
+ (VOID **)&GraphicsOutput
);
UgaDraw = NULL;
@@ -384,9 +384,10 @@ InternalPrintGraphic (
Status = gBS->HandleProtocol (
ConsoleHandle,
&gEfiUgaDrawProtocolGuid,
- (VOID **) &UgaDraw
+ (VOID **)&UgaDraw
);
}
+
if (EFI_ERROR (Status)) {
goto Error;
}
@@ -394,7 +395,7 @@ InternalPrintGraphic (
Status = gBS->HandleProtocol (
ConsoleHandle,
&gEfiSimpleTextOutProtocolGuid,
- (VOID **) &Sto
+ (VOID **)&Sto
);
if (EFI_ERROR (Status)) {
@@ -403,25 +404,25 @@ InternalPrintGraphic (
if (GraphicsOutput != NULL) {
HorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution;
- VerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution;
- } else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {
+ VerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution;
+ } else if ((UgaDraw != NULL) && FeaturePcdGet (PcdUgaConsumeSupport)) {
UgaDraw->GetMode (UgaDraw, &HorizontalResolution, &VerticalResolution, &ColorDepth, &RefreshRate);
} else {
goto Error;
}
- ASSERT ((HorizontalResolution != 0) && (VerticalResolution !=0));
+ ASSERT ((HorizontalResolution != 0) && (VerticalResolution != 0));
- Status = gBS->LocateProtocol (&gEfiHiiFontProtocolGuid, NULL, (VOID **) &HiiFont);
+ Status = gBS->LocateProtocol (&gEfiHiiFontProtocolGuid, NULL, (VOID **)&HiiFont);
if (EFI_ERROR (Status)) {
goto Error;
}
- Blt = (EFI_IMAGE_OUTPUT *) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT));
+ Blt = (EFI_IMAGE_OUTPUT *)AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT));
ASSERT (Blt != NULL);
- Blt->Width = (UINT16) (HorizontalResolution);
- Blt->Height = (UINT16) (VerticalResolution);
+ Blt->Width = (UINT16)(HorizontalResolution);
+ Blt->Height = (UINT16)(VerticalResolution);
ZeroMem (&FontInfo, sizeof (EFI_FONT_DISPLAY_INFO));
@@ -434,6 +435,7 @@ InternalPrintGraphic (
sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
);
}
+
if (Background != NULL) {
CopyMem (&FontInfo.BackgroundColor, Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
} else {
@@ -448,25 +450,24 @@ InternalPrintGraphic (
Blt->Image.Screen = GraphicsOutput;
Status = HiiFont->StringToImage (
- HiiFont,
- EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_OUT_FLAG_CLIP |
- EFI_HII_OUT_FLAG_CLIP_CLEAN_X | EFI_HII_OUT_FLAG_CLIP_CLEAN_Y |
- EFI_HII_IGNORE_LINE_BREAK | EFI_HII_DIRECT_TO_SCREEN,
- Buffer,
- &FontInfo,
- &Blt,
- PointX,
- PointY,
- &RowInfoArray,
- &RowInfoArraySize,
- NULL
- );
+ HiiFont,
+ EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_OUT_FLAG_CLIP |
+ EFI_HII_OUT_FLAG_CLIP_CLEAN_X | EFI_HII_OUT_FLAG_CLIP_CLEAN_Y |
+ EFI_HII_IGNORE_LINE_BREAK | EFI_HII_DIRECT_TO_SCREEN,
+ Buffer,
+ &FontInfo,
+ &Blt,
+ PointX,
+ PointY,
+ &RowInfoArray,
+ &RowInfoArraySize,
+ NULL
+ );
if (EFI_ERROR (Status)) {
goto Error;
}
-
} else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
- ASSERT (UgaDraw!= NULL);
+ ASSERT (UgaDraw != NULL);
//
// Ensure Width * Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) doesn't overflow.
@@ -475,7 +476,7 @@ InternalPrintGraphic (
goto Error;
}
- Blt->Image.Bitmap = AllocateZeroPool ((UINT32) Blt->Width * Blt->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
+ Blt->Image.Bitmap = AllocateZeroPool ((UINT32)Blt->Width * Blt->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
ASSERT (Blt->Image.Bitmap != NULL);
//
@@ -483,19 +484,19 @@ InternalPrintGraphic (
// we ask StringToImage to print the string to blt buffer, then blt to device using UgaDraw.
//
Status = HiiFont->StringToImage (
- HiiFont,
- EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_OUT_FLAG_CLIP |
- EFI_HII_OUT_FLAG_CLIP_CLEAN_X | EFI_HII_OUT_FLAG_CLIP_CLEAN_Y |
- EFI_HII_IGNORE_LINE_BREAK,
- Buffer,
- &FontInfo,
- &Blt,
- PointX,
- PointY,
- &RowInfoArray,
- &RowInfoArraySize,
- NULL
- );
+ HiiFont,
+ EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_OUT_FLAG_CLIP |
+ EFI_HII_OUT_FLAG_CLIP_CLEAN_X | EFI_HII_OUT_FLAG_CLIP_CLEAN_Y |
+ EFI_HII_IGNORE_LINE_BREAK,
+ Buffer,
+ &FontInfo,
+ &Blt,
+ PointX,
+ PointY,
+ &RowInfoArray,
+ &RowInfoArraySize,
+ NULL
+ );
if (!EFI_ERROR (Status)) {
ASSERT (RowInfoArray != NULL);
@@ -514,9 +515,10 @@ InternalPrintGraphic (
Height = 0;
Delta = 0;
}
+
Status = UgaDraw->Blt (
UgaDraw,
- (EFI_UGA_PIXEL *) Blt->Image.Bitmap,
+ (EFI_UGA_PIXEL *)Blt->Image.Bitmap,
EfiUgaBltBufferToVideo,
PointX,
PointY,
@@ -529,10 +531,12 @@ InternalPrintGraphic (
} else {
goto Error;
}
+
FreePool (Blt->Image.Bitmap);
} else {
goto Error;
}
+
//
// Calculate the number of actual printed characters
//
@@ -550,6 +554,7 @@ Error:
if (Blt != NULL) {
FreePool (Blt);
}
+
return 0;
}
@@ -598,28 +603,28 @@ Error:
UINTN
EFIAPI
PrintXY (
- IN UINTN PointX,
- IN UINTN PointY,
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *ForeGround OPTIONAL,
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BackGround OPTIONAL,
- IN CONST CHAR16 *Format,
+ IN UINTN PointX,
+ IN UINTN PointY,
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *ForeGround OPTIONAL,
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BackGround OPTIONAL,
+ IN CONST CHAR16 *Format,
...
)
{
- VA_LIST Marker;
- CHAR16 *Buffer;
- UINTN BufferSize;
- UINTN PrintNum;
- UINTN ReturnNum;
+ VA_LIST Marker;
+ CHAR16 *Buffer;
+ UINTN BufferSize;
+ UINTN PrintNum;
+ UINTN ReturnNum;
ASSERT (Format != NULL);
- ASSERT (((UINTN) Format & BIT0) == 0);
+ ASSERT (((UINTN)Format & BIT0) == 0);
VA_START (Marker, Format);
BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);
- Buffer = (CHAR16 *) AllocatePool (BufferSize);
+ Buffer = (CHAR16 *)AllocatePool (BufferSize);
ASSERT (Buffer != NULL);
PrintNum = UnicodeVSPrint (Buffer, BufferSize, Format, Marker);
@@ -677,19 +682,19 @@ PrintXY (
UINTN
EFIAPI
AsciiPrintXY (
- IN UINTN PointX,
- IN UINTN PointY,
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *ForeGround OPTIONAL,
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BackGround OPTIONAL,
- IN CONST CHAR8 *Format,
+ IN UINTN PointX,
+ IN UINTN PointY,
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *ForeGround OPTIONAL,
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BackGround OPTIONAL,
+ IN CONST CHAR8 *Format,
...
)
{
- VA_LIST Marker;
- CHAR16 *Buffer;
- UINTN BufferSize;
- UINTN PrintNum;
- UINTN ReturnNum;
+ VA_LIST Marker;
+ CHAR16 *Buffer;
+ UINTN BufferSize;
+ UINTN PrintNum;
+ UINTN ReturnNum;
ASSERT (Format != NULL);
@@ -697,7 +702,7 @@ AsciiPrintXY (
BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);
- Buffer = (CHAR16 *) AllocatePool (BufferSize);
+ Buffer = (CHAR16 *)AllocatePool (BufferSize);
ASSERT (Buffer != NULL);
PrintNum = UnicodeSPrintAsciiFormat (Buffer, BufferSize, Format, Marker);
@@ -732,30 +737,30 @@ AsciiPrintXY (
@return Null-terminated Unicode string is that is the formatted
string appended to String.
**/
-CHAR16*
+CHAR16 *
EFIAPI
CatVSPrint (
- IN CHAR16 *String OPTIONAL,
+ IN CHAR16 *String OPTIONAL,
IN CONST CHAR16 *FormatString,
IN VA_LIST Marker
)
{
- UINTN CharactersRequired;
- UINTN SizeRequired;
- CHAR16 *BufferToReturn;
- VA_LIST ExtraMarker;
+ UINTN CharactersRequired;
+ UINTN SizeRequired;
+ CHAR16 *BufferToReturn;
+ VA_LIST ExtraMarker;
VA_COPY (ExtraMarker, Marker);
- CharactersRequired = SPrintLength(FormatString, ExtraMarker);
+ CharactersRequired = SPrintLength (FormatString, ExtraMarker);
VA_END (ExtraMarker);
if (String != NULL) {
- SizeRequired = StrSize(String) + (CharactersRequired * sizeof(CHAR16));
+ SizeRequired = StrSize (String) + (CharactersRequired * sizeof (CHAR16));
} else {
- SizeRequired = sizeof(CHAR16) + (CharactersRequired * sizeof(CHAR16));
+ SizeRequired = sizeof (CHAR16) + (CharactersRequired * sizeof (CHAR16));
}
- BufferToReturn = AllocatePool(SizeRequired);
+ BufferToReturn = AllocatePool (SizeRequired);
if (BufferToReturn == NULL) {
return NULL;
@@ -764,12 +769,12 @@ CatVSPrint (
}
if (String != NULL) {
- StrCpyS(BufferToReturn, SizeRequired / sizeof(CHAR16), String);
+ StrCpyS (BufferToReturn, SizeRequired / sizeof (CHAR16), String);
}
- UnicodeVSPrint(BufferToReturn + StrLen(BufferToReturn), (CharactersRequired+1) * sizeof(CHAR16), FormatString, Marker);
+ UnicodeVSPrint (BufferToReturn + StrLen (BufferToReturn), (CharactersRequired+1) * sizeof (CHAR16), FormatString, Marker);
- ASSERT(StrSize(BufferToReturn)==SizeRequired);
+ ASSERT (StrSize (BufferToReturn) == SizeRequired);
return (BufferToReturn);
}
@@ -800,16 +805,16 @@ CatVSPrint (
CHAR16 *
EFIAPI
CatSPrint (
- IN CHAR16 *String OPTIONAL,
+ IN CHAR16 *String OPTIONAL,
IN CONST CHAR16 *FormatString,
...
)
{
- VA_LIST Marker;
- CHAR16 *NewString;
+ VA_LIST Marker;
+ CHAR16 *NewString;
VA_START (Marker, FormatString);
- NewString = CatVSPrint(String, FormatString, Marker);
+ NewString = CatVSPrint (String, FormatString, Marker);
VA_END (Marker);
return NewString;
}