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
)) {
431 // Compute the maximum number of text Rows and Columns that this current graphics mode can support
433 Columns
= HorizontalResolution
/ GLYPH_WIDTH
;
434 Rows
= VerticalResolution
/ GLYPH_HEIGHT
;
437 // See if the mode is too small to support the required 80x25 text mode
439 if (Columns
< 80 || Rows
< 25) {
443 // Add Mode #0 that must be 80x25
446 Private
->ModeData
[MaxMode
].GopWidth
= HorizontalResolution
;
447 Private
->ModeData
[MaxMode
].GopHeight
= VerticalResolution
;
448 Private
->ModeData
[MaxMode
].GopModeNumber
= ModeNumber
;
449 Private
->ModeData
[MaxMode
].DeltaX
= (HorizontalResolution
- (80 * GLYPH_WIDTH
)) >> 1;
450 Private
->ModeData
[MaxMode
].DeltaY
= (VerticalResolution
- (25 * GLYPH_HEIGHT
)) >> 1;
454 // If it is possible to support Mode #1 - 80x50, than add it as an active mode
457 Private
->ModeData
[MaxMode
].GopWidth
= HorizontalResolution
;
458 Private
->ModeData
[MaxMode
].GopHeight
= VerticalResolution
;
459 Private
->ModeData
[MaxMode
].GopModeNumber
= ModeNumber
;
460 Private
->ModeData
[MaxMode
].DeltaX
= (HorizontalResolution
- (80 * GLYPH_WIDTH
)) >> 1;
461 Private
->ModeData
[MaxMode
].DeltaY
= (VerticalResolution
- (50 * GLYPH_HEIGHT
)) >> 1;
466 // If it is not to support Mode #1 - 80x50, then skip it
469 Private
->ModeData
[MaxMode
].Columns
= 0;
470 Private
->ModeData
[MaxMode
].Rows
= 0;
471 Private
->ModeData
[MaxMode
].GopWidth
= HorizontalResolution
;
472 Private
->ModeData
[MaxMode
].GopHeight
= VerticalResolution
;
473 Private
->ModeData
[MaxMode
].GopModeNumber
= ModeNumber
;
474 Private
->ModeData
[MaxMode
].DeltaX
= 0;
475 Private
->ModeData
[MaxMode
].DeltaY
= 0;
480 // Add Mode #2 that must be 100x31 (graphic mode >= 800x600)
482 if (Columns
>= 100 && Rows
>= 31) {
483 Private
->ModeData
[MaxMode
].GopWidth
= HorizontalResolution
;
484 Private
->ModeData
[MaxMode
].GopHeight
= VerticalResolution
;
485 Private
->ModeData
[MaxMode
].GopModeNumber
= ModeNumber
;
486 Private
->ModeData
[MaxMode
].DeltaX
= (HorizontalResolution
- (100 * GLYPH_WIDTH
)) >> 1;
487 Private
->ModeData
[MaxMode
].DeltaY
= (VerticalResolution
- (31 * GLYPH_HEIGHT
)) >> 1;
492 // Add Mode #3 that uses the entire display for user-defined mode
494 if (HorizontalResolution
> 800 && VerticalResolution
> 600) {
495 Private
->ModeData
[MaxMode
].Columns
= HorizontalResolution
/GLYPH_WIDTH
;
496 Private
->ModeData
[MaxMode
].Rows
= VerticalResolution
/GLYPH_HEIGHT
;
497 Private
->ModeData
[MaxMode
].GopWidth
= HorizontalResolution
;
498 Private
->ModeData
[MaxMode
].GopHeight
= VerticalResolution
;
499 Private
->ModeData
[MaxMode
].GopModeNumber
= ModeNumber
;
500 Private
->ModeData
[MaxMode
].DeltaX
= (HorizontalResolution
% GLYPH_WIDTH
) >> 1;
501 Private
->ModeData
[MaxMode
].DeltaY
= (VerticalResolution
% GLYPH_HEIGHT
) >> 1;
506 // Update the maximum number of modes
508 Private
->SimpleTextOutputMode
.MaxMode
= (INT32
) MaxMode
;
511 // Determine the number of text modes that this protocol can support
513 Status
= GraphicsConsoleConOutSetMode (&Private
->SimpleTextOutput
, 0);
514 if (EFI_ERROR (Status
)) {
519 GraphicsConsoleConOutOutputString (&Private
->SimpleTextOutput
, (CHAR16
*)L
"Graphics Console Started\n\r");
523 // Install protocol interfaces for the Graphics Console device.
525 Status
= gBS
->InstallMultipleProtocolInterfaces (
527 &gEfiSimpleTextOutProtocolGuid
,
528 &Private
->SimpleTextOutput
,
533 if (EFI_ERROR (Status
)) {
535 // Close the GOP or UGA IO Protocol
537 if (Private
->GraphicsOutput
!= NULL
) {
540 &gEfiGraphicsOutputProtocolGuid
,
541 This
->DriverBindingHandle
,
544 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
547 &gEfiUgaDrawProtocolGuid
,
548 This
->DriverBindingHandle
,
556 if (Private
!= NULL
) {
557 if (Private
->LineBuffer
!= NULL
) {
558 FreePool (Private
->LineBuffer
);
569 GraphicsConsoleControllerDriverStop (
570 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
571 IN EFI_HANDLE Controller
,
572 IN UINTN NumberOfChildren
,
573 IN EFI_HANDLE
*ChildHandleBuffer
577 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*SimpleTextOutput
;
578 GRAPHICS_CONSOLE_DEV
*Private
;
580 Status
= gBS
->OpenProtocol (
582 &gEfiSimpleTextOutProtocolGuid
,
583 (VOID
**) &SimpleTextOutput
,
584 This
->DriverBindingHandle
,
586 EFI_OPEN_PROTOCOL_GET_PROTOCOL
588 if (EFI_ERROR (Status
)) {
589 return EFI_NOT_STARTED
;
592 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (SimpleTextOutput
);
594 Status
= gBS
->UninstallProtocolInterface (
596 &gEfiSimpleTextOutProtocolGuid
,
597 &Private
->SimpleTextOutput
600 if (!EFI_ERROR (Status
)) {
602 // Close the GOP or UGA IO Protocol
604 if (Private
->GraphicsOutput
!= NULL
) {
607 &gEfiGraphicsOutputProtocolGuid
,
608 This
->DriverBindingHandle
,
611 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
614 &gEfiUgaDrawProtocolGuid
,
615 This
->DriverBindingHandle
,
621 // Remove the font pack
623 if (Private
->HiiHandle
!= NULL
) {
624 HiiLibRemovePackages (Private
->HiiHandle
);
625 mFirstAccessFlag
= TRUE
;
629 // Free our instance data
631 if (Private
!= NULL
) {
632 FreePool (Private
->LineBuffer
);
642 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
643 IN UINT32 HorizontalResolution
,
644 IN UINT32 VerticalResolution
,
645 OUT UINT32
*CurrentModeNumber
651 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
653 Status
= EFI_SUCCESS
;
655 for (ModeNumber
= 0; ModeNumber
< GraphicsOutput
->Mode
->MaxMode
; ModeNumber
++) {
656 Status
= GraphicsOutput
->QueryMode (
662 if (!EFI_ERROR (Status
)) {
663 if ((Info
->HorizontalResolution
== HorizontalResolution
) &&
664 (Info
->VerticalResolution
== VerticalResolution
)) {
665 Status
= GraphicsOutput
->SetMode (GraphicsOutput
, ModeNumber
);
666 if (!EFI_ERROR (Status
)) {
667 gBS
->FreePool (Info
);
671 gBS
->FreePool (Info
);
675 if (ModeNumber
== GraphicsOutput
->Mode
->MaxMode
) {
676 Status
= EFI_UNSUPPORTED
;
679 *CurrentModeNumber
= ModeNumber
;
684 EfiLocateHiiProtocol (
690 Locate HII protocols for future usage.
703 // There should only be one - so buffer size is this
705 Size
= sizeof (EFI_HANDLE
);
707 Status
= gBS
->LocateHandle (
709 &gEfiHiiDatabaseProtocolGuid
,
715 if (EFI_ERROR (Status
)) {
719 Status
= gBS
->HandleProtocol (
721 &gEfiHiiDatabaseProtocolGuid
,
722 (VOID
**) &mHiiDatabase
725 if (EFI_ERROR (Status
)) {
729 Status
= gBS
->HandleProtocol (
731 &gEfiHiiFontProtocolGuid
,
738 // Body of the STO functions
742 GraphicsConsoleConOutReset (
743 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
744 IN BOOLEAN ExtendedVerification
749 Implements SIMPLE_TEXT_OUTPUT.Reset().
750 If ExtendeVerification is TRUE, then perform dependent Graphics Console
751 device reset, and set display mode to mode 0.
752 If ExtendedVerification is FALSE, only set display mode to mode 0.
756 This - Indicates the calling context.
758 ExtendedVerification - Indicates that the driver may perform a more exhaustive
759 verification operation of the device during reset.
764 The reset operation succeeds.
767 The Graphics Console is not functioning correctly
771 This
->SetAttribute (This
, EFI_TEXT_ATTR (This
->Mode
->Attribute
& 0x0F, EFI_BACKGROUND_BLACK
));
772 return This
->SetMode (This
, 0);
777 GraphicsConsoleConOutOutputString (
778 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
784 Implements SIMPLE_TEXT_OUTPUT.OutputString().
785 The Unicode string will be converted to Glyphs and will be
786 sent to the Graphics Console.
791 This - Indicates the calling context.
793 WString - The Null-terminated Unicode string to be displayed on
794 the Graphics Console.
799 The string is output successfully.
802 The Graphics Console failed to send the string out.
804 EFI_WARN_UNKNOWN_GLYPH
805 Indicates that some of the characters in the Unicode string could not
806 be rendered and are skipped.
810 GRAPHICS_CONSOLE_DEV
*Private
;
811 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
812 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
821 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
822 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
827 INT32 OriginAttribute
;
829 CHAR16 SpaceStr
[] = { NARROW_CHAR
, ' ', 0 };
831 Status
= EFI_SUCCESS
;
833 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
837 Mode
= This
->Mode
->Mode
;
838 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
839 GraphicsOutput
= Private
->GraphicsOutput
;
840 UgaDraw
= Private
->UgaDraw
;
842 MaxColumn
= Private
->ModeData
[Mode
].Columns
;
843 MaxRow
= Private
->ModeData
[Mode
].Rows
;
844 DeltaX
= Private
->ModeData
[Mode
].DeltaX
;
845 DeltaY
= Private
->ModeData
[Mode
].DeltaY
;
846 Width
= MaxColumn
* GLYPH_WIDTH
;
847 Height
= (MaxRow
- 1) * GLYPH_HEIGHT
;
848 Delta
= Width
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
);
851 // The Attributes won't change when during the time OutputString is called
853 GetTextColors (This
, &Foreground
, &Background
);
862 OriginAttribute
= This
->Mode
->Attribute
;
866 if (*WString
== CHAR_BACKSPACE
) {
868 // If the cursor is at the left edge of the display, then move the cursor
871 if (This
->Mode
->CursorColumn
== 0 && This
->Mode
->CursorRow
> 0) {
872 This
->Mode
->CursorRow
--;
873 This
->Mode
->CursorColumn
= (INT32
) (MaxColumn
- 1);
874 This
->OutputString (This
, SpaceStr
);
876 This
->Mode
->CursorRow
--;
877 This
->Mode
->CursorColumn
= (INT32
) (MaxColumn
- 1);
878 } else if (This
->Mode
->CursorColumn
> 0) {
880 // If the cursor is not at the left edge of the display, then move the cursor
883 This
->Mode
->CursorColumn
--;
884 This
->OutputString (This
, SpaceStr
);
886 This
->Mode
->CursorColumn
--;
891 } else if (*WString
== CHAR_LINEFEED
) {
893 // If the cursor is at the bottom of the display, then scroll the display one
894 // row, and do not update the cursor position. Otherwise, move the cursor
897 if (This
->Mode
->CursorRow
== (INT32
) (MaxRow
- 1)) {
898 if (GraphicsOutput
!= NULL
) {
900 // Scroll Screen Up One Row
902 GraphicsOutput
->Blt (
907 DeltaY
+ GLYPH_HEIGHT
,
916 // Print Blank Line at last line
918 GraphicsOutput
->Blt (
930 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
932 // Scroll Screen Up One Row
939 DeltaY
+ GLYPH_HEIGHT
,
948 // Print Blank Line at last line
952 (EFI_UGA_PIXEL
*) (UINTN
) &Background
,
964 This
->Mode
->CursorRow
++;
969 } else if (*WString
== CHAR_CARRIAGE_RETURN
) {
971 // Move the cursor to the beginning of the current row.
973 This
->Mode
->CursorColumn
= 0;
976 } else if (*WString
== WIDE_CHAR
) {
978 This
->Mode
->Attribute
|= EFI_WIDE_ATTRIBUTE
;
981 } else if (*WString
== NARROW_CHAR
) {
983 This
->Mode
->Attribute
&= (~ (UINT32
) EFI_WIDE_ATTRIBUTE
);
988 // Print the character at the current cursor position and move the cursor
989 // right one column. If this moves the cursor past the right edge of the
990 // display, then the line should wrap to the beginning of the next line. This
991 // is equivalent to inserting a CR and an LF. Note that if the cursor is at the
992 // bottom of the display, and the line wraps, then the display will be scrolled
994 // If wide char is going to be displayed, need to display one character at a time
995 // Or, need to know the display length of a certain string.
997 // Index is used to determine how many character width units (wide = 2, narrow = 1)
998 // Count is used to determine how many characters are used regardless of their attributes
1000 for (Count
= 0, Index
= 0; (This
->Mode
->CursorColumn
+ Index
) < MaxColumn
; Count
++, Index
++) {
1001 if (WString
[Count
] == CHAR_NULL
) {
1005 if (WString
[Count
] == CHAR_BACKSPACE
) {
1009 if (WString
[Count
] == CHAR_LINEFEED
) {
1013 if (WString
[Count
] == CHAR_CARRIAGE_RETURN
) {
1017 if (WString
[Count
] == WIDE_CHAR
) {
1021 if (WString
[Count
] == NARROW_CHAR
) {
1025 // Is the wide attribute on?
1027 if (This
->Mode
->Attribute
& EFI_WIDE_ATTRIBUTE
) {
1029 // If wide, add one more width unit than normal since we are going to increment at the end of the for loop
1033 // This is the end-case where if we are at column 79 and about to print a wide character
1034 // We should prevent this from happening because we will wrap inappropriately. We should
1035 // not print this character until the next line.
1037 if ((This
->Mode
->CursorColumn
+ Index
+ 1) > MaxColumn
) {
1044 Status
= DrawUnicodeWeightAtCursorN (This
, WString
, Count
);
1045 if (EFI_ERROR (Status
)) {
1049 // At the end of line, output carriage return and line feed
1052 This
->Mode
->CursorColumn
+= (INT32
) Index
;
1053 if (This
->Mode
->CursorColumn
> (INT32
) MaxColumn
) {
1054 This
->Mode
->CursorColumn
-= 2;
1055 This
->OutputString (This
, SpaceStr
);
1058 if (This
->Mode
->CursorColumn
>= (INT32
) MaxColumn
) {
1060 This
->OutputString (This
, mCrLfString
);
1066 This
->Mode
->Attribute
= OriginAttribute
;
1071 Status
= EFI_WARN_UNKNOWN_GLYPH
;
1074 gBS
->RestoreTPL (OldTpl
);
1081 GraphicsConsoleConOutTestString (
1082 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1086 Routine Description:
1088 Implements SIMPLE_TEXT_OUTPUT.TestString().
1089 If one of the characters in the *Wstring is
1090 neither valid valid Unicode drawing characters,
1091 not ASCII code, then this function will return
1097 This - Indicates the calling context.
1099 WString - The Null-terminated Unicode string to be tested.
1104 The Graphics Console is capable of rendering the output string.
1107 Some of the characters in the Unicode string cannot be rendered.
1114 EFI_IMAGE_OUTPUT
*Blt
= NULL
;
1118 while (WString
[Count
] != 0) {
1119 Status
= mHiiFont
->GetGlyph (
1130 if (EFI_ERROR (Status
)) {
1131 return EFI_UNSUPPORTED
;
1140 GraphicsConsoleConOutQueryMode (
1141 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1142 IN UINTN ModeNumber
,
1147 Routine Description:
1149 Implements SIMPLE_TEXT_OUTPUT.QueryMode().
1150 It returnes information for an available text mode
1151 that the Graphics Console supports.
1152 In this driver,we only support text mode 80x25, which is
1158 This - Indicates the calling context.
1160 ModeNumber - The mode number to return information on.
1162 Columns - The returned columns of the requested mode.
1164 Rows - The returned rows of the requested mode.
1169 The requested mode information is returned.
1172 The mode number is not valid.
1176 GRAPHICS_CONSOLE_DEV
*Private
;
1180 if (ModeNumber
>= (UINTN
) This
->Mode
->MaxMode
) {
1181 return EFI_UNSUPPORTED
;
1184 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1185 Status
= EFI_SUCCESS
;
1187 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1189 *Columns
= Private
->ModeData
[ModeNumber
].Columns
;
1190 *Rows
= Private
->ModeData
[ModeNumber
].Rows
;
1192 if (*Columns
<= 0 && *Rows
<= 0) {
1193 Status
= EFI_UNSUPPORTED
;
1199 gBS
->RestoreTPL (OldTpl
);
1205 GraphicsConsoleConOutSetMode (
1206 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1210 Routine Description:
1212 Implements SIMPLE_TEXT_OUTPUT.SetMode().
1213 Set the Graphics Console to a specified mode.
1214 In this driver, we only support mode 0.
1218 This - Indicates the calling context.
1220 ModeNumber - The text mode to set.
1225 The requested text mode is set.
1228 The requested text mode cannot be set because of Graphics Console device error.
1231 The text mode number is not valid.
1236 GRAPHICS_CONSOLE_DEV
*Private
;
1237 GRAPHICS_CONSOLE_MODE_DATA
*ModeData
;
1238 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*NewLineBuffer
;
1239 UINT32 HorizontalResolution
;
1240 UINT32 VerticalResolution
;
1241 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1242 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1247 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1249 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1250 GraphicsOutput
= Private
->GraphicsOutput
;
1251 UgaDraw
= Private
->UgaDraw
;
1252 ModeData
= &(Private
->ModeData
[ModeNumber
]);
1254 if (ModeData
->Columns
<= 0 && ModeData
->Rows
<= 0) {
1255 Status
= EFI_UNSUPPORTED
;
1260 // Make sure the requested mode number is supported
1262 if (ModeNumber
>= (UINTN
) This
->Mode
->MaxMode
) {
1263 Status
= EFI_UNSUPPORTED
;
1267 if (ModeData
->Columns
<= 0 && ModeData
->Rows
<= 0) {
1268 Status
= EFI_UNSUPPORTED
;
1272 // Attempt to allocate a line buffer for the requested mode number
1274 NewLineBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
) * ModeData
->Columns
* GLYPH_WIDTH
* GLYPH_HEIGHT
);
1276 if (NewLineBuffer
== NULL
) {
1278 // The new line buffer could not be allocated, so return an error.
1279 // No changes to the state of the current console have been made, so the current console is still valid
1281 Status
= EFI_OUT_OF_RESOURCES
;
1285 // If the mode has been set at least one other time, then LineBuffer will not be NULL
1287 if (Private
->LineBuffer
!= NULL
) {
1289 // Clear the current text window on the current graphics console
1291 This
->ClearScreen (This
);
1294 // If the new mode is the same as the old mode, then just return EFI_SUCCESS
1296 if ((INT32
) ModeNumber
== This
->Mode
->Mode
) {
1297 FreePool (NewLineBuffer
);
1298 Status
= EFI_SUCCESS
;
1302 // Otherwise, the size of the text console and/or the GOP/UGA mode will be changed,
1303 // so erase the cursor, and free the LineBuffer for the current mode
1307 FreePool (Private
->LineBuffer
);
1310 // Assign the current line buffer to the newly allocated line buffer
1312 Private
->LineBuffer
= NewLineBuffer
;
1314 if (GraphicsOutput
!= NULL
) {
1315 if (ModeData
->GopModeNumber
!= GraphicsOutput
->Mode
->Mode
) {
1317 // Either no graphics mode is currently set, or it is set to the wrong resolution, so set the new grapghics mode
1319 Status
= GraphicsOutput
->SetMode (GraphicsOutput
, ModeData
->GopModeNumber
);
1320 if (EFI_ERROR (Status
)) {
1322 // The mode set operation failed
1328 // The current graphics mode is correct, so simply clear the entire display
1330 Status
= GraphicsOutput
->Blt (
1339 ModeData
->GopHeight
,
1343 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
1345 // Get the current UGA Draw mode information
1347 Status
= UgaDraw
->GetMode (
1349 &HorizontalResolution
,
1350 &VerticalResolution
,
1354 if (EFI_ERROR (Status
) || HorizontalResolution
!= ModeData
->GopWidth
|| VerticalResolution
!= ModeData
->GopHeight
) {
1356 // Either no graphics mode is currently set, or it is set to the wrong resolution, so set the new grapghics mode
1358 Status
= UgaDraw
->SetMode (
1361 ModeData
->GopHeight
,
1365 if (EFI_ERROR (Status
)) {
1367 // The mode set operation failed
1373 // The current graphics mode is correct, so simply clear the entire display
1375 Status
= UgaDraw
->Blt (
1377 (EFI_UGA_PIXEL
*) (UINTN
) &mEfiColors
[0],
1384 ModeData
->GopHeight
,
1391 // The new mode is valid, so commit the mode change
1393 This
->Mode
->Mode
= (INT32
) ModeNumber
;
1396 // Move the text cursor to the upper left hand corner of the displat and enable it
1398 This
->SetCursorPosition (This
, 0, 0);
1400 Status
= EFI_SUCCESS
;
1403 gBS
->RestoreTPL (OldTpl
);
1409 GraphicsConsoleConOutSetAttribute (
1410 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1414 Routine Description:
1416 Implements SIMPLE_TEXT_OUTPUT.SetAttribute().
1420 This - Indicates the calling context.
1422 Attrubute - The attribute to set. Only bit0..6 are valid, all other bits
1423 are undefined and must be zero.
1428 The requested attribute is set.
1431 The requested attribute cannot be set due to Graphics Console port error.
1434 The attribute requested is not defined by EFI spec.
1440 if ((Attribute
| 0xFF) != 0xFF) {
1441 return EFI_UNSUPPORTED
;
1444 if ((INT32
) Attribute
== This
->Mode
->Attribute
) {
1448 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1452 This
->Mode
->Attribute
= (INT32
) Attribute
;
1456 gBS
->RestoreTPL (OldTpl
);
1463 GraphicsConsoleConOutClearScreen (
1464 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
1467 Routine Description:
1469 Implements SIMPLE_TEXT_OUTPUT.ClearScreen().
1470 It clears the Graphics Console's display to the
1471 currently selected background color.
1476 This - Indicates the calling context.
1481 The operation completed successfully.
1484 The Graphics Console cannot be cleared due to Graphics Console device error.
1487 The Graphics Console is not in a valid text mode.
1492 GRAPHICS_CONSOLE_DEV
*Private
;
1493 GRAPHICS_CONSOLE_MODE_DATA
*ModeData
;
1494 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1495 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1496 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
1497 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
1500 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1502 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1503 GraphicsOutput
= Private
->GraphicsOutput
;
1504 UgaDraw
= Private
->UgaDraw
;
1505 ModeData
= &(Private
->ModeData
[This
->Mode
->Mode
]);
1507 GetTextColors (This
, &Foreground
, &Background
);
1508 if (GraphicsOutput
!= NULL
) {
1509 Status
= GraphicsOutput
->Blt (
1518 ModeData
->GopHeight
,
1521 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
1522 Status
= UgaDraw
->Blt (
1524 (EFI_UGA_PIXEL
*) (UINTN
) &Background
,
1531 ModeData
->GopHeight
,
1535 Status
= EFI_UNSUPPORTED
;
1538 This
->Mode
->CursorColumn
= 0;
1539 This
->Mode
->CursorRow
= 0;
1543 gBS
->RestoreTPL (OldTpl
);
1550 GraphicsConsoleConOutSetCursorPosition (
1551 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1556 Routine Description:
1558 Implements SIMPLE_TEXT_OUTPUT.SetCursorPosition().
1562 This - Indicates the calling context.
1564 Column - The row to set cursor to.
1566 Row - The column to set cursor to.
1571 The operation completed successfully.
1574 The request fails due to Graphics Console device error.
1577 The Graphics Console is not in a valid text mode, or the cursor position
1578 is invalid for current mode.
1582 GRAPHICS_CONSOLE_DEV
*Private
;
1583 GRAPHICS_CONSOLE_MODE_DATA
*ModeData
;
1587 Status
= EFI_SUCCESS
;
1589 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1591 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1592 ModeData
= &(Private
->ModeData
[This
->Mode
->Mode
]);
1594 if ((Column
>= ModeData
->Columns
) || (Row
>= ModeData
->Rows
)) {
1595 Status
= EFI_UNSUPPORTED
;
1599 if (((INT32
) Column
== This
->Mode
->CursorColumn
) && ((INT32
) Row
== This
->Mode
->CursorRow
)) {
1600 Status
= EFI_SUCCESS
;
1606 This
->Mode
->CursorColumn
= (INT32
) Column
;
1607 This
->Mode
->CursorRow
= (INT32
) Row
;
1612 gBS
->RestoreTPL (OldTpl
);
1619 GraphicsConsoleConOutEnableCursor (
1620 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1624 Routine Description:
1626 Implements SIMPLE_TEXT_OUTPUT.EnableCursor().
1627 In this driver, the cursor cannot be hidden.
1631 This - Indicates the calling context.
1633 Visible - If TRUE, the cursor is set to be visible,
1634 If FALSE, the cursor is set to be invisible.
1639 The request is valid.
1642 The Graphics Console does not support a hidden cursor.
1648 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1652 This
->Mode
->CursorVisible
= Visible
;
1656 gBS
->RestoreTPL (OldTpl
);
1663 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1664 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Foreground
,
1665 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Background
1670 Attribute
= This
->Mode
->Attribute
& 0x7F;
1672 *Foreground
= mEfiColors
[Attribute
& 0x0f];
1673 *Background
= mEfiColors
[Attribute
>> 4];
1679 DrawUnicodeWeightAtCursorN (
1680 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1681 IN CHAR16
*UnicodeWeight
,
1686 GRAPHICS_CONSOLE_DEV
*Private
;
1687 EFI_IMAGE_OUTPUT
*Blt
;
1689 EFI_FONT_DISPLAY_INFO
*FontInfo
;
1690 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1691 EFI_HII_ROW_INFO
*RowInfoArray
;
1692 UINTN RowInfoArraySize
;
1694 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1695 Blt
= (EFI_IMAGE_OUTPUT
*) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT
));
1697 return EFI_OUT_OF_RESOURCES
;
1700 Blt
->Width
= (UINT16
) (Private
->ModeData
[This
->Mode
->Mode
].GopWidth
);
1701 Blt
->Height
= (UINT16
) (Private
->ModeData
[This
->Mode
->Mode
].GopHeight
);
1703 String
= AllocateCopyPool ((Count
+ 1) * sizeof (CHAR16
), UnicodeWeight
);
1704 if (String
== NULL
) {
1706 return EFI_OUT_OF_RESOURCES
;
1708 *(String
+ Count
) = 0;
1710 FontInfo
= (EFI_FONT_DISPLAY_INFO
*) AllocateZeroPool (sizeof (EFI_FONT_DISPLAY_INFO
));
1711 if (FontInfo
== NULL
) {
1713 SafeFreePool (String
);
1714 return EFI_OUT_OF_RESOURCES
;
1716 GetTextColors (This
, &FontInfo
->ForegroundColor
, &FontInfo
->BackgroundColor
);
1718 if (Private
->GraphicsOutput
!= NULL
) {
1719 Blt
->Image
.Screen
= Private
->GraphicsOutput
;
1721 Status
= mHiiFont
->StringToImage (
1723 EFI_HII_IGNORE_IF_NO_GLYPH
| EFI_HII_DIRECT_TO_SCREEN
,
1727 This
->Mode
->CursorColumn
* GLYPH_WIDTH
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaX
,
1728 This
->Mode
->CursorRow
* GLYPH_HEIGHT
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaY
,
1734 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
1735 ASSERT (Private
->UgaDraw
!= NULL
);
1737 UgaDraw
= Private
->UgaDraw
;
1739 Blt
->Image
.Bitmap
= AllocateZeroPool (Blt
->Width
* Blt
->Height
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
));
1740 if (Blt
->Image
.Bitmap
== NULL
) {
1742 SafeFreePool (String
);
1743 return EFI_OUT_OF_RESOURCES
;
1746 RowInfoArray
= NULL
;
1748 // StringToImage only support blt'ing image to device using GOP protocol. If GOP is not supported in this platform,
1749 // we ask StringToImage to print the string to blt buffer, then blt to device using UgaDraw.
1751 Status
= mHiiFont
->StringToImage (
1753 EFI_HII_IGNORE_IF_NO_GLYPH
,
1757 This
->Mode
->CursorColumn
* GLYPH_WIDTH
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaX
,
1758 This
->Mode
->CursorRow
* GLYPH_HEIGHT
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaY
,
1764 if (!EFI_ERROR (Status
)) {
1766 // Line breaks are handled by caller of DrawUnicodeWeightAtCursorN, so the updated parameter RowInfoArraySize by StringToImage will
1767 // always be 1. ASSERT here to make sure.
1769 ASSERT (RowInfoArraySize
== 1);
1771 Status
= UgaDraw
->Blt (
1773 (EFI_UGA_PIXEL
*) Blt
->Image
.Bitmap
,
1774 EfiUgaBltBufferToVideo
,
1775 This
->Mode
->CursorColumn
* GLYPH_WIDTH
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaX
,
1776 (This
->Mode
->CursorRow
) * GLYPH_HEIGHT
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaY
,
1777 This
->Mode
->CursorColumn
* GLYPH_WIDTH
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaX
,
1778 (This
->Mode
->CursorRow
) * GLYPH_HEIGHT
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaY
,
1779 RowInfoArray
[0].LineWidth
,
1780 RowInfoArray
[0].LineHeight
,
1781 Blt
->Width
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
1785 SafeFreePool (RowInfoArray
);
1786 SafeFreePool (Blt
->Image
.Bitmap
);
1788 Status
= EFI_UNSUPPORTED
;
1792 SafeFreePool (String
);
1793 SafeFreePool (FontInfo
);
1801 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
1804 GRAPHICS_CONSOLE_DEV
*Private
;
1805 EFI_SIMPLE_TEXT_OUTPUT_MODE
*CurrentMode
;
1808 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1809 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1810 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Foreground
;
1811 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Background
;
1812 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION BltChar
[GLYPH_HEIGHT
][GLYPH_WIDTH
];
1816 CurrentMode
= This
->Mode
;
1818 if (!CurrentMode
->CursorVisible
) {
1822 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1823 GraphicsOutput
= Private
->GraphicsOutput
;
1824 UgaDraw
= Private
->UgaDraw
;
1827 // BUGBUG - we need to think about what to do with wide and narrow character deletions.
1830 // Blt a character to the screen
1832 GlyphX
= (CurrentMode
->CursorColumn
* GLYPH_WIDTH
) + Private
->ModeData
[CurrentMode
->Mode
].DeltaX
;
1833 GlyphY
= (CurrentMode
->CursorRow
* GLYPH_HEIGHT
) + Private
->ModeData
[CurrentMode
->Mode
].DeltaY
;
1834 if (GraphicsOutput
!= NULL
) {
1835 GraphicsOutput
->Blt (
1837 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*) BltChar
,
1838 EfiBltVideoToBltBuffer
,
1845 GLYPH_WIDTH
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
1847 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
1850 (EFI_UGA_PIXEL
*) (UINTN
) BltChar
,
1851 EfiUgaVideoToBltBuffer
,
1858 GLYPH_WIDTH
* sizeof (EFI_UGA_PIXEL
)
1862 GetTextColors (This
, &Foreground
.Pixel
, &Background
.Pixel
);
1865 // Convert Monochrome bitmap of the Glyph to BltBuffer structure
1867 for (Y
= 0; Y
< GLYPH_HEIGHT
; Y
++) {
1868 for (X
= 0; X
< GLYPH_WIDTH
; X
++) {
1869 if ((mCursorGlyph
.GlyphCol1
[Y
] & (1 << X
)) != 0) {
1870 BltChar
[Y
][GLYPH_WIDTH
- X
- 1].Raw
^= Foreground
.Raw
;
1875 if (GraphicsOutput
!= NULL
) {
1876 GraphicsOutput
->Blt (
1878 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*) BltChar
,
1879 EfiBltBufferToVideo
,
1886 GLYPH_WIDTH
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
1888 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
1891 (EFI_UGA_PIXEL
*) (UINTN
) BltChar
,
1892 EfiUgaBltBufferToVideo
,
1899 GLYPH_WIDTH
* sizeof (EFI_UGA_PIXEL
)
1907 The user Entry Point for module GraphicsConsole. The user code starts with this function.
1909 @param[in] ImageHandle The firmware allocated handle for the EFI image.
1910 @param[in] SystemTable A pointer to the EFI System Table.
1912 @retval EFI_SUCCESS The entry point is executed successfully.
1913 @retval other Some error occurs when executing this entry point.
1918 InitializeGraphicsConsole (
1919 IN EFI_HANDLE ImageHandle
,
1920 IN EFI_SYSTEM_TABLE
*SystemTable
1926 // Install driver model protocol(s).
1928 Status
= EfiLibInstallDriverBindingComponentName2 (
1931 &gGraphicsConsoleDriverBinding
,
1933 &gGraphicsConsoleComponentName
,
1934 &gGraphicsConsoleComponentName2
1936 ASSERT_EFI_ERROR (Status
);