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 Status
= HiiLibRemovePackagesFromHiiDatabase (Private
->HiiHandle
);
623 if (!EFI_ERROR (Status
)) {
624 mFirstAccessFlag
= TRUE
;
627 mHii
->RemovePack (mHii
, Private
->HiiHandle
);
631 // Free our instance data
633 if (Private
!= NULL
) {
634 FreePool (Private
->LineBuffer
);
644 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
645 IN UINT32 HorizontalResolution
,
646 IN UINT32 VerticalResolution
,
647 OUT UINT32
*CurrentModeNumber
653 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
655 Status
= EFI_SUCCESS
;
657 for (ModeNumber
= 0; ModeNumber
< GraphicsOutput
->Mode
->MaxMode
; ModeNumber
++) {
658 Status
= GraphicsOutput
->QueryMode (
664 if (!EFI_ERROR (Status
)) {
665 if ((Info
->HorizontalResolution
== HorizontalResolution
) &&
666 (Info
->VerticalResolution
== VerticalResolution
)) {
667 Status
= GraphicsOutput
->SetMode (GraphicsOutput
, ModeNumber
);
668 if (!EFI_ERROR (Status
)) {
669 gBS
->FreePool (Info
);
673 gBS
->FreePool (Info
);
677 if (ModeNumber
== GraphicsOutput
->Mode
->MaxMode
) {
678 Status
= EFI_UNSUPPORTED
;
681 *CurrentModeNumber
= ModeNumber
;
686 EfiLocateHiiProtocol (
692 Locate HII protocols for future usage.
704 #if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
707 // There should only be one - so buffer size is this
709 Size
= sizeof (EFI_HANDLE
);
711 Status
= gBS
->LocateHandle (
713 &gEfiHiiDatabaseProtocolGuid
,
719 if (EFI_ERROR (Status
)) {
723 Status
= gBS
->HandleProtocol (
725 &gEfiHiiDatabaseProtocolGuid
,
726 (VOID
**) &mHiiDatabase
729 if (EFI_ERROR (Status
)) {
733 Status
= gBS
->HandleProtocol (
735 &gEfiHiiFontProtocolGuid
,
742 // There should only be one - so buffer size is this
744 Size
= sizeof (EFI_HANDLE
);
746 Status
= gBS
->LocateHandle (
748 &gEfiHiiProtocolGuid
,
754 if (EFI_ERROR (Status
)) {
758 Status
= gBS
->HandleProtocol (
760 &gEfiHiiProtocolGuid
,
769 // Body of the STO functions
773 GraphicsConsoleConOutReset (
774 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
775 IN BOOLEAN ExtendedVerification
780 Implements SIMPLE_TEXT_OUTPUT.Reset().
781 If ExtendeVerification is TRUE, then perform dependent Graphics Console
782 device reset, and set display mode to mode 0.
783 If ExtendedVerification is FALSE, only set display mode to mode 0.
787 This - Indicates the calling context.
789 ExtendedVerification - Indicates that the driver may perform a more exhaustive
790 verification operation of the device during reset.
795 The reset operation succeeds.
798 The Graphics Console is not functioning correctly
802 This
->SetAttribute (This
, EFI_TEXT_ATTR (This
->Mode
->Attribute
& 0x0F, EFI_BACKGROUND_BLACK
));
803 return This
->SetMode (This
, 0);
808 GraphicsConsoleConOutOutputString (
809 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
815 Implements SIMPLE_TEXT_OUTPUT.OutputString().
816 The Unicode string will be converted to Glyphs and will be
817 sent to the Graphics Console.
822 This - Indicates the calling context.
824 WString - The Null-terminated Unicode string to be displayed on
825 the Graphics Console.
830 The string is output successfully.
833 The Graphics Console failed to send the string out.
835 EFI_WARN_UNKNOWN_GLYPH
836 Indicates that some of the characters in the Unicode string could not
837 be rendered and are skipped.
841 GRAPHICS_CONSOLE_DEV
*Private
;
842 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
843 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
852 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
853 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
858 INT32 OriginAttribute
;
860 CHAR16 SpaceStr
[] = { NARROW_CHAR
, ' ', 0 };
862 Status
= EFI_SUCCESS
;
864 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
868 Mode
= This
->Mode
->Mode
;
869 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
870 GraphicsOutput
= Private
->GraphicsOutput
;
871 UgaDraw
= Private
->UgaDraw
;
873 MaxColumn
= Private
->ModeData
[Mode
].Columns
;
874 MaxRow
= Private
->ModeData
[Mode
].Rows
;
875 DeltaX
= Private
->ModeData
[Mode
].DeltaX
;
876 DeltaY
= Private
->ModeData
[Mode
].DeltaY
;
877 Width
= MaxColumn
* GLYPH_WIDTH
;
878 Height
= (MaxRow
- 1) * GLYPH_HEIGHT
;
879 Delta
= Width
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
);
882 // The Attributes won't change when during the time OutputString is called
884 GetTextColors (This
, &Foreground
, &Background
);
893 OriginAttribute
= This
->Mode
->Attribute
;
897 if (*WString
== CHAR_BACKSPACE
) {
899 // If the cursor is at the left edge of the display, then move the cursor
902 if (This
->Mode
->CursorColumn
== 0 && This
->Mode
->CursorRow
> 0) {
903 This
->Mode
->CursorRow
--;
904 This
->Mode
->CursorColumn
= (INT32
) (MaxColumn
- 1);
905 This
->OutputString (This
, SpaceStr
);
907 This
->Mode
->CursorRow
--;
908 This
->Mode
->CursorColumn
= (INT32
) (MaxColumn
- 1);
909 } else if (This
->Mode
->CursorColumn
> 0) {
911 // If the cursor is not at the left edge of the display, then move the cursor
914 This
->Mode
->CursorColumn
--;
915 This
->OutputString (This
, SpaceStr
);
917 This
->Mode
->CursorColumn
--;
922 } else if (*WString
== CHAR_LINEFEED
) {
924 // If the cursor is at the bottom of the display, then scroll the display one
925 // row, and do not update the cursor position. Otherwise, move the cursor
928 if (This
->Mode
->CursorRow
== (INT32
) (MaxRow
- 1)) {
929 if (GraphicsOutput
!= NULL
) {
931 // Scroll Screen Up One Row
933 GraphicsOutput
->Blt (
938 DeltaY
+ GLYPH_HEIGHT
,
947 // Print Blank Line at last line
949 GraphicsOutput
->Blt (
963 // Scroll Screen Up One Row
970 DeltaY
+ GLYPH_HEIGHT
,
979 // Print Blank Line at last line
983 (EFI_UGA_PIXEL
*) (UINTN
) &Background
,
995 This
->Mode
->CursorRow
++;
1000 } else if (*WString
== CHAR_CARRIAGE_RETURN
) {
1002 // Move the cursor to the beginning of the current row.
1004 This
->Mode
->CursorColumn
= 0;
1007 } else if (*WString
== WIDE_CHAR
) {
1009 This
->Mode
->Attribute
|= EFI_WIDE_ATTRIBUTE
;
1012 } else if (*WString
== NARROW_CHAR
) {
1014 This
->Mode
->Attribute
&= (~ (UINT32
) EFI_WIDE_ATTRIBUTE
);
1019 // Print the character at the current cursor position and move the cursor
1020 // right one column. If this moves the cursor past the right edge of the
1021 // display, then the line should wrap to the beginning of the next line. This
1022 // is equivalent to inserting a CR and an LF. Note that if the cursor is at the
1023 // bottom of the display, and the line wraps, then the display will be scrolled
1025 // If wide char is going to be displayed, need to display one character at a time
1026 // Or, need to know the display length of a certain string.
1028 // Index is used to determine how many character width units (wide = 2, narrow = 1)
1029 // Count is used to determine how many characters are used regardless of their attributes
1031 for (Count
= 0, Index
= 0; (This
->Mode
->CursorColumn
+ Index
) < MaxColumn
; Count
++, Index
++) {
1032 if (WString
[Count
] == CHAR_NULL
) {
1036 if (WString
[Count
] == CHAR_BACKSPACE
) {
1040 if (WString
[Count
] == CHAR_LINEFEED
) {
1044 if (WString
[Count
] == CHAR_CARRIAGE_RETURN
) {
1048 if (WString
[Count
] == WIDE_CHAR
) {
1052 if (WString
[Count
] == NARROW_CHAR
) {
1056 // Is the wide attribute on?
1058 if (This
->Mode
->Attribute
& EFI_WIDE_ATTRIBUTE
) {
1060 // If wide, add one more width unit than normal since we are going to increment at the end of the for loop
1064 // This is the end-case where if we are at column 79 and about to print a wide character
1065 // We should prevent this from happening because we will wrap inappropriately. We should
1066 // not print this character until the next line.
1068 if ((This
->Mode
->CursorColumn
+ Index
+ 1) > MaxColumn
) {
1075 Status
= DrawUnicodeWeightAtCursorN (This
, WString
, Count
);
1076 if (EFI_ERROR (Status
)) {
1080 // At the end of line, output carriage return and line feed
1083 This
->Mode
->CursorColumn
+= (INT32
) Index
;
1084 if (This
->Mode
->CursorColumn
> (INT32
) MaxColumn
) {
1085 This
->Mode
->CursorColumn
-= 2;
1086 This
->OutputString (This
, SpaceStr
);
1089 if (This
->Mode
->CursorColumn
>= (INT32
) MaxColumn
) {
1091 This
->OutputString (This
, mCrLfString
);
1097 This
->Mode
->Attribute
= OriginAttribute
;
1102 Status
= EFI_WARN_UNKNOWN_GLYPH
;
1105 gBS
->RestoreTPL (OldTpl
);
1112 GraphicsConsoleConOutTestString (
1113 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1117 Routine Description:
1119 Implements SIMPLE_TEXT_OUTPUT.TestString().
1120 If one of the characters in the *Wstring is
1121 neither valid valid Unicode drawing characters,
1122 not ASCII code, then this function will return
1128 This - Indicates the calling context.
1130 WString - The Null-terminated Unicode string to be tested.
1135 The Graphics Console is capable of rendering the output string.
1138 Some of the characters in the Unicode string cannot be rendered.
1145 #if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
1146 EFI_IMAGE_OUTPUT
*Blt
= NULL
;
1149 UINT32 GlyphStatus
= 0;
1155 while (WString
[Count
] != 0) {
1156 #if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
1157 Status
= mHiiFont
->GetGlyph (
1168 Status
= mHii
->GetGlyph (
1177 if (EFI_ERROR (Status
)) {
1178 return EFI_UNSUPPORTED
;
1187 GraphicsConsoleConOutQueryMode (
1188 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1189 IN UINTN ModeNumber
,
1194 Routine Description:
1196 Implements SIMPLE_TEXT_OUTPUT.QueryMode().
1197 It returnes information for an available text mode
1198 that the Graphics Console supports.
1199 In this driver,we only support text mode 80x25, which is
1205 This - Indicates the calling context.
1207 ModeNumber - The mode number to return information on.
1209 Columns - The returned columns of the requested mode.
1211 Rows - The returned rows of the requested mode.
1216 The requested mode information is returned.
1219 The mode number is not valid.
1223 GRAPHICS_CONSOLE_DEV
*Private
;
1227 if (ModeNumber
>= (UINTN
) This
->Mode
->MaxMode
) {
1228 return EFI_UNSUPPORTED
;
1231 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1232 Status
= EFI_SUCCESS
;
1234 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1236 *Columns
= Private
->ModeData
[ModeNumber
].Columns
;
1237 *Rows
= Private
->ModeData
[ModeNumber
].Rows
;
1239 if (*Columns
<= 0 && *Rows
<= 0) {
1240 Status
= EFI_UNSUPPORTED
;
1246 gBS
->RestoreTPL (OldTpl
);
1252 GraphicsConsoleConOutSetMode (
1253 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1257 Routine Description:
1259 Implements SIMPLE_TEXT_OUTPUT.SetMode().
1260 Set the Graphics Console to a specified mode.
1261 In this driver, we only support mode 0.
1265 This - Indicates the calling context.
1267 ModeNumber - The text mode to set.
1272 The requested text mode is set.
1275 The requested text mode cannot be set because of Graphics Console device error.
1278 The text mode number is not valid.
1283 GRAPHICS_CONSOLE_DEV
*Private
;
1284 GRAPHICS_CONSOLE_MODE_DATA
*ModeData
;
1285 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*NewLineBuffer
;
1286 UINT32 HorizontalResolution
;
1287 UINT32 VerticalResolution
;
1288 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1289 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1294 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1296 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1297 GraphicsOutput
= Private
->GraphicsOutput
;
1298 UgaDraw
= Private
->UgaDraw
;
1299 ModeData
= &(Private
->ModeData
[ModeNumber
]);
1301 if (ModeData
->Columns
<= 0 && ModeData
->Rows
<= 0) {
1302 Status
= EFI_UNSUPPORTED
;
1307 // Make sure the requested mode number is supported
1309 if (ModeNumber
>= (UINTN
) This
->Mode
->MaxMode
) {
1310 Status
= EFI_UNSUPPORTED
;
1314 if (ModeData
->Columns
<= 0 && ModeData
->Rows
<= 0) {
1315 Status
= EFI_UNSUPPORTED
;
1319 // Attempt to allocate a line buffer for the requested mode number
1321 NewLineBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
) * ModeData
->Columns
* GLYPH_WIDTH
* GLYPH_HEIGHT
);
1323 if (NewLineBuffer
== NULL
) {
1325 // The new line buffer could not be allocated, so return an error.
1326 // No changes to the state of the current console have been made, so the current console is still valid
1328 Status
= EFI_OUT_OF_RESOURCES
;
1332 // If the mode has been set at least one other time, then LineBuffer will not be NULL
1334 if (Private
->LineBuffer
!= NULL
) {
1336 // Clear the current text window on the current graphics console
1338 This
->ClearScreen (This
);
1341 // If the new mode is the same as the old mode, then just return EFI_SUCCESS
1343 if ((INT32
) ModeNumber
== This
->Mode
->Mode
) {
1344 FreePool (NewLineBuffer
);
1345 Status
= EFI_SUCCESS
;
1349 // Otherwise, the size of the text console and/or the GOP/UGA mode will be changed,
1350 // so erase the cursor, and free the LineBuffer for the current mode
1354 FreePool (Private
->LineBuffer
);
1357 // Assign the current line buffer to the newly allocated line buffer
1359 Private
->LineBuffer
= NewLineBuffer
;
1361 if (GraphicsOutput
!= NULL
) {
1362 if (ModeData
->GopModeNumber
!= GraphicsOutput
->Mode
->Mode
) {
1364 // Either no graphics mode is currently set, or it is set to the wrong resolution, so set the new grapghics mode
1366 Status
= GraphicsOutput
->SetMode (GraphicsOutput
, ModeData
->GopModeNumber
);
1367 if (EFI_ERROR (Status
)) {
1369 // The mode set operation failed
1375 // The current graphics mode is correct, so simply clear the entire display
1377 Status
= GraphicsOutput
->Blt (
1386 ModeData
->GopHeight
,
1392 // Get the current UGA Draw mode information
1394 Status
= UgaDraw
->GetMode (
1396 &HorizontalResolution
,
1397 &VerticalResolution
,
1401 if (EFI_ERROR (Status
) || HorizontalResolution
!= ModeData
->GopWidth
|| VerticalResolution
!= ModeData
->GopHeight
) {
1403 // Either no graphics mode is currently set, or it is set to the wrong resolution, so set the new grapghics mode
1405 Status
= UgaDraw
->SetMode (
1408 ModeData
->GopHeight
,
1412 if (EFI_ERROR (Status
)) {
1414 // The mode set operation failed
1420 // The current graphics mode is correct, so simply clear the entire display
1422 Status
= UgaDraw
->Blt (
1424 (EFI_UGA_PIXEL
*) (UINTN
) &mEfiColors
[0],
1431 ModeData
->GopHeight
,
1438 // The new mode is valid, so commit the mode change
1440 This
->Mode
->Mode
= (INT32
) ModeNumber
;
1443 // Move the text cursor to the upper left hand corner of the displat and enable it
1445 This
->SetCursorPosition (This
, 0, 0);
1447 Status
= EFI_SUCCESS
;
1450 gBS
->RestoreTPL (OldTpl
);
1456 GraphicsConsoleConOutSetAttribute (
1457 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1461 Routine Description:
1463 Implements SIMPLE_TEXT_OUTPUT.SetAttribute().
1467 This - Indicates the calling context.
1469 Attrubute - The attribute to set. Only bit0..6 are valid, all other bits
1470 are undefined and must be zero.
1475 The requested attribute is set.
1478 The requested attribute cannot be set due to Graphics Console port error.
1481 The attribute requested is not defined by EFI spec.
1487 if ((Attribute
| 0xFF) != 0xFF) {
1488 return EFI_UNSUPPORTED
;
1491 if ((INT32
) Attribute
== This
->Mode
->Attribute
) {
1495 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1499 This
->Mode
->Attribute
= (INT32
) Attribute
;
1503 gBS
->RestoreTPL (OldTpl
);
1510 GraphicsConsoleConOutClearScreen (
1511 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
1514 Routine Description:
1516 Implements SIMPLE_TEXT_OUTPUT.ClearScreen().
1517 It clears the Graphics Console's display to the
1518 currently selected background color.
1523 This - Indicates the calling context.
1528 The operation completed successfully.
1531 The Graphics Console cannot be cleared due to Graphics Console device error.
1534 The Graphics Console is not in a valid text mode.
1539 GRAPHICS_CONSOLE_DEV
*Private
;
1540 GRAPHICS_CONSOLE_MODE_DATA
*ModeData
;
1541 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1542 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1543 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
1544 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
1547 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1549 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1550 GraphicsOutput
= Private
->GraphicsOutput
;
1551 UgaDraw
= Private
->UgaDraw
;
1552 ModeData
= &(Private
->ModeData
[This
->Mode
->Mode
]);
1554 GetTextColors (This
, &Foreground
, &Background
);
1555 if (GraphicsOutput
!= NULL
) {
1556 Status
= GraphicsOutput
->Blt (
1565 ModeData
->GopHeight
,
1569 Status
= UgaDraw
->Blt (
1571 (EFI_UGA_PIXEL
*) (UINTN
) &Background
,
1578 ModeData
->GopHeight
,
1583 This
->Mode
->CursorColumn
= 0;
1584 This
->Mode
->CursorRow
= 0;
1588 gBS
->RestoreTPL (OldTpl
);
1595 GraphicsConsoleConOutSetCursorPosition (
1596 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1601 Routine Description:
1603 Implements SIMPLE_TEXT_OUTPUT.SetCursorPosition().
1607 This - Indicates the calling context.
1609 Column - The row to set cursor to.
1611 Row - The column to set cursor to.
1616 The operation completed successfully.
1619 The request fails due to Graphics Console device error.
1622 The Graphics Console is not in a valid text mode, or the cursor position
1623 is invalid for current mode.
1627 GRAPHICS_CONSOLE_DEV
*Private
;
1628 GRAPHICS_CONSOLE_MODE_DATA
*ModeData
;
1632 Status
= EFI_SUCCESS
;
1634 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1636 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1637 ModeData
= &(Private
->ModeData
[This
->Mode
->Mode
]);
1639 if ((Column
>= ModeData
->Columns
) || (Row
>= ModeData
->Rows
)) {
1640 Status
= EFI_UNSUPPORTED
;
1644 if (((INT32
) Column
== This
->Mode
->CursorColumn
) && ((INT32
) Row
== This
->Mode
->CursorRow
)) {
1645 Status
= EFI_SUCCESS
;
1651 This
->Mode
->CursorColumn
= (INT32
) Column
;
1652 This
->Mode
->CursorRow
= (INT32
) Row
;
1657 gBS
->RestoreTPL (OldTpl
);
1664 GraphicsConsoleConOutEnableCursor (
1665 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1669 Routine Description:
1671 Implements SIMPLE_TEXT_OUTPUT.EnableCursor().
1672 In this driver, the cursor cannot be hidden.
1676 This - Indicates the calling context.
1678 Visible - If TRUE, the cursor is set to be visible,
1679 If FALSE, the cursor is set to be invisible.
1684 The request is valid.
1687 The Graphics Console does not support a hidden cursor.
1693 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1697 This
->Mode
->CursorVisible
= Visible
;
1701 gBS
->RestoreTPL (OldTpl
);
1708 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1709 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Foreground
,
1710 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Background
1715 Attribute
= This
->Mode
->Attribute
& 0x7F;
1717 *Foreground
= mEfiColors
[Attribute
& 0x0f];
1718 *Background
= mEfiColors
[Attribute
>> 4];
1723 #if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
1725 DrawUnicodeWeightAtCursorN (
1726 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1727 IN CHAR16
*UnicodeWeight
,
1732 GRAPHICS_CONSOLE_DEV
*Private
;
1733 EFI_IMAGE_OUTPUT
*Blt
;
1735 EFI_FONT_DISPLAY_INFO
*FontInfo
;
1737 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1739 // GOP protocol is required in UEFI mode.
1741 ASSERT (Private
->GraphicsOutput
!= NULL
);
1743 Blt
= (EFI_IMAGE_OUTPUT
*) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT
));
1745 return EFI_OUT_OF_RESOURCES
;
1748 Blt
->Width
= (UINT16
) (Private
->ModeData
[This
->Mode
->Mode
].GopWidth
);
1749 Blt
->Height
= (UINT16
) (Private
->ModeData
[This
->Mode
->Mode
].GopHeight
);
1750 Blt
->Image
.Screen
= Private
->GraphicsOutput
;
1752 String
= AllocateCopyPool ((Count
+ 1) * sizeof (CHAR16
), UnicodeWeight
);
1753 if (String
== NULL
) {
1755 return EFI_OUT_OF_RESOURCES
;
1757 *(String
+ Count
) = 0;
1759 FontInfo
= (EFI_FONT_DISPLAY_INFO
*) AllocateZeroPool (sizeof (EFI_FONT_DISPLAY_INFO
));
1760 if (FontInfo
== NULL
) {
1762 SafeFreePool (String
);
1763 return EFI_OUT_OF_RESOURCES
;
1765 GetTextColors (This
, &FontInfo
->ForegroundColor
, &FontInfo
->BackgroundColor
);
1767 Status
= mHiiFont
->StringToImage (
1769 EFI_HII_IGNORE_IF_NO_GLYPH
| EFI_HII_DIRECT_TO_SCREEN
,
1773 This
->Mode
->CursorColumn
* GLYPH_WIDTH
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaX
,
1774 This
->Mode
->CursorRow
* GLYPH_HEIGHT
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaY
,
1781 SafeFreePool (String
);
1782 SafeFreePool (FontInfo
);
1788 DrawUnicodeWeightAtCursorN (
1789 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1790 IN CHAR16
*UnicodeWeight
,
1794 GRAPHICS_CONSOLE_DEV
*Private
;
1796 EFI_STATUS ReturnStatus
;
1798 GLYPH_UNION GlyphData
;
1801 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1802 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1803 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
1804 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
1811 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1813 ReturnStatus
= EFI_SUCCESS
;
1817 GetTextColors (This
, &Foreground
, &Background
);
1821 while (Index
< Count
) {
1822 if (This
->Mode
->Attribute
& EFI_WIDE_ATTRIBUTE
) {
1823 GlyphStatus
= WIDE_CHAR
;
1825 GlyphStatus
= NARROW_CHAR
;
1828 Status
= mHii
->GetGlyph (
1836 if (EFI_ERROR (Status
)) {
1837 ReturnStatus
= Status
;
1842 CopyMem (&GlyphData
, Glyph
, sizeof (GLYPH_UNION
));
1846 // We are creating the second half of the wide character's BLT buffer
1848 if (GlyphWidth
== 0x10 && Counts
== 1) {
1849 CopyMem (&GlyphData
.NarrowGlyph
.GlyphCol1
, &Glyph
->WideGlyph
.GlyphCol2
, sizeof (Glyph
->WideGlyph
.GlyphCol2
));
1854 if (GlyphWidth
== 0x10) {
1857 (UINT8
*) &GlyphData
,
1863 &Private
->LineBuffer
[ArrayIndex
* GLYPH_WIDTH
]
1868 (UINT8
*) &GlyphData
,
1874 &Private
->LineBuffer
[ArrayIndex
* GLYPH_WIDTH
]
1880 } while (Counts
< 2 && GlyphWidth
== 0x10);
1884 // If we are printing Wide characters, treat the BLT as if it is twice as many characters
1886 if (GlyphWidth
== 0x10) {
1890 // Blt a character to the screen
1892 GlyphX
= This
->Mode
->CursorColumn
* GLYPH_WIDTH
;
1893 GlyphY
= This
->Mode
->CursorRow
* GLYPH_HEIGHT
;
1894 GraphicsOutput
= Private
->GraphicsOutput
;
1895 UgaDraw
= Private
->UgaDraw
;
1896 if (GraphicsOutput
!= NULL
) {
1897 GraphicsOutput
->Blt (
1899 Private
->LineBuffer
,
1900 EfiBltBufferToVideo
,
1903 GlyphX
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaX
,
1904 GlyphY
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaY
,
1905 GLYPH_WIDTH
* Count
,
1907 GLYPH_WIDTH
* Count
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
1912 (EFI_UGA_PIXEL
*) (UINTN
) Private
->LineBuffer
,
1913 EfiUgaBltBufferToVideo
,
1916 GlyphX
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaX
,
1917 GlyphY
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaY
,
1918 GLYPH_WIDTH
* Count
,
1920 GLYPH_WIDTH
* Count
* sizeof (EFI_UGA_PIXEL
)
1924 return ReturnStatus
;
1931 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
1934 GRAPHICS_CONSOLE_DEV
*Private
;
1935 EFI_SIMPLE_TEXT_OUTPUT_MODE
*CurrentMode
;
1938 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1939 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1940 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Foreground
;
1941 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Background
;
1942 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION BltChar
[GLYPH_HEIGHT
][GLYPH_WIDTH
];
1946 CurrentMode
= This
->Mode
;
1948 if (!CurrentMode
->CursorVisible
) {
1952 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1953 GraphicsOutput
= Private
->GraphicsOutput
;
1954 UgaDraw
= Private
->UgaDraw
;
1957 // BUGBUG - we need to think about what to do with wide and narrow character deletions.
1960 // Blt a character to the screen
1962 GlyphX
= (CurrentMode
->CursorColumn
* GLYPH_WIDTH
) + Private
->ModeData
[CurrentMode
->Mode
].DeltaX
;
1963 GlyphY
= (CurrentMode
->CursorRow
* GLYPH_HEIGHT
) + Private
->ModeData
[CurrentMode
->Mode
].DeltaY
;
1964 if (GraphicsOutput
!= NULL
) {
1965 GraphicsOutput
->Blt (
1967 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*) BltChar
,
1968 EfiBltVideoToBltBuffer
,
1975 GLYPH_WIDTH
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
1980 (EFI_UGA_PIXEL
*) (UINTN
) BltChar
,
1981 EfiUgaVideoToBltBuffer
,
1988 GLYPH_WIDTH
* sizeof (EFI_UGA_PIXEL
)
1992 GetTextColors (This
, &Foreground
.Pixel
, &Background
.Pixel
);
1995 // Convert Monochrome bitmap of the Glyph to BltBuffer structure
1997 for (Y
= 0; Y
< GLYPH_HEIGHT
; Y
++) {
1998 for (X
= 0; X
< GLYPH_WIDTH
; X
++) {
1999 if ((mCursorGlyph
.GlyphCol1
[Y
] & (1 << X
)) != 0) {
2000 BltChar
[Y
][GLYPH_WIDTH
- X
- 1].Raw
^= Foreground
.Raw
;
2005 if (GraphicsOutput
!= NULL
) {
2006 GraphicsOutput
->Blt (
2008 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*) BltChar
,
2009 EfiBltBufferToVideo
,
2016 GLYPH_WIDTH
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
2021 (EFI_UGA_PIXEL
*) (UINTN
) BltChar
,
2022 EfiUgaBltBufferToVideo
,
2029 GLYPH_WIDTH
* sizeof (EFI_UGA_PIXEL
)
2037 The user Entry Point for module GraphicsConsole. The user code starts with this function.
2039 @param[in] ImageHandle The firmware allocated handle for the EFI image.
2040 @param[in] SystemTable A pointer to the EFI System Table.
2042 @retval EFI_SUCCESS The entry point is executed successfully.
2043 @retval other Some error occurs when executing this entry point.
2048 InitializeGraphicsConsole (
2049 IN EFI_HANDLE ImageHandle
,
2050 IN EFI_SYSTEM_TABLE
*SystemTable
2056 // Install driver model protocol(s).
2058 Status
= EfiLibInstallDriverBindingComponentName2 (
2061 &gGraphicsConsoleDriverBinding
,
2063 &gGraphicsConsoleComponentName
,
2064 &gGraphicsConsoleComponentName2
2066 ASSERT_EFI_ERROR (Status
);