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 #if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
90 EFI_HII_DATABASE_PROTOCOL
*mHiiDatabase
;
91 EFI_HII_FONT_PROTOCOL
*mHiiFont
;
92 BOOLEAN mFirstAccessFlag
= TRUE
;
94 STATIC EFI_GUID mFontPackageListGuid
= {0xf5f219d3, 0x7006, 0x4648, 0xac, 0x8d, 0xd6, 0x1d, 0xfb, 0x7b, 0xc6, 0xad};
97 EFI_HII_PROTOCOL
*mHii
;
100 static CHAR16 mCrLfString
[3] = { CHAR_CARRIAGE_RETURN
, CHAR_LINEFEED
, CHAR_NULL
};
102 static EFI_GRAPHICS_OUTPUT_BLT_PIXEL mEfiColors
[16] = {
106 {0x00, 0x00, 0x00, 0x00}, // BLACK
107 {0x98, 0x00, 0x00, 0x00}, // BLUE
108 {0x00, 0x98, 0x00, 0x00}, // GREEN
109 {0x98, 0x98, 0x00, 0x00}, // CYAN
110 {0x00, 0x00, 0x98, 0x00}, // RED
111 {0x98, 0x00, 0x98, 0x00}, // MAGENTA
112 {0x00, 0x98, 0x98, 0x00}, // BROWN
113 {0x98, 0x98, 0x98, 0x00}, // LIGHTGRAY
114 {0x30, 0x30, 0x30, 0x00}, // DARKGRAY - BRIGHT BLACK
115 {0xff, 0x00, 0x00, 0x00}, // LIGHTBLUE - ?
116 {0x00, 0xff, 0x00, 0x00}, // LIGHTGREEN - ?
117 {0xff, 0xff, 0x00, 0x00}, // LIGHTCYAN
118 {0x00, 0x00, 0xff, 0x00}, // LIGHTRED
119 {0xff, 0x00, 0xff, 0x00}, // LIGHTMAGENTA
120 {0x00, 0xff, 0xff, 0x00}, // LIGHTBROWN
121 {0xff, 0xff, 0xff, 0x00} // WHITE
124 static EFI_NARROW_GLYPH mCursorGlyph
= {
127 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF }
130 EFI_DRIVER_BINDING_PROTOCOL gGraphicsConsoleDriverBinding
= {
131 GraphicsConsoleControllerDriverSupported
,
132 GraphicsConsoleControllerDriverStart
,
133 GraphicsConsoleControllerDriverStop
,
141 GraphicsConsoleControllerDriverSupported (
142 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
143 IN EFI_HANDLE Controller
,
144 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
148 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
149 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
150 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
154 // Open the IO Abstraction(s) needed to perform the supported test
156 Status
= gBS
->OpenProtocol (
158 &gEfiGraphicsOutputProtocolGuid
,
159 (VOID
**) &GraphicsOutput
,
160 This
->DriverBindingHandle
,
162 EFI_OPEN_PROTOCOL_BY_DRIVER
165 if (EFI_ERROR (Status
)) {
166 GraphicsOutput
= NULL
;
168 // Open Graphics Output Protocol failed, try to open UGA Draw Protocol
170 Status
= gBS
->OpenProtocol (
172 &gEfiUgaDrawProtocolGuid
,
174 This
->DriverBindingHandle
,
176 EFI_OPEN_PROTOCOL_BY_DRIVER
178 if (EFI_ERROR (Status
)) {
184 // We need to ensure that we do not layer on top of a virtual handle.
185 // We need to ensure that the handles produced by the conspliter do not
188 Status
= gBS
->OpenProtocol (
190 &gEfiDevicePathProtocolGuid
,
191 (VOID
**) &DevicePath
,
192 This
->DriverBindingHandle
,
194 EFI_OPEN_PROTOCOL_BY_DRIVER
196 if (!EFI_ERROR (Status
)) {
199 &gEfiDevicePathProtocolGuid
,
200 This
->DriverBindingHandle
,
208 // Does Hii Exist? If not, we aren't ready to run
210 Status
= EfiLocateHiiProtocol ();
213 // Close the I/O Abstraction(s) used to perform the supported test
216 if (GraphicsOutput
!= NULL
) {
219 &gEfiGraphicsOutputProtocolGuid
,
220 This
->DriverBindingHandle
,
226 &gEfiUgaDrawProtocolGuid
,
227 This
->DriverBindingHandle
,
236 GraphicsConsoleControllerDriverStart (
237 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
238 IN EFI_HANDLE Controller
,
239 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
245 Start the controller.
249 This - A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
250 Controller - The handle of the controller to start.
251 RemainingDevicePath - A pointer to the remaining portion of a devcie path.
255 EFI_SUCCESS - Return successfully.
256 EFI_OUT_OF_RESOURCES - Out of resources.
261 GRAPHICS_CONSOLE_DEV
*Private
;
262 UINTN NarrowFontSize
;
263 UINT32 HorizontalResolution
;
264 UINT32 VerticalResolution
;
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
295 if (EFI_ERROR(Status
)) {
296 Private
->GraphicsOutput
= NULL
;
298 Status
= gBS
->OpenProtocol (
300 &gEfiUgaDrawProtocolGuid
,
301 (VOID
**) &Private
->UgaDraw
,
302 This
->DriverBindingHandle
,
304 EFI_OPEN_PROTOCOL_BY_DRIVER
306 if (EFI_ERROR (Status
)) {
311 NarrowFontSize
= ReturnNarrowFontSize ();
314 if (mFirstAccessFlag
) {
315 HiiLibAddFontPackageToHiiDatabase (NarrowFontSize
, (UINT8
*) UsStdNarrowGlyphData
, &mFontPackageListGuid
, &(Private
->HiiHandle
));
316 mFirstAccessFlag
= FALSE
;
319 FontPack
= AllocateZeroPool (sizeof (EFI_HII_FONT_PACK
) + NarrowFontSize
);
322 FontPack
->Header
.Length
= (UINT32
) (sizeof (EFI_HII_FONT_PACK
) + NarrowFontSize
);
323 FontPack
->Header
.Type
= EFI_HII_FONT
;
324 FontPack
->NumberOfNarrowGlyphs
= (UINT16
) (NarrowFontSize
/ sizeof (EFI_NARROW_GLYPH
));
326 Location
= (UINT8
*) (&FontPack
->NumberOfWideGlyphs
+ sizeof (UINT8
));
327 CopyMem (Location
, UsStdNarrowGlyphData
, NarrowFontSize
);
330 // Register our Fonts into the global database
332 Package
= PreparePackages (1, NULL
, FontPack
);
333 mHii
->NewPack (mHii
, Package
, &(Private
->HiiHandle
));
337 // Free the font database
342 // If the current mode information can not be retrieved, then attemp to set the default mode
343 // of 800x600, 32 bit colot, 60 Hz refresh.
345 HorizontalResolution
= 800;
346 VerticalResolution
= 600;
348 if (Private
->GraphicsOutput
!= NULL
) {
350 // The console is build on top of Graphics Output Protocol, find the mode number
351 // for the user-defined mode; if there are multiple video devices,
352 // graphic console driver will set all the video devices to the same mode.
354 Status
= CheckModeSupported (
355 Private
->GraphicsOutput
,
356 CURRENT_HORIZONTAL_RESOLUTION
,
357 CURRENT_VERTICAL_RESOLUTION
,
360 if (!EFI_ERROR(Status
)) {
362 // Update default mode to current mode
364 HorizontalResolution
= CURRENT_HORIZONTAL_RESOLUTION
;
365 VerticalResolution
= CURRENT_VERTICAL_RESOLUTION
;
368 // if not supporting current mode, try 800x600 which is required by UEFI/EFI spec
370 Status
= CheckModeSupported (
371 Private
->GraphicsOutput
,
378 if (EFI_ERROR (Status
) || (ModeNumber
== Private
->GraphicsOutput
->Mode
->MaxMode
)) {
380 // Set default mode failed or device don't support default mode, then get the current mode information
382 HorizontalResolution
= Private
->GraphicsOutput
->Mode
->Info
->HorizontalResolution
;
383 VerticalResolution
= Private
->GraphicsOutput
->Mode
->Info
->VerticalResolution
;
384 ModeNumber
= Private
->GraphicsOutput
->Mode
->Mode
;
388 // At first try to set user-defined resolution
392 Status
= Private
->UgaDraw
->SetMode (
394 CURRENT_HORIZONTAL_RESOLUTION
,
395 CURRENT_VERTICAL_RESOLUTION
,
399 if (!EFI_ERROR (Status
)) {
400 HorizontalResolution
= CURRENT_HORIZONTAL_RESOLUTION
;
401 VerticalResolution
= CURRENT_VERTICAL_RESOLUTION
;
404 // Try to set 800*600 which is required by UEFI/EFI spec
406 Status
= Private
->UgaDraw
->SetMode (
408 HorizontalResolution
,
413 if (EFI_ERROR (Status
)) {
414 Status
= Private
->UgaDraw
->GetMode (
416 &HorizontalResolution
,
421 if (EFI_ERROR (Status
)) {
429 // Compute the maximum number of text Rows and Columns that this current graphics mode can support
431 Columns
= HorizontalResolution
/ GLYPH_WIDTH
;
432 Rows
= VerticalResolution
/ GLYPH_HEIGHT
;
435 // See if the mode is too small to support the required 80x25 text mode
437 if (Columns
< 80 || Rows
< 25) {
441 // Add Mode #0 that must be 80x25
444 Private
->ModeData
[MaxMode
].GopWidth
= HorizontalResolution
;
445 Private
->ModeData
[MaxMode
].GopHeight
= VerticalResolution
;
446 Private
->ModeData
[MaxMode
].GopModeNumber
= ModeNumber
;
447 Private
->ModeData
[MaxMode
].DeltaX
= (HorizontalResolution
- (80 * GLYPH_WIDTH
)) >> 1;
448 Private
->ModeData
[MaxMode
].DeltaY
= (VerticalResolution
- (25 * GLYPH_HEIGHT
)) >> 1;
452 // If it is possible to support Mode #1 - 80x50, than add it as an active mode
455 Private
->ModeData
[MaxMode
].GopWidth
= HorizontalResolution
;
456 Private
->ModeData
[MaxMode
].GopHeight
= VerticalResolution
;
457 Private
->ModeData
[MaxMode
].GopModeNumber
= ModeNumber
;
458 Private
->ModeData
[MaxMode
].DeltaX
= (HorizontalResolution
- (80 * GLYPH_WIDTH
)) >> 1;
459 Private
->ModeData
[MaxMode
].DeltaY
= (VerticalResolution
- (50 * GLYPH_HEIGHT
)) >> 1;
464 // If it is not to support Mode #1 - 80x50, then skip it
467 Private
->ModeData
[MaxMode
].Columns
= 0;
468 Private
->ModeData
[MaxMode
].Rows
= 0;
469 Private
->ModeData
[MaxMode
].GopWidth
= HorizontalResolution
;
470 Private
->ModeData
[MaxMode
].GopHeight
= VerticalResolution
;
471 Private
->ModeData
[MaxMode
].GopModeNumber
= ModeNumber
;
472 Private
->ModeData
[MaxMode
].DeltaX
= 0;
473 Private
->ModeData
[MaxMode
].DeltaY
= 0;
478 // Add Mode #2 that must be 100x31 (graphic mode >= 800x600)
480 if (Columns
>= 100 && Rows
>= 31) {
481 Private
->ModeData
[MaxMode
].GopWidth
= HorizontalResolution
;
482 Private
->ModeData
[MaxMode
].GopHeight
= VerticalResolution
;
483 Private
->ModeData
[MaxMode
].GopModeNumber
= ModeNumber
;
484 Private
->ModeData
[MaxMode
].DeltaX
= (HorizontalResolution
- (100 * GLYPH_WIDTH
)) >> 1;
485 Private
->ModeData
[MaxMode
].DeltaY
= (VerticalResolution
- (31 * GLYPH_HEIGHT
)) >> 1;
490 // Add Mode #3 that uses the entire display for user-defined mode
492 if (HorizontalResolution
> 800 && VerticalResolution
> 600) {
493 Private
->ModeData
[MaxMode
].Columns
= HorizontalResolution
/GLYPH_WIDTH
;
494 Private
->ModeData
[MaxMode
].Rows
= VerticalResolution
/GLYPH_HEIGHT
;
495 Private
->ModeData
[MaxMode
].GopWidth
= HorizontalResolution
;
496 Private
->ModeData
[MaxMode
].GopHeight
= VerticalResolution
;
497 Private
->ModeData
[MaxMode
].GopModeNumber
= ModeNumber
;
498 Private
->ModeData
[MaxMode
].DeltaX
= (HorizontalResolution
% GLYPH_WIDTH
) >> 1;
499 Private
->ModeData
[MaxMode
].DeltaY
= (VerticalResolution
% GLYPH_HEIGHT
) >> 1;
504 // Update the maximum number of modes
506 Private
->SimpleTextOutputMode
.MaxMode
= (INT32
) MaxMode
;
509 // Determine the number of text modes that this protocol can support
511 Status
= GraphicsConsoleConOutSetMode (&Private
->SimpleTextOutput
, 0);
512 if (EFI_ERROR (Status
)) {
517 GraphicsConsoleConOutOutputString (&Private
->SimpleTextOutput
, (CHAR16
*)L
"Graphics Console Started\n\r");
521 // Install protocol interfaces for the Graphics Console device.
523 Status
= gBS
->InstallMultipleProtocolInterfaces (
525 &gEfiSimpleTextOutProtocolGuid
,
526 &Private
->SimpleTextOutput
,
531 if (EFI_ERROR (Status
)) {
533 // Close the GOP or UGA IO Protocol
535 if (Private
->GraphicsOutput
!= NULL
) {
538 &gEfiGraphicsOutputProtocolGuid
,
539 This
->DriverBindingHandle
,
545 &gEfiUgaDrawProtocolGuid
,
546 This
->DriverBindingHandle
,
554 if (Private
!= NULL
) {
555 if (Private
->LineBuffer
!= NULL
) {
556 FreePool (Private
->LineBuffer
);
567 GraphicsConsoleControllerDriverStop (
568 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
569 IN EFI_HANDLE Controller
,
570 IN UINTN NumberOfChildren
,
571 IN EFI_HANDLE
*ChildHandleBuffer
575 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*SimpleTextOutput
;
576 GRAPHICS_CONSOLE_DEV
*Private
;
578 Status
= gBS
->OpenProtocol (
580 &gEfiSimpleTextOutProtocolGuid
,
581 (VOID
**) &SimpleTextOutput
,
582 This
->DriverBindingHandle
,
584 EFI_OPEN_PROTOCOL_GET_PROTOCOL
586 if (EFI_ERROR (Status
)) {
587 return EFI_NOT_STARTED
;
590 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (SimpleTextOutput
);
592 Status
= gBS
->UninstallProtocolInterface (
594 &gEfiSimpleTextOutProtocolGuid
,
595 &Private
->SimpleTextOutput
598 if (!EFI_ERROR (Status
)) {
600 // Close the GOP or UGA IO Protocol
602 if (Private
->GraphicsOutput
!= NULL
) {
605 &gEfiGraphicsOutputProtocolGuid
,
606 This
->DriverBindingHandle
,
612 &gEfiUgaDrawProtocolGuid
,
613 This
->DriverBindingHandle
,
619 // Remove the font pack
622 HiiLibRemovePackages (Private
->HiiHandle
);
623 mFirstAccessFlag
= TRUE
;
625 mHii
->RemovePack (mHii
, Private
->HiiHandle
);
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.
702 #if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
705 // There should only be one - so buffer size is this
707 Size
= sizeof (EFI_HANDLE
);
709 Status
= gBS
->LocateHandle (
711 &gEfiHiiDatabaseProtocolGuid
,
717 if (EFI_ERROR (Status
)) {
721 Status
= gBS
->HandleProtocol (
723 &gEfiHiiDatabaseProtocolGuid
,
724 (VOID
**) &mHiiDatabase
727 if (EFI_ERROR (Status
)) {
731 Status
= gBS
->HandleProtocol (
733 &gEfiHiiFontProtocolGuid
,
740 // There should only be one - so buffer size is this
742 Size
= sizeof (EFI_HANDLE
);
744 Status
= gBS
->LocateHandle (
746 &gEfiHiiProtocolGuid
,
752 if (EFI_ERROR (Status
)) {
756 Status
= gBS
->HandleProtocol (
758 &gEfiHiiProtocolGuid
,
767 // Body of the STO functions
771 GraphicsConsoleConOutReset (
772 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
773 IN BOOLEAN ExtendedVerification
778 Implements SIMPLE_TEXT_OUTPUT.Reset().
779 If ExtendeVerification is TRUE, then perform dependent Graphics Console
780 device reset, and set display mode to mode 0.
781 If ExtendedVerification is FALSE, only set display mode to mode 0.
785 This - Indicates the calling context.
787 ExtendedVerification - Indicates that the driver may perform a more exhaustive
788 verification operation of the device during reset.
793 The reset operation succeeds.
796 The Graphics Console is not functioning correctly
800 This
->SetAttribute (This
, EFI_TEXT_ATTR (This
->Mode
->Attribute
& 0x0F, EFI_BACKGROUND_BLACK
));
801 return This
->SetMode (This
, 0);
806 GraphicsConsoleConOutOutputString (
807 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
813 Implements SIMPLE_TEXT_OUTPUT.OutputString().
814 The Unicode string will be converted to Glyphs and will be
815 sent to the Graphics Console.
820 This - Indicates the calling context.
822 WString - The Null-terminated Unicode string to be displayed on
823 the Graphics Console.
828 The string is output successfully.
831 The Graphics Console failed to send the string out.
833 EFI_WARN_UNKNOWN_GLYPH
834 Indicates that some of the characters in the Unicode string could not
835 be rendered and are skipped.
839 GRAPHICS_CONSOLE_DEV
*Private
;
840 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
841 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
850 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
851 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
856 INT32 OriginAttribute
;
858 CHAR16 SpaceStr
[] = { NARROW_CHAR
, ' ', 0 };
860 Status
= EFI_SUCCESS
;
862 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
866 Mode
= This
->Mode
->Mode
;
867 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
868 GraphicsOutput
= Private
->GraphicsOutput
;
869 UgaDraw
= Private
->UgaDraw
;
871 MaxColumn
= Private
->ModeData
[Mode
].Columns
;
872 MaxRow
= Private
->ModeData
[Mode
].Rows
;
873 DeltaX
= Private
->ModeData
[Mode
].DeltaX
;
874 DeltaY
= Private
->ModeData
[Mode
].DeltaY
;
875 Width
= MaxColumn
* GLYPH_WIDTH
;
876 Height
= (MaxRow
- 1) * GLYPH_HEIGHT
;
877 Delta
= Width
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
);
880 // The Attributes won't change when during the time OutputString is called
882 GetTextColors (This
, &Foreground
, &Background
);
891 OriginAttribute
= This
->Mode
->Attribute
;
895 if (*WString
== CHAR_BACKSPACE
) {
897 // If the cursor is at the left edge of the display, then move the cursor
900 if (This
->Mode
->CursorColumn
== 0 && This
->Mode
->CursorRow
> 0) {
901 This
->Mode
->CursorRow
--;
902 This
->Mode
->CursorColumn
= (INT32
) (MaxColumn
- 1);
903 This
->OutputString (This
, SpaceStr
);
905 This
->Mode
->CursorRow
--;
906 This
->Mode
->CursorColumn
= (INT32
) (MaxColumn
- 1);
907 } else if (This
->Mode
->CursorColumn
> 0) {
909 // If the cursor is not at the left edge of the display, then move the cursor
912 This
->Mode
->CursorColumn
--;
913 This
->OutputString (This
, SpaceStr
);
915 This
->Mode
->CursorColumn
--;
920 } else if (*WString
== CHAR_LINEFEED
) {
922 // If the cursor is at the bottom of the display, then scroll the display one
923 // row, and do not update the cursor position. Otherwise, move the cursor
926 if (This
->Mode
->CursorRow
== (INT32
) (MaxRow
- 1)) {
927 if (GraphicsOutput
!= NULL
) {
929 // Scroll Screen Up One Row
931 GraphicsOutput
->Blt (
936 DeltaY
+ GLYPH_HEIGHT
,
945 // Print Blank Line at last line
947 GraphicsOutput
->Blt (
961 // Scroll Screen Up One Row
968 DeltaY
+ GLYPH_HEIGHT
,
977 // Print Blank Line at last line
981 (EFI_UGA_PIXEL
*) (UINTN
) &Background
,
993 This
->Mode
->CursorRow
++;
998 } else if (*WString
== CHAR_CARRIAGE_RETURN
) {
1000 // Move the cursor to the beginning of the current row.
1002 This
->Mode
->CursorColumn
= 0;
1005 } else if (*WString
== WIDE_CHAR
) {
1007 This
->Mode
->Attribute
|= EFI_WIDE_ATTRIBUTE
;
1010 } else if (*WString
== NARROW_CHAR
) {
1012 This
->Mode
->Attribute
&= (~ (UINT32
) EFI_WIDE_ATTRIBUTE
);
1017 // Print the character at the current cursor position and move the cursor
1018 // right one column. If this moves the cursor past the right edge of the
1019 // display, then the line should wrap to the beginning of the next line. This
1020 // is equivalent to inserting a CR and an LF. Note that if the cursor is at the
1021 // bottom of the display, and the line wraps, then the display will be scrolled
1023 // If wide char is going to be displayed, need to display one character at a time
1024 // Or, need to know the display length of a certain string.
1026 // Index is used to determine how many character width units (wide = 2, narrow = 1)
1027 // Count is used to determine how many characters are used regardless of their attributes
1029 for (Count
= 0, Index
= 0; (This
->Mode
->CursorColumn
+ Index
) < MaxColumn
; Count
++, Index
++) {
1030 if (WString
[Count
] == CHAR_NULL
) {
1034 if (WString
[Count
] == CHAR_BACKSPACE
) {
1038 if (WString
[Count
] == CHAR_LINEFEED
) {
1042 if (WString
[Count
] == CHAR_CARRIAGE_RETURN
) {
1046 if (WString
[Count
] == WIDE_CHAR
) {
1050 if (WString
[Count
] == NARROW_CHAR
) {
1054 // Is the wide attribute on?
1056 if (This
->Mode
->Attribute
& EFI_WIDE_ATTRIBUTE
) {
1058 // If wide, add one more width unit than normal since we are going to increment at the end of the for loop
1062 // This is the end-case where if we are at column 79 and about to print a wide character
1063 // We should prevent this from happening because we will wrap inappropriately. We should
1064 // not print this character until the next line.
1066 if ((This
->Mode
->CursorColumn
+ Index
+ 1) > MaxColumn
) {
1073 Status
= DrawUnicodeWeightAtCursorN (This
, WString
, Count
);
1074 if (EFI_ERROR (Status
)) {
1078 // At the end of line, output carriage return and line feed
1081 This
->Mode
->CursorColumn
+= (INT32
) Index
;
1082 if (This
->Mode
->CursorColumn
> (INT32
) MaxColumn
) {
1083 This
->Mode
->CursorColumn
-= 2;
1084 This
->OutputString (This
, SpaceStr
);
1087 if (This
->Mode
->CursorColumn
>= (INT32
) MaxColumn
) {
1089 This
->OutputString (This
, mCrLfString
);
1095 This
->Mode
->Attribute
= OriginAttribute
;
1100 Status
= EFI_WARN_UNKNOWN_GLYPH
;
1103 gBS
->RestoreTPL (OldTpl
);
1110 GraphicsConsoleConOutTestString (
1111 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1115 Routine Description:
1117 Implements SIMPLE_TEXT_OUTPUT.TestString().
1118 If one of the characters in the *Wstring is
1119 neither valid valid Unicode drawing characters,
1120 not ASCII code, then this function will return
1126 This - Indicates the calling context.
1128 WString - The Null-terminated Unicode string to be tested.
1133 The Graphics Console is capable of rendering the output string.
1136 Some of the characters in the Unicode string cannot be rendered.
1143 #if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
1144 EFI_IMAGE_OUTPUT
*Blt
= NULL
;
1147 UINT32 GlyphStatus
= 0;
1153 while (WString
[Count
] != 0) {
1154 #if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
1155 Status
= mHiiFont
->GetGlyph (
1166 Status
= mHii
->GetGlyph (
1175 if (EFI_ERROR (Status
)) {
1176 return EFI_UNSUPPORTED
;
1185 GraphicsConsoleConOutQueryMode (
1186 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1187 IN UINTN ModeNumber
,
1192 Routine Description:
1194 Implements SIMPLE_TEXT_OUTPUT.QueryMode().
1195 It returnes information for an available text mode
1196 that the Graphics Console supports.
1197 In this driver,we only support text mode 80x25, which is
1203 This - Indicates the calling context.
1205 ModeNumber - The mode number to return information on.
1207 Columns - The returned columns of the requested mode.
1209 Rows - The returned rows of the requested mode.
1214 The requested mode information is returned.
1217 The mode number is not valid.
1221 GRAPHICS_CONSOLE_DEV
*Private
;
1225 if (ModeNumber
>= (UINTN
) This
->Mode
->MaxMode
) {
1226 return EFI_UNSUPPORTED
;
1229 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1230 Status
= EFI_SUCCESS
;
1232 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1234 *Columns
= Private
->ModeData
[ModeNumber
].Columns
;
1235 *Rows
= Private
->ModeData
[ModeNumber
].Rows
;
1237 if (*Columns
<= 0 && *Rows
<= 0) {
1238 Status
= EFI_UNSUPPORTED
;
1244 gBS
->RestoreTPL (OldTpl
);
1250 GraphicsConsoleConOutSetMode (
1251 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1255 Routine Description:
1257 Implements SIMPLE_TEXT_OUTPUT.SetMode().
1258 Set the Graphics Console to a specified mode.
1259 In this driver, we only support mode 0.
1263 This - Indicates the calling context.
1265 ModeNumber - The text mode to set.
1270 The requested text mode is set.
1273 The requested text mode cannot be set because of Graphics Console device error.
1276 The text mode number is not valid.
1281 GRAPHICS_CONSOLE_DEV
*Private
;
1282 GRAPHICS_CONSOLE_MODE_DATA
*ModeData
;
1283 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*NewLineBuffer
;
1284 UINT32 HorizontalResolution
;
1285 UINT32 VerticalResolution
;
1286 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1287 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1292 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1294 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1295 GraphicsOutput
= Private
->GraphicsOutput
;
1296 UgaDraw
= Private
->UgaDraw
;
1297 ModeData
= &(Private
->ModeData
[ModeNumber
]);
1299 if (ModeData
->Columns
<= 0 && ModeData
->Rows
<= 0) {
1300 Status
= EFI_UNSUPPORTED
;
1305 // Make sure the requested mode number is supported
1307 if (ModeNumber
>= (UINTN
) This
->Mode
->MaxMode
) {
1308 Status
= EFI_UNSUPPORTED
;
1312 if (ModeData
->Columns
<= 0 && ModeData
->Rows
<= 0) {
1313 Status
= EFI_UNSUPPORTED
;
1317 // Attempt to allocate a line buffer for the requested mode number
1319 NewLineBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
) * ModeData
->Columns
* GLYPH_WIDTH
* GLYPH_HEIGHT
);
1321 if (NewLineBuffer
== NULL
) {
1323 // The new line buffer could not be allocated, so return an error.
1324 // No changes to the state of the current console have been made, so the current console is still valid
1326 Status
= EFI_OUT_OF_RESOURCES
;
1330 // If the mode has been set at least one other time, then LineBuffer will not be NULL
1332 if (Private
->LineBuffer
!= NULL
) {
1334 // Clear the current text window on the current graphics console
1336 This
->ClearScreen (This
);
1339 // If the new mode is the same as the old mode, then just return EFI_SUCCESS
1341 if ((INT32
) ModeNumber
== This
->Mode
->Mode
) {
1342 FreePool (NewLineBuffer
);
1343 Status
= EFI_SUCCESS
;
1347 // Otherwise, the size of the text console and/or the GOP/UGA mode will be changed,
1348 // so erase the cursor, and free the LineBuffer for the current mode
1352 FreePool (Private
->LineBuffer
);
1355 // Assign the current line buffer to the newly allocated line buffer
1357 Private
->LineBuffer
= NewLineBuffer
;
1359 if (GraphicsOutput
!= NULL
) {
1360 if (ModeData
->GopModeNumber
!= GraphicsOutput
->Mode
->Mode
) {
1362 // Either no graphics mode is currently set, or it is set to the wrong resolution, so set the new grapghics mode
1364 Status
= GraphicsOutput
->SetMode (GraphicsOutput
, ModeData
->GopModeNumber
);
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
= GraphicsOutput
->Blt (
1384 ModeData
->GopHeight
,
1390 // Get the current UGA Draw mode information
1392 Status
= UgaDraw
->GetMode (
1394 &HorizontalResolution
,
1395 &VerticalResolution
,
1399 if (EFI_ERROR (Status
) || HorizontalResolution
!= ModeData
->GopWidth
|| VerticalResolution
!= ModeData
->GopHeight
) {
1401 // Either no graphics mode is currently set, or it is set to the wrong resolution, so set the new grapghics mode
1403 Status
= UgaDraw
->SetMode (
1406 ModeData
->GopHeight
,
1410 if (EFI_ERROR (Status
)) {
1412 // The mode set operation failed
1418 // The current graphics mode is correct, so simply clear the entire display
1420 Status
= UgaDraw
->Blt (
1422 (EFI_UGA_PIXEL
*) (UINTN
) &mEfiColors
[0],
1429 ModeData
->GopHeight
,
1436 // The new mode is valid, so commit the mode change
1438 This
->Mode
->Mode
= (INT32
) ModeNumber
;
1441 // Move the text cursor to the upper left hand corner of the displat and enable it
1443 This
->SetCursorPosition (This
, 0, 0);
1445 Status
= EFI_SUCCESS
;
1448 gBS
->RestoreTPL (OldTpl
);
1454 GraphicsConsoleConOutSetAttribute (
1455 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1459 Routine Description:
1461 Implements SIMPLE_TEXT_OUTPUT.SetAttribute().
1465 This - Indicates the calling context.
1467 Attrubute - The attribute to set. Only bit0..6 are valid, all other bits
1468 are undefined and must be zero.
1473 The requested attribute is set.
1476 The requested attribute cannot be set due to Graphics Console port error.
1479 The attribute requested is not defined by EFI spec.
1485 if ((Attribute
| 0xFF) != 0xFF) {
1486 return EFI_UNSUPPORTED
;
1489 if ((INT32
) Attribute
== This
->Mode
->Attribute
) {
1493 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1497 This
->Mode
->Attribute
= (INT32
) Attribute
;
1501 gBS
->RestoreTPL (OldTpl
);
1508 GraphicsConsoleConOutClearScreen (
1509 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
1512 Routine Description:
1514 Implements SIMPLE_TEXT_OUTPUT.ClearScreen().
1515 It clears the Graphics Console's display to the
1516 currently selected background color.
1521 This - Indicates the calling context.
1526 The operation completed successfully.
1529 The Graphics Console cannot be cleared due to Graphics Console device error.
1532 The Graphics Console is not in a valid text mode.
1537 GRAPHICS_CONSOLE_DEV
*Private
;
1538 GRAPHICS_CONSOLE_MODE_DATA
*ModeData
;
1539 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1540 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1541 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
1542 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
1545 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1547 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1548 GraphicsOutput
= Private
->GraphicsOutput
;
1549 UgaDraw
= Private
->UgaDraw
;
1550 ModeData
= &(Private
->ModeData
[This
->Mode
->Mode
]);
1552 GetTextColors (This
, &Foreground
, &Background
);
1553 if (GraphicsOutput
!= NULL
) {
1554 Status
= GraphicsOutput
->Blt (
1563 ModeData
->GopHeight
,
1567 Status
= UgaDraw
->Blt (
1569 (EFI_UGA_PIXEL
*) (UINTN
) &Background
,
1576 ModeData
->GopHeight
,
1581 This
->Mode
->CursorColumn
= 0;
1582 This
->Mode
->CursorRow
= 0;
1586 gBS
->RestoreTPL (OldTpl
);
1593 GraphicsConsoleConOutSetCursorPosition (
1594 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1599 Routine Description:
1601 Implements SIMPLE_TEXT_OUTPUT.SetCursorPosition().
1605 This - Indicates the calling context.
1607 Column - The row to set cursor to.
1609 Row - The column to set cursor to.
1614 The operation completed successfully.
1617 The request fails due to Graphics Console device error.
1620 The Graphics Console is not in a valid text mode, or the cursor position
1621 is invalid for current mode.
1625 GRAPHICS_CONSOLE_DEV
*Private
;
1626 GRAPHICS_CONSOLE_MODE_DATA
*ModeData
;
1630 Status
= EFI_SUCCESS
;
1632 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1634 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1635 ModeData
= &(Private
->ModeData
[This
->Mode
->Mode
]);
1637 if ((Column
>= ModeData
->Columns
) || (Row
>= ModeData
->Rows
)) {
1638 Status
= EFI_UNSUPPORTED
;
1642 if (((INT32
) Column
== This
->Mode
->CursorColumn
) && ((INT32
) Row
== This
->Mode
->CursorRow
)) {
1643 Status
= EFI_SUCCESS
;
1649 This
->Mode
->CursorColumn
= (INT32
) Column
;
1650 This
->Mode
->CursorRow
= (INT32
) Row
;
1655 gBS
->RestoreTPL (OldTpl
);
1662 GraphicsConsoleConOutEnableCursor (
1663 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1667 Routine Description:
1669 Implements SIMPLE_TEXT_OUTPUT.EnableCursor().
1670 In this driver, the cursor cannot be hidden.
1674 This - Indicates the calling context.
1676 Visible - If TRUE, the cursor is set to be visible,
1677 If FALSE, the cursor is set to be invisible.
1682 The request is valid.
1685 The Graphics Console does not support a hidden cursor.
1691 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1695 This
->Mode
->CursorVisible
= Visible
;
1699 gBS
->RestoreTPL (OldTpl
);
1706 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1707 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Foreground
,
1708 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Background
1713 Attribute
= This
->Mode
->Attribute
& 0x7F;
1715 *Foreground
= mEfiColors
[Attribute
& 0x0f];
1716 *Background
= mEfiColors
[Attribute
>> 4];
1721 #if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
1723 DrawUnicodeWeightAtCursorN (
1724 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1725 IN CHAR16
*UnicodeWeight
,
1730 GRAPHICS_CONSOLE_DEV
*Private
;
1731 EFI_IMAGE_OUTPUT
*Blt
;
1733 EFI_FONT_DISPLAY_INFO
*FontInfo
;
1735 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1737 // GOP protocol is required in UEFI mode.
1739 ASSERT (Private
->GraphicsOutput
!= NULL
);
1741 Blt
= (EFI_IMAGE_OUTPUT
*) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT
));
1743 return EFI_OUT_OF_RESOURCES
;
1746 Blt
->Width
= (UINT16
) (Private
->ModeData
[This
->Mode
->Mode
].GopWidth
);
1747 Blt
->Height
= (UINT16
) (Private
->ModeData
[This
->Mode
->Mode
].GopHeight
);
1748 Blt
->Image
.Screen
= Private
->GraphicsOutput
;
1750 String
= AllocateCopyPool ((Count
+ 1) * sizeof (CHAR16
), UnicodeWeight
);
1751 if (String
== NULL
) {
1753 return EFI_OUT_OF_RESOURCES
;
1755 *(String
+ Count
) = 0;
1757 FontInfo
= (EFI_FONT_DISPLAY_INFO
*) AllocateZeroPool (sizeof (EFI_FONT_DISPLAY_INFO
));
1758 if (FontInfo
== NULL
) {
1760 SafeFreePool (String
);
1761 return EFI_OUT_OF_RESOURCES
;
1763 GetTextColors (This
, &FontInfo
->ForegroundColor
, &FontInfo
->BackgroundColor
);
1765 Status
= mHiiFont
->StringToImage (
1767 EFI_HII_IGNORE_IF_NO_GLYPH
| EFI_HII_DIRECT_TO_SCREEN
,
1771 This
->Mode
->CursorColumn
* GLYPH_WIDTH
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaX
,
1772 This
->Mode
->CursorRow
* GLYPH_HEIGHT
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaY
,
1779 SafeFreePool (String
);
1780 SafeFreePool (FontInfo
);
1786 DrawUnicodeWeightAtCursorN (
1787 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1788 IN CHAR16
*UnicodeWeight
,
1792 GRAPHICS_CONSOLE_DEV
*Private
;
1794 EFI_STATUS ReturnStatus
;
1796 GLYPH_UNION GlyphData
;
1799 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1800 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1801 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
1802 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
1809 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1811 ReturnStatus
= EFI_SUCCESS
;
1815 GetTextColors (This
, &Foreground
, &Background
);
1819 while (Index
< Count
) {
1820 if (This
->Mode
->Attribute
& EFI_WIDE_ATTRIBUTE
) {
1821 GlyphStatus
= WIDE_CHAR
;
1823 GlyphStatus
= NARROW_CHAR
;
1826 Status
= mHii
->GetGlyph (
1834 if (EFI_ERROR (Status
)) {
1835 ReturnStatus
= Status
;
1840 CopyMem (&GlyphData
, Glyph
, sizeof (GLYPH_UNION
));
1844 // We are creating the second half of the wide character's BLT buffer
1846 if (GlyphWidth
== 0x10 && Counts
== 1) {
1847 CopyMem (&GlyphData
.NarrowGlyph
.GlyphCol1
, &Glyph
->WideGlyph
.GlyphCol2
, sizeof (Glyph
->WideGlyph
.GlyphCol2
));
1852 if (GlyphWidth
== 0x10) {
1855 (UINT8
*) &GlyphData
,
1861 &Private
->LineBuffer
[ArrayIndex
* GLYPH_WIDTH
]
1866 (UINT8
*) &GlyphData
,
1872 &Private
->LineBuffer
[ArrayIndex
* GLYPH_WIDTH
]
1878 } while (Counts
< 2 && GlyphWidth
== 0x10);
1882 // If we are printing Wide characters, treat the BLT as if it is twice as many characters
1884 if (GlyphWidth
== 0x10) {
1888 // Blt a character to the screen
1890 GlyphX
= This
->Mode
->CursorColumn
* GLYPH_WIDTH
;
1891 GlyphY
= This
->Mode
->CursorRow
* GLYPH_HEIGHT
;
1892 GraphicsOutput
= Private
->GraphicsOutput
;
1893 UgaDraw
= Private
->UgaDraw
;
1894 if (GraphicsOutput
!= NULL
) {
1895 GraphicsOutput
->Blt (
1897 Private
->LineBuffer
,
1898 EfiBltBufferToVideo
,
1901 GlyphX
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaX
,
1902 GlyphY
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaY
,
1903 GLYPH_WIDTH
* Count
,
1905 GLYPH_WIDTH
* Count
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
1910 (EFI_UGA_PIXEL
*) (UINTN
) Private
->LineBuffer
,
1911 EfiUgaBltBufferToVideo
,
1914 GlyphX
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaX
,
1915 GlyphY
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaY
,
1916 GLYPH_WIDTH
* Count
,
1918 GLYPH_WIDTH
* Count
* sizeof (EFI_UGA_PIXEL
)
1922 return ReturnStatus
;
1929 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
1932 GRAPHICS_CONSOLE_DEV
*Private
;
1933 EFI_SIMPLE_TEXT_OUTPUT_MODE
*CurrentMode
;
1936 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1937 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1938 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Foreground
;
1939 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Background
;
1940 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION BltChar
[GLYPH_HEIGHT
][GLYPH_WIDTH
];
1944 CurrentMode
= This
->Mode
;
1946 if (!CurrentMode
->CursorVisible
) {
1950 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1951 GraphicsOutput
= Private
->GraphicsOutput
;
1952 UgaDraw
= Private
->UgaDraw
;
1955 // BUGBUG - we need to think about what to do with wide and narrow character deletions.
1958 // Blt a character to the screen
1960 GlyphX
= (CurrentMode
->CursorColumn
* GLYPH_WIDTH
) + Private
->ModeData
[CurrentMode
->Mode
].DeltaX
;
1961 GlyphY
= (CurrentMode
->CursorRow
* GLYPH_HEIGHT
) + Private
->ModeData
[CurrentMode
->Mode
].DeltaY
;
1962 if (GraphicsOutput
!= NULL
) {
1963 GraphicsOutput
->Blt (
1965 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*) BltChar
,
1966 EfiBltVideoToBltBuffer
,
1973 GLYPH_WIDTH
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
1978 (EFI_UGA_PIXEL
*) (UINTN
) BltChar
,
1979 EfiUgaVideoToBltBuffer
,
1986 GLYPH_WIDTH
* sizeof (EFI_UGA_PIXEL
)
1990 GetTextColors (This
, &Foreground
.Pixel
, &Background
.Pixel
);
1993 // Convert Monochrome bitmap of the Glyph to BltBuffer structure
1995 for (Y
= 0; Y
< GLYPH_HEIGHT
; Y
++) {
1996 for (X
= 0; X
< GLYPH_WIDTH
; X
++) {
1997 if ((mCursorGlyph
.GlyphCol1
[Y
] & (1 << X
)) != 0) {
1998 BltChar
[Y
][GLYPH_WIDTH
- X
- 1].Raw
^= Foreground
.Raw
;
2003 if (GraphicsOutput
!= NULL
) {
2004 GraphicsOutput
->Blt (
2006 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*) BltChar
,
2007 EfiBltBufferToVideo
,
2014 GLYPH_WIDTH
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
2019 (EFI_UGA_PIXEL
*) (UINTN
) BltChar
,
2020 EfiUgaBltBufferToVideo
,
2027 GLYPH_WIDTH
* sizeof (EFI_UGA_PIXEL
)
2035 The user Entry Point for module GraphicsConsole. The user code starts with this function.
2037 @param[in] ImageHandle The firmware allocated handle for the EFI image.
2038 @param[in] SystemTable A pointer to the EFI System Table.
2040 @retval EFI_SUCCESS The entry point is executed successfully.
2041 @retval other Some error occurs when executing this entry point.
2046 InitializeGraphicsConsole (
2047 IN EFI_HANDLE ImageHandle
,
2048 IN EFI_SYSTEM_TABLE
*SystemTable
2054 // Install driver model protocol(s).
2056 Status
= EfiLibInstallDriverBindingComponentName2 (
2059 &gGraphicsConsoleDriverBinding
,
2061 &gGraphicsConsoleComponentName
,
2062 &gGraphicsConsoleComponentName2
2064 ASSERT_EFI_ERROR (Status
);