2 BDS Lib functions which contain all the code to connect console device
4 Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "InternalBdsLib.h"
16 #include <IndustryStandard/Bmp.h>
18 #include <Protocol/BootLogo.h>
21 Check if we need to save the EFI variable with "ConVarName" as name
23 If ConVarName is NULL, then ASSERT().
25 @param ConVarName The name of the EFI variable.
27 @retval TRUE Set the EFI variable as NV type.
28 @retval FALSE EFI variable as NV type can be set NonNV.
37 ASSERT (ConVarName
!= NULL
);
42 // If the variable includes "Dev" at last, we consider
43 // it does not support NV attribute.
45 while (*Ptr
!= L
'\0') {
49 if (((INTN
)((UINTN
)Ptr
- (UINTN
)ConVarName
) / sizeof (CHAR16
)) <= 3) {
53 if ((*(Ptr
- 3) == 'D') && (*(Ptr
- 2) == 'e') && (*(Ptr
- 1) == 'v')) {
61 Fill console handle in System Table if there are no valid console handle in.
63 Firstly, check the validation of console handle in System Table. If it is invalid,
64 update it by the first console device handle from EFI console variable.
66 @param VarName The name of the EFI console variable.
67 @param ConsoleGuid Specified Console protocol GUID.
68 @param ConsoleHandle On IN, console handle in System Table to be checked.
69 On OUT, new console hanlde in system table.
70 @param ProtocolInterface On IN, console protocol on console handle in System Table to be checked.
71 On OUT, new console protocol on new console hanlde in system table.
73 @retval TRUE System Table has been updated.
74 @retval FALSE System Table hasn't been updated.
78 UpdateSystemTableConsole (
80 IN EFI_GUID
*ConsoleGuid
,
81 IN OUT EFI_HANDLE
*ConsoleHandle
,
82 IN OUT VOID
**ProtocolInterface
87 EFI_DEVICE_PATH_PROTOCOL
*FullDevicePath
;
88 EFI_DEVICE_PATH_PROTOCOL
*VarConsole
;
89 EFI_DEVICE_PATH_PROTOCOL
*Instance
;
93 ASSERT (VarName
!= NULL
);
94 ASSERT (ConsoleHandle
!= NULL
);
95 ASSERT (ConsoleGuid
!= NULL
);
96 ASSERT (ProtocolInterface
!= NULL
);
98 if (*ConsoleHandle
!= NULL
) {
99 Status
= gBS
->HandleProtocol (
104 if (Status
== EFI_SUCCESS
&& Interface
== *ProtocolInterface
) {
106 // If ConsoleHandle is valid and console protocol on this handle also
107 // also matched, just return.
114 // Get all possible consoles device path from EFI variable
116 VarConsole
= BdsLibGetVariableAndSize (
118 &gEfiGlobalVariableGuid
,
121 if (VarConsole
== NULL
) {
123 // If there is no any console device, just return.
128 FullDevicePath
= VarConsole
;
132 // Check every instance of the console variable
134 Instance
= GetNextDevicePathInstance (&VarConsole
, &DevicePathSize
);
135 if (Instance
== NULL
) {
136 FreePool (FullDevicePath
);
141 // Find console device handle by device path instance
143 Status
= gBS
->LocateDevicePath (
148 if (!EFI_ERROR (Status
)) {
150 // Get the console protocol on this console device handle
152 Status
= gBS
->HandleProtocol (
157 if (!EFI_ERROR (Status
)) {
159 // Update new console handle in System Table.
161 *ConsoleHandle
= NewHandle
;
162 *ProtocolInterface
= Interface
;
167 } while (Instance
!= NULL
);
170 // No any available console devcie found.
176 This function update console variable based on ConVarName, it can
177 add or remove one specific console device path from the variable
179 @param ConVarName Console related variable name, ConIn, ConOut,
181 @param CustomizedConDevicePath The console device path which will be added to
182 the console variable ConVarName, this parameter
183 can not be multi-instance.
184 @param ExclusiveDevicePath The console device path which will be removed
185 from the console variable ConVarName, this
186 parameter can not be multi-instance.
188 @retval EFI_UNSUPPORTED The added device path is same to the removed one.
189 @retval EFI_SUCCESS Success add or remove the device path from the
195 BdsLibUpdateConsoleVariable (
196 IN CHAR16
*ConVarName
,
197 IN EFI_DEVICE_PATH_PROTOCOL
*CustomizedConDevicePath
,
198 IN EFI_DEVICE_PATH_PROTOCOL
*ExclusiveDevicePath
202 EFI_DEVICE_PATH_PROTOCOL
*VarConsole
;
203 UINTN DevicePathSize
;
204 EFI_DEVICE_PATH_PROTOCOL
*NewDevicePath
;
205 EFI_DEVICE_PATH_PROTOCOL
*TempNewDevicePath
;
212 // Notes: check the device path point, here should check
213 // with compare memory
215 if (CustomizedConDevicePath
== ExclusiveDevicePath
) {
216 return EFI_UNSUPPORTED
;
219 // Delete the ExclusiveDevicePath from current default console
221 VarConsole
= BdsLibGetVariableAndSize (
223 &gEfiGlobalVariableGuid
,
228 // Initialize NewDevicePath
230 NewDevicePath
= VarConsole
;
233 // If ExclusiveDevicePath is even the part of the instance in VarConsole, delete it.
234 // In the end, NewDevicePath is the final device path.
236 if (ExclusiveDevicePath
!= NULL
&& VarConsole
!= NULL
) {
237 NewDevicePath
= BdsLibDelPartMatchInstance (VarConsole
, ExclusiveDevicePath
);
240 // Try to append customized device path to NewDevicePath.
242 if (CustomizedConDevicePath
!= NULL
) {
243 if (!BdsLibMatchDevicePaths (NewDevicePath
, CustomizedConDevicePath
)) {
245 // Check if there is part of CustomizedConDevicePath in NewDevicePath, delete it.
247 NewDevicePath
= BdsLibDelPartMatchInstance (NewDevicePath
, CustomizedConDevicePath
);
249 // In the first check, the default console variable will be _ModuleEntryPoint,
250 // just append current customized device path
252 TempNewDevicePath
= NewDevicePath
;
253 NewDevicePath
= AppendDevicePathInstance (NewDevicePath
, CustomizedConDevicePath
);
254 if (TempNewDevicePath
!= NULL
) {
255 FreePool(TempNewDevicePath
);
261 // The attribute for ConInDev, ConOutDev and ErrOutDev does not include NV.
263 if (IsNvNeed(ConVarName
)) {
265 // ConVarName has NV attribute.
267 Attributes
= EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
| EFI_VARIABLE_NON_VOLATILE
;
270 // ConVarName does not have NV attribute.
272 Attributes
= EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
;
276 // Finally, Update the variable of the default console by NewDevicePath
278 DevicePathSize
= GetDevicePathSize (NewDevicePath
);
279 Status
= gRT
->SetVariable (
281 &gEfiGlobalVariableGuid
,
286 if ((DevicePathSize
== 0) && (Status
== EFI_NOT_FOUND
)) {
287 Status
= EFI_SUCCESS
;
289 ASSERT_EFI_ERROR (Status
);
291 if (VarConsole
== NewDevicePath
) {
292 if (VarConsole
!= NULL
) {
293 FreePool(VarConsole
);
296 if (VarConsole
!= NULL
) {
297 FreePool(VarConsole
);
299 if (NewDevicePath
!= NULL
) {
300 FreePool(NewDevicePath
);
310 Connect the console device base on the variable ConVarName, if
311 device path of the ConVarName is multi-instance device path, if
312 anyone of the instances is connected success, then this function
315 @param ConVarName Console related variable name, ConIn, ConOut,
318 @retval EFI_NOT_FOUND There is not any console devices connected
320 @retval EFI_SUCCESS Success connect any one instance of the console
321 device path base on the variable ConVarName.
326 BdsLibConnectConsoleVariable (
327 IN CHAR16
*ConVarName
331 EFI_DEVICE_PATH_PROTOCOL
*StartDevicePath
;
333 EFI_DEVICE_PATH_PROTOCOL
*Instance
;
334 EFI_DEVICE_PATH_PROTOCOL
*Next
;
335 EFI_DEVICE_PATH_PROTOCOL
*CopyOfDevicePath
;
339 Status
= EFI_SUCCESS
;
343 // Check if the console variable exist
345 StartDevicePath
= BdsLibGetVariableAndSize (
347 &gEfiGlobalVariableGuid
,
350 if (StartDevicePath
== NULL
) {
351 return EFI_UNSUPPORTED
;
354 CopyOfDevicePath
= StartDevicePath
;
357 // Check every instance of the console variable
359 Instance
= GetNextDevicePathInstance (&CopyOfDevicePath
, &Size
);
360 if (Instance
== NULL
) {
361 FreePool (StartDevicePath
);
362 return EFI_UNSUPPORTED
;
366 while (!IsDevicePathEndType (Next
)) {
367 Next
= NextDevicePathNode (Next
);
370 SetDevicePathEndNode (Next
);
372 // Connect the USB console
373 // USB console device path is a short-form device path that
374 // starts with the first element being a USB WWID
375 // or a USB Class device path
377 if ((DevicePathType (Instance
) == MESSAGING_DEVICE_PATH
) &&
378 ((DevicePathSubType (Instance
) == MSG_USB_CLASS_DP
)
379 || (DevicePathSubType (Instance
) == MSG_USB_WWID_DP
)
381 Status
= BdsLibConnectUsbDevByShortFormDP (0xFF, Instance
);
382 if (!EFI_ERROR (Status
)) {
387 // Connect the instance device path
389 Status
= BdsLibConnectDevicePath (Instance
);
390 if (EFI_ERROR (Status
)) {
392 // Delete the instance from the console varialbe
394 BdsLibUpdateConsoleVariable (ConVarName
, NULL
, Instance
);
400 } while (CopyOfDevicePath
!= NULL
);
402 FreePool (StartDevicePath
);
405 return EFI_NOT_FOUND
;
413 This function will search every simpletext device in current system,
414 and make every simpletext device as pertantial console device.
419 BdsLibConnectAllConsoles (
424 EFI_DEVICE_PATH_PROTOCOL
*ConDevicePath
;
426 EFI_HANDLE
*HandleBuffer
;
431 ConDevicePath
= NULL
;
434 // Update all the console variables
436 gBS
->LocateHandleBuffer (
438 &gEfiSimpleTextInProtocolGuid
,
444 for (Index
= 0; Index
< HandleCount
; Index
++) {
445 gBS
->HandleProtocol (
447 &gEfiDevicePathProtocolGuid
,
448 (VOID
**) &ConDevicePath
450 BdsLibUpdateConsoleVariable (L
"ConIn", ConDevicePath
, NULL
);
453 if (HandleBuffer
!= NULL
) {
454 FreePool(HandleBuffer
);
458 gBS
->LocateHandleBuffer (
460 &gEfiSimpleTextOutProtocolGuid
,
465 for (Index
= 0; Index
< HandleCount
; Index
++) {
466 gBS
->HandleProtocol (
468 &gEfiDevicePathProtocolGuid
,
469 (VOID
**) &ConDevicePath
471 BdsLibUpdateConsoleVariable (L
"ConOut", ConDevicePath
, NULL
);
472 BdsLibUpdateConsoleVariable (L
"ErrOut", ConDevicePath
, NULL
);
475 if (HandleBuffer
!= NULL
) {
476 FreePool(HandleBuffer
);
480 // Connect all console variables
482 BdsLibConnectAllDefaultConsoles ();
487 This function will connect console device base on the console
488 device variable ConIn, ConOut and ErrOut.
490 @retval EFI_SUCCESS At least one of the ConIn and ConOut device have
491 been connected success.
492 @retval EFI_STATUS Return the status of BdsLibConnectConsoleVariable ().
497 BdsLibConnectAllDefaultConsoles (
502 BOOLEAN SystemTableUpdated
;
505 // Connect all default console variables
509 // It seems impossible not to have any ConOut device on platform,
510 // so we check the status here.
512 Status
= BdsLibConnectConsoleVariable (L
"ConOut");
513 if (EFI_ERROR (Status
)) {
518 // Insert the performance probe for Console Out
520 PERF_START (NULL
, "ConOut", "BDS", 1);
521 PERF_END (NULL
, "ConOut", "BDS", 0);
524 // Because possibly the platform is legacy free, in such case,
525 // ConIn devices (Serial Port and PS2 Keyboard ) does not exist,
526 // so we need not check the status.
528 BdsLibConnectConsoleVariable (L
"ConIn");
531 // The _ModuleEntryPoint err out var is legal.
533 BdsLibConnectConsoleVariable (L
"ErrOut");
535 SystemTableUpdated
= FALSE
;
537 // Fill console handles in System Table if no console device assignd.
539 if (UpdateSystemTableConsole (L
"ConIn", &gEfiSimpleTextInProtocolGuid
, &gST
->ConsoleInHandle
, (VOID
**) &gST
->ConIn
)) {
540 SystemTableUpdated
= TRUE
;
542 if (UpdateSystemTableConsole (L
"ConOut", &gEfiSimpleTextOutProtocolGuid
, &gST
->ConsoleOutHandle
, (VOID
**) &gST
->ConOut
)) {
543 SystemTableUpdated
= TRUE
;
545 if (UpdateSystemTableConsole (L
"ErrOut", &gEfiSimpleTextOutProtocolGuid
, &gST
->StandardErrorHandle
, (VOID
**) &gST
->StdErr
)) {
546 SystemTableUpdated
= TRUE
;
549 if (SystemTableUpdated
) {
551 // Update the CRC32 in the EFI System Table header
554 gBS
->CalculateCrc32 (
566 Convert a *.BMP graphics image to a GOP blt buffer. If a NULL Blt buffer
567 is passed in a GopBlt buffer will be allocated by this routine. If a GopBlt
568 buffer is passed in it will be used if it is big enough.
570 @param BmpImage Pointer to BMP file
571 @param BmpImageSize Number of bytes in BmpImage
572 @param GopBlt Buffer containing GOP version of BmpImage.
573 @param GopBltSize Size of GopBlt in bytes.
574 @param PixelHeight Height of GopBlt/BmpImage in pixels
575 @param PixelWidth Width of GopBlt/BmpImage in pixels
577 @retval EFI_SUCCESS GopBlt and GopBltSize are returned.
578 @retval EFI_UNSUPPORTED BmpImage is not a valid *.BMP image
579 @retval EFI_BUFFER_TOO_SMALL The passed in GopBlt buffer is not big enough.
580 GopBltSize will contain the required size.
581 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate.
587 IN UINTN BmpImageSize
,
588 IN OUT VOID
**GopBlt
,
589 IN OUT UINTN
*GopBltSize
,
590 OUT UINTN
*PixelHeight
,
591 OUT UINTN
*PixelWidth
596 BMP_IMAGE_HEADER
*BmpHeader
;
597 BMP_COLOR_MAP
*BmpColorMap
;
598 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BltBuffer
;
599 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Blt
;
600 UINT64 BltBufferSize
;
607 BmpHeader
= (BMP_IMAGE_HEADER
*) BmpImage
;
609 if (BmpHeader
->CharB
!= 'B' || BmpHeader
->CharM
!= 'M') {
610 return EFI_UNSUPPORTED
;
614 // Doesn't support compress.
616 if (BmpHeader
->CompressionType
!= 0) {
617 return EFI_UNSUPPORTED
;
621 // Calculate Color Map offset in the image.
624 BmpColorMap
= (BMP_COLOR_MAP
*) (Image
+ sizeof (BMP_IMAGE_HEADER
));
627 // Calculate graphics image data address in the image
629 Image
= ((UINT8
*) BmpImage
) + BmpHeader
->ImageOffset
;
633 // Calculate the BltBuffer needed size.
635 BltBufferSize
= MultU64x32 ((UINT64
) BmpHeader
->PixelWidth
, BmpHeader
->PixelHeight
);
637 // Ensure the BltBufferSize * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) doesn't overflow
639 if (BltBufferSize
> DivU64x32 ((UINTN
) ~0, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
))) {
640 return EFI_UNSUPPORTED
;
642 BltBufferSize
= MultU64x32 (BltBufferSize
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
));
645 if (*GopBlt
== NULL
) {
647 // GopBlt is not allocated by caller.
649 *GopBltSize
= (UINTN
) BltBufferSize
;
650 *GopBlt
= AllocatePool (*GopBltSize
);
652 if (*GopBlt
== NULL
) {
653 return EFI_OUT_OF_RESOURCES
;
657 // GopBlt has been allocated by caller.
659 if (*GopBltSize
< (UINTN
) BltBufferSize
) {
660 *GopBltSize
= (UINTN
) BltBufferSize
;
661 return EFI_BUFFER_TOO_SMALL
;
665 *PixelWidth
= BmpHeader
->PixelWidth
;
666 *PixelHeight
= BmpHeader
->PixelHeight
;
669 // Convert image from BMP to Blt buffer format
672 for (Height
= 0; Height
< BmpHeader
->PixelHeight
; Height
++) {
673 Blt
= &BltBuffer
[(BmpHeader
->PixelHeight
- Height
- 1) * BmpHeader
->PixelWidth
];
674 for (Width
= 0; Width
< BmpHeader
->PixelWidth
; Width
++, Image
++, Blt
++) {
675 switch (BmpHeader
->BitPerPixel
) {
678 // Convert 1-bit (2 colors) BMP to 24-bit color
680 for (Index
= 0; Index
< 8 && Width
< BmpHeader
->PixelWidth
; Index
++) {
681 Blt
->Red
= BmpColorMap
[((*Image
) >> (7 - Index
)) & 0x1].Red
;
682 Blt
->Green
= BmpColorMap
[((*Image
) >> (7 - Index
)) & 0x1].Green
;
683 Blt
->Blue
= BmpColorMap
[((*Image
) >> (7 - Index
)) & 0x1].Blue
;
694 // Convert 4-bit (16 colors) BMP Palette to 24-bit color
696 Index
= (*Image
) >> 4;
697 Blt
->Red
= BmpColorMap
[Index
].Red
;
698 Blt
->Green
= BmpColorMap
[Index
].Green
;
699 Blt
->Blue
= BmpColorMap
[Index
].Blue
;
700 if (Width
< (BmpHeader
->PixelWidth
- 1)) {
703 Index
= (*Image
) & 0x0f;
704 Blt
->Red
= BmpColorMap
[Index
].Red
;
705 Blt
->Green
= BmpColorMap
[Index
].Green
;
706 Blt
->Blue
= BmpColorMap
[Index
].Blue
;
712 // Convert 8-bit (256 colors) BMP Palette to 24-bit color
714 Blt
->Red
= BmpColorMap
[*Image
].Red
;
715 Blt
->Green
= BmpColorMap
[*Image
].Green
;
716 Blt
->Blue
= BmpColorMap
[*Image
].Blue
;
723 Blt
->Blue
= *Image
++;
724 Blt
->Green
= *Image
++;
730 // Other bit format BMP is not supported.
736 return EFI_UNSUPPORTED
;
742 ImageIndex
= (UINTN
) (Image
- ImageHeader
);
743 if ((ImageIndex
% 4) != 0) {
745 // Bmp Image starts each row on a 32-bit boundary!
747 Image
= Image
+ (4 - (ImageIndex
% 4));
755 Use SystemTable Conout to stop video based Simple Text Out consoles from going
756 to the video device. Put up LogoFile on every video device that is a console.
758 @param[in] LogoFile File name of logo to display on the center of the screen.
760 @retval EFI_SUCCESS ConsoleControl has been flipped to graphics and logo displayed.
761 @retval EFI_UNSUPPORTED Logo not found
767 IN EFI_GUID
*LogoFile
771 EFI_OEM_BADGING_PROTOCOL
*Badging
;
780 EFI_BADGING_FORMAT Format
;
781 EFI_BADGING_DISPLAY_ATTRIBUTE Attribute
;
786 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Blt
;
787 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
790 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
791 EFI_BOOT_LOGO_PROTOCOL
*BootLogo
;
793 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*LogoBlt
;
805 // Try to open GOP first
807 Status
= gBS
->HandleProtocol (gST
->ConsoleOutHandle
, &gEfiGraphicsOutputProtocolGuid
, (VOID
**) &GraphicsOutput
);
808 if (EFI_ERROR (Status
) && FeaturePcdGet (PcdUgaConsumeSupport
)) {
809 GraphicsOutput
= NULL
;
811 // Open GOP failed, try to open UGA
813 Status
= gBS
->HandleProtocol (gST
->ConsoleOutHandle
, &gEfiUgaDrawProtocolGuid
, (VOID
**) &UgaDraw
);
815 if (EFI_ERROR (Status
)) {
816 return EFI_UNSUPPORTED
;
820 // Try to open Boot Logo Protocol.
823 gBS
->LocateProtocol (&gEfiBootLogoProtocolGuid
, NULL
, (VOID
**) &BootLogo
);
826 // Erase Cursor from screen
828 gST
->ConOut
->EnableCursor (gST
->ConOut
, FALSE
);
831 Status
= gBS
->LocateProtocol (&gEfiOEMBadgingProtocolGuid
, NULL
, (VOID
**) &Badging
);
833 if (GraphicsOutput
!= NULL
) {
834 SizeOfX
= GraphicsOutput
->Mode
->Info
->HorizontalResolution
;
835 SizeOfY
= GraphicsOutput
->Mode
->Info
->VerticalResolution
;
837 } else if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
838 Status
= UgaDraw
->GetMode (UgaDraw
, &SizeOfX
, &SizeOfY
, &ColorDepth
, &RefreshRate
);
839 if (EFI_ERROR (Status
)) {
840 return EFI_UNSUPPORTED
;
843 return EFI_UNSUPPORTED
;
861 if (Badging
!= NULL
) {
863 // Get image from OEMBadging protocol.
865 Status
= Badging
->GetImage (
875 if (EFI_ERROR (Status
)) {
880 // Currently only support BMP format.
882 if (Format
!= EfiBadgingFormatBMP
) {
883 if (ImageData
!= NULL
) {
884 FreePool (ImageData
);
890 // Get the specified image from FV.
892 Status
= GetSectionFromAnyFv (LogoFile
, EFI_SECTION_RAW
, 0, (VOID
**) &ImageData
, &ImageSize
);
893 if (EFI_ERROR (Status
)) {
894 return EFI_UNSUPPORTED
;
899 Attribute
= EfiBadgingDisplayAttributeCenter
;
906 Status
= ConvertBmpToGopBlt (
914 if (EFI_ERROR (Status
)) {
915 FreePool (ImageData
);
917 if (Badging
== NULL
) {
925 // Calculate the display position according to Attribute.
928 case EfiBadgingDisplayAttributeLeftTop
:
933 case EfiBadgingDisplayAttributeCenterTop
:
934 DestX
= (SizeOfX
- Width
) / 2;
938 case EfiBadgingDisplayAttributeRightTop
:
939 DestX
= (SizeOfX
- Width
- CoordinateX
);
940 DestY
= CoordinateY
;;
943 case EfiBadgingDisplayAttributeCenterRight
:
944 DestX
= (SizeOfX
- Width
- CoordinateX
);
945 DestY
= (SizeOfY
- Height
) / 2;
948 case EfiBadgingDisplayAttributeRightBottom
:
949 DestX
= (SizeOfX
- Width
- CoordinateX
);
950 DestY
= (SizeOfY
- Height
- CoordinateY
);
953 case EfiBadgingDisplayAttributeCenterBottom
:
954 DestX
= (SizeOfX
- Width
) / 2;
955 DestY
= (SizeOfY
- Height
- CoordinateY
);
958 case EfiBadgingDisplayAttributeLeftBottom
:
960 DestY
= (SizeOfY
- Height
- CoordinateY
);
963 case EfiBadgingDisplayAttributeCenterLeft
:
965 DestY
= (SizeOfY
- Height
) / 2;
968 case EfiBadgingDisplayAttributeCenter
:
969 DestX
= (SizeOfX
- Width
) / 2;
970 DestY
= (SizeOfY
- Height
) / 2;
979 if ((DestX
>= 0) && (DestY
>= 0)) {
980 if (GraphicsOutput
!= NULL
) {
981 Status
= GraphicsOutput
->Blt (
991 Width
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
993 } else if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
994 Status
= UgaDraw
->Blt (
996 (EFI_UGA_PIXEL
*) Blt
,
997 EfiUgaBltBufferToVideo
,
1004 Width
* sizeof (EFI_UGA_PIXEL
)
1007 Status
= EFI_UNSUPPORTED
;
1011 // Report displayed Logo information.
1013 if (!EFI_ERROR (Status
)) {
1016 if (LogoWidth
== 0) {
1020 LogoDestX
= (UINTN
) DestX
;
1021 LogoDestY
= (UINTN
) DestY
;
1023 LogoHeight
= Height
;
1026 // Merge new logo with old one.
1028 NewDestX
= MIN ((UINTN
) DestX
, LogoDestX
);
1029 NewDestY
= MIN ((UINTN
) DestY
, LogoDestY
);
1030 NewWidth
= MAX ((UINTN
) DestX
+ Width
, LogoDestX
+ LogoWidth
) - NewDestX
;
1031 NewHeight
= MAX ((UINTN
) DestY
+ Height
, LogoDestY
+ LogoHeight
) - NewDestY
;
1033 LogoDestX
= NewDestX
;
1034 LogoDestY
= NewDestY
;
1035 LogoWidth
= NewWidth
;
1036 LogoHeight
= NewHeight
;
1041 FreePool (ImageData
);
1043 if (Badging
== NULL
) {
1049 if (BootLogo
== NULL
|| NumberOfLogos
== 0) {
1051 // No logo displayed.
1061 // Advertise displayed Logo information.
1063 if (NumberOfLogos
== 1) {
1065 // Only one logo displayed, use its Blt buffer directly for BootLogo protocol.
1068 Status
= EFI_SUCCESS
;
1071 // More than one Logo displayed, get merged BltBuffer using VideoToBuffer operation.
1077 LogoBlt
= AllocateZeroPool (LogoWidth
* LogoHeight
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
));
1078 if (LogoBlt
== NULL
) {
1079 return EFI_OUT_OF_RESOURCES
;
1082 if (GraphicsOutput
!= NULL
) {
1083 Status
= GraphicsOutput
->Blt (
1086 EfiBltVideoToBltBuffer
,
1093 LogoWidth
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
1095 } else if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
1096 Status
= UgaDraw
->Blt (
1098 (EFI_UGA_PIXEL
*) LogoBlt
,
1099 EfiUgaVideoToBltBuffer
,
1106 LogoWidth
* sizeof (EFI_UGA_PIXEL
)
1109 Status
= EFI_UNSUPPORTED
;
1113 if (!EFI_ERROR (Status
)) {
1114 BootLogo
->SetBootLogo (BootLogo
, LogoBlt
, LogoDestX
, LogoDestY
, LogoWidth
, LogoHeight
);
1122 Use SystemTable Conout to turn on video based Simple Text Out consoles. The
1123 Simple Text Out screens will now be synced up with all non video output devices
1125 @retval EFI_SUCCESS UGA devices are back in text mode and synced up.
1136 // Enable Cursor on Screen
1138 gST
->ConOut
->EnableCursor (gST
->ConOut
, TRUE
);