2 Perform the platform memory test
4 Copyright (c) 2004 - 2015, 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 "PlatformBootManager.h"
17 EFI_HII_HANDLE gStringPackHandle
= NULL
;
18 EFI_GUID mPlatformBootManagerStringPackGuid
= {
19 0x154dd51, 0x9079, 0x4a10, { 0x89, 0x5c, 0x9c, 0x7, 0x72, 0x81, 0x57, 0x88 }
21 // extern UINT8 BdsDxeStrings[];
24 // BDS Platform Functions
28 Show progress bar with title above it. It only works in Graphics mode.
31 @param TitleForeground Foreground color for Title.
32 @param TitleBackground Background color for Title.
33 @param Title Title above progress bar.
34 @param ProgressColor Progress bar color.
35 @param Progress Progress (0-100)
36 @param PreviousValue The previous value of the progress.
38 @retval EFI_STATUS Success update the progress bar
42 PlatformBootManagerShowProgress (
43 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleForeground
,
44 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleBackground
,
46 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL ProgressColor
,
48 IN UINTN PreviousValue
52 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
53 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
58 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color
;
67 return EFI_INVALID_PARAMETER
;
71 Status
= gBS
->HandleProtocol (
72 gST
->ConsoleOutHandle
,
73 &gEfiGraphicsOutputProtocolGuid
,
74 (VOID
**) &GraphicsOutput
76 if (EFI_ERROR (Status
) && FeaturePcdGet (PcdUgaConsumeSupport
)) {
77 GraphicsOutput
= NULL
;
79 Status
= gBS
->HandleProtocol (
80 gST
->ConsoleOutHandle
,
81 &gEfiUgaDrawProtocolGuid
,
85 if (EFI_ERROR (Status
)) {
86 return EFI_UNSUPPORTED
;
91 if (GraphicsOutput
!= NULL
) {
92 SizeOfX
= GraphicsOutput
->Mode
->Info
->HorizontalResolution
;
93 SizeOfY
= GraphicsOutput
->Mode
->Info
->VerticalResolution
;
94 } else if (UgaDraw
!= NULL
) {
95 Status
= UgaDraw
->GetMode (
102 if (EFI_ERROR (Status
)) {
103 return EFI_UNSUPPORTED
;
106 return EFI_UNSUPPORTED
;
109 BlockWidth
= SizeOfX
/ 100;
110 BlockHeight
= SizeOfY
/ 50;
115 PosY
= SizeOfY
* 48 / 50;
119 // Clear progress area
121 SetMem (&Color
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0x0);
123 if (GraphicsOutput
!= NULL
) {
124 Status
= GraphicsOutput
->Blt (
131 PosY
- EFI_GLYPH_HEIGHT
- 1,
133 SizeOfY
- (PosY
- EFI_GLYPH_HEIGHT
- 1),
134 SizeOfX
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
136 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
137 Status
= UgaDraw
->Blt (
139 (EFI_UGA_PIXEL
*) &Color
,
144 PosY
- EFI_GLYPH_HEIGHT
- 1,
146 SizeOfY
- (PosY
- EFI_GLYPH_HEIGHT
- 1),
147 SizeOfX
* sizeof (EFI_UGA_PIXEL
)
150 return EFI_UNSUPPORTED
;
154 // Show progress by drawing blocks
156 for (Index
= PreviousValue
; Index
< BlockNum
; Index
++) {
157 PosX
= Index
* BlockWidth
;
158 if (GraphicsOutput
!= NULL
) {
159 Status
= GraphicsOutput
->Blt (
169 (BlockWidth
) * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
171 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
172 Status
= UgaDraw
->Blt (
174 (EFI_UGA_PIXEL
*) &ProgressColor
,
182 (BlockWidth
) * sizeof (EFI_UGA_PIXEL
)
185 return EFI_UNSUPPORTED
;
190 (SizeOfX
- StrLen (Title
) * EFI_GLYPH_WIDTH
) / 2,
191 PosY
- EFI_GLYPH_HEIGHT
- 1,
201 Perform the memory test base on the memory test intensive level,
202 and update the memory resource.
204 @param Level The memory test intensive level.
206 @retval EFI_STATUS Success test all the system memory and update
211 PlatformBootManagerMemoryTest (
212 IN EXTENDMEM_COVERAGE_LEVEL Level
216 EFI_STATUS KeyStatus
;
217 EFI_STATUS InitStatus
;
218 EFI_STATUS ReturnStatus
;
219 BOOLEAN RequireSoftECCInit
;
220 EFI_GENERIC_MEMORY_TEST_PROTOCOL
*GenMemoryTest
;
221 UINT64 TestedMemorySize
;
222 UINT64 TotalMemorySize
;
224 UINT64 PreviousValue
;
228 CHAR16 StrPercent
[80];
229 CHAR16
*StrTotalMemory
;
232 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
233 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
234 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color
;
236 UINTN StrTotalMemorySize
;
238 ReturnStatus
= EFI_SUCCESS
;
239 ZeroMem (&Key
, sizeof (EFI_INPUT_KEY
));
241 StrTotalMemorySize
= 128;
242 Pos
= AllocateZeroPool (StrTotalMemorySize
);
243 ASSERT (Pos
!= NULL
);
245 if (gStringPackHandle
== NULL
) {
246 gStringPackHandle
= HiiAddPackages (
247 &mPlatformBootManagerStringPackGuid
,
249 PlatformBootManagerLibStrings
,
252 ASSERT (gStringPackHandle
!= NULL
);
255 StrTotalMemory
= Pos
;
257 TestedMemorySize
= 0;
263 SetMem (&Foreground
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0xff);
264 SetMem (&Background
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0x0);
265 SetMem (&Color
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0xff);
267 RequireSoftECCInit
= FALSE
;
269 Status
= gBS
->LocateProtocol (
270 &gEfiGenericMemTestProtocolGuid
,
272 (VOID
**) &GenMemoryTest
274 if (EFI_ERROR (Status
)) {
279 InitStatus
= GenMemoryTest
->MemoryTestInit (
284 if (InitStatus
== EFI_NO_MEDIA
) {
286 // The PEI codes also have the relevant memory test code to check the memory,
287 // it can select to test some range of the memory or all of them. If PEI code
288 // checks all the memory, this BDS memory test will has no not-test memory to
289 // do the test, and then the status of EFI_NO_MEDIA will be returned by
290 // "MemoryTestInit". So it does not need to test memory again, just return.
296 if (!FeaturePcdGet(PcdBootlogoOnlyEnable
)) {
297 TmpStr
= HiiGetString (gStringPackHandle
, STRING_TOKEN (STR_ESC_TO_SKIP_MEM_TEST
), NULL
);
299 if (TmpStr
!= NULL
) {
300 PrintXY (10, 10, NULL
, NULL
, TmpStr
);
304 DEBUG ((EFI_D_INFO
, "Enter memory test.\n"));
307 Status
= GenMemoryTest
->PerformMemoryTest (
314 if (ErrorOut
&& (Status
== EFI_DEVICE_ERROR
)) {
315 TmpStr
= HiiGetString (gStringPackHandle
, STRING_TOKEN (STR_SYSTEM_MEM_ERROR
), NULL
);
316 if (TmpStr
!= NULL
) {
317 PrintXY (10, 10, NULL
, NULL
, TmpStr
);
324 if (!FeaturePcdGet(PcdBootlogoOnlyEnable
)) {
325 TempData
= (UINT32
) DivU64x32 (TotalMemorySize
, 16);
326 TestPercent
= (UINTN
) DivU64x32 (
327 DivU64x32 (MultU64x32 (TestedMemorySize
, 100), 16),
330 if (TestPercent
!= PreviousValue
) {
331 UnicodeValueToString (StrPercent
, 0, TestPercent
, 0);
332 TmpStr
= HiiGetString (gStringPackHandle
, STRING_TOKEN (STR_MEMORY_TEST_PERCENT
), NULL
);
333 if (TmpStr
!= NULL
) {
335 // TmpStr size is 64, StrPercent is reserved to 16.
339 sizeof (StrPercent
) / sizeof (CHAR16
),
341 sizeof (StrPercent
) / sizeof (CHAR16
) - StrLen (StrPercent
) - 1
343 PrintXY (10, 10, NULL
, NULL
, StrPercent
);
347 TmpStr
= HiiGetString (gStringPackHandle
, STRING_TOKEN (STR_PERFORM_MEM_TEST
), NULL
);
348 if (TmpStr
!= NULL
) {
349 PlatformBootManagerShowProgress (
355 (UINTN
) PreviousValue
361 PreviousValue
= TestPercent
;
363 DEBUG ((EFI_D_INFO
, "Perform memory test (ESC to skip).\n"));
366 if (!PcdGetBool (PcdConInConnectOnDemand
)) {
367 KeyStatus
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
368 if (!EFI_ERROR (KeyStatus
) && (Key
.ScanCode
== SCAN_ESC
)) {
369 if (!RequireSoftECCInit
) {
370 if (!FeaturePcdGet(PcdBootlogoOnlyEnable
)) {
371 TmpStr
= HiiGetString (gStringPackHandle
, STRING_TOKEN (STR_PERFORM_MEM_TEST
), NULL
);
372 if (TmpStr
!= NULL
) {
373 PlatformBootManagerShowProgress (
379 (UINTN
) PreviousValue
384 PrintXY (10, 10, NULL
, NULL
, L
"100");
386 Status
= GenMemoryTest
->Finished (GenMemoryTest
);
393 } while (Status
!= EFI_NOT_FOUND
);
395 Status
= GenMemoryTest
->Finished (GenMemoryTest
);
398 if (!FeaturePcdGet(PcdBootlogoOnlyEnable
)) {
399 UnicodeValueToString (StrTotalMemory
, COMMA_TYPE
, TotalMemorySize
, 0);
400 if (StrTotalMemory
[0] == L
',') {
402 StrTotalMemorySize
-= sizeof (CHAR16
);
405 TmpStr
= HiiGetString (gStringPackHandle
, STRING_TOKEN (STR_MEM_TEST_COMPLETED
), NULL
);
406 if (TmpStr
!= NULL
) {
409 StrTotalMemorySize
/ sizeof (CHAR16
),
411 StrTotalMemorySize
/ sizeof (CHAR16
) - StrLen (StrTotalMemory
) - 1
416 PrintXY (10, 10, NULL
, NULL
, StrTotalMemory
);
417 PlatformBootManagerShowProgress (
423 (UINTN
) PreviousValue
427 DEBUG ((EFI_D_INFO
, "%d bytes of system memory tested OK\r\n", TotalMemorySize
));
435 Convert a *.BMP graphics image to a GOP blt buffer. If a NULL Blt buffer
436 is passed in a GopBlt buffer will be allocated by this routine. If a GopBlt
437 buffer is passed in it will be used if it is big enough.
439 @param BmpImage Pointer to BMP file
440 @param BmpImageSize Number of bytes in BmpImage
441 @param GopBlt Buffer containing GOP version of BmpImage.
442 @param GopBltSize Size of GopBlt in bytes.
443 @param PixelHeight Height of GopBlt/BmpImage in pixels
444 @param PixelWidth Width of GopBlt/BmpImage in pixels
446 @retval EFI_SUCCESS GopBlt and GopBltSize are returned.
447 @retval EFI_UNSUPPORTED BmpImage is not a valid *.BMP image
448 @retval EFI_BUFFER_TOO_SMALL The passed in GopBlt buffer is not big enough.
449 GopBltSize will contain the required size.
450 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate.
454 PlatformBootManagerConvertBmpToGopBlt (
456 IN UINTN BmpImageSize
,
457 IN OUT VOID
**GopBlt
,
458 IN OUT UINTN
*GopBltSize
,
459 OUT UINTN
*PixelHeight
,
460 OUT UINTN
*PixelWidth
465 BMP_IMAGE_HEADER
*BmpHeader
;
466 BMP_COLOR_MAP
*BmpColorMap
;
467 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BltBuffer
;
468 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Blt
;
469 UINT64 BltBufferSize
;
474 UINT32 DataSizePerLine
;
478 if (sizeof (BMP_IMAGE_HEADER
) > BmpImageSize
) {
479 return EFI_INVALID_PARAMETER
;
482 BmpHeader
= (BMP_IMAGE_HEADER
*) BmpImage
;
484 if (BmpHeader
->CharB
!= 'B' || BmpHeader
->CharM
!= 'M') {
485 return EFI_UNSUPPORTED
;
489 // Doesn't support compress.
491 if (BmpHeader
->CompressionType
!= 0) {
492 return EFI_UNSUPPORTED
;
496 // Only support BITMAPINFOHEADER format.
497 // BITMAPFILEHEADER + BITMAPINFOHEADER = BMP_IMAGE_HEADER
499 if (BmpHeader
->HeaderSize
!= sizeof (BMP_IMAGE_HEADER
) - OFFSET_OF(BMP_IMAGE_HEADER
, HeaderSize
)) {
500 return EFI_UNSUPPORTED
;
504 // The data size in each line must be 4 byte alignment.
506 DataSizePerLine
= ((BmpHeader
->PixelWidth
* BmpHeader
->BitPerPixel
+ 31) >> 3) & (~0x3);
507 BltBufferSize
= MultU64x32 (DataSizePerLine
, BmpHeader
->PixelHeight
);
508 if (BltBufferSize
> (UINT32
) ~0) {
509 return EFI_INVALID_PARAMETER
;
512 if ((BmpHeader
->Size
!= BmpImageSize
) ||
513 (BmpHeader
->Size
< BmpHeader
->ImageOffset
) ||
514 (BmpHeader
->Size
- BmpHeader
->ImageOffset
!= BmpHeader
->PixelHeight
* DataSizePerLine
)) {
515 return EFI_INVALID_PARAMETER
;
519 // Calculate Color Map offset in the image.
522 BmpColorMap
= (BMP_COLOR_MAP
*) (Image
+ sizeof (BMP_IMAGE_HEADER
));
523 if (BmpHeader
->ImageOffset
< sizeof (BMP_IMAGE_HEADER
)) {
524 return EFI_INVALID_PARAMETER
;
527 if (BmpHeader
->ImageOffset
> sizeof (BMP_IMAGE_HEADER
)) {
528 switch (BmpHeader
->BitPerPixel
) {
543 // BMP file may has padding data between the bmp header section and the bmp data section.
545 if (BmpHeader
->ImageOffset
- sizeof (BMP_IMAGE_HEADER
) < sizeof (BMP_COLOR_MAP
) * ColorMapNum
) {
546 return EFI_INVALID_PARAMETER
;
551 // Calculate graphics image data address in the image
553 Image
= ((UINT8
*) BmpImage
) + BmpHeader
->ImageOffset
;
557 // Calculate the BltBuffer needed size.
559 BltBufferSize
= MultU64x32 ((UINT64
) BmpHeader
->PixelWidth
, BmpHeader
->PixelHeight
);
561 // Ensure the BltBufferSize * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) doesn't overflow
563 if (BltBufferSize
> DivU64x32 ((UINTN
) ~0, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
))) {
564 return EFI_UNSUPPORTED
;
566 BltBufferSize
= MultU64x32 (BltBufferSize
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
));
569 if (*GopBlt
== NULL
) {
571 // GopBlt is not allocated by caller.
573 *GopBltSize
= (UINTN
) BltBufferSize
;
574 *GopBlt
= AllocatePool (*GopBltSize
);
576 if (*GopBlt
== NULL
) {
577 return EFI_OUT_OF_RESOURCES
;
581 // GopBlt has been allocated by caller.
583 if (*GopBltSize
< (UINTN
) BltBufferSize
) {
584 *GopBltSize
= (UINTN
) BltBufferSize
;
585 return EFI_BUFFER_TOO_SMALL
;
589 *PixelWidth
= BmpHeader
->PixelWidth
;
590 *PixelHeight
= BmpHeader
->PixelHeight
;
593 // Convert image from BMP to Blt buffer format
596 for (Height
= 0; Height
< BmpHeader
->PixelHeight
; Height
++) {
597 Blt
= &BltBuffer
[(BmpHeader
->PixelHeight
- Height
- 1) * BmpHeader
->PixelWidth
];
598 for (Width
= 0; Width
< BmpHeader
->PixelWidth
; Width
++, Image
++, Blt
++) {
599 switch (BmpHeader
->BitPerPixel
) {
602 // Convert 1-bit (2 colors) BMP to 24-bit color
604 for (Index
= 0; Index
< 8 && Width
< BmpHeader
->PixelWidth
; Index
++) {
605 Blt
->Red
= BmpColorMap
[((*Image
) >> (7 - Index
)) & 0x1].Red
;
606 Blt
->Green
= BmpColorMap
[((*Image
) >> (7 - Index
)) & 0x1].Green
;
607 Blt
->Blue
= BmpColorMap
[((*Image
) >> (7 - Index
)) & 0x1].Blue
;
618 // Convert 4-bit (16 colors) BMP Palette to 24-bit color
620 Index
= (*Image
) >> 4;
621 Blt
->Red
= BmpColorMap
[Index
].Red
;
622 Blt
->Green
= BmpColorMap
[Index
].Green
;
623 Blt
->Blue
= BmpColorMap
[Index
].Blue
;
624 if (Width
< (BmpHeader
->PixelWidth
- 1)) {
627 Index
= (*Image
) & 0x0f;
628 Blt
->Red
= BmpColorMap
[Index
].Red
;
629 Blt
->Green
= BmpColorMap
[Index
].Green
;
630 Blt
->Blue
= BmpColorMap
[Index
].Blue
;
636 // Convert 8-bit (256 colors) BMP Palette to 24-bit color
638 Blt
->Red
= BmpColorMap
[*Image
].Red
;
639 Blt
->Green
= BmpColorMap
[*Image
].Green
;
640 Blt
->Blue
= BmpColorMap
[*Image
].Blue
;
647 Blt
->Blue
= *Image
++;
648 Blt
->Green
= *Image
++;
654 // Other bit format BMP is not supported.
660 return EFI_UNSUPPORTED
;
666 ImageIndex
= (UINTN
) (Image
- ImageHeader
);
667 if ((ImageIndex
% 4) != 0) {
669 // Bmp Image starts each row on a 32-bit boundary!
671 Image
= Image
+ (4 - (ImageIndex
% 4));
679 Use SystemTable Conout to stop video based Simple Text Out consoles from going
680 to the video device. Put up LogoFile on every video device that is a console.
682 @param[in] LogoFile File name of logo to display on the center of the screen.
684 @retval EFI_SUCCESS ConsoleControl has been flipped to graphics and logo displayed.
685 @retval EFI_UNSUPPORTED Logo not found
689 PlatformBootManagerEnableQuietBoot (
690 IN EFI_GUID
*LogoFile
694 EFI_OEM_BADGING_PROTOCOL
*Badging
;
703 EFI_BADGING_FORMAT Format
;
704 EFI_BADGING_DISPLAY_ATTRIBUTE Attribute
;
709 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Blt
;
710 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
713 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
714 EFI_BOOT_LOGO_PROTOCOL
*BootLogo
;
716 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*LogoBlt
;
729 // Try to open GOP first
731 Status
= gBS
->HandleProtocol (gST
->ConsoleOutHandle
, &gEfiGraphicsOutputProtocolGuid
, (VOID
**) &GraphicsOutput
);
732 if (EFI_ERROR (Status
) && FeaturePcdGet (PcdUgaConsumeSupport
)) {
733 GraphicsOutput
= NULL
;
735 // Open GOP failed, try to open UGA
737 Status
= gBS
->HandleProtocol (gST
->ConsoleOutHandle
, &gEfiUgaDrawProtocolGuid
, (VOID
**) &UgaDraw
);
739 if (EFI_ERROR (Status
)) {
740 return EFI_UNSUPPORTED
;
744 // Try to open Boot Logo Protocol.
747 gBS
->LocateProtocol (&gEfiBootLogoProtocolGuid
, NULL
, (VOID
**) &BootLogo
);
750 // Erase Cursor from screen
752 gST
->ConOut
->EnableCursor (gST
->ConOut
, FALSE
);
755 Status
= gBS
->LocateProtocol (&gEfiOEMBadgingProtocolGuid
, NULL
, (VOID
**) &Badging
);
757 if (GraphicsOutput
!= NULL
) {
758 SizeOfX
= GraphicsOutput
->Mode
->Info
->HorizontalResolution
;
759 SizeOfY
= GraphicsOutput
->Mode
->Info
->VerticalResolution
;
761 } else if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
762 Status
= UgaDraw
->GetMode (UgaDraw
, &SizeOfX
, &SizeOfY
, &ColorDepth
, &RefreshRate
);
763 if (EFI_ERROR (Status
)) {
764 return EFI_UNSUPPORTED
;
767 return EFI_UNSUPPORTED
;
785 if (Badging
!= NULL
) {
787 // Get image from OEMBadging protocol.
789 Status
= Badging
->GetImage (
799 if (EFI_ERROR (Status
)) {
804 // Currently only support BMP format.
806 if (Format
!= EfiBadgingFormatBMP
) {
807 if (ImageData
!= NULL
) {
808 FreePool (ImageData
);
814 // Get the specified image from FV.
816 Status
= GetSectionFromAnyFv (LogoFile
, EFI_SECTION_RAW
, 0, (VOID
**) &ImageData
, &ImageSize
);
817 if (EFI_ERROR (Status
)) {
818 return EFI_UNSUPPORTED
;
823 if (!FeaturePcdGet(PcdBootlogoOnlyEnable
)) {
824 Attribute
= EfiBadgingDisplayAttributeCenter
;
826 Attribute
= EfiBadgingDisplayAttributeCustomized
;
834 Status
= PlatformBootManagerConvertBmpToGopBlt (
842 if (EFI_ERROR (Status
)) {
843 FreePool (ImageData
);
845 if (Badging
== NULL
) {
853 // Calculate the display position according to Attribute.
856 case EfiBadgingDisplayAttributeLeftTop
:
861 case EfiBadgingDisplayAttributeCenterTop
:
862 DestX
= (SizeOfX
- Width
) / 2;
866 case EfiBadgingDisplayAttributeRightTop
:
867 DestX
= (SizeOfX
- Width
- CoordinateX
);
868 DestY
= CoordinateY
;;
871 case EfiBadgingDisplayAttributeCenterRight
:
872 DestX
= (SizeOfX
- Width
- CoordinateX
);
873 DestY
= (SizeOfY
- Height
) / 2;
876 case EfiBadgingDisplayAttributeRightBottom
:
877 DestX
= (SizeOfX
- Width
- CoordinateX
);
878 DestY
= (SizeOfY
- Height
- CoordinateY
);
881 case EfiBadgingDisplayAttributeCenterBottom
:
882 DestX
= (SizeOfX
- Width
) / 2;
883 DestY
= (SizeOfY
- Height
- CoordinateY
);
886 case EfiBadgingDisplayAttributeLeftBottom
:
888 DestY
= (SizeOfY
- Height
- CoordinateY
);
891 case EfiBadgingDisplayAttributeCenterLeft
:
893 DestY
= (SizeOfY
- Height
) / 2;
896 case EfiBadgingDisplayAttributeCenter
:
897 DestX
= (SizeOfX
- Width
) / 2;
898 DestY
= (SizeOfY
- Height
) / 2;
901 case EfiBadgingDisplayAttributeCustomized
:
902 DestX
= (SizeOfX
- Width
) / 2;
903 DestY
= ((SizeOfY
* 382) / 1000) - Height
/ 2;
912 if ((DestX
>= 0) && (DestY
>= 0)) {
913 if (GraphicsOutput
!= NULL
) {
914 Status
= GraphicsOutput
->Blt (
924 Width
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
926 } else if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
927 Status
= UgaDraw
->Blt (
929 (EFI_UGA_PIXEL
*) Blt
,
930 EfiUgaBltBufferToVideo
,
937 Width
* sizeof (EFI_UGA_PIXEL
)
940 Status
= EFI_UNSUPPORTED
;
944 // Report displayed Logo information.
946 if (!EFI_ERROR (Status
)) {
949 if (LogoWidth
== 0) {
953 LogoDestX
= (UINTN
) DestX
;
954 LogoDestY
= (UINTN
) DestY
;
959 // Merge new logo with old one.
961 NewDestX
= MIN ((UINTN
) DestX
, LogoDestX
);
962 NewDestY
= MIN ((UINTN
) DestY
, LogoDestY
);
963 NewWidth
= MAX ((UINTN
) DestX
+ Width
, LogoDestX
+ LogoWidth
) - NewDestX
;
964 NewHeight
= MAX ((UINTN
) DestY
+ Height
, LogoDestY
+ LogoHeight
) - NewDestY
;
966 LogoDestX
= NewDestX
;
967 LogoDestY
= NewDestY
;
968 LogoWidth
= NewWidth
;
969 LogoHeight
= NewHeight
;
974 FreePool (ImageData
);
976 if (Badging
== NULL
) {
982 if (BootLogo
== NULL
|| NumberOfLogos
== 0) {
984 // No logo displayed.
994 // Advertise displayed Logo information.
996 if (NumberOfLogos
== 1) {
998 // Only one logo displayed, use its Blt buffer directly for BootLogo protocol.
1001 Status
= EFI_SUCCESS
;
1004 // More than one Logo displayed, get merged BltBuffer using VideoToBuffer operation.
1011 // Ensure the LogoHeight * LogoWidth doesn't overflow
1013 if (LogoHeight
> DivU64x64Remainder ((UINTN
) ~0, LogoWidth
, NULL
)) {
1014 return EFI_UNSUPPORTED
;
1016 BufferSize
= MultU64x64 (LogoWidth
, LogoHeight
);
1019 // Ensure the BufferSize * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) doesn't overflow
1021 if (BufferSize
> DivU64x32 ((UINTN
) ~0, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
))) {
1022 return EFI_UNSUPPORTED
;
1025 LogoBlt
= AllocateZeroPool ((UINTN
)BufferSize
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
));
1026 if (LogoBlt
== NULL
) {
1027 return EFI_OUT_OF_RESOURCES
;
1030 if (GraphicsOutput
!= NULL
) {
1031 Status
= GraphicsOutput
->Blt (
1034 EfiBltVideoToBltBuffer
,
1041 LogoWidth
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
1043 } else if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
1044 Status
= UgaDraw
->Blt (
1046 (EFI_UGA_PIXEL
*) LogoBlt
,
1047 EfiUgaVideoToBltBuffer
,
1054 LogoWidth
* sizeof (EFI_UGA_PIXEL
)
1057 Status
= EFI_UNSUPPORTED
;
1061 if (!EFI_ERROR (Status
)) {
1062 BootLogo
->SetBootLogo (BootLogo
, LogoBlt
, LogoDestX
, LogoDestY
, LogoWidth
, LogoHeight
);
1070 Use SystemTable Conout to turn on video based Simple Text Out consoles. The
1071 Simple Text Out screens will now be synced up with all non video output devices
1073 @retval EFI_SUCCESS UGA devices are back in text mode and synced up.
1077 PlatformBootManagerDisableQuietBoot (
1082 // Enable Cursor on Screen
1084 gST
->ConOut
->EnableCursor (gST
->ConOut
, TRUE
);