2 This is the main routine for initializing the Graphics Console support routines.
4 Add all standard Glyphs from UEFI 2.0 Specification
5 Implement optimal automatic Mode creation algorithm
6 Solve palette issues for mixed graphics and text
7 When does this protocol reset the palette?
9 Copyright (c) 2006 - 2007 Intel Corporation. <BR>
10 All rights reserved. This program and the accompanying materials
11 are licensed and made available under the terms and conditions of the BSD License
12 which accompanies this distribution. The full text of the license may be found at
13 http://opensource.org/licenses/bsd-license.php
15 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
16 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 #include "GraphicsConsole.h"
25 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
26 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Foreground
,
27 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Background
32 DrawUnicodeWeightAtCursorN (
33 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
34 IN CHAR16
*UnicodeWeight
,
41 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
46 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
47 IN UINT32 HorizontalResolution
,
48 IN UINT32 VerticalResolution
,
49 OUT UINT32
*CurrentModeNumber
55 GRAPHICS_CONSOLE_DEV mGraphicsConsoleDevTemplate
= {
56 GRAPHICS_CONSOLE_DEV_SIGNATURE
,
57 (EFI_GRAPHICS_OUTPUT_PROTOCOL
*) NULL
,
58 (EFI_UGA_DRAW_PROTOCOL
*) NULL
,
60 GraphicsConsoleConOutReset
,
61 GraphicsConsoleConOutOutputString
,
62 GraphicsConsoleConOutTestString
,
63 GraphicsConsoleConOutQueryMode
,
64 GraphicsConsoleConOutSetMode
,
65 GraphicsConsoleConOutSetAttribute
,
66 GraphicsConsoleConOutClearScreen
,
67 GraphicsConsoleConOutSetCursorPosition
,
68 GraphicsConsoleConOutEnableCursor
,
69 (EFI_SIMPLE_TEXT_OUTPUT_MODE
*) NULL
74 EFI_TEXT_ATTR(EFI_LIGHTGRAY
, EFI_BLACK
),
80 { 80, 25, 0, 0, 0, 0 }, // Mode 0
81 { 80, 50, 0, 0, 0, 0 }, // Mode 1
82 { 100,31, 0, 0, 0, 0 }, // Mode 2
83 { 0, 0, 0, 0, 0, 0 } // Mode 3
85 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*) NULL
,
89 EFI_HII_DATABASE_PROTOCOL
*mHiiDatabase
;
90 EFI_HII_FONT_PROTOCOL
*mHiiFont
;
91 BOOLEAN mFirstAccessFlag
= TRUE
;
93 STATIC EFI_GUID mFontPackageListGuid
= {0xf5f219d3, 0x7006, 0x4648, 0xac, 0x8d, 0xd6, 0x1d, 0xfb, 0x7b, 0xc6, 0xad};
95 static CHAR16 mCrLfString
[3] = { CHAR_CARRIAGE_RETURN
, CHAR_LINEFEED
, CHAR_NULL
};
97 static EFI_GRAPHICS_OUTPUT_BLT_PIXEL mEfiColors
[16] = {
101 {0x00, 0x00, 0x00, 0x00}, // BLACK
102 {0x98, 0x00, 0x00, 0x00}, // BLUE
103 {0x00, 0x98, 0x00, 0x00}, // GREEN
104 {0x98, 0x98, 0x00, 0x00}, // CYAN
105 {0x00, 0x00, 0x98, 0x00}, // RED
106 {0x98, 0x00, 0x98, 0x00}, // MAGENTA
107 {0x00, 0x98, 0x98, 0x00}, // BROWN
108 {0x98, 0x98, 0x98, 0x00}, // LIGHTGRAY
109 {0x30, 0x30, 0x30, 0x00}, // DARKGRAY - BRIGHT BLACK
110 {0xff, 0x00, 0x00, 0x00}, // LIGHTBLUE - ?
111 {0x00, 0xff, 0x00, 0x00}, // LIGHTGREEN - ?
112 {0xff, 0xff, 0x00, 0x00}, // LIGHTCYAN
113 {0x00, 0x00, 0xff, 0x00}, // LIGHTRED
114 {0xff, 0x00, 0xff, 0x00}, // LIGHTMAGENTA
115 {0x00, 0xff, 0xff, 0x00}, // LIGHTBROWN
116 {0xff, 0xff, 0xff, 0x00} // WHITE
119 static EFI_NARROW_GLYPH mCursorGlyph
= {
122 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF }
125 EFI_DRIVER_BINDING_PROTOCOL gGraphicsConsoleDriverBinding
= {
126 GraphicsConsoleControllerDriverSupported
,
127 GraphicsConsoleControllerDriverStart
,
128 GraphicsConsoleControllerDriverStop
,
136 GraphicsConsoleControllerDriverSupported (
137 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
138 IN EFI_HANDLE Controller
,
139 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
143 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
144 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
145 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
147 GraphicsOutput
= NULL
;
150 // Open the IO Abstraction(s) needed to perform the supported test
152 Status
= gBS
->OpenProtocol (
154 &gEfiGraphicsOutputProtocolGuid
,
155 (VOID
**) &GraphicsOutput
,
156 This
->DriverBindingHandle
,
158 EFI_OPEN_PROTOCOL_BY_DRIVER
161 if (EFI_ERROR (Status
) && FeaturePcdGet (PcdUgaConsumeSupport
)) {
163 // Open Graphics Output Protocol failed, try to open UGA Draw Protocol
165 Status
= gBS
->OpenProtocol (
167 &gEfiUgaDrawProtocolGuid
,
169 This
->DriverBindingHandle
,
171 EFI_OPEN_PROTOCOL_BY_DRIVER
174 if (EFI_ERROR (Status
)) {
179 // We need to ensure that we do not layer on top of a virtual handle.
180 // We need to ensure that the handles produced by the conspliter do not
183 Status
= gBS
->OpenProtocol (
185 &gEfiDevicePathProtocolGuid
,
186 (VOID
**) &DevicePath
,
187 This
->DriverBindingHandle
,
189 EFI_OPEN_PROTOCOL_BY_DRIVER
191 if (!EFI_ERROR (Status
)) {
194 &gEfiDevicePathProtocolGuid
,
195 This
->DriverBindingHandle
,
203 // Does Hii Exist? If not, we aren't ready to run
205 Status
= EfiLocateHiiProtocol ();
208 // Close the I/O Abstraction(s) used to perform the supported test
211 if (GraphicsOutput
!= NULL
) {
214 &gEfiGraphicsOutputProtocolGuid
,
215 This
->DriverBindingHandle
,
218 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
221 &gEfiUgaDrawProtocolGuid
,
222 This
->DriverBindingHandle
,
231 GraphicsConsoleControllerDriverStart (
232 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
233 IN EFI_HANDLE Controller
,
234 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
240 Start the controller.
244 This - A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
245 Controller - The handle of the controller to start.
246 RemainingDevicePath - A pointer to the remaining portion of a devcie path.
250 EFI_SUCCESS - Return successfully.
251 EFI_OUT_OF_RESOURCES - Out of resources.
256 GRAPHICS_CONSOLE_DEV
*Private
;
257 UINTN NarrowFontSize
;
258 UINT32 HorizontalResolution
;
259 UINT32 VerticalResolution
;
266 EFI_HII_SIMPLE_FONT_PACKAGE_HDR
*SimplifiedFont
;
268 EFI_HII_PACKAGE_LIST_HEADER
*PackageList
;
275 // Initialize the Graphics Console device instance
277 Private
= AllocateCopyPool (
278 sizeof (GRAPHICS_CONSOLE_DEV
),
279 &mGraphicsConsoleDevTemplate
281 if (Private
== NULL
) {
282 return EFI_OUT_OF_RESOURCES
;
285 Private
->SimpleTextOutput
.Mode
= &(Private
->SimpleTextOutputMode
);
287 Status
= gBS
->OpenProtocol (
289 &gEfiGraphicsOutputProtocolGuid
,
290 (VOID
**) &Private
->GraphicsOutput
,
291 This
->DriverBindingHandle
,
293 EFI_OPEN_PROTOCOL_BY_DRIVER
296 if (EFI_ERROR(Status
) && FeaturePcdGet (PcdUgaConsumeSupport
)) {
297 Status
= gBS
->OpenProtocol (
299 &gEfiUgaDrawProtocolGuid
,
300 (VOID
**) &Private
->UgaDraw
,
301 This
->DriverBindingHandle
,
303 EFI_OPEN_PROTOCOL_BY_DRIVER
307 if (EFI_ERROR (Status
)) {
311 NarrowFontSize
= ReturnNarrowFontSize ();
313 if (mFirstAccessFlag
) {
315 // Add 4 bytes to the header for entire length for HiiLibPreparePackageList use only.
316 // Looks ugly. Might be updated when font tool is ready.
318 PackageLength
= sizeof (EFI_HII_SIMPLE_FONT_PACKAGE_HDR
) + NarrowFontSize
+ 4;
319 Package
= AllocateZeroPool (PackageLength
);
320 if (Package
== NULL
) {
321 return EFI_OUT_OF_RESOURCES
;
323 CopyMem (Package
, &PackageLength
, 4);
324 SimplifiedFont
= (EFI_HII_SIMPLE_FONT_PACKAGE_HDR
*) (Package
+ 4);
325 SimplifiedFont
->Header
.Length
= (UINT32
) (PackageLength
- 4);
326 SimplifiedFont
->Header
.Type
= EFI_HII_PACKAGE_SIMPLE_FONTS
;
327 SimplifiedFont
->NumberOfNarrowGlyphs
= (UINT16
) (NarrowFontSize
/ sizeof (EFI_NARROW_GLYPH
));
329 Location
= (UINT8
*) (&SimplifiedFont
->NumberOfWideGlyphs
+ 1);
330 CopyMem (Location
, UsStdNarrowGlyphData
, NarrowFontSize
);
333 // Add this simplified font package to a package list then install it.
335 PackageList
= HiiLibPreparePackageList (1, &mFontPackageListGuid
, Package
);
336 Status
= mHiiDatabase
->NewPackageList (mHiiDatabase
, PackageList
, NULL
, &(Private
->HiiHandle
));
337 ASSERT_EFI_ERROR (Status
);
338 SafeFreePool (PackageList
);
339 SafeFreePool (Package
);
341 mFirstAccessFlag
= FALSE
;
344 // If the current mode information can not be retrieved, then attemp to set the default mode
345 // of 800x600, 32 bit colot, 60 Hz refresh.
347 HorizontalResolution
= 800;
348 VerticalResolution
= 600;
350 if (Private
->GraphicsOutput
!= NULL
) {
352 // The console is build on top of Graphics Output Protocol, find the mode number
353 // for the user-defined mode; if there are multiple video devices,
354 // graphic console driver will set all the video devices to the same mode.
356 Status
= CheckModeSupported (
357 Private
->GraphicsOutput
,
358 CURRENT_HORIZONTAL_RESOLUTION
,
359 CURRENT_VERTICAL_RESOLUTION
,
362 if (!EFI_ERROR(Status
)) {
364 // Update default mode to current mode
366 HorizontalResolution
= CURRENT_HORIZONTAL_RESOLUTION
;
367 VerticalResolution
= CURRENT_VERTICAL_RESOLUTION
;
370 // if not supporting current mode, try 800x600 which is required by UEFI/EFI spec
372 Status
= CheckModeSupported (
373 Private
->GraphicsOutput
,
380 if (EFI_ERROR (Status
) || (ModeNumber
== Private
->GraphicsOutput
->Mode
->MaxMode
)) {
382 // Set default mode failed or device don't support default mode, then get the current mode information
384 HorizontalResolution
= Private
->GraphicsOutput
->Mode
->Info
->HorizontalResolution
;
385 VerticalResolution
= Private
->GraphicsOutput
->Mode
->Info
->VerticalResolution
;
386 ModeNumber
= Private
->GraphicsOutput
->Mode
->Mode
;
388 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
390 // At first try to set user-defined resolution
394 Status
= Private
->UgaDraw
->SetMode (
396 CURRENT_HORIZONTAL_RESOLUTION
,
397 CURRENT_VERTICAL_RESOLUTION
,
401 if (!EFI_ERROR (Status
)) {
402 HorizontalResolution
= CURRENT_HORIZONTAL_RESOLUTION
;
403 VerticalResolution
= CURRENT_VERTICAL_RESOLUTION
;
404 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
406 // Try to set 800*600 which is required by UEFI/EFI spec
408 Status
= Private
->UgaDraw
->SetMode (
410 HorizontalResolution
,
415 if (EFI_ERROR (Status
)) {
416 Status
= Private
->UgaDraw
->GetMode (
418 &HorizontalResolution
,
423 if (EFI_ERROR (Status
)) {
428 Status
= EFI_UNSUPPORTED
;
434 // Compute the maximum number of text Rows and Columns that this current graphics mode can support
436 Columns
= HorizontalResolution
/ EFI_GLYPH_WIDTH
;
437 Rows
= VerticalResolution
/ EFI_GLYPH_HEIGHT
;
440 // See if the mode is too small to support the required 80x25 text mode
442 if (Columns
< 80 || Rows
< 25) {
446 // Add Mode #0 that must be 80x25
449 Private
->ModeData
[MaxMode
].GopWidth
= HorizontalResolution
;
450 Private
->ModeData
[MaxMode
].GopHeight
= VerticalResolution
;
451 Private
->ModeData
[MaxMode
].GopModeNumber
= ModeNumber
;
452 Private
->ModeData
[MaxMode
].DeltaX
= (HorizontalResolution
- (80 * EFI_GLYPH_WIDTH
)) >> 1;
453 Private
->ModeData
[MaxMode
].DeltaY
= (VerticalResolution
- (25 * EFI_GLYPH_HEIGHT
)) >> 1;
457 // If it is possible to support Mode #1 - 80x50, than add it as an active mode
460 Private
->ModeData
[MaxMode
].GopWidth
= HorizontalResolution
;
461 Private
->ModeData
[MaxMode
].GopHeight
= VerticalResolution
;
462 Private
->ModeData
[MaxMode
].GopModeNumber
= ModeNumber
;
463 Private
->ModeData
[MaxMode
].DeltaX
= (HorizontalResolution
- (80 * EFI_GLYPH_WIDTH
)) >> 1;
464 Private
->ModeData
[MaxMode
].DeltaY
= (VerticalResolution
- (50 * EFI_GLYPH_HEIGHT
)) >> 1;
469 // If it is not to support Mode #1 - 80x50, then skip it
472 Private
->ModeData
[MaxMode
].Columns
= 0;
473 Private
->ModeData
[MaxMode
].Rows
= 0;
474 Private
->ModeData
[MaxMode
].GopWidth
= HorizontalResolution
;
475 Private
->ModeData
[MaxMode
].GopHeight
= VerticalResolution
;
476 Private
->ModeData
[MaxMode
].GopModeNumber
= ModeNumber
;
477 Private
->ModeData
[MaxMode
].DeltaX
= 0;
478 Private
->ModeData
[MaxMode
].DeltaY
= 0;
483 // Add Mode #2 that must be 100x31 (graphic mode >= 800x600)
485 if (Columns
>= 100 && Rows
>= 31) {
486 Private
->ModeData
[MaxMode
].GopWidth
= HorizontalResolution
;
487 Private
->ModeData
[MaxMode
].GopHeight
= VerticalResolution
;
488 Private
->ModeData
[MaxMode
].GopModeNumber
= ModeNumber
;
489 Private
->ModeData
[MaxMode
].DeltaX
= (HorizontalResolution
- (100 * EFI_GLYPH_WIDTH
)) >> 1;
490 Private
->ModeData
[MaxMode
].DeltaY
= (VerticalResolution
- (31 * EFI_GLYPH_HEIGHT
)) >> 1;
495 // Add Mode #3 that uses the entire display for user-defined mode
497 if (HorizontalResolution
> 800 && VerticalResolution
> 600) {
498 Private
->ModeData
[MaxMode
].Columns
= HorizontalResolution
/EFI_GLYPH_WIDTH
;
499 Private
->ModeData
[MaxMode
].Rows
= VerticalResolution
/EFI_GLYPH_HEIGHT
;
500 Private
->ModeData
[MaxMode
].GopWidth
= HorizontalResolution
;
501 Private
->ModeData
[MaxMode
].GopHeight
= VerticalResolution
;
502 Private
->ModeData
[MaxMode
].GopModeNumber
= ModeNumber
;
503 Private
->ModeData
[MaxMode
].DeltaX
= (HorizontalResolution
% EFI_GLYPH_WIDTH
) >> 1;
504 Private
->ModeData
[MaxMode
].DeltaY
= (VerticalResolution
% EFI_GLYPH_HEIGHT
) >> 1;
509 // Update the maximum number of modes
511 Private
->SimpleTextOutputMode
.MaxMode
= (INT32
) MaxMode
;
514 // Determine the number of text modes that this protocol can support
516 Status
= GraphicsConsoleConOutSetMode (&Private
->SimpleTextOutput
, 0);
517 if (EFI_ERROR (Status
)) {
522 GraphicsConsoleConOutOutputString (&Private
->SimpleTextOutput
, (CHAR16
*)L
"Graphics Console Started\n\r");
526 // Install protocol interfaces for the Graphics Console device.
528 Status
= gBS
->InstallMultipleProtocolInterfaces (
530 &gEfiSimpleTextOutProtocolGuid
,
531 &Private
->SimpleTextOutput
,
536 if (EFI_ERROR (Status
)) {
538 // Close the GOP or UGA IO Protocol
540 if (Private
->GraphicsOutput
!= NULL
) {
543 &gEfiGraphicsOutputProtocolGuid
,
544 This
->DriverBindingHandle
,
547 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
550 &gEfiUgaDrawProtocolGuid
,
551 This
->DriverBindingHandle
,
559 if (Private
!= NULL
) {
560 if (Private
->LineBuffer
!= NULL
) {
561 FreePool (Private
->LineBuffer
);
572 GraphicsConsoleControllerDriverStop (
573 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
574 IN EFI_HANDLE Controller
,
575 IN UINTN NumberOfChildren
,
576 IN EFI_HANDLE
*ChildHandleBuffer
580 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*SimpleTextOutput
;
581 GRAPHICS_CONSOLE_DEV
*Private
;
583 Status
= gBS
->OpenProtocol (
585 &gEfiSimpleTextOutProtocolGuid
,
586 (VOID
**) &SimpleTextOutput
,
587 This
->DriverBindingHandle
,
589 EFI_OPEN_PROTOCOL_GET_PROTOCOL
591 if (EFI_ERROR (Status
)) {
592 return EFI_NOT_STARTED
;
595 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (SimpleTextOutput
);
597 Status
= gBS
->UninstallProtocolInterface (
599 &gEfiSimpleTextOutProtocolGuid
,
600 &Private
->SimpleTextOutput
603 if (!EFI_ERROR (Status
)) {
605 // Close the GOP or UGA IO Protocol
607 if (Private
->GraphicsOutput
!= NULL
) {
610 &gEfiGraphicsOutputProtocolGuid
,
611 This
->DriverBindingHandle
,
614 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
617 &gEfiUgaDrawProtocolGuid
,
618 This
->DriverBindingHandle
,
624 // Remove the font pack
626 if (Private
->HiiHandle
!= NULL
) {
627 HiiLibRemovePackages (Private
->HiiHandle
);
628 mFirstAccessFlag
= TRUE
;
632 // Free our instance data
634 if (Private
!= NULL
) {
635 FreePool (Private
->LineBuffer
);
645 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
646 IN UINT32 HorizontalResolution
,
647 IN UINT32 VerticalResolution
,
648 OUT UINT32
*CurrentModeNumber
654 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
656 Status
= EFI_SUCCESS
;
658 for (ModeNumber
= 0; ModeNumber
< GraphicsOutput
->Mode
->MaxMode
; ModeNumber
++) {
659 Status
= GraphicsOutput
->QueryMode (
665 if (!EFI_ERROR (Status
)) {
666 if ((Info
->HorizontalResolution
== HorizontalResolution
) &&
667 (Info
->VerticalResolution
== VerticalResolution
)) {
668 Status
= GraphicsOutput
->SetMode (GraphicsOutput
, ModeNumber
);
669 if (!EFI_ERROR (Status
)) {
670 gBS
->FreePool (Info
);
674 gBS
->FreePool (Info
);
678 if (ModeNumber
== GraphicsOutput
->Mode
->MaxMode
) {
679 Status
= EFI_UNSUPPORTED
;
682 *CurrentModeNumber
= ModeNumber
;
687 EfiLocateHiiProtocol (
693 Locate HII protocols for future usage.
706 // There should only be one - so buffer size is this
708 Size
= sizeof (EFI_HANDLE
);
710 Status
= gBS
->LocateHandle (
712 &gEfiHiiDatabaseProtocolGuid
,
718 if (EFI_ERROR (Status
)) {
722 Status
= gBS
->HandleProtocol (
724 &gEfiHiiDatabaseProtocolGuid
,
725 (VOID
**) &mHiiDatabase
728 if (EFI_ERROR (Status
)) {
732 Status
= gBS
->HandleProtocol (
734 &gEfiHiiFontProtocolGuid
,
741 // Body of the STO functions
745 GraphicsConsoleConOutReset (
746 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
747 IN BOOLEAN ExtendedVerification
752 Implements SIMPLE_TEXT_OUTPUT.Reset().
753 If ExtendeVerification is TRUE, then perform dependent Graphics Console
754 device reset, and set display mode to mode 0.
755 If ExtendedVerification is FALSE, only set display mode to mode 0.
759 This - Indicates the calling context.
761 ExtendedVerification - Indicates that the driver may perform a more exhaustive
762 verification operation of the device during reset.
767 The reset operation succeeds.
770 The Graphics Console is not functioning correctly
774 This
->SetAttribute (This
, EFI_TEXT_ATTR (This
->Mode
->Attribute
& 0x0F, EFI_BACKGROUND_BLACK
));
775 return This
->SetMode (This
, 0);
780 GraphicsConsoleConOutOutputString (
781 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
787 Implements SIMPLE_TEXT_OUTPUT.OutputString().
788 The Unicode string will be converted to Glyphs and will be
789 sent to the Graphics Console.
794 This - Indicates the calling context.
796 WString - The Null-terminated Unicode string to be displayed on
797 the Graphics Console.
802 The string is output successfully.
805 The Graphics Console failed to send the string out.
807 EFI_WARN_UNKNOWN_GLYPH
808 Indicates that some of the characters in the Unicode string could not
809 be rendered and are skipped.
813 GRAPHICS_CONSOLE_DEV
*Private
;
814 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
815 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
824 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
825 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
830 INT32 OriginAttribute
;
832 CHAR16 SpaceStr
[] = { NARROW_CHAR
, ' ', 0 };
834 Status
= EFI_SUCCESS
;
836 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
840 Mode
= This
->Mode
->Mode
;
841 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
842 GraphicsOutput
= Private
->GraphicsOutput
;
843 UgaDraw
= Private
->UgaDraw
;
845 MaxColumn
= Private
->ModeData
[Mode
].Columns
;
846 MaxRow
= Private
->ModeData
[Mode
].Rows
;
847 DeltaX
= Private
->ModeData
[Mode
].DeltaX
;
848 DeltaY
= Private
->ModeData
[Mode
].DeltaY
;
849 Width
= MaxColumn
* EFI_GLYPH_WIDTH
;
850 Height
= (MaxRow
- 1) * EFI_GLYPH_HEIGHT
;
851 Delta
= Width
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
);
854 // The Attributes won't change when during the time OutputString is called
856 GetTextColors (This
, &Foreground
, &Background
);
865 OriginAttribute
= This
->Mode
->Attribute
;
869 if (*WString
== CHAR_BACKSPACE
) {
871 // If the cursor is at the left edge of the display, then move the cursor
874 if (This
->Mode
->CursorColumn
== 0 && This
->Mode
->CursorRow
> 0) {
875 This
->Mode
->CursorRow
--;
876 This
->Mode
->CursorColumn
= (INT32
) (MaxColumn
- 1);
877 This
->OutputString (This
, SpaceStr
);
879 This
->Mode
->CursorRow
--;
880 This
->Mode
->CursorColumn
= (INT32
) (MaxColumn
- 1);
881 } else if (This
->Mode
->CursorColumn
> 0) {
883 // If the cursor is not at the left edge of the display, then move the cursor
886 This
->Mode
->CursorColumn
--;
887 This
->OutputString (This
, SpaceStr
);
889 This
->Mode
->CursorColumn
--;
894 } else if (*WString
== CHAR_LINEFEED
) {
896 // If the cursor is at the bottom of the display, then scroll the display one
897 // row, and do not update the cursor position. Otherwise, move the cursor
900 if (This
->Mode
->CursorRow
== (INT32
) (MaxRow
- 1)) {
901 if (GraphicsOutput
!= NULL
) {
903 // Scroll Screen Up One Row
905 GraphicsOutput
->Blt (
910 DeltaY
+ EFI_GLYPH_HEIGHT
,
919 // Print Blank Line at last line
921 GraphicsOutput
->Blt (
933 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
935 // Scroll Screen Up One Row
942 DeltaY
+ EFI_GLYPH_HEIGHT
,
951 // Print Blank Line at last line
955 (EFI_UGA_PIXEL
*) (UINTN
) &Background
,
967 This
->Mode
->CursorRow
++;
972 } else if (*WString
== CHAR_CARRIAGE_RETURN
) {
974 // Move the cursor to the beginning of the current row.
976 This
->Mode
->CursorColumn
= 0;
979 } else if (*WString
== WIDE_CHAR
) {
981 This
->Mode
->Attribute
|= EFI_WIDE_ATTRIBUTE
;
984 } else if (*WString
== NARROW_CHAR
) {
986 This
->Mode
->Attribute
&= (~ (UINT32
) EFI_WIDE_ATTRIBUTE
);
991 // Print the character at the current cursor position and move the cursor
992 // right one column. If this moves the cursor past the right edge of the
993 // display, then the line should wrap to the beginning of the next line. This
994 // is equivalent to inserting a CR and an LF. Note that if the cursor is at the
995 // bottom of the display, and the line wraps, then the display will be scrolled
997 // If wide char is going to be displayed, need to display one character at a time
998 // Or, need to know the display length of a certain string.
1000 // Index is used to determine how many character width units (wide = 2, narrow = 1)
1001 // Count is used to determine how many characters are used regardless of their attributes
1003 for (Count
= 0, Index
= 0; (This
->Mode
->CursorColumn
+ Index
) < MaxColumn
; Count
++, Index
++) {
1004 if (WString
[Count
] == CHAR_NULL
) {
1008 if (WString
[Count
] == CHAR_BACKSPACE
) {
1012 if (WString
[Count
] == CHAR_LINEFEED
) {
1016 if (WString
[Count
] == CHAR_CARRIAGE_RETURN
) {
1020 if (WString
[Count
] == WIDE_CHAR
) {
1024 if (WString
[Count
] == NARROW_CHAR
) {
1028 // Is the wide attribute on?
1030 if (This
->Mode
->Attribute
& EFI_WIDE_ATTRIBUTE
) {
1032 // If wide, add one more width unit than normal since we are going to increment at the end of the for loop
1036 // This is the end-case where if we are at column 79 and about to print a wide character
1037 // We should prevent this from happening because we will wrap inappropriately. We should
1038 // not print this character until the next line.
1040 if ((This
->Mode
->CursorColumn
+ Index
+ 1) > MaxColumn
) {
1047 Status
= DrawUnicodeWeightAtCursorN (This
, WString
, Count
);
1048 if (EFI_ERROR (Status
)) {
1052 // At the end of line, output carriage return and line feed
1055 This
->Mode
->CursorColumn
+= (INT32
) Index
;
1056 if (This
->Mode
->CursorColumn
> (INT32
) MaxColumn
) {
1057 This
->Mode
->CursorColumn
-= 2;
1058 This
->OutputString (This
, SpaceStr
);
1061 if (This
->Mode
->CursorColumn
>= (INT32
) MaxColumn
) {
1063 This
->OutputString (This
, mCrLfString
);
1069 This
->Mode
->Attribute
= OriginAttribute
;
1074 Status
= EFI_WARN_UNKNOWN_GLYPH
;
1077 gBS
->RestoreTPL (OldTpl
);
1084 GraphicsConsoleConOutTestString (
1085 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1089 Routine Description:
1091 Implements SIMPLE_TEXT_OUTPUT.TestString().
1092 If one of the characters in the *Wstring is
1093 neither valid valid Unicode drawing characters,
1094 not ASCII code, then this function will return
1100 This - Indicates the calling context.
1102 WString - The Null-terminated Unicode string to be tested.
1107 The Graphics Console is capable of rendering the output string.
1110 Some of the characters in the Unicode string cannot be rendered.
1117 EFI_IMAGE_OUTPUT
*Blt
= NULL
;
1121 while (WString
[Count
] != 0) {
1122 Status
= mHiiFont
->GetGlyph (
1133 if (EFI_ERROR (Status
)) {
1134 return EFI_UNSUPPORTED
;
1143 GraphicsConsoleConOutQueryMode (
1144 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1145 IN UINTN ModeNumber
,
1150 Routine Description:
1152 Implements SIMPLE_TEXT_OUTPUT.QueryMode().
1153 It returnes information for an available text mode
1154 that the Graphics Console supports.
1155 In this driver,we only support text mode 80x25, which is
1161 This - Indicates the calling context.
1163 ModeNumber - The mode number to return information on.
1165 Columns - The returned columns of the requested mode.
1167 Rows - The returned rows of the requested mode.
1172 The requested mode information is returned.
1175 The mode number is not valid.
1179 GRAPHICS_CONSOLE_DEV
*Private
;
1183 if (ModeNumber
>= (UINTN
) This
->Mode
->MaxMode
) {
1184 return EFI_UNSUPPORTED
;
1187 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1188 Status
= EFI_SUCCESS
;
1190 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1192 *Columns
= Private
->ModeData
[ModeNumber
].Columns
;
1193 *Rows
= Private
->ModeData
[ModeNumber
].Rows
;
1195 if (*Columns
<= 0 && *Rows
<= 0) {
1196 Status
= EFI_UNSUPPORTED
;
1202 gBS
->RestoreTPL (OldTpl
);
1208 GraphicsConsoleConOutSetMode (
1209 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1213 Routine Description:
1215 Implements SIMPLE_TEXT_OUTPUT.SetMode().
1216 Set the Graphics Console to a specified mode.
1217 In this driver, we only support mode 0.
1221 This - Indicates the calling context.
1223 ModeNumber - The text mode to set.
1228 The requested text mode is set.
1231 The requested text mode cannot be set because of Graphics Console device error.
1234 The text mode number is not valid.
1239 GRAPHICS_CONSOLE_DEV
*Private
;
1240 GRAPHICS_CONSOLE_MODE_DATA
*ModeData
;
1241 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*NewLineBuffer
;
1242 UINT32 HorizontalResolution
;
1243 UINT32 VerticalResolution
;
1244 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1245 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1250 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1252 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1253 GraphicsOutput
= Private
->GraphicsOutput
;
1254 UgaDraw
= Private
->UgaDraw
;
1255 ModeData
= &(Private
->ModeData
[ModeNumber
]);
1257 if (ModeData
->Columns
<= 0 && ModeData
->Rows
<= 0) {
1258 Status
= EFI_UNSUPPORTED
;
1263 // Make sure the requested mode number is supported
1265 if (ModeNumber
>= (UINTN
) This
->Mode
->MaxMode
) {
1266 Status
= EFI_UNSUPPORTED
;
1270 if (ModeData
->Columns
<= 0 && ModeData
->Rows
<= 0) {
1271 Status
= EFI_UNSUPPORTED
;
1275 // Attempt to allocate a line buffer for the requested mode number
1277 NewLineBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
) * ModeData
->Columns
* EFI_GLYPH_WIDTH
* EFI_GLYPH_HEIGHT
);
1279 if (NewLineBuffer
== NULL
) {
1281 // The new line buffer could not be allocated, so return an error.
1282 // No changes to the state of the current console have been made, so the current console is still valid
1284 Status
= EFI_OUT_OF_RESOURCES
;
1288 // If the mode has been set at least one other time, then LineBuffer will not be NULL
1290 if (Private
->LineBuffer
!= NULL
) {
1292 // Clear the current text window on the current graphics console
1294 This
->ClearScreen (This
);
1297 // If the new mode is the same as the old mode, then just return EFI_SUCCESS
1299 if ((INT32
) ModeNumber
== This
->Mode
->Mode
) {
1300 FreePool (NewLineBuffer
);
1301 Status
= EFI_SUCCESS
;
1305 // Otherwise, the size of the text console and/or the GOP/UGA mode will be changed,
1306 // so erase the cursor, and free the LineBuffer for the current mode
1310 FreePool (Private
->LineBuffer
);
1313 // Assign the current line buffer to the newly allocated line buffer
1315 Private
->LineBuffer
= NewLineBuffer
;
1317 if (GraphicsOutput
!= NULL
) {
1318 if (ModeData
->GopModeNumber
!= GraphicsOutput
->Mode
->Mode
) {
1320 // Either no graphics mode is currently set, or it is set to the wrong resolution, so set the new grapghics mode
1322 Status
= GraphicsOutput
->SetMode (GraphicsOutput
, ModeData
->GopModeNumber
);
1323 if (EFI_ERROR (Status
)) {
1325 // The mode set operation failed
1331 // The current graphics mode is correct, so simply clear the entire display
1333 Status
= GraphicsOutput
->Blt (
1342 ModeData
->GopHeight
,
1346 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
1348 // Get the current UGA Draw mode information
1350 Status
= UgaDraw
->GetMode (
1352 &HorizontalResolution
,
1353 &VerticalResolution
,
1357 if (EFI_ERROR (Status
) || HorizontalResolution
!= ModeData
->GopWidth
|| VerticalResolution
!= ModeData
->GopHeight
) {
1359 // Either no graphics mode is currently set, or it is set to the wrong resolution, so set the new grapghics mode
1361 Status
= UgaDraw
->SetMode (
1364 ModeData
->GopHeight
,
1368 if (EFI_ERROR (Status
)) {
1370 // The mode set operation failed
1376 // The current graphics mode is correct, so simply clear the entire display
1378 Status
= UgaDraw
->Blt (
1380 (EFI_UGA_PIXEL
*) (UINTN
) &mEfiColors
[0],
1387 ModeData
->GopHeight
,
1394 // The new mode is valid, so commit the mode change
1396 This
->Mode
->Mode
= (INT32
) ModeNumber
;
1399 // Move the text cursor to the upper left hand corner of the displat and enable it
1401 This
->SetCursorPosition (This
, 0, 0);
1403 Status
= EFI_SUCCESS
;
1406 gBS
->RestoreTPL (OldTpl
);
1412 GraphicsConsoleConOutSetAttribute (
1413 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1417 Routine Description:
1419 Implements SIMPLE_TEXT_OUTPUT.SetAttribute().
1423 This - Indicates the calling context.
1425 Attrubute - The attribute to set. Only bit0..6 are valid, all other bits
1426 are undefined and must be zero.
1431 The requested attribute is set.
1434 The requested attribute cannot be set due to Graphics Console port error.
1437 The attribute requested is not defined by EFI spec.
1443 if ((Attribute
| 0xFF) != 0xFF) {
1444 return EFI_UNSUPPORTED
;
1447 if ((INT32
) Attribute
== This
->Mode
->Attribute
) {
1451 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1455 This
->Mode
->Attribute
= (INT32
) Attribute
;
1459 gBS
->RestoreTPL (OldTpl
);
1466 GraphicsConsoleConOutClearScreen (
1467 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
1470 Routine Description:
1472 Implements SIMPLE_TEXT_OUTPUT.ClearScreen().
1473 It clears the Graphics Console's display to the
1474 currently selected background color.
1479 This - Indicates the calling context.
1484 The operation completed successfully.
1487 The Graphics Console cannot be cleared due to Graphics Console device error.
1490 The Graphics Console is not in a valid text mode.
1495 GRAPHICS_CONSOLE_DEV
*Private
;
1496 GRAPHICS_CONSOLE_MODE_DATA
*ModeData
;
1497 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1498 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1499 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
1500 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
1503 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1505 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1506 GraphicsOutput
= Private
->GraphicsOutput
;
1507 UgaDraw
= Private
->UgaDraw
;
1508 ModeData
= &(Private
->ModeData
[This
->Mode
->Mode
]);
1510 GetTextColors (This
, &Foreground
, &Background
);
1511 if (GraphicsOutput
!= NULL
) {
1512 Status
= GraphicsOutput
->Blt (
1521 ModeData
->GopHeight
,
1524 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
1525 Status
= UgaDraw
->Blt (
1527 (EFI_UGA_PIXEL
*) (UINTN
) &Background
,
1534 ModeData
->GopHeight
,
1538 Status
= EFI_UNSUPPORTED
;
1541 This
->Mode
->CursorColumn
= 0;
1542 This
->Mode
->CursorRow
= 0;
1546 gBS
->RestoreTPL (OldTpl
);
1553 GraphicsConsoleConOutSetCursorPosition (
1554 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1559 Routine Description:
1561 Implements SIMPLE_TEXT_OUTPUT.SetCursorPosition().
1565 This - Indicates the calling context.
1567 Column - The row to set cursor to.
1569 Row - The column to set cursor to.
1574 The operation completed successfully.
1577 The request fails due to Graphics Console device error.
1580 The Graphics Console is not in a valid text mode, or the cursor position
1581 is invalid for current mode.
1585 GRAPHICS_CONSOLE_DEV
*Private
;
1586 GRAPHICS_CONSOLE_MODE_DATA
*ModeData
;
1590 Status
= EFI_SUCCESS
;
1592 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1594 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1595 ModeData
= &(Private
->ModeData
[This
->Mode
->Mode
]);
1597 if ((Column
>= ModeData
->Columns
) || (Row
>= ModeData
->Rows
)) {
1598 Status
= EFI_UNSUPPORTED
;
1602 if (((INT32
) Column
== This
->Mode
->CursorColumn
) && ((INT32
) Row
== This
->Mode
->CursorRow
)) {
1603 Status
= EFI_SUCCESS
;
1609 This
->Mode
->CursorColumn
= (INT32
) Column
;
1610 This
->Mode
->CursorRow
= (INT32
) Row
;
1615 gBS
->RestoreTPL (OldTpl
);
1622 GraphicsConsoleConOutEnableCursor (
1623 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1627 Routine Description:
1629 Implements SIMPLE_TEXT_OUTPUT.EnableCursor().
1630 In this driver, the cursor cannot be hidden.
1634 This - Indicates the calling context.
1636 Visible - If TRUE, the cursor is set to be visible,
1637 If FALSE, the cursor is set to be invisible.
1642 The request is valid.
1645 The Graphics Console does not support a hidden cursor.
1651 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1655 This
->Mode
->CursorVisible
= Visible
;
1659 gBS
->RestoreTPL (OldTpl
);
1666 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1667 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Foreground
,
1668 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Background
1673 Attribute
= This
->Mode
->Attribute
& 0x7F;
1675 *Foreground
= mEfiColors
[Attribute
& 0x0f];
1676 *Background
= mEfiColors
[Attribute
>> 4];
1682 DrawUnicodeWeightAtCursorN (
1683 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1684 IN CHAR16
*UnicodeWeight
,
1689 GRAPHICS_CONSOLE_DEV
*Private
;
1690 EFI_IMAGE_OUTPUT
*Blt
;
1692 EFI_FONT_DISPLAY_INFO
*FontInfo
;
1693 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1694 EFI_HII_ROW_INFO
*RowInfoArray
;
1695 UINTN RowInfoArraySize
;
1697 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1698 Blt
= (EFI_IMAGE_OUTPUT
*) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT
));
1700 return EFI_OUT_OF_RESOURCES
;
1703 Blt
->Width
= (UINT16
) (Private
->ModeData
[This
->Mode
->Mode
].GopWidth
);
1704 Blt
->Height
= (UINT16
) (Private
->ModeData
[This
->Mode
->Mode
].GopHeight
);
1706 String
= AllocateCopyPool ((Count
+ 1) * sizeof (CHAR16
), UnicodeWeight
);
1707 if (String
== NULL
) {
1709 return EFI_OUT_OF_RESOURCES
;
1711 *(String
+ Count
) = 0;
1713 FontInfo
= (EFI_FONT_DISPLAY_INFO
*) AllocateZeroPool (sizeof (EFI_FONT_DISPLAY_INFO
));
1714 if (FontInfo
== NULL
) {
1716 SafeFreePool (String
);
1717 return EFI_OUT_OF_RESOURCES
;
1719 GetTextColors (This
, &FontInfo
->ForegroundColor
, &FontInfo
->BackgroundColor
);
1721 if (Private
->GraphicsOutput
!= NULL
) {
1722 Blt
->Image
.Screen
= Private
->GraphicsOutput
;
1724 Status
= mHiiFont
->StringToImage (
1726 EFI_HII_IGNORE_IF_NO_GLYPH
| EFI_HII_DIRECT_TO_SCREEN
,
1730 This
->Mode
->CursorColumn
* EFI_GLYPH_WIDTH
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaX
,
1731 This
->Mode
->CursorRow
* EFI_GLYPH_HEIGHT
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaY
,
1737 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
1738 ASSERT (Private
->UgaDraw
!= NULL
);
1740 UgaDraw
= Private
->UgaDraw
;
1742 Blt
->Image
.Bitmap
= AllocateZeroPool (Blt
->Width
* Blt
->Height
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
));
1743 if (Blt
->Image
.Bitmap
== NULL
) {
1745 SafeFreePool (String
);
1746 return EFI_OUT_OF_RESOURCES
;
1749 RowInfoArray
= NULL
;
1751 // StringToImage only support blt'ing image to device using GOP protocol. If GOP is not supported in this platform,
1752 // we ask StringToImage to print the string to blt buffer, then blt to device using UgaDraw.
1754 Status
= mHiiFont
->StringToImage (
1756 EFI_HII_IGNORE_IF_NO_GLYPH
,
1760 This
->Mode
->CursorColumn
* EFI_GLYPH_WIDTH
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaX
,
1761 This
->Mode
->CursorRow
* EFI_GLYPH_HEIGHT
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaY
,
1767 if (!EFI_ERROR (Status
)) {
1769 // Line breaks are handled by caller of DrawUnicodeWeightAtCursorN, so the updated parameter RowInfoArraySize by StringToImage will
1770 // always be 1. ASSERT here to make sure.
1772 ASSERT (RowInfoArraySize
== 1);
1774 Status
= UgaDraw
->Blt (
1776 (EFI_UGA_PIXEL
*) Blt
->Image
.Bitmap
,
1777 EfiUgaBltBufferToVideo
,
1778 This
->Mode
->CursorColumn
* EFI_GLYPH_WIDTH
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaX
,
1779 (This
->Mode
->CursorRow
) * EFI_GLYPH_HEIGHT
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaY
,
1780 This
->Mode
->CursorColumn
* EFI_GLYPH_WIDTH
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaX
,
1781 (This
->Mode
->CursorRow
) * EFI_GLYPH_HEIGHT
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaY
,
1782 RowInfoArray
[0].LineWidth
,
1783 RowInfoArray
[0].LineHeight
,
1784 Blt
->Width
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
1788 SafeFreePool (RowInfoArray
);
1789 SafeFreePool (Blt
->Image
.Bitmap
);
1791 Status
= EFI_UNSUPPORTED
;
1795 SafeFreePool (String
);
1796 SafeFreePool (FontInfo
);
1804 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
1807 GRAPHICS_CONSOLE_DEV
*Private
;
1808 EFI_SIMPLE_TEXT_OUTPUT_MODE
*CurrentMode
;
1811 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1812 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1813 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Foreground
;
1814 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Background
;
1815 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION BltChar
[EFI_GLYPH_HEIGHT
][EFI_GLYPH_WIDTH
];
1819 CurrentMode
= This
->Mode
;
1821 if (!CurrentMode
->CursorVisible
) {
1825 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1826 GraphicsOutput
= Private
->GraphicsOutput
;
1827 UgaDraw
= Private
->UgaDraw
;
1830 // BUGBUG - we need to think about what to do with wide and narrow character deletions.
1833 // Blt a character to the screen
1835 GlyphX
= (CurrentMode
->CursorColumn
* EFI_GLYPH_WIDTH
) + Private
->ModeData
[CurrentMode
->Mode
].DeltaX
;
1836 GlyphY
= (CurrentMode
->CursorRow
* EFI_GLYPH_HEIGHT
) + Private
->ModeData
[CurrentMode
->Mode
].DeltaY
;
1837 if (GraphicsOutput
!= NULL
) {
1838 GraphicsOutput
->Blt (
1840 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*) BltChar
,
1841 EfiBltVideoToBltBuffer
,
1848 EFI_GLYPH_WIDTH
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
1850 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
1853 (EFI_UGA_PIXEL
*) (UINTN
) BltChar
,
1854 EfiUgaVideoToBltBuffer
,
1861 EFI_GLYPH_WIDTH
* sizeof (EFI_UGA_PIXEL
)
1865 GetTextColors (This
, &Foreground
.Pixel
, &Background
.Pixel
);
1868 // Convert Monochrome bitmap of the Glyph to BltBuffer structure
1870 for (Y
= 0; Y
< EFI_GLYPH_HEIGHT
; Y
++) {
1871 for (X
= 0; X
< EFI_GLYPH_WIDTH
; X
++) {
1872 if ((mCursorGlyph
.GlyphCol1
[Y
] & (1 << X
)) != 0) {
1873 BltChar
[Y
][EFI_GLYPH_WIDTH
- X
- 1].Raw
^= Foreground
.Raw
;
1878 if (GraphicsOutput
!= NULL
) {
1879 GraphicsOutput
->Blt (
1881 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*) BltChar
,
1882 EfiBltBufferToVideo
,
1889 EFI_GLYPH_WIDTH
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
1891 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
1894 (EFI_UGA_PIXEL
*) (UINTN
) BltChar
,
1895 EfiUgaBltBufferToVideo
,
1902 EFI_GLYPH_WIDTH
* sizeof (EFI_UGA_PIXEL
)
1910 The user Entry Point for module GraphicsConsole. The user code starts with this function.
1912 @param[in] ImageHandle The firmware allocated handle for the EFI image.
1913 @param[in] SystemTable A pointer to the EFI System Table.
1915 @retval EFI_SUCCESS The entry point is executed successfully.
1916 @retval other Some error occurs when executing this entry point.
1921 InitializeGraphicsConsole (
1922 IN EFI_HANDLE ImageHandle
,
1923 IN EFI_SYSTEM_TABLE
*SystemTable
1929 // Install driver model protocol(s).
1931 Status
= EfiLibInstallDriverBindingComponentName2 (
1934 &gGraphicsConsoleDriverBinding
,
1936 &gGraphicsConsoleComponentName
,
1937 &gGraphicsConsoleComponentName2
1939 ASSERT_EFI_ERROR (Status
);