2 Library supports diplaying graphical splash screen,
3 locking of keyboard input and printing character on
4 screen. These basic graphics operations are based on UEFI HII,
5 Graphics Output protocol or UGA Draw protocol.
7 Copyright (c) 2006 - 2008, Intel Corporation
8 All rights reserved. This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 #include <Protocol/SimpleTextOut.h>
22 #include <Protocol/OEMBadging.h>
23 #include <Protocol/ConsoleControl.h>
24 #include <Protocol/GraphicsOutput.h>
25 #include <Protocol/FirmwareVolume2.h>
26 #include <Protocol/UgaDraw.h>
27 #include <Protocol/HiiFont.h>
28 #include <Protocol/HiiImage.h>
32 #include <Library/GraphicsLib.h>
33 #include <Library/PrintLib.h>
34 #include <Library/BaseLib.h>
35 #include <Library/MemoryAllocationLib.h>
36 #include <Library/UefiBootServicesTableLib.h>
37 #include <Library/DebugLib.h>
38 #include <Library/BaseMemoryLib.h>
39 #include <Library/DxePiLib.h>
40 #include <Library/PcdLib.h>
42 STATIC EFI_GRAPHICS_OUTPUT_BLT_PIXEL mEfiColors
[16] = {
43 { 0x00, 0x00, 0x00, 0x00 },
44 { 0x98, 0x00, 0x00, 0x00 },
45 { 0x00, 0x98, 0x00, 0x00 },
46 { 0x98, 0x98, 0x00, 0x00 },
47 { 0x00, 0x00, 0x98, 0x00 },
48 { 0x98, 0x00, 0x98, 0x00 },
49 { 0x00, 0x98, 0x98, 0x00 },
50 { 0x98, 0x98, 0x98, 0x00 },
51 { 0x10, 0x10, 0x10, 0x00 },
52 { 0xff, 0x10, 0x10, 0x00 },
53 { 0x10, 0xff, 0x10, 0x00 },
54 { 0xff, 0xff, 0x10, 0x00 },
55 { 0x10, 0x10, 0xff, 0x00 },
56 { 0xf0, 0x10, 0xff, 0x00 },
57 { 0x10, 0xff, 0xff, 0x00 },
58 { 0xff, 0xff, 0xff, 0x00 }
63 Return the graphics image file named FileNameGuid into Image and return it's
64 size in ImageSize. All Firmware Volumes (FV) in the system are searched for the
67 @param FileNameGuid File Name of graphics file in the FV(s).
68 @param Image Pointer to pointer to return graphics image. If NULL, a
69 buffer will be allocated.
70 @param ImageSize Size of the graphics Image in bytes. Zero if no image found.
72 @retval EFI_SUCCESS Image and ImageSize are valid.
73 @retval EFI_BUFFER_TOO_SMALL Image not big enough. ImageSize has required size
74 @retval EFI_NOT_FOUND FileNameGuid not found
79 GetGraphicsBitMapFromFV (
80 IN EFI_GUID
*FileNameGuid
,
85 return GetGraphicsBitMapFromFVEx (NULL
, FileNameGuid
, Image
, ImageSize
);
89 Return the graphics image file named FileNameGuid into Image and return it's
90 size in ImageSize. All Firmware Volumes (FV) in the system are searched for the
93 @param ImageHandle The driver image handle of the caller. The parameter is used to
94 optimize the loading of the image file so that the FV from which
95 the driver image is loaded will be tried first.
96 @param FileNameGuid File Name of graphics file in the FV(s).
97 @param Image Pointer to pointer to return graphics image. If NULL, a
98 buffer will be allocated.
99 @param ImageSize Size of the graphics Image in bytes. Zero if no image found.
101 @retval EFI_SUCCESS Image and ImageSize are valid.
102 @retval EFI_BUFFER_TOO_SMALL Image not big enough. ImageSize has required size
103 @retval EFI_NOT_FOUND FileNameGuid not found
108 GetGraphicsBitMapFromFVEx (
109 IN EFI_HANDLE ImageHandle
,
110 IN EFI_GUID
*FileNameGuid
,
115 return PiLibGetSectionFromAnyFv (
125 Convert a *.BMP graphics image to a GOP blt buffer. If a NULL Blt buffer
126 is passed in a GopBlt buffer will be allocated by this routine. If a GopBlt
127 buffer is passed in it will be used if it is big enough.
129 @param BmpImage Pointer to BMP file
130 @param BmpImageSize Number of bytes in BmpImage
131 @param GopBlt Buffer containing GOP version of BmpImage.
132 @param GopBltSize Size of GopBlt in bytes.
133 @param PixelHeight Height of GopBlt/BmpImage in pixels
134 @param PixelWidth Width of GopBlt/BmpImage in pixels
136 @retval EFI_SUCCESS GopBlt and GopBltSize are returned.
137 @retval EFI_UNSUPPORTED BmpImage is not a valid *.BMP image
138 @retval EFI_BUFFER_TOO_SMALL The passed in GopBlt buffer is not big enough.
139 GopBltSize will contain the required size.
140 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate.
147 IN UINTN BmpImageSize
,
148 IN OUT VOID
**GopBlt
,
149 IN OUT UINTN
*GopBltSize
,
150 OUT UINTN
*PixelHeight
,
151 OUT UINTN
*PixelWidth
156 BMP_IMAGE_HEADER
*BmpHeader
;
157 BMP_COLOR_MAP
*BmpColorMap
;
158 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BltBuffer
;
159 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Blt
;
167 BmpHeader
= (BMP_IMAGE_HEADER
*) BmpImage
;
169 if (BmpHeader
->CharB
!= 'B' || BmpHeader
->CharM
!= 'M') {
170 return EFI_UNSUPPORTED
;
174 // Doesn't support compress.
176 if (BmpHeader
->CompressionType
!= 0) {
177 return EFI_UNSUPPORTED
;
181 // Calculate Color Map offset in the image.
184 BmpColorMap
= (BMP_COLOR_MAP
*) (Image
+ sizeof (BMP_IMAGE_HEADER
));
187 // Calculate graphics image data address in the image
189 Image
= ((UINT8
*) BmpImage
) + BmpHeader
->ImageOffset
;
193 // Calculate the BltBuffer needed size.
195 BltBufferSize
= BmpHeader
->PixelWidth
* BmpHeader
->PixelHeight
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
);
197 if (*GopBlt
== NULL
) {
199 // GopBlt is not allocated by caller.
201 *GopBltSize
= BltBufferSize
;
202 *GopBlt
= AllocatePool (*GopBltSize
);
204 if (*GopBlt
== NULL
) {
205 return EFI_OUT_OF_RESOURCES
;
209 // GopBlt has been allocated by caller.
211 if (*GopBltSize
< BltBufferSize
) {
212 *GopBltSize
= BltBufferSize
;
213 return EFI_BUFFER_TOO_SMALL
;
217 *PixelWidth
= BmpHeader
->PixelWidth
;
218 *PixelHeight
= BmpHeader
->PixelHeight
;
221 // Convert image from BMP to Blt buffer format
224 for (Height
= 0; Height
< BmpHeader
->PixelHeight
; Height
++) {
225 Blt
= &BltBuffer
[(BmpHeader
->PixelHeight
- Height
- 1) * BmpHeader
->PixelWidth
];
226 for (Width
= 0; Width
< BmpHeader
->PixelWidth
; Width
++, Image
++, Blt
++) {
227 switch (BmpHeader
->BitPerPixel
) {
230 // Convert 1-bit (2 colors) BMP to 24-bit color
232 for (Index
= 0; Index
< 8 && Width
< BmpHeader
->PixelWidth
; Index
++) {
233 Blt
->Red
= BmpColorMap
[((*Image
) >> (7 - Index
)) & 0x1].Red
;
234 Blt
->Green
= BmpColorMap
[((*Image
) >> (7 - Index
)) & 0x1].Green
;
235 Blt
->Blue
= BmpColorMap
[((*Image
) >> (7 - Index
)) & 0x1].Blue
;
246 // Convert 4-bit (16 colors) BMP Palette to 24-bit color
248 Index
= (*Image
) >> 4;
249 Blt
->Red
= BmpColorMap
[Index
].Red
;
250 Blt
->Green
= BmpColorMap
[Index
].Green
;
251 Blt
->Blue
= BmpColorMap
[Index
].Blue
;
252 if (Width
< (BmpHeader
->PixelWidth
- 1)) {
255 Index
= (*Image
) & 0x0f;
256 Blt
->Red
= BmpColorMap
[Index
].Red
;
257 Blt
->Green
= BmpColorMap
[Index
].Green
;
258 Blt
->Blue
= BmpColorMap
[Index
].Blue
;
264 // Convert 8-bit (256 colors) BMP Palette to 24-bit color
266 Blt
->Red
= BmpColorMap
[*Image
].Red
;
267 Blt
->Green
= BmpColorMap
[*Image
].Green
;
268 Blt
->Blue
= BmpColorMap
[*Image
].Blue
;
275 Blt
->Blue
= *Image
++;
276 Blt
->Green
= *Image
++;
282 // Other bit format BMP is not supported.
288 return EFI_UNSUPPORTED
;
294 ImageIndex
= (UINTN
) (Image
- ImageHeader
);
295 if ((ImageIndex
% 4) != 0) {
297 // Bmp Image starts each row on a 32-bit boundary!
299 Image
= Image
+ (4 - (ImageIndex
% 4));
308 Use Console Control Protocol to lock the Console In Spliter virtual handle.
309 This is the ConInHandle and ConIn handle in the EFI system table. All key
310 presses will be ignored until the Password is typed in. The only way to
311 disable the password is to type it in to a ConIn device.
313 @param Password Password used to lock ConIn device.
315 @retval EFI_SUCCESS ConsoleControl has been flipped to graphics and logo
317 @retval EFI_UNSUPPORTED Password not found.
327 EFI_CONSOLE_CONTROL_PROTOCOL
*ConsoleControl
;
329 Status
= gBS
->LocateProtocol (&gEfiConsoleControlProtocolGuid
, NULL
, (VOID
**) &ConsoleControl
);
330 if (EFI_ERROR (Status
)) {
331 return EFI_UNSUPPORTED
;
334 Status
= ConsoleControl
->LockStdIn (ConsoleControl
, Password
);
340 Use Console Control to turn off UGA based Simple Text Out consoles from going
341 to the UGA device. Put up LogoFile on every UGA device that is a console.
343 @param LogoFile File name of logo to display on the center of the screen.
345 @retval EFI_SUCCESS ConsoleControl has been flipped to graphics and logo displayed.
346 @retval EFI_UNSUPPORTED Logo not found.
352 IN EFI_GUID
*LogoFile
355 return EnableQuietBootEx (LogoFile
, NULL
);
359 Use Console Control to turn off UGA based Simple Text Out consoles from going
360 to the UGA device. Put up LogoFile on every UGA device that is a console
362 @param LogoFile File name of logo to display on the center of the screen.
363 @param ImageHandle The driver image handle of the caller. The parameter is used to
364 optimize the loading of the logo file so that the FV from which
365 the driver image is loaded will be tried first.
367 @retval EFI_SUCCESS ConsoleControl has been flipped to graphics and logo displayed.
368 @retval EFI_UNSUPPORTED Logo not found.
374 IN EFI_GUID
*LogoFile
,
375 IN EFI_HANDLE ImageHandle
379 EFI_CONSOLE_CONTROL_PROTOCOL
*ConsoleControl
;
380 EFI_OEM_BADGING_PROTOCOL
*Badging
;
389 EFI_BADGING_FORMAT Format
;
390 EFI_BADGING_DISPLAY_ATTRIBUTE Attribute
;
395 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Blt
;
396 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
399 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
401 Status
= gBS
->LocateProtocol (&gEfiConsoleControlProtocolGuid
, NULL
, (VOID
**) &ConsoleControl
);
402 if (EFI_ERROR (Status
)) {
403 return EFI_UNSUPPORTED
;
408 // Try to open GOP first
410 Status
= gBS
->HandleProtocol (gST
->ConsoleOutHandle
, &gEfiGraphicsOutputProtocolGuid
, (VOID
**) &GraphicsOutput
);
411 if (EFI_ERROR (Status
) && FeaturePcdGet (PcdUgaConsumeSupport
)) {
412 GraphicsOutput
= NULL
;
414 // Open GOP failed, try to open UGA
416 Status
= gBS
->HandleProtocol (gST
->ConsoleOutHandle
, &gEfiUgaDrawProtocolGuid
, (VOID
**) &UgaDraw
);
418 if (EFI_ERROR (Status
)) {
419 return EFI_UNSUPPORTED
;
423 Status
= gBS
->LocateProtocol (&gEfiOEMBadgingProtocolGuid
, NULL
, (VOID
**) &Badging
);
426 // Set console control to graphics mode.
428 Status
= ConsoleControl
->SetMode (ConsoleControl
, EfiConsoleControlScreenGraphics
);
429 if (EFI_ERROR (Status
)) {
430 return EFI_UNSUPPORTED
;
433 if (GraphicsOutput
!= NULL
) {
434 SizeOfX
= GraphicsOutput
->Mode
->Info
->HorizontalResolution
;
435 SizeOfY
= GraphicsOutput
->Mode
->Info
->VerticalResolution
;
436 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
437 Status
= UgaDraw
->GetMode (UgaDraw
, &SizeOfX
, &SizeOfY
, &ColorDepth
, &RefreshRate
);
438 if (EFI_ERROR (Status
)) {
439 return EFI_UNSUPPORTED
;
442 return EFI_UNSUPPORTED
;
450 if (Badging
!= NULL
) {
452 // Get image from OEMBadging protocol.
454 Status
= Badging
->GetImage (
464 if (EFI_ERROR (Status
)) {
469 // Currently only support BMP format.
471 if (Format
!= EfiBadgingFormatBMP
) {
472 SafeFreePool (ImageData
);
477 // Get the specified image from FV.
479 Status
= GetGraphicsBitMapFromFVEx (ImageHandle
, LogoFile
, (VOID
**) &ImageData
, &ImageSize
);
480 if (EFI_ERROR (Status
)) {
481 return EFI_UNSUPPORTED
;
486 Attribute
= EfiBadgingDisplayAttributeCenter
;
490 Status
= ConvertBmpToGopBlt (
498 if (EFI_ERROR (Status
)) {
499 SafeFreePool (ImageData
);
500 if (Badging
== NULL
) {
508 // Caculate the display position according to Attribute.
511 case EfiBadgingDisplayAttributeLeftTop
:
516 case EfiBadgingDisplayAttributeCenterTop
:
517 DestX
= (SizeOfX
- Width
) / 2;
521 case EfiBadgingDisplayAttributeRightTop
:
522 DestX
= (SizeOfX
- Width
- CoordinateX
);
523 DestY
= CoordinateY
;;
526 case EfiBadgingDisplayAttributeCenterRight
:
527 DestX
= (SizeOfX
- Width
- CoordinateX
);
528 DestY
= (SizeOfY
- Height
) / 2;
531 case EfiBadgingDisplayAttributeRightBottom
:
532 DestX
= (SizeOfX
- Width
- CoordinateX
);
533 DestY
= (SizeOfY
- Height
- CoordinateY
);
536 case EfiBadgingDisplayAttributeCenterBottom
:
537 DestX
= (SizeOfX
- Width
) / 2;
538 DestY
= (SizeOfY
- Height
- CoordinateY
);
541 case EfiBadgingDisplayAttributeLeftBottom
:
543 DestY
= (SizeOfY
- Height
- CoordinateY
);
546 case EfiBadgingDisplayAttributeCenterLeft
:
548 DestY
= (SizeOfY
- Height
) / 2;
551 case EfiBadgingDisplayAttributeCenter
:
552 DestX
= (SizeOfX
- Width
) / 2;
553 DestY
= (SizeOfY
- Height
) / 2;
562 if ((DestX
>= 0) && (DestY
>= 0)) {
563 if (GraphicsOutput
!= NULL
) {
564 Status
= GraphicsOutput
->Blt (
574 Width
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
576 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
577 Status
= UgaDraw
->Blt (
579 (EFI_UGA_PIXEL
*) Blt
,
580 EfiUgaBltBufferToVideo
,
587 Width
* sizeof (EFI_UGA_PIXEL
)
590 Status
= EFI_UNSUPPORTED
;
594 SafeFreePool (ImageData
);
597 if (Badging
== NULL
) {
606 Use Console Control to turn on UGA based Simple Text Out consoles. The UGA
607 Simple Text Out screens will now be synced up with all non UGA output devices
609 @retval EFI_SUCCESS UGA devices are back in text mode and synced up.
610 @retval EFI_UNSUPPORTED Logo not found
620 EFI_CONSOLE_CONTROL_PROTOCOL
*ConsoleControl
;
622 Status
= gBS
->LocateProtocol (&gEfiConsoleControlProtocolGuid
, NULL
, (VOID
**) &ConsoleControl
);
623 if (EFI_ERROR (Status
)) {
624 return EFI_UNSUPPORTED
;
628 // Set console control to text mode.
630 return ConsoleControl
->SetMode (ConsoleControl
, EfiConsoleControlScreenText
);
634 Internal display string worker function.
636 @param GraphicsOutput Graphics output protocol interface.
637 @param UgaDraw UGA draw protocol interface.
638 @param Sto Simple text out protocol interface.
639 @param X X coordinate to start printing.
640 @param Y Y coordinate to start printing.
641 @param Foreground Foreground color.
642 @param Background Background color.
643 @param fmt Format string.
644 @param args Print arguments.
646 @return Number of Characters printed. Zero means no any character
647 displayed successfully.
652 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
653 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
,
654 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*Sto
,
657 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Foreground
,
658 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Background
,
666 CHAR16
*UnicodeWeight
;
667 UINT32 HorizontalResolution
;
668 UINT32 VerticalResolution
;
673 EFI_HII_FONT_PROTOCOL
*HiiFont
;
674 EFI_IMAGE_OUTPUT
*Blt
;
675 EFI_FONT_DISPLAY_INFO
*FontInfo
;
676 EFI_HII_ROW_INFO
*RowInfoArray
;
677 UINTN RowInfoArraySize
;
681 // For now, allocate an arbitrarily long buffer
683 Buffer
= AllocateZeroPool (0x10000);
684 if (Buffer
== NULL
) {
688 HorizontalResolution
= 0;
689 VerticalResolution
= 0;
694 if (GraphicsOutput
!= NULL
) {
695 HorizontalResolution
= GraphicsOutput
->Mode
->Info
->HorizontalResolution
;
696 VerticalResolution
= GraphicsOutput
->Mode
->Info
->VerticalResolution
;
697 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
698 UgaDraw
->GetMode (UgaDraw
, &HorizontalResolution
, &VerticalResolution
, &ColorDepth
, &RefreshRate
);
700 Status
= EFI_UNSUPPORTED
;
704 ASSERT ((HorizontalResolution
!= 0) && (VerticalResolution
!=0));
706 Status
= gBS
->LocateProtocol (&gEfiHiiFontProtocolGuid
, NULL
, (VOID
**) &HiiFont
);
707 if (EFI_ERROR (Status
)) {
711 PrintNum
= UnicodeVSPrint (Buffer
, 0x10000, fmt
, args
);
713 UnicodeWeight
= (CHAR16
*) Buffer
;
715 for (Index
= 0; UnicodeWeight
[Index
] != 0; Index
++) {
716 if (UnicodeWeight
[Index
] == CHAR_BACKSPACE
||
717 UnicodeWeight
[Index
] == CHAR_LINEFEED
||
718 UnicodeWeight
[Index
] == CHAR_CARRIAGE_RETURN
) {
719 UnicodeWeight
[Index
] = 0;
723 BufferLen
= StrLen (Buffer
);
725 LineBufferLen
= sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
) * HorizontalResolution
* EFI_GLYPH_HEIGHT
;
726 if (EFI_GLYPH_WIDTH
* EFI_GLYPH_HEIGHT
* sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL
) * BufferLen
> LineBufferLen
) {
727 Status
= EFI_INVALID_PARAMETER
;
731 Blt
= (EFI_IMAGE_OUTPUT
*) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT
));
733 Status
= EFI_OUT_OF_RESOURCES
;
737 Blt
->Width
= (UINT16
) (HorizontalResolution
);
738 Blt
->Height
= (UINT16
) (VerticalResolution
);
740 FontInfo
= (EFI_FONT_DISPLAY_INFO
*) AllocateZeroPool (sizeof (EFI_FONT_DISPLAY_INFO
));
741 if (FontInfo
== NULL
) {
742 Status
= EFI_OUT_OF_RESOURCES
;
745 if (Foreground
!= NULL
) {
746 CopyMem (&FontInfo
->ForegroundColor
, Foreground
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
));
749 &FontInfo
->ForegroundColor
,
750 &mEfiColors
[Sto
->Mode
->Attribute
& 0x0f],
751 sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
754 if (Background
!= NULL
) {
755 CopyMem (&FontInfo
->BackgroundColor
, Background
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
));
758 &FontInfo
->BackgroundColor
,
759 &mEfiColors
[Sto
->Mode
->Attribute
>> 4],
760 sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
764 if (GraphicsOutput
!= NULL
) {
765 Blt
->Image
.Screen
= GraphicsOutput
;
767 Status
= HiiFont
->StringToImage (
769 EFI_HII_IGNORE_IF_NO_GLYPH
| EFI_HII_DIRECT_TO_SCREEN
,
780 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
781 ASSERT (UgaDraw
!= NULL
);
783 Blt
->Image
.Bitmap
= AllocateZeroPool (Blt
->Width
* Blt
->Height
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
));
784 if (Blt
->Image
.Bitmap
== NULL
) {
786 SafeFreePool (Buffer
);
787 return EFI_OUT_OF_RESOURCES
;
792 // StringToImage only support blt'ing image to device using GOP protocol. If GOP is not supported in this platform,
793 // we ask StringToImage to print the string to blt buffer, then blt to device using UgaDraw.
795 Status
= HiiFont
->StringToImage (
797 EFI_HII_IGNORE_IF_NO_GLYPH
,
808 if (!EFI_ERROR (Status
)) {
810 // Line breaks are handled by caller of DrawUnicodeWeightAtCursorN, so the updated parameter RowInfoArraySize by StringToImage will
811 // always be 1 or 0 (if there is no valid Unicode Char can be printed). ASSERT here to make sure.
813 ASSERT (RowInfoArraySize
<= 1);
815 Status
= UgaDraw
->Blt (
817 (EFI_UGA_PIXEL
*) Blt
->Image
.Bitmap
,
818 EfiUgaBltBufferToVideo
,
823 RowInfoArray
[0].LineWidth
,
824 RowInfoArray
[0].LineHeight
,
825 Blt
->Width
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
829 SafeFreePool (RowInfoArray
);
830 SafeFreePool (Blt
->Image
.Bitmap
);
832 Status
= EFI_UNSUPPORTED
;
837 SafeFreePool (FontInfo
);
840 if (EFI_ERROR (Status
)) {
848 Print to graphics screen at the given X,Y coordinates of the graphics screen.
849 see definition of Print to find rules for constructing Fmt.
851 @param X Row to start printing at.
852 @param Y Column to start printing at.
853 @param ForeGround Foreground color.
854 @param BackGround background color.
855 @param Fmt Print format sting. See definition of Print.
856 @param ... Argumnet stream defined by Fmt string.
858 @return Number of Characters printed. Zero means no any character
859 displayed successfully.
867 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*ForeGround
, OPTIONAL
868 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BackGround
, OPTIONAL
874 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
875 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
876 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*Sto
;
880 VA_START (Args
, Fmt
);
882 Handle
= gST
->ConsoleOutHandle
;
884 Status
= gBS
->HandleProtocol (
886 &gEfiGraphicsOutputProtocolGuid
,
887 (VOID
**) &GraphicsOutput
891 if (EFI_ERROR (Status
) && FeaturePcdGet (PcdUgaConsumeSupport
)) {
893 // If no GOP available, try to open UGA Draw protocol if supported.
895 GraphicsOutput
= NULL
;
897 Status
= gBS
->HandleProtocol (
899 &gEfiUgaDrawProtocolGuid
,
903 if (EFI_ERROR (Status
)) {
907 Status
= gBS
->HandleProtocol (
909 &gEfiSimpleTextOutProtocolGuid
,
913 if (EFI_ERROR (Status
)) {
917 return Print (GraphicsOutput
, UgaDraw
, Sto
, X
, Y
, ForeGround
, BackGround
, Fmt
, Args
);