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
621 if (Private
->HiiHandle
!= NULL
) {
622 HiiLibRemovePackages (Private
->HiiHandle
);
623 mFirstAccessFlag
= TRUE
;
627 // Free our instance data
629 if (Private
!= NULL
) {
630 FreePool (Private
->LineBuffer
);
640 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
641 IN UINT32 HorizontalResolution
,
642 IN UINT32 VerticalResolution
,
643 OUT UINT32
*CurrentModeNumber
649 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
651 Status
= EFI_SUCCESS
;
653 for (ModeNumber
= 0; ModeNumber
< GraphicsOutput
->Mode
->MaxMode
; ModeNumber
++) {
654 Status
= GraphicsOutput
->QueryMode (
660 if (!EFI_ERROR (Status
)) {
661 if ((Info
->HorizontalResolution
== HorizontalResolution
) &&
662 (Info
->VerticalResolution
== VerticalResolution
)) {
663 Status
= GraphicsOutput
->SetMode (GraphicsOutput
, ModeNumber
);
664 if (!EFI_ERROR (Status
)) {
665 gBS
->FreePool (Info
);
669 gBS
->FreePool (Info
);
673 if (ModeNumber
== GraphicsOutput
->Mode
->MaxMode
) {
674 Status
= EFI_UNSUPPORTED
;
677 *CurrentModeNumber
= ModeNumber
;
682 EfiLocateHiiProtocol (
688 Locate HII protocols for future usage.
700 #if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
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 // There should only be one - so buffer size is this
740 Size
= sizeof (EFI_HANDLE
);
742 Status
= gBS
->LocateHandle (
744 &gEfiHiiProtocolGuid
,
750 if (EFI_ERROR (Status
)) {
754 Status
= gBS
->HandleProtocol (
756 &gEfiHiiProtocolGuid
,
765 // Body of the STO functions
769 GraphicsConsoleConOutReset (
770 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
771 IN BOOLEAN ExtendedVerification
776 Implements SIMPLE_TEXT_OUTPUT.Reset().
777 If ExtendeVerification is TRUE, then perform dependent Graphics Console
778 device reset, and set display mode to mode 0.
779 If ExtendedVerification is FALSE, only set display mode to mode 0.
783 This - Indicates the calling context.
785 ExtendedVerification - Indicates that the driver may perform a more exhaustive
786 verification operation of the device during reset.
791 The reset operation succeeds.
794 The Graphics Console is not functioning correctly
798 This
->SetAttribute (This
, EFI_TEXT_ATTR (This
->Mode
->Attribute
& 0x0F, EFI_BACKGROUND_BLACK
));
799 return This
->SetMode (This
, 0);
804 GraphicsConsoleConOutOutputString (
805 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
811 Implements SIMPLE_TEXT_OUTPUT.OutputString().
812 The Unicode string will be converted to Glyphs and will be
813 sent to the Graphics Console.
818 This - Indicates the calling context.
820 WString - The Null-terminated Unicode string to be displayed on
821 the Graphics Console.
826 The string is output successfully.
829 The Graphics Console failed to send the string out.
831 EFI_WARN_UNKNOWN_GLYPH
832 Indicates that some of the characters in the Unicode string could not
833 be rendered and are skipped.
837 GRAPHICS_CONSOLE_DEV
*Private
;
838 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
839 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
848 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
849 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
854 INT32 OriginAttribute
;
856 CHAR16 SpaceStr
[] = { NARROW_CHAR
, ' ', 0 };
858 Status
= EFI_SUCCESS
;
860 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
864 Mode
= This
->Mode
->Mode
;
865 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
866 GraphicsOutput
= Private
->GraphicsOutput
;
867 UgaDraw
= Private
->UgaDraw
;
869 MaxColumn
= Private
->ModeData
[Mode
].Columns
;
870 MaxRow
= Private
->ModeData
[Mode
].Rows
;
871 DeltaX
= Private
->ModeData
[Mode
].DeltaX
;
872 DeltaY
= Private
->ModeData
[Mode
].DeltaY
;
873 Width
= MaxColumn
* GLYPH_WIDTH
;
874 Height
= (MaxRow
- 1) * GLYPH_HEIGHT
;
875 Delta
= Width
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
);
878 // The Attributes won't change when during the time OutputString is called
880 GetTextColors (This
, &Foreground
, &Background
);
889 OriginAttribute
= This
->Mode
->Attribute
;
893 if (*WString
== CHAR_BACKSPACE
) {
895 // If the cursor is at the left edge of the display, then move the cursor
898 if (This
->Mode
->CursorColumn
== 0 && This
->Mode
->CursorRow
> 0) {
899 This
->Mode
->CursorRow
--;
900 This
->Mode
->CursorColumn
= (INT32
) (MaxColumn
- 1);
901 This
->OutputString (This
, SpaceStr
);
903 This
->Mode
->CursorRow
--;
904 This
->Mode
->CursorColumn
= (INT32
) (MaxColumn
- 1);
905 } else if (This
->Mode
->CursorColumn
> 0) {
907 // If the cursor is not at the left edge of the display, then move the cursor
910 This
->Mode
->CursorColumn
--;
911 This
->OutputString (This
, SpaceStr
);
913 This
->Mode
->CursorColumn
--;
918 } else if (*WString
== CHAR_LINEFEED
) {
920 // If the cursor is at the bottom of the display, then scroll the display one
921 // row, and do not update the cursor position. Otherwise, move the cursor
924 if (This
->Mode
->CursorRow
== (INT32
) (MaxRow
- 1)) {
925 if (GraphicsOutput
!= NULL
) {
927 // Scroll Screen Up One Row
929 GraphicsOutput
->Blt (
934 DeltaY
+ GLYPH_HEIGHT
,
943 // Print Blank Line at last line
945 GraphicsOutput
->Blt (
959 // Scroll Screen Up One Row
966 DeltaY
+ GLYPH_HEIGHT
,
975 // Print Blank Line at last line
979 (EFI_UGA_PIXEL
*) (UINTN
) &Background
,
991 This
->Mode
->CursorRow
++;
996 } else if (*WString
== CHAR_CARRIAGE_RETURN
) {
998 // Move the cursor to the beginning of the current row.
1000 This
->Mode
->CursorColumn
= 0;
1003 } else if (*WString
== WIDE_CHAR
) {
1005 This
->Mode
->Attribute
|= EFI_WIDE_ATTRIBUTE
;
1008 } else if (*WString
== NARROW_CHAR
) {
1010 This
->Mode
->Attribute
&= (~ (UINT32
) EFI_WIDE_ATTRIBUTE
);
1015 // Print the character at the current cursor position and move the cursor
1016 // right one column. If this moves the cursor past the right edge of the
1017 // display, then the line should wrap to the beginning of the next line. This
1018 // is equivalent to inserting a CR and an LF. Note that if the cursor is at the
1019 // bottom of the display, and the line wraps, then the display will be scrolled
1021 // If wide char is going to be displayed, need to display one character at a time
1022 // Or, need to know the display length of a certain string.
1024 // Index is used to determine how many character width units (wide = 2, narrow = 1)
1025 // Count is used to determine how many characters are used regardless of their attributes
1027 for (Count
= 0, Index
= 0; (This
->Mode
->CursorColumn
+ Index
) < MaxColumn
; Count
++, Index
++) {
1028 if (WString
[Count
] == CHAR_NULL
) {
1032 if (WString
[Count
] == CHAR_BACKSPACE
) {
1036 if (WString
[Count
] == CHAR_LINEFEED
) {
1040 if (WString
[Count
] == CHAR_CARRIAGE_RETURN
) {
1044 if (WString
[Count
] == WIDE_CHAR
) {
1048 if (WString
[Count
] == NARROW_CHAR
) {
1052 // Is the wide attribute on?
1054 if (This
->Mode
->Attribute
& EFI_WIDE_ATTRIBUTE
) {
1056 // If wide, add one more width unit than normal since we are going to increment at the end of the for loop
1060 // This is the end-case where if we are at column 79 and about to print a wide character
1061 // We should prevent this from happening because we will wrap inappropriately. We should
1062 // not print this character until the next line.
1064 if ((This
->Mode
->CursorColumn
+ Index
+ 1) > MaxColumn
) {
1071 Status
= DrawUnicodeWeightAtCursorN (This
, WString
, Count
);
1072 if (EFI_ERROR (Status
)) {
1076 // At the end of line, output carriage return and line feed
1079 This
->Mode
->CursorColumn
+= (INT32
) Index
;
1080 if (This
->Mode
->CursorColumn
> (INT32
) MaxColumn
) {
1081 This
->Mode
->CursorColumn
-= 2;
1082 This
->OutputString (This
, SpaceStr
);
1085 if (This
->Mode
->CursorColumn
>= (INT32
) MaxColumn
) {
1087 This
->OutputString (This
, mCrLfString
);
1093 This
->Mode
->Attribute
= OriginAttribute
;
1098 Status
= EFI_WARN_UNKNOWN_GLYPH
;
1101 gBS
->RestoreTPL (OldTpl
);
1108 GraphicsConsoleConOutTestString (
1109 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1113 Routine Description:
1115 Implements SIMPLE_TEXT_OUTPUT.TestString().
1116 If one of the characters in the *Wstring is
1117 neither valid valid Unicode drawing characters,
1118 not ASCII code, then this function will return
1124 This - Indicates the calling context.
1126 WString - The Null-terminated Unicode string to be tested.
1131 The Graphics Console is capable of rendering the output string.
1134 Some of the characters in the Unicode string cannot be rendered.
1141 #if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
1142 EFI_IMAGE_OUTPUT
*Blt
= NULL
;
1145 UINT32 GlyphStatus
= 0;
1151 while (WString
[Count
] != 0) {
1152 #if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
1153 Status
= mHiiFont
->GetGlyph (
1164 Status
= mHii
->GetGlyph (
1173 if (EFI_ERROR (Status
)) {
1174 return EFI_UNSUPPORTED
;
1183 GraphicsConsoleConOutQueryMode (
1184 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1185 IN UINTN ModeNumber
,
1190 Routine Description:
1192 Implements SIMPLE_TEXT_OUTPUT.QueryMode().
1193 It returnes information for an available text mode
1194 that the Graphics Console supports.
1195 In this driver,we only support text mode 80x25, which is
1201 This - Indicates the calling context.
1203 ModeNumber - The mode number to return information on.
1205 Columns - The returned columns of the requested mode.
1207 Rows - The returned rows of the requested mode.
1212 The requested mode information is returned.
1215 The mode number is not valid.
1219 GRAPHICS_CONSOLE_DEV
*Private
;
1223 if (ModeNumber
>= (UINTN
) This
->Mode
->MaxMode
) {
1224 return EFI_UNSUPPORTED
;
1227 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1228 Status
= EFI_SUCCESS
;
1230 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1232 *Columns
= Private
->ModeData
[ModeNumber
].Columns
;
1233 *Rows
= Private
->ModeData
[ModeNumber
].Rows
;
1235 if (*Columns
<= 0 && *Rows
<= 0) {
1236 Status
= EFI_UNSUPPORTED
;
1242 gBS
->RestoreTPL (OldTpl
);
1248 GraphicsConsoleConOutSetMode (
1249 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1253 Routine Description:
1255 Implements SIMPLE_TEXT_OUTPUT.SetMode().
1256 Set the Graphics Console to a specified mode.
1257 In this driver, we only support mode 0.
1261 This - Indicates the calling context.
1263 ModeNumber - The text mode to set.
1268 The requested text mode is set.
1271 The requested text mode cannot be set because of Graphics Console device error.
1274 The text mode number is not valid.
1279 GRAPHICS_CONSOLE_DEV
*Private
;
1280 GRAPHICS_CONSOLE_MODE_DATA
*ModeData
;
1281 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*NewLineBuffer
;
1282 UINT32 HorizontalResolution
;
1283 UINT32 VerticalResolution
;
1284 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1285 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1290 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1292 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1293 GraphicsOutput
= Private
->GraphicsOutput
;
1294 UgaDraw
= Private
->UgaDraw
;
1295 ModeData
= &(Private
->ModeData
[ModeNumber
]);
1297 if (ModeData
->Columns
<= 0 && ModeData
->Rows
<= 0) {
1298 Status
= EFI_UNSUPPORTED
;
1303 // Make sure the requested mode number is supported
1305 if (ModeNumber
>= (UINTN
) This
->Mode
->MaxMode
) {
1306 Status
= EFI_UNSUPPORTED
;
1310 if (ModeData
->Columns
<= 0 && ModeData
->Rows
<= 0) {
1311 Status
= EFI_UNSUPPORTED
;
1315 // Attempt to allocate a line buffer for the requested mode number
1317 NewLineBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
) * ModeData
->Columns
* GLYPH_WIDTH
* GLYPH_HEIGHT
);
1319 if (NewLineBuffer
== NULL
) {
1321 // The new line buffer could not be allocated, so return an error.
1322 // No changes to the state of the current console have been made, so the current console is still valid
1324 Status
= EFI_OUT_OF_RESOURCES
;
1328 // If the mode has been set at least one other time, then LineBuffer will not be NULL
1330 if (Private
->LineBuffer
!= NULL
) {
1332 // Clear the current text window on the current graphics console
1334 This
->ClearScreen (This
);
1337 // If the new mode is the same as the old mode, then just return EFI_SUCCESS
1339 if ((INT32
) ModeNumber
== This
->Mode
->Mode
) {
1340 FreePool (NewLineBuffer
);
1341 Status
= EFI_SUCCESS
;
1345 // Otherwise, the size of the text console and/or the GOP/UGA mode will be changed,
1346 // so erase the cursor, and free the LineBuffer for the current mode
1350 FreePool (Private
->LineBuffer
);
1353 // Assign the current line buffer to the newly allocated line buffer
1355 Private
->LineBuffer
= NewLineBuffer
;
1357 if (GraphicsOutput
!= NULL
) {
1358 if (ModeData
->GopModeNumber
!= GraphicsOutput
->Mode
->Mode
) {
1360 // Either no graphics mode is currently set, or it is set to the wrong resolution, so set the new grapghics mode
1362 Status
= GraphicsOutput
->SetMode (GraphicsOutput
, ModeData
->GopModeNumber
);
1363 if (EFI_ERROR (Status
)) {
1365 // The mode set operation failed
1371 // The current graphics mode is correct, so simply clear the entire display
1373 Status
= GraphicsOutput
->Blt (
1382 ModeData
->GopHeight
,
1388 // Get the current UGA Draw mode information
1390 Status
= UgaDraw
->GetMode (
1392 &HorizontalResolution
,
1393 &VerticalResolution
,
1397 if (EFI_ERROR (Status
) || HorizontalResolution
!= ModeData
->GopWidth
|| VerticalResolution
!= ModeData
->GopHeight
) {
1399 // Either no graphics mode is currently set, or it is set to the wrong resolution, so set the new grapghics mode
1401 Status
= UgaDraw
->SetMode (
1404 ModeData
->GopHeight
,
1408 if (EFI_ERROR (Status
)) {
1410 // The mode set operation failed
1416 // The current graphics mode is correct, so simply clear the entire display
1418 Status
= UgaDraw
->Blt (
1420 (EFI_UGA_PIXEL
*) (UINTN
) &mEfiColors
[0],
1427 ModeData
->GopHeight
,
1434 // The new mode is valid, so commit the mode change
1436 This
->Mode
->Mode
= (INT32
) ModeNumber
;
1439 // Move the text cursor to the upper left hand corner of the displat and enable it
1441 This
->SetCursorPosition (This
, 0, 0);
1443 Status
= EFI_SUCCESS
;
1446 gBS
->RestoreTPL (OldTpl
);
1452 GraphicsConsoleConOutSetAttribute (
1453 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1457 Routine Description:
1459 Implements SIMPLE_TEXT_OUTPUT.SetAttribute().
1463 This - Indicates the calling context.
1465 Attrubute - The attribute to set. Only bit0..6 are valid, all other bits
1466 are undefined and must be zero.
1471 The requested attribute is set.
1474 The requested attribute cannot be set due to Graphics Console port error.
1477 The attribute requested is not defined by EFI spec.
1483 if ((Attribute
| 0xFF) != 0xFF) {
1484 return EFI_UNSUPPORTED
;
1487 if ((INT32
) Attribute
== This
->Mode
->Attribute
) {
1491 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1495 This
->Mode
->Attribute
= (INT32
) Attribute
;
1499 gBS
->RestoreTPL (OldTpl
);
1506 GraphicsConsoleConOutClearScreen (
1507 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
1510 Routine Description:
1512 Implements SIMPLE_TEXT_OUTPUT.ClearScreen().
1513 It clears the Graphics Console's display to the
1514 currently selected background color.
1519 This - Indicates the calling context.
1524 The operation completed successfully.
1527 The Graphics Console cannot be cleared due to Graphics Console device error.
1530 The Graphics Console is not in a valid text mode.
1535 GRAPHICS_CONSOLE_DEV
*Private
;
1536 GRAPHICS_CONSOLE_MODE_DATA
*ModeData
;
1537 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1538 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1539 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
1540 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
1543 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1545 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1546 GraphicsOutput
= Private
->GraphicsOutput
;
1547 UgaDraw
= Private
->UgaDraw
;
1548 ModeData
= &(Private
->ModeData
[This
->Mode
->Mode
]);
1550 GetTextColors (This
, &Foreground
, &Background
);
1551 if (GraphicsOutput
!= NULL
) {
1552 Status
= GraphicsOutput
->Blt (
1561 ModeData
->GopHeight
,
1565 Status
= UgaDraw
->Blt (
1567 (EFI_UGA_PIXEL
*) (UINTN
) &Background
,
1574 ModeData
->GopHeight
,
1579 This
->Mode
->CursorColumn
= 0;
1580 This
->Mode
->CursorRow
= 0;
1584 gBS
->RestoreTPL (OldTpl
);
1591 GraphicsConsoleConOutSetCursorPosition (
1592 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1597 Routine Description:
1599 Implements SIMPLE_TEXT_OUTPUT.SetCursorPosition().
1603 This - Indicates the calling context.
1605 Column - The row to set cursor to.
1607 Row - The column to set cursor to.
1612 The operation completed successfully.
1615 The request fails due to Graphics Console device error.
1618 The Graphics Console is not in a valid text mode, or the cursor position
1619 is invalid for current mode.
1623 GRAPHICS_CONSOLE_DEV
*Private
;
1624 GRAPHICS_CONSOLE_MODE_DATA
*ModeData
;
1628 Status
= EFI_SUCCESS
;
1630 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1632 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1633 ModeData
= &(Private
->ModeData
[This
->Mode
->Mode
]);
1635 if ((Column
>= ModeData
->Columns
) || (Row
>= ModeData
->Rows
)) {
1636 Status
= EFI_UNSUPPORTED
;
1640 if (((INT32
) Column
== This
->Mode
->CursorColumn
) && ((INT32
) Row
== This
->Mode
->CursorRow
)) {
1641 Status
= EFI_SUCCESS
;
1647 This
->Mode
->CursorColumn
= (INT32
) Column
;
1648 This
->Mode
->CursorRow
= (INT32
) Row
;
1653 gBS
->RestoreTPL (OldTpl
);
1660 GraphicsConsoleConOutEnableCursor (
1661 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1665 Routine Description:
1667 Implements SIMPLE_TEXT_OUTPUT.EnableCursor().
1668 In this driver, the cursor cannot be hidden.
1672 This - Indicates the calling context.
1674 Visible - If TRUE, the cursor is set to be visible,
1675 If FALSE, the cursor is set to be invisible.
1680 The request is valid.
1683 The Graphics Console does not support a hidden cursor.
1689 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1693 This
->Mode
->CursorVisible
= Visible
;
1697 gBS
->RestoreTPL (OldTpl
);
1704 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1705 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Foreground
,
1706 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Background
1711 Attribute
= This
->Mode
->Attribute
& 0x7F;
1713 *Foreground
= mEfiColors
[Attribute
& 0x0f];
1714 *Background
= mEfiColors
[Attribute
>> 4];
1719 #if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
1721 DrawUnicodeWeightAtCursorN (
1722 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1723 IN CHAR16
*UnicodeWeight
,
1728 GRAPHICS_CONSOLE_DEV
*Private
;
1729 EFI_IMAGE_OUTPUT
*Blt
;
1731 EFI_FONT_DISPLAY_INFO
*FontInfo
;
1733 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1735 // GOP protocol is required in UEFI mode.
1737 ASSERT (Private
->GraphicsOutput
!= NULL
);
1739 Blt
= (EFI_IMAGE_OUTPUT
*) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT
));
1741 return EFI_OUT_OF_RESOURCES
;
1744 Blt
->Width
= (UINT16
) (Private
->ModeData
[This
->Mode
->Mode
].GopWidth
);
1745 Blt
->Height
= (UINT16
) (Private
->ModeData
[This
->Mode
->Mode
].GopHeight
);
1746 Blt
->Image
.Screen
= Private
->GraphicsOutput
;
1748 String
= AllocateCopyPool ((Count
+ 1) * sizeof (CHAR16
), UnicodeWeight
);
1749 if (String
== NULL
) {
1751 return EFI_OUT_OF_RESOURCES
;
1753 *(String
+ Count
) = 0;
1755 FontInfo
= (EFI_FONT_DISPLAY_INFO
*) AllocateZeroPool (sizeof (EFI_FONT_DISPLAY_INFO
));
1756 if (FontInfo
== NULL
) {
1758 SafeFreePool (String
);
1759 return EFI_OUT_OF_RESOURCES
;
1761 GetTextColors (This
, &FontInfo
->ForegroundColor
, &FontInfo
->BackgroundColor
);
1763 Status
= mHiiFont
->StringToImage (
1765 EFI_HII_IGNORE_IF_NO_GLYPH
| EFI_HII_DIRECT_TO_SCREEN
,
1769 This
->Mode
->CursorColumn
* GLYPH_WIDTH
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaX
,
1770 This
->Mode
->CursorRow
* GLYPH_HEIGHT
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaY
,
1777 SafeFreePool (String
);
1778 SafeFreePool (FontInfo
);
1784 DrawUnicodeWeightAtCursorN (
1785 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1786 IN CHAR16
*UnicodeWeight
,
1790 GRAPHICS_CONSOLE_DEV
*Private
;
1792 EFI_STATUS ReturnStatus
;
1794 GLYPH_UNION GlyphData
;
1797 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1798 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1799 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
1800 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
1807 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1809 ReturnStatus
= EFI_SUCCESS
;
1813 GetTextColors (This
, &Foreground
, &Background
);
1817 while (Index
< Count
) {
1818 if (This
->Mode
->Attribute
& EFI_WIDE_ATTRIBUTE
) {
1819 GlyphStatus
= WIDE_CHAR
;
1821 GlyphStatus
= NARROW_CHAR
;
1824 Status
= mHii
->GetGlyph (
1832 if (EFI_ERROR (Status
)) {
1833 ReturnStatus
= Status
;
1838 CopyMem (&GlyphData
, Glyph
, sizeof (GLYPH_UNION
));
1842 // We are creating the second half of the wide character's BLT buffer
1844 if (GlyphWidth
== 0x10 && Counts
== 1) {
1845 CopyMem (&GlyphData
.NarrowGlyph
.GlyphCol1
, &Glyph
->WideGlyph
.GlyphCol2
, sizeof (Glyph
->WideGlyph
.GlyphCol2
));
1850 if (GlyphWidth
== 0x10) {
1853 (UINT8
*) &GlyphData
,
1859 &Private
->LineBuffer
[ArrayIndex
* GLYPH_WIDTH
]
1864 (UINT8
*) &GlyphData
,
1870 &Private
->LineBuffer
[ArrayIndex
* GLYPH_WIDTH
]
1876 } while (Counts
< 2 && GlyphWidth
== 0x10);
1880 // If we are printing Wide characters, treat the BLT as if it is twice as many characters
1882 if (GlyphWidth
== 0x10) {
1886 // Blt a character to the screen
1888 GlyphX
= This
->Mode
->CursorColumn
* GLYPH_WIDTH
;
1889 GlyphY
= This
->Mode
->CursorRow
* GLYPH_HEIGHT
;
1890 GraphicsOutput
= Private
->GraphicsOutput
;
1891 UgaDraw
= Private
->UgaDraw
;
1892 if (GraphicsOutput
!= NULL
) {
1893 GraphicsOutput
->Blt (
1895 Private
->LineBuffer
,
1896 EfiBltBufferToVideo
,
1899 GlyphX
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaX
,
1900 GlyphY
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaY
,
1901 GLYPH_WIDTH
* Count
,
1903 GLYPH_WIDTH
* Count
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
1908 (EFI_UGA_PIXEL
*) (UINTN
) Private
->LineBuffer
,
1909 EfiUgaBltBufferToVideo
,
1912 GlyphX
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaX
,
1913 GlyphY
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaY
,
1914 GLYPH_WIDTH
* Count
,
1916 GLYPH_WIDTH
* Count
* sizeof (EFI_UGA_PIXEL
)
1920 return ReturnStatus
;
1927 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
1930 GRAPHICS_CONSOLE_DEV
*Private
;
1931 EFI_SIMPLE_TEXT_OUTPUT_MODE
*CurrentMode
;
1934 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1935 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1936 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Foreground
;
1937 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Background
;
1938 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION BltChar
[GLYPH_HEIGHT
][GLYPH_WIDTH
];
1942 CurrentMode
= This
->Mode
;
1944 if (!CurrentMode
->CursorVisible
) {
1948 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1949 GraphicsOutput
= Private
->GraphicsOutput
;
1950 UgaDraw
= Private
->UgaDraw
;
1953 // BUGBUG - we need to think about what to do with wide and narrow character deletions.
1956 // Blt a character to the screen
1958 GlyphX
= (CurrentMode
->CursorColumn
* GLYPH_WIDTH
) + Private
->ModeData
[CurrentMode
->Mode
].DeltaX
;
1959 GlyphY
= (CurrentMode
->CursorRow
* GLYPH_HEIGHT
) + Private
->ModeData
[CurrentMode
->Mode
].DeltaY
;
1960 if (GraphicsOutput
!= NULL
) {
1961 GraphicsOutput
->Blt (
1963 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*) BltChar
,
1964 EfiBltVideoToBltBuffer
,
1971 GLYPH_WIDTH
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
1976 (EFI_UGA_PIXEL
*) (UINTN
) BltChar
,
1977 EfiUgaVideoToBltBuffer
,
1984 GLYPH_WIDTH
* sizeof (EFI_UGA_PIXEL
)
1988 GetTextColors (This
, &Foreground
.Pixel
, &Background
.Pixel
);
1991 // Convert Monochrome bitmap of the Glyph to BltBuffer structure
1993 for (Y
= 0; Y
< GLYPH_HEIGHT
; Y
++) {
1994 for (X
= 0; X
< GLYPH_WIDTH
; X
++) {
1995 if ((mCursorGlyph
.GlyphCol1
[Y
] & (1 << X
)) != 0) {
1996 BltChar
[Y
][GLYPH_WIDTH
- X
- 1].Raw
^= Foreground
.Raw
;
2001 if (GraphicsOutput
!= NULL
) {
2002 GraphicsOutput
->Blt (
2004 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*) BltChar
,
2005 EfiBltBufferToVideo
,
2012 GLYPH_WIDTH
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
2017 (EFI_UGA_PIXEL
*) (UINTN
) BltChar
,
2018 EfiUgaBltBufferToVideo
,
2025 GLYPH_WIDTH
* sizeof (EFI_UGA_PIXEL
)
2033 The user Entry Point for module GraphicsConsole. The user code starts with this function.
2035 @param[in] ImageHandle The firmware allocated handle for the EFI image.
2036 @param[in] SystemTable A pointer to the EFI System Table.
2038 @retval EFI_SUCCESS The entry point is executed successfully.
2039 @retval other Some error occurs when executing this entry point.
2044 InitializeGraphicsConsole (
2045 IN EFI_HANDLE ImageHandle
,
2046 IN EFI_SYSTEM_TABLE
*SystemTable
2052 // Install driver model protocol(s).
2054 Status
= EfiLibInstallDriverBindingComponentName2 (
2057 &gGraphicsConsoleDriverBinding
,
2059 &gGraphicsConsoleComponentName
,
2060 &gGraphicsConsoleComponentName2
2062 ASSERT_EFI_ERROR (Status
);