remove unnecessary check for NULL pointer.
[edk2.git] / MdeModulePkg / Library / GenericBdsLib / BdsConsole.c
blobf826e6d95c84d5a3a359bce3a43123217879eef3
1 /** @file
2 BDS Lib functions which contain all the code to connect console device
4 Copyright (c) 2004 - 2008, Intel Corporation. <BR>
5 All rights reserved. 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.
13 **/
15 #include "InternalBdsLib.h"
17 /**
18 Check if we need to save the EFI variable with "ConVarName" as name
19 as NV type
21 @param ConVarName The name of the EFI variable.
23 @retval TRUE Set the EFI variabel as NV type.
24 @retval FALSE EFI variabel as NV type can be set NonNV.
25 **/
26 BOOLEAN
27 IsNvNeed (
28 IN CHAR16 *ConVarName
31 CHAR16 *Ptr;
33 Ptr = ConVarName;
36 // If the variable includes "Dev" at last, we consider
37 // it does not support NV attribute.
39 while (*Ptr != L'\0') {
40 Ptr++;
43 if ((*(Ptr - 3) == 'D') && (*(Ptr - 2) == 'e') && (*(Ptr - 1) == 'v')) {
44 return FALSE;
45 } else {
46 return TRUE;
50 /**
51 This function update console variable based on ConVarName, it can
52 add or remove one specific console device path from the variable
54 @param ConVarName Console related variable name, ConIn, ConOut,
55 ErrOut.
56 @param CustomizedConDevicePath The console device path which will be added to
57 the console variable ConVarName, this parameter
58 can not be multi-instance.
59 @param ExclusiveDevicePath The console device path which will be removed
60 from the console variable ConVarName, this
61 parameter can not be multi-instance.
63 @retval EFI_UNSUPPORTED The added device path is same to the removed one.
64 @retval EFI_SUCCESS Success add or remove the device path from the
65 console variable.
67 **/
68 EFI_STATUS
69 EFIAPI
70 BdsLibUpdateConsoleVariable (
71 IN CHAR16 *ConVarName,
72 IN EFI_DEVICE_PATH_PROTOCOL *CustomizedConDevicePath,
73 IN EFI_DEVICE_PATH_PROTOCOL *ExclusiveDevicePath
76 EFI_DEVICE_PATH_PROTOCOL *VarConsole;
77 UINTN DevicePathSize;
78 EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
79 EFI_DEVICE_PATH_PROTOCOL *TempNewDevicePath;
80 UINT32 Attributes;
82 VarConsole = NULL;
83 DevicePathSize = 0;
86 // Notes: check the device path point, here should check
87 // with compare memory
89 if (CustomizedConDevicePath == ExclusiveDevicePath) {
90 return EFI_UNSUPPORTED;
93 // Delete the ExclusiveDevicePath from current default console
95 VarConsole = BdsLibGetVariableAndSize (
96 ConVarName,
97 &gEfiGlobalVariableGuid,
98 &DevicePathSize
102 // Initialize NewDevicePath
104 NewDevicePath = VarConsole;
107 // If ExclusiveDevicePath is even the part of the instance in VarConsole, delete it.
108 // In the end, NewDevicePath is the final device path.
110 if (ExclusiveDevicePath != NULL && VarConsole != NULL) {
111 NewDevicePath = BdsLibDelPartMatchInstance (VarConsole, ExclusiveDevicePath);
114 // Try to append customized device path to NewDevicePath.
116 if (CustomizedConDevicePath != NULL) {
117 if (!BdsLibMatchDevicePaths (NewDevicePath, CustomizedConDevicePath)) {
119 // Check if there is part of CustomizedConDevicePath in NewDevicePath, delete it.
121 NewDevicePath = BdsLibDelPartMatchInstance (NewDevicePath, CustomizedConDevicePath);
123 // In the first check, the default console variable will be _ModuleEntryPoint,
124 // just append current customized device path
126 TempNewDevicePath = NewDevicePath;
127 NewDevicePath = AppendDevicePathInstance (NewDevicePath, CustomizedConDevicePath);
128 if (TempNewDevicePath != NULL) {
129 FreePool(TempNewDevicePath);
135 // The attribute for ConInDev, ConOutDev and ErrOutDev does not include NV.
137 if (IsNvNeed(ConVarName)) {
139 // ConVarName has NV attribute.
141 Attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE;
142 } else {
144 // ConVarName does not have NV attribute.
146 Attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS;
150 // Finally, Update the variable of the default console by NewDevicePath
152 gRT->SetVariable (
153 ConVarName,
154 &gEfiGlobalVariableGuid,
155 Attributes,
156 GetDevicePathSize (NewDevicePath),
157 NewDevicePath
160 if (VarConsole == NewDevicePath) {
161 if (VarConsole != NULL) {
162 FreePool(VarConsole);
164 } else {
165 if (VarConsole != NULL) {
166 FreePool(VarConsole);
168 if (NewDevicePath != NULL) {
169 FreePool(NewDevicePath);
173 return EFI_SUCCESS;
179 Connect the console device base on the variable ConVarName, if
180 device path of the ConVarName is multi-instance device path, if
181 anyone of the instances is connected success, then this function
182 will return success.
184 @param ConVarName Console related variable name, ConIn, ConOut,
185 ErrOut.
187 @retval EFI_NOT_FOUND There is not any console devices connected
188 success
189 @retval EFI_SUCCESS Success connect any one instance of the console
190 device path base on the variable ConVarName.
193 EFI_STATUS
194 EFIAPI
195 BdsLibConnectConsoleVariable (
196 IN CHAR16 *ConVarName
199 EFI_STATUS Status;
200 EFI_DEVICE_PATH_PROTOCOL *StartDevicePath;
201 UINTN VariableSize;
202 EFI_DEVICE_PATH_PROTOCOL *Instance;
203 EFI_DEVICE_PATH_PROTOCOL *Next;
204 EFI_DEVICE_PATH_PROTOCOL *CopyOfDevicePath;
205 UINTN Size;
206 BOOLEAN DeviceExist;
208 Status = EFI_SUCCESS;
209 DeviceExist = FALSE;
212 // Check if the console variable exist
214 StartDevicePath = BdsLibGetVariableAndSize (
215 ConVarName,
216 &gEfiGlobalVariableGuid,
217 &VariableSize
219 if (StartDevicePath == NULL) {
220 return EFI_UNSUPPORTED;
223 CopyOfDevicePath = StartDevicePath;
224 do {
226 // Check every instance of the console variable
228 Instance = GetNextDevicePathInstance (&CopyOfDevicePath, &Size);
229 Next = Instance;
230 while (!IsDevicePathEndType (Next)) {
231 Next = NextDevicePathNode (Next);
234 SetDevicePathEndNode (Next);
236 // Check USB1.1 console
238 if ((DevicePathType (Instance) == MESSAGING_DEVICE_PATH) &&
239 ((DevicePathSubType (Instance) == MSG_USB_CLASS_DP)
240 || (DevicePathSubType (Instance) == MSG_USB_WWID_DP)
241 )) {
243 // Check the Usb console in Usb2.0 bus firstly, then Usb1.1 bus
245 Status = BdsLibConnectUsbDevByShortFormDP (PCI_CLASSC_PI_EHCI, Instance);
246 if (!EFI_ERROR (Status)) {
247 DeviceExist = TRUE;
250 Status = BdsLibConnectUsbDevByShortFormDP (PCI_CLASSC_PI_UHCI, Instance);
251 if (!EFI_ERROR (Status)) {
252 DeviceExist = TRUE;
254 } else {
256 // Connect the instance device path
258 Status = BdsLibConnectDevicePath (Instance);
259 if (EFI_ERROR (Status)) {
261 // Delete the instance from the console varialbe
263 BdsLibUpdateConsoleVariable (ConVarName, NULL, Instance);
264 } else {
265 DeviceExist = TRUE;
268 FreePool(Instance);
269 } while (CopyOfDevicePath != NULL);
271 FreePool (StartDevicePath);
273 if (!DeviceExist) {
274 return EFI_NOT_FOUND;
277 return EFI_SUCCESS;
282 This function will search every simpletxt devive in current system,
283 and make every simpletxt device as pertantial console device.
286 VOID
287 EFIAPI
288 BdsLibConnectAllConsoles (
289 VOID
292 UINTN Index;
293 EFI_DEVICE_PATH_PROTOCOL *ConDevicePath;
294 UINTN HandleCount;
295 EFI_HANDLE *HandleBuffer;
297 Index = 0;
298 HandleCount = 0;
299 HandleBuffer = NULL;
300 ConDevicePath = NULL;
303 // Update all the console varables
305 gBS->LocateHandleBuffer (
306 ByProtocol,
307 &gEfiSimpleTextInProtocolGuid,
308 NULL,
309 &HandleCount,
310 &HandleBuffer
313 for (Index = 0; Index < HandleCount; Index++) {
314 gBS->HandleProtocol (
315 HandleBuffer[Index],
316 &gEfiDevicePathProtocolGuid,
317 (VOID **) &ConDevicePath
319 BdsLibUpdateConsoleVariable (L"ConIn", ConDevicePath, NULL);
322 if (HandleBuffer != NULL) {
323 FreePool(HandleBuffer);
324 HandleBuffer = NULL;
327 gBS->LocateHandleBuffer (
328 ByProtocol,
329 &gEfiSimpleTextOutProtocolGuid,
330 NULL,
331 &HandleCount,
332 &HandleBuffer
334 for (Index = 0; Index < HandleCount; Index++) {
335 gBS->HandleProtocol (
336 HandleBuffer[Index],
337 &gEfiDevicePathProtocolGuid,
338 (VOID **) &ConDevicePath
340 BdsLibUpdateConsoleVariable (L"ConOut", ConDevicePath, NULL);
341 BdsLibUpdateConsoleVariable (L"ErrOut", ConDevicePath, NULL);
344 if (HandleBuffer != NULL) {
345 FreePool(HandleBuffer);
349 // Connect all console variables
351 BdsLibConnectAllDefaultConsoles ();
356 This function will connect console device base on the console
357 device variable ConIn, ConOut and ErrOut.
359 @retval EFI_SUCCESS At least one of the ConIn and ConOut device have
360 been connected success.
361 @retval EFI_STATUS Return the status of BdsLibConnectConsoleVariable ().
364 EFI_STATUS
365 EFIAPI
366 BdsLibConnectAllDefaultConsoles (
367 VOID
370 EFI_STATUS Status;
373 // Connect all default console variables
377 // It seems impossible not to have any ConOut device on platform,
378 // so we check the status here.
380 Status = BdsLibConnectConsoleVariable (L"ConOut");
381 if (EFI_ERROR (Status)) {
382 return Status;
386 // Insert the performance probe for Console Out
388 PERF_START (NULL, "ConOut", "BDS", 1);
389 PERF_END (NULL, "ConOut", "BDS", 0);
392 // Because possibly the platform is legacy free, in such case,
393 // ConIn devices (Serial Port and PS2 Keyboard ) does not exist,
394 // so we need not check the status.
396 BdsLibConnectConsoleVariable (L"ConIn");
399 // The _ModuleEntryPoint err out var is legal.
401 BdsLibConnectConsoleVariable (L"ErrOut");
403 return EFI_SUCCESS;
408 Convert a *.BMP graphics image to a GOP blt buffer. If a NULL Blt buffer
409 is passed in a GopBlt buffer will be allocated by this routine. If a GopBlt
410 buffer is passed in it will be used if it is big enough.
412 @param BmpImage Pointer to BMP file
413 @param BmpImageSize Number of bytes in BmpImage
414 @param GopBlt Buffer containing GOP version of BmpImage.
415 @param GopBltSize Size of GopBlt in bytes.
416 @param PixelHeight Height of GopBlt/BmpImage in pixels
417 @param PixelWidth Width of GopBlt/BmpImage in pixels
419 @retval EFI_SUCCESS GopBlt and GopBltSize are returned.
420 @retval EFI_UNSUPPORTED BmpImage is not a valid *.BMP image
421 @retval EFI_BUFFER_TOO_SMALL The passed in GopBlt buffer is not big enough.
422 GopBltSize will contain the required size.
423 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate.
426 EFI_STATUS
427 ConvertBmpToGopBlt (
428 IN VOID *BmpImage,
429 IN UINTN BmpImageSize,
430 IN OUT VOID **GopBlt,
431 IN OUT UINTN *GopBltSize,
432 OUT UINTN *PixelHeight,
433 OUT UINTN *PixelWidth
436 UINT8 *Image;
437 UINT8 *ImageHeader;
438 BMP_IMAGE_HEADER *BmpHeader;
439 BMP_COLOR_MAP *BmpColorMap;
440 EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer;
441 EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
442 UINTN BltBufferSize;
443 UINTN Index;
444 UINTN Height;
445 UINTN Width;
446 UINTN ImageIndex;
447 BOOLEAN IsAllocated;
449 BmpHeader = (BMP_IMAGE_HEADER *) BmpImage;
451 if (BmpHeader->CharB != 'B' || BmpHeader->CharM != 'M') {
452 return EFI_UNSUPPORTED;
456 // Doesn't support compress.
458 if (BmpHeader->CompressionType != 0) {
459 return EFI_UNSUPPORTED;
463 // Calculate Color Map offset in the image.
465 Image = BmpImage;
466 BmpColorMap = (BMP_COLOR_MAP *) (Image + sizeof (BMP_IMAGE_HEADER));
469 // Calculate graphics image data address in the image
471 Image = ((UINT8 *) BmpImage) + BmpHeader->ImageOffset;
472 ImageHeader = Image;
475 // Calculate the BltBuffer needed size.
477 BltBufferSize = BmpHeader->PixelWidth * BmpHeader->PixelHeight * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);
478 IsAllocated = FALSE;
479 if (*GopBlt == NULL) {
481 // GopBlt is not allocated by caller.
483 *GopBltSize = BltBufferSize;
484 *GopBlt = AllocatePool (*GopBltSize);
485 IsAllocated = TRUE;
486 if (*GopBlt == NULL) {
487 return EFI_OUT_OF_RESOURCES;
489 } else {
491 // GopBlt has been allocated by caller.
493 if (*GopBltSize < BltBufferSize) {
494 *GopBltSize = BltBufferSize;
495 return EFI_BUFFER_TOO_SMALL;
499 *PixelWidth = BmpHeader->PixelWidth;
500 *PixelHeight = BmpHeader->PixelHeight;
503 // Convert image from BMP to Blt buffer format
505 BltBuffer = *GopBlt;
506 for (Height = 0; Height < BmpHeader->PixelHeight; Height++) {
507 Blt = &BltBuffer[(BmpHeader->PixelHeight - Height - 1) * BmpHeader->PixelWidth];
508 for (Width = 0; Width < BmpHeader->PixelWidth; Width++, Image++, Blt++) {
509 switch (BmpHeader->BitPerPixel) {
510 case 1:
512 // Convert 1-bit (2 colors) BMP to 24-bit color
514 for (Index = 0; Index < 8 && Width < BmpHeader->PixelWidth; Index++) {
515 Blt->Red = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Red;
516 Blt->Green = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Green;
517 Blt->Blue = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Blue;
518 Blt++;
519 Width++;
522 Blt --;
523 Width --;
524 break;
526 case 4:
528 // Convert 4-bit (16 colors) BMP Palette to 24-bit color
530 Index = (*Image) >> 4;
531 Blt->Red = BmpColorMap[Index].Red;
532 Blt->Green = BmpColorMap[Index].Green;
533 Blt->Blue = BmpColorMap[Index].Blue;
534 if (Width < (BmpHeader->PixelWidth - 1)) {
535 Blt++;
536 Width++;
537 Index = (*Image) & 0x0f;
538 Blt->Red = BmpColorMap[Index].Red;
539 Blt->Green = BmpColorMap[Index].Green;
540 Blt->Blue = BmpColorMap[Index].Blue;
542 break;
544 case 8:
546 // Convert 8-bit (256 colors) BMP Palette to 24-bit color
548 Blt->Red = BmpColorMap[*Image].Red;
549 Blt->Green = BmpColorMap[*Image].Green;
550 Blt->Blue = BmpColorMap[*Image].Blue;
551 break;
553 case 24:
555 // It is 24-bit BMP.
557 Blt->Blue = *Image++;
558 Blt->Green = *Image++;
559 Blt->Red = *Image;
560 break;
562 default:
564 // Other bit format BMP is not supported.
566 if (IsAllocated) {
567 FreePool (*GopBlt);
568 *GopBlt = NULL;
570 return EFI_UNSUPPORTED;
571 break;
576 ImageIndex = (UINTN) (Image - ImageHeader);
577 if ((ImageIndex % 4) != 0) {
579 // Bmp Image starts each row on a 32-bit boundary!
581 Image = Image + (4 - (ImageIndex % 4));
585 return EFI_SUCCESS;
590 Use Console Control Protocol to lock the Console In Spliter virtual handle.
591 This is the ConInHandle and ConIn handle in the EFI system table. All key
592 presses will be ignored until the Password is typed in. The only way to
593 disable the password is to type it in to a ConIn device.
595 @param Password Password used to lock ConIn device.
597 @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.
598 @retval EFI_UNSUPPORTED Password not found
601 EFI_STATUS
602 EFIAPI
603 LockKeyboards (
604 IN CHAR16 *Password
607 EFI_STATUS Status;
608 EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl;
610 Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, (VOID **) &ConsoleControl);
611 if (EFI_ERROR (Status)) {
612 return EFI_UNSUPPORTED;
615 Status = ConsoleControl->LockStdIn (ConsoleControl, Password);
616 return Status;
621 Use Console Control to turn off UGA based Simple Text Out consoles from going
622 to the UGA device. Put up LogoFile on every UGA device that is a console
624 @param[in] LogoFile File name of logo to display on the center of the screen.
626 @retval EFI_SUCCESS ConsoleControl has been flipped to graphics and logo displayed.
627 @retval EFI_UNSUPPORTED Logo not found
630 EFI_STATUS
631 EFIAPI
632 EnableQuietBoot (
633 IN EFI_GUID *LogoFile
636 EFI_STATUS Status;
637 EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl;
638 EFI_OEM_BADGING_PROTOCOL *Badging;
639 UINT32 SizeOfX;
640 UINT32 SizeOfY;
641 INTN DestX;
642 INTN DestY;
643 UINT8 *ImageData;
644 UINTN ImageSize;
645 UINTN BltSize;
646 UINT32 Instance;
647 EFI_BADGING_FORMAT Format;
648 EFI_BADGING_DISPLAY_ATTRIBUTE Attribute;
649 UINTN CoordinateX;
650 UINTN CoordinateY;
651 UINTN Height;
652 UINTN Width;
653 EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
654 EFI_UGA_DRAW_PROTOCOL *UgaDraw;
655 UINT32 ColorDepth;
656 UINT32 RefreshRate;
657 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
659 Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, (VOID **) &ConsoleControl);
660 if (EFI_ERROR (Status)) {
661 return EFI_UNSUPPORTED;
664 UgaDraw = NULL;
666 // Try to open GOP first
668 Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiGraphicsOutputProtocolGuid, (VOID **) &GraphicsOutput);
669 if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {
670 GraphicsOutput = NULL;
672 // Open GOP failed, try to open UGA
674 Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiUgaDrawProtocolGuid, (VOID **) &UgaDraw);
676 if (EFI_ERROR (Status)) {
677 return EFI_UNSUPPORTED;
680 Badging = NULL;
681 Status = gBS->LocateProtocol (&gEfiOEMBadgingProtocolGuid, NULL, (VOID **) &Badging);
684 // Set console control to graphics mode.
686 Status = ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenGraphics);
687 if (EFI_ERROR (Status)) {
688 return EFI_UNSUPPORTED;
691 if (GraphicsOutput != NULL) {
692 SizeOfX = GraphicsOutput->Mode->Info->HorizontalResolution;
693 SizeOfY = GraphicsOutput->Mode->Info->VerticalResolution;
695 } else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {
696 Status = UgaDraw->GetMode (UgaDraw, &SizeOfX, &SizeOfY, &ColorDepth, &RefreshRate);
697 if (EFI_ERROR (Status)) {
698 return EFI_UNSUPPORTED;
700 } else {
701 return EFI_UNSUPPORTED;
704 Instance = 0;
705 while (1) {
706 ImageData = NULL;
707 ImageSize = 0;
709 if (Badging != NULL) {
711 // Get image from OEMBadging protocol.
713 Status = Badging->GetImage (
714 Badging,
715 &Instance,
716 &Format,
717 &ImageData,
718 &ImageSize,
719 &Attribute,
720 &CoordinateX,
721 &CoordinateY
723 if (EFI_ERROR (Status)) {
724 return Status;
728 // Currently only support BMP format.
730 if (Format != EfiBadgingFormatBMP) {
731 if (ImageData != NULL) {
732 FreePool (ImageData);
734 continue;
736 } else {
738 // Get the specified image from FV.
740 Status = GetSectionFromAnyFv (LogoFile, EFI_SECTION_RAW, 0, (VOID **) &ImageData, &ImageSize);
741 if (EFI_ERROR (Status)) {
742 return EFI_UNSUPPORTED;
745 CoordinateX = 0;
746 CoordinateY = 0;
747 Attribute = EfiBadgingDisplayAttributeCenter;
750 Blt = NULL;
751 Status = ConvertBmpToGopBlt (
752 ImageData,
753 ImageSize,
754 (VOID **) &Blt,
755 &BltSize,
756 &Height,
757 &Width
759 if (EFI_ERROR (Status)) {
760 FreePool (ImageData);
762 if (Badging == NULL) {
763 return Status;
764 } else {
765 continue;
770 // Caculate the display position according to Attribute.
772 switch (Attribute) {
773 case EfiBadgingDisplayAttributeLeftTop:
774 DestX = CoordinateX;
775 DestY = CoordinateY;
776 break;
778 case EfiBadgingDisplayAttributeCenterTop:
779 DestX = (SizeOfX - Width) / 2;
780 DestY = CoordinateY;
781 break;
783 case EfiBadgingDisplayAttributeRightTop:
784 DestX = (SizeOfX - Width - CoordinateX);
785 DestY = CoordinateY;;
786 break;
788 case EfiBadgingDisplayAttributeCenterRight:
789 DestX = (SizeOfX - Width - CoordinateX);
790 DestY = (SizeOfY - Height) / 2;
791 break;
793 case EfiBadgingDisplayAttributeRightBottom:
794 DestX = (SizeOfX - Width - CoordinateX);
795 DestY = (SizeOfY - Height - CoordinateY);
796 break;
798 case EfiBadgingDisplayAttributeCenterBottom:
799 DestX = (SizeOfX - Width) / 2;
800 DestY = (SizeOfY - Height - CoordinateY);
801 break;
803 case EfiBadgingDisplayAttributeLeftBottom:
804 DestX = CoordinateX;
805 DestY = (SizeOfY - Height - CoordinateY);
806 break;
808 case EfiBadgingDisplayAttributeCenterLeft:
809 DestX = CoordinateX;
810 DestY = (SizeOfY - Height) / 2;
811 break;
813 case EfiBadgingDisplayAttributeCenter:
814 DestX = (SizeOfX - Width) / 2;
815 DestY = (SizeOfY - Height) / 2;
816 break;
818 default:
819 DestX = CoordinateX;
820 DestY = CoordinateY;
821 break;
824 if ((DestX >= 0) && (DestY >= 0)) {
825 if (GraphicsOutput != NULL) {
826 Status = GraphicsOutput->Blt (
827 GraphicsOutput,
828 Blt,
829 EfiBltBufferToVideo,
832 (UINTN) DestX,
833 (UINTN) DestY,
834 Width,
835 Height,
836 Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
838 } else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {
839 Status = UgaDraw->Blt (
840 UgaDraw,
841 (EFI_UGA_PIXEL *) Blt,
842 EfiUgaBltBufferToVideo,
845 (UINTN) DestX,
846 (UINTN) DestY,
847 Width,
848 Height,
849 Width * sizeof (EFI_UGA_PIXEL)
851 } else {
852 Status = EFI_UNSUPPORTED;
856 FreePool (ImageData);
858 if (Blt != NULL) {
859 FreePool (Blt);
862 if (Badging == NULL) {
863 break;
867 return Status;
871 Use Console Control to turn on UGA based Simple Text Out consoles. The UGA
872 Simple Text Out screens will now be synced up with all non UGA output devices
874 @retval EFI_SUCCESS UGA devices are back in text mode and synced up.
877 EFI_STATUS
878 EFIAPI
879 DisableQuietBoot (
880 VOID
883 EFI_STATUS Status;
884 EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl;
886 Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, (VOID **) &ConsoleControl);
887 if (EFI_ERROR (Status)) {
888 return EFI_UNSUPPORTED;
892 // Set console control to text mode.
894 return ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenText);