2 This is the main routine for initializing the Graphics Console support routines.
4 Add all standard Glyphs from UEFI 2.0 Specification
5 Implement optimal automatic Mode creation algorithm
6 Solve palette issues for mixed graphics and text
7 When does this protocol reset the palette?
9 Copyright (c) 2006 - 2007 Intel Corporation. <BR>
10 All rights reserved. This program and the accompanying materials
11 are licensed and made available under the terms and conditions of the BSD License
12 which accompanies this distribution. The full text of the license may be found at
13 http://opensource.org/licenses/bsd-license.php
15 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
16 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 #include "GraphicsConsole.h"
25 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
26 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Foreground
,
27 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Background
32 DrawUnicodeWeightAtCursorN (
33 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
34 IN CHAR16
*UnicodeWeight
,
41 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
46 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
47 IN UINT32 HorizontalResolution
,
48 IN UINT32 VerticalResolution
,
49 OUT UINT32
*CurrentModeNumber
55 GRAPHICS_CONSOLE_DEV mGraphicsConsoleDevTemplate
= {
56 GRAPHICS_CONSOLE_DEV_SIGNATURE
,
57 (EFI_GRAPHICS_OUTPUT_PROTOCOL
*) NULL
,
58 (EFI_UGA_DRAW_PROTOCOL
*) NULL
,
60 GraphicsConsoleConOutReset
,
61 GraphicsConsoleConOutOutputString
,
62 GraphicsConsoleConOutTestString
,
63 GraphicsConsoleConOutQueryMode
,
64 GraphicsConsoleConOutSetMode
,
65 GraphicsConsoleConOutSetAttribute
,
66 GraphicsConsoleConOutClearScreen
,
67 GraphicsConsoleConOutSetCursorPosition
,
68 GraphicsConsoleConOutEnableCursor
,
69 (EFI_SIMPLE_TEXT_OUTPUT_MODE
*) NULL
74 EFI_TEXT_ATTR(EFI_LIGHTGRAY
, EFI_BLACK
),
80 { 80, 25, 0, 0, 0, 0 }, // Mode 0
81 { 80, 50, 0, 0, 0, 0 }, // Mode 1
82 { 100,31, 0, 0, 0, 0 }, // Mode 2
83 { 0, 0, 0, 0, 0, 0 } // Mode 3
85 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*) NULL
,
89 EFI_HII_DATABASE_PROTOCOL
*mHiiDatabase
;
90 EFI_HII_FONT_PROTOCOL
*mHiiFont
;
91 BOOLEAN mFirstAccessFlag
= TRUE
;
93 STATIC EFI_GUID mFontPackageListGuid
= {0xf5f219d3, 0x7006, 0x4648, 0xac, 0x8d, 0xd6, 0x1d, 0xfb, 0x7b, 0xc6, 0xad};
95 static CHAR16 mCrLfString
[3] = { CHAR_CARRIAGE_RETURN
, CHAR_LINEFEED
, CHAR_NULL
};
97 static EFI_GRAPHICS_OUTPUT_BLT_PIXEL mEfiColors
[16] = {
101 {0x00, 0x00, 0x00, 0x00}, // BLACK
102 {0x98, 0x00, 0x00, 0x00}, // BLUE
103 {0x00, 0x98, 0x00, 0x00}, // GREEN
104 {0x98, 0x98, 0x00, 0x00}, // CYAN
105 {0x00, 0x00, 0x98, 0x00}, // RED
106 {0x98, 0x00, 0x98, 0x00}, // MAGENTA
107 {0x00, 0x98, 0x98, 0x00}, // BROWN
108 {0x98, 0x98, 0x98, 0x00}, // LIGHTGRAY
109 {0x30, 0x30, 0x30, 0x00}, // DARKGRAY - BRIGHT BLACK
110 {0xff, 0x00, 0x00, 0x00}, // LIGHTBLUE - ?
111 {0x00, 0xff, 0x00, 0x00}, // LIGHTGREEN - ?
112 {0xff, 0xff, 0x00, 0x00}, // LIGHTCYAN
113 {0x00, 0x00, 0xff, 0x00}, // LIGHTRED
114 {0xff, 0x00, 0xff, 0x00}, // LIGHTMAGENTA
115 {0x00, 0xff, 0xff, 0x00}, // LIGHTBROWN
116 {0xff, 0xff, 0xff, 0x00} // WHITE
119 static EFI_NARROW_GLYPH mCursorGlyph
= {
122 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF }
125 EFI_DRIVER_BINDING_PROTOCOL gGraphicsConsoleDriverBinding
= {
126 GraphicsConsoleControllerDriverSupported
,
127 GraphicsConsoleControllerDriverStart
,
128 GraphicsConsoleControllerDriverStop
,
136 GraphicsConsoleControllerDriverSupported (
137 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
138 IN EFI_HANDLE Controller
,
139 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
143 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
144 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
145 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
149 // Open the IO Abstraction(s) needed to perform the supported test
151 Status
= gBS
->OpenProtocol (
153 &gEfiGraphicsOutputProtocolGuid
,
154 (VOID
**) &GraphicsOutput
,
155 This
->DriverBindingHandle
,
157 EFI_OPEN_PROTOCOL_BY_DRIVER
160 if (EFI_ERROR (Status
)) {
161 GraphicsOutput
= NULL
;
163 // Open Graphics Output Protocol failed, try to open UGA Draw Protocol
165 Status
= gBS
->OpenProtocol (
167 &gEfiUgaDrawProtocolGuid
,
169 This
->DriverBindingHandle
,
171 EFI_OPEN_PROTOCOL_BY_DRIVER
173 if (EFI_ERROR (Status
)) {
179 // We need to ensure that we do not layer on top of a virtual handle.
180 // We need to ensure that the handles produced by the conspliter do not
183 Status
= gBS
->OpenProtocol (
185 &gEfiDevicePathProtocolGuid
,
186 (VOID
**) &DevicePath
,
187 This
->DriverBindingHandle
,
189 EFI_OPEN_PROTOCOL_BY_DRIVER
191 if (!EFI_ERROR (Status
)) {
194 &gEfiDevicePathProtocolGuid
,
195 This
->DriverBindingHandle
,
203 // Does Hii Exist? If not, we aren't ready to run
205 Status
= EfiLocateHiiProtocol ();
208 // Close the I/O Abstraction(s) used to perform the supported test
211 if (GraphicsOutput
!= NULL
) {
214 &gEfiGraphicsOutputProtocolGuid
,
215 This
->DriverBindingHandle
,
221 &gEfiUgaDrawProtocolGuid
,
222 This
->DriverBindingHandle
,
231 GraphicsConsoleControllerDriverStart (
232 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
233 IN EFI_HANDLE Controller
,
234 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
240 Start the controller.
244 This - A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
245 Controller - The handle of the controller to start.
246 RemainingDevicePath - A pointer to the remaining portion of a devcie path.
250 EFI_SUCCESS - Return successfully.
251 EFI_OUT_OF_RESOURCES - Out of resources.
256 GRAPHICS_CONSOLE_DEV
*Private
;
257 UINTN NarrowFontSize
;
258 UINT32 HorizontalResolution
;
259 UINT32 VerticalResolution
;
270 // Initialize the Graphics Console device instance
272 Private
= AllocateCopyPool (
273 sizeof (GRAPHICS_CONSOLE_DEV
),
274 &mGraphicsConsoleDevTemplate
276 if (Private
== NULL
) {
277 return EFI_OUT_OF_RESOURCES
;
280 Private
->SimpleTextOutput
.Mode
= &(Private
->SimpleTextOutputMode
);
282 Status
= gBS
->OpenProtocol (
284 &gEfiGraphicsOutputProtocolGuid
,
285 (VOID
**) &Private
->GraphicsOutput
,
286 This
->DriverBindingHandle
,
288 EFI_OPEN_PROTOCOL_BY_DRIVER
290 if (EFI_ERROR(Status
)) {
291 Private
->GraphicsOutput
= NULL
;
293 Status
= gBS
->OpenProtocol (
295 &gEfiUgaDrawProtocolGuid
,
296 (VOID
**) &Private
->UgaDraw
,
297 This
->DriverBindingHandle
,
299 EFI_OPEN_PROTOCOL_BY_DRIVER
301 if (EFI_ERROR (Status
)) {
306 NarrowFontSize
= ReturnNarrowFontSize ();
309 if (mFirstAccessFlag
) {
310 HiiLibAddFontPackageToHiiDatabase (NarrowFontSize
, (UINT8
*) UsStdNarrowGlyphData
, &mFontPackageListGuid
, &(Private
->HiiHandle
));
311 mFirstAccessFlag
= FALSE
;
314 FontPack
= AllocateZeroPool (sizeof (EFI_HII_FONT_PACK
) + NarrowFontSize
);
317 FontPack
->Header
.Length
= (UINT32
) (sizeof (EFI_HII_FONT_PACK
) + NarrowFontSize
);
318 FontPack
->Header
.Type
= EFI_HII_FONT
;
319 FontPack
->NumberOfNarrowGlyphs
= (UINT16
) (NarrowFontSize
/ sizeof (EFI_NARROW_GLYPH
));
321 Location
= (UINT8
*) (&FontPack
->NumberOfWideGlyphs
+ sizeof (UINT8
));
322 CopyMem (Location
, UsStdNarrowGlyphData
, NarrowFontSize
);
325 // Register our Fonts into the global database
327 Package
= PreparePackages (1, NULL
, FontPack
);
328 mHii
->NewPack (mHii
, Package
, &(Private
->HiiHandle
));
332 // Free the font database
337 // If the current mode information can not be retrieved, then attemp to set the default mode
338 // of 800x600, 32 bit colot, 60 Hz refresh.
340 HorizontalResolution
= 800;
341 VerticalResolution
= 600;
343 if (Private
->GraphicsOutput
!= NULL
) {
345 // The console is build on top of Graphics Output Protocol, find the mode number
346 // for the user-defined mode; if there are multiple video devices,
347 // graphic console driver will set all the video devices to the same mode.
349 Status
= CheckModeSupported (
350 Private
->GraphicsOutput
,
351 CURRENT_HORIZONTAL_RESOLUTION
,
352 CURRENT_VERTICAL_RESOLUTION
,
355 if (!EFI_ERROR(Status
)) {
357 // Update default mode to current mode
359 HorizontalResolution
= CURRENT_HORIZONTAL_RESOLUTION
;
360 VerticalResolution
= CURRENT_VERTICAL_RESOLUTION
;
363 // if not supporting current mode, try 800x600 which is required by UEFI/EFI spec
365 Status
= CheckModeSupported (
366 Private
->GraphicsOutput
,
373 if (EFI_ERROR (Status
) || (ModeNumber
== Private
->GraphicsOutput
->Mode
->MaxMode
)) {
375 // Set default mode failed or device don't support default mode, then get the current mode information
377 HorizontalResolution
= Private
->GraphicsOutput
->Mode
->Info
->HorizontalResolution
;
378 VerticalResolution
= Private
->GraphicsOutput
->Mode
->Info
->VerticalResolution
;
379 ModeNumber
= Private
->GraphicsOutput
->Mode
->Mode
;
383 // At first try to set user-defined resolution
387 Status
= Private
->UgaDraw
->SetMode (
389 CURRENT_HORIZONTAL_RESOLUTION
,
390 CURRENT_VERTICAL_RESOLUTION
,
394 if (!EFI_ERROR (Status
)) {
395 HorizontalResolution
= CURRENT_HORIZONTAL_RESOLUTION
;
396 VerticalResolution
= CURRENT_VERTICAL_RESOLUTION
;
399 // Try to set 800*600 which is required by UEFI/EFI spec
401 Status
= Private
->UgaDraw
->SetMode (
403 HorizontalResolution
,
408 if (EFI_ERROR (Status
)) {
409 Status
= Private
->UgaDraw
->GetMode (
411 &HorizontalResolution
,
416 if (EFI_ERROR (Status
)) {
424 // Compute the maximum number of text Rows and Columns that this current graphics mode can support
426 Columns
= HorizontalResolution
/ GLYPH_WIDTH
;
427 Rows
= VerticalResolution
/ GLYPH_HEIGHT
;
430 // See if the mode is too small to support the required 80x25 text mode
432 if (Columns
< 80 || Rows
< 25) {
436 // Add Mode #0 that must be 80x25
439 Private
->ModeData
[MaxMode
].GopWidth
= HorizontalResolution
;
440 Private
->ModeData
[MaxMode
].GopHeight
= VerticalResolution
;
441 Private
->ModeData
[MaxMode
].GopModeNumber
= ModeNumber
;
442 Private
->ModeData
[MaxMode
].DeltaX
= (HorizontalResolution
- (80 * GLYPH_WIDTH
)) >> 1;
443 Private
->ModeData
[MaxMode
].DeltaY
= (VerticalResolution
- (25 * GLYPH_HEIGHT
)) >> 1;
447 // If it is possible to support Mode #1 - 80x50, than add it as an active mode
450 Private
->ModeData
[MaxMode
].GopWidth
= HorizontalResolution
;
451 Private
->ModeData
[MaxMode
].GopHeight
= VerticalResolution
;
452 Private
->ModeData
[MaxMode
].GopModeNumber
= ModeNumber
;
453 Private
->ModeData
[MaxMode
].DeltaX
= (HorizontalResolution
- (80 * GLYPH_WIDTH
)) >> 1;
454 Private
->ModeData
[MaxMode
].DeltaY
= (VerticalResolution
- (50 * GLYPH_HEIGHT
)) >> 1;
459 // If it is not to support Mode #1 - 80x50, then skip it
462 Private
->ModeData
[MaxMode
].Columns
= 0;
463 Private
->ModeData
[MaxMode
].Rows
= 0;
464 Private
->ModeData
[MaxMode
].GopWidth
= HorizontalResolution
;
465 Private
->ModeData
[MaxMode
].GopHeight
= VerticalResolution
;
466 Private
->ModeData
[MaxMode
].GopModeNumber
= ModeNumber
;
467 Private
->ModeData
[MaxMode
].DeltaX
= 0;
468 Private
->ModeData
[MaxMode
].DeltaY
= 0;
473 // Add Mode #2 that must be 100x31 (graphic mode >= 800x600)
475 if (Columns
>= 100 && Rows
>= 31) {
476 Private
->ModeData
[MaxMode
].GopWidth
= HorizontalResolution
;
477 Private
->ModeData
[MaxMode
].GopHeight
= VerticalResolution
;
478 Private
->ModeData
[MaxMode
].GopModeNumber
= ModeNumber
;
479 Private
->ModeData
[MaxMode
].DeltaX
= (HorizontalResolution
- (100 * GLYPH_WIDTH
)) >> 1;
480 Private
->ModeData
[MaxMode
].DeltaY
= (VerticalResolution
- (31 * GLYPH_HEIGHT
)) >> 1;
485 // Add Mode #3 that uses the entire display for user-defined mode
487 if (HorizontalResolution
> 800 && VerticalResolution
> 600) {
488 Private
->ModeData
[MaxMode
].Columns
= HorizontalResolution
/GLYPH_WIDTH
;
489 Private
->ModeData
[MaxMode
].Rows
= VerticalResolution
/GLYPH_HEIGHT
;
490 Private
->ModeData
[MaxMode
].GopWidth
= HorizontalResolution
;
491 Private
->ModeData
[MaxMode
].GopHeight
= VerticalResolution
;
492 Private
->ModeData
[MaxMode
].GopModeNumber
= ModeNumber
;
493 Private
->ModeData
[MaxMode
].DeltaX
= (HorizontalResolution
% GLYPH_WIDTH
) >> 1;
494 Private
->ModeData
[MaxMode
].DeltaY
= (VerticalResolution
% GLYPH_HEIGHT
) >> 1;
499 // Update the maximum number of modes
501 Private
->SimpleTextOutputMode
.MaxMode
= (INT32
) MaxMode
;
504 // Determine the number of text modes that this protocol can support
506 Status
= GraphicsConsoleConOutSetMode (&Private
->SimpleTextOutput
, 0);
507 if (EFI_ERROR (Status
)) {
512 GraphicsConsoleConOutOutputString (&Private
->SimpleTextOutput
, (CHAR16
*)L
"Graphics Console Started\n\r");
516 // Install protocol interfaces for the Graphics Console device.
518 Status
= gBS
->InstallMultipleProtocolInterfaces (
520 &gEfiSimpleTextOutProtocolGuid
,
521 &Private
->SimpleTextOutput
,
526 if (EFI_ERROR (Status
)) {
528 // Close the GOP or UGA IO Protocol
530 if (Private
->GraphicsOutput
!= NULL
) {
533 &gEfiGraphicsOutputProtocolGuid
,
534 This
->DriverBindingHandle
,
540 &gEfiUgaDrawProtocolGuid
,
541 This
->DriverBindingHandle
,
549 if (Private
!= NULL
) {
550 if (Private
->LineBuffer
!= NULL
) {
551 FreePool (Private
->LineBuffer
);
562 GraphicsConsoleControllerDriverStop (
563 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
564 IN EFI_HANDLE Controller
,
565 IN UINTN NumberOfChildren
,
566 IN EFI_HANDLE
*ChildHandleBuffer
570 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*SimpleTextOutput
;
571 GRAPHICS_CONSOLE_DEV
*Private
;
573 Status
= gBS
->OpenProtocol (
575 &gEfiSimpleTextOutProtocolGuid
,
576 (VOID
**) &SimpleTextOutput
,
577 This
->DriverBindingHandle
,
579 EFI_OPEN_PROTOCOL_GET_PROTOCOL
581 if (EFI_ERROR (Status
)) {
582 return EFI_NOT_STARTED
;
585 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (SimpleTextOutput
);
587 Status
= gBS
->UninstallProtocolInterface (
589 &gEfiSimpleTextOutProtocolGuid
,
590 &Private
->SimpleTextOutput
593 if (!EFI_ERROR (Status
)) {
595 // Close the GOP or UGA IO Protocol
597 if (Private
->GraphicsOutput
!= NULL
) {
600 &gEfiGraphicsOutputProtocolGuid
,
601 This
->DriverBindingHandle
,
607 &gEfiUgaDrawProtocolGuid
,
608 This
->DriverBindingHandle
,
614 // Remove the font pack
616 if (Private
->HiiHandle
!= NULL
) {
617 HiiLibRemovePackages (Private
->HiiHandle
);
618 mFirstAccessFlag
= TRUE
;
622 // Free our instance data
624 if (Private
!= NULL
) {
625 FreePool (Private
->LineBuffer
);
635 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
636 IN UINT32 HorizontalResolution
,
637 IN UINT32 VerticalResolution
,
638 OUT UINT32
*CurrentModeNumber
644 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
646 Status
= EFI_SUCCESS
;
648 for (ModeNumber
= 0; ModeNumber
< GraphicsOutput
->Mode
->MaxMode
; ModeNumber
++) {
649 Status
= GraphicsOutput
->QueryMode (
655 if (!EFI_ERROR (Status
)) {
656 if ((Info
->HorizontalResolution
== HorizontalResolution
) &&
657 (Info
->VerticalResolution
== VerticalResolution
)) {
658 Status
= GraphicsOutput
->SetMode (GraphicsOutput
, ModeNumber
);
659 if (!EFI_ERROR (Status
)) {
660 gBS
->FreePool (Info
);
664 gBS
->FreePool (Info
);
668 if (ModeNumber
== GraphicsOutput
->Mode
->MaxMode
) {
669 Status
= EFI_UNSUPPORTED
;
672 *CurrentModeNumber
= ModeNumber
;
677 EfiLocateHiiProtocol (
683 Locate HII protocols for future usage.
696 // There should only be one - so buffer size is this
698 Size
= sizeof (EFI_HANDLE
);
700 Status
= gBS
->LocateHandle (
702 &gEfiHiiDatabaseProtocolGuid
,
708 if (EFI_ERROR (Status
)) {
712 Status
= gBS
->HandleProtocol (
714 &gEfiHiiDatabaseProtocolGuid
,
715 (VOID
**) &mHiiDatabase
718 if (EFI_ERROR (Status
)) {
722 Status
= gBS
->HandleProtocol (
724 &gEfiHiiFontProtocolGuid
,
731 // Body of the STO functions
735 GraphicsConsoleConOutReset (
736 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
737 IN BOOLEAN ExtendedVerification
742 Implements SIMPLE_TEXT_OUTPUT.Reset().
743 If ExtendeVerification is TRUE, then perform dependent Graphics Console
744 device reset, and set display mode to mode 0.
745 If ExtendedVerification is FALSE, only set display mode to mode 0.
749 This - Indicates the calling context.
751 ExtendedVerification - Indicates that the driver may perform a more exhaustive
752 verification operation of the device during reset.
757 The reset operation succeeds.
760 The Graphics Console is not functioning correctly
764 This
->SetAttribute (This
, EFI_TEXT_ATTR (This
->Mode
->Attribute
& 0x0F, EFI_BACKGROUND_BLACK
));
765 return This
->SetMode (This
, 0);
770 GraphicsConsoleConOutOutputString (
771 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
777 Implements SIMPLE_TEXT_OUTPUT.OutputString().
778 The Unicode string will be converted to Glyphs and will be
779 sent to the Graphics Console.
784 This - Indicates the calling context.
786 WString - The Null-terminated Unicode string to be displayed on
787 the Graphics Console.
792 The string is output successfully.
795 The Graphics Console failed to send the string out.
797 EFI_WARN_UNKNOWN_GLYPH
798 Indicates that some of the characters in the Unicode string could not
799 be rendered and are skipped.
803 GRAPHICS_CONSOLE_DEV
*Private
;
804 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
805 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
814 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
815 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
820 INT32 OriginAttribute
;
822 CHAR16 SpaceStr
[] = { NARROW_CHAR
, ' ', 0 };
824 Status
= EFI_SUCCESS
;
826 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
830 Mode
= This
->Mode
->Mode
;
831 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
832 GraphicsOutput
= Private
->GraphicsOutput
;
833 UgaDraw
= Private
->UgaDraw
;
835 MaxColumn
= Private
->ModeData
[Mode
].Columns
;
836 MaxRow
= Private
->ModeData
[Mode
].Rows
;
837 DeltaX
= Private
->ModeData
[Mode
].DeltaX
;
838 DeltaY
= Private
->ModeData
[Mode
].DeltaY
;
839 Width
= MaxColumn
* GLYPH_WIDTH
;
840 Height
= (MaxRow
- 1) * GLYPH_HEIGHT
;
841 Delta
= Width
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
);
844 // The Attributes won't change when during the time OutputString is called
846 GetTextColors (This
, &Foreground
, &Background
);
855 OriginAttribute
= This
->Mode
->Attribute
;
859 if (*WString
== CHAR_BACKSPACE
) {
861 // If the cursor is at the left edge of the display, then move the cursor
864 if (This
->Mode
->CursorColumn
== 0 && This
->Mode
->CursorRow
> 0) {
865 This
->Mode
->CursorRow
--;
866 This
->Mode
->CursorColumn
= (INT32
) (MaxColumn
- 1);
867 This
->OutputString (This
, SpaceStr
);
869 This
->Mode
->CursorRow
--;
870 This
->Mode
->CursorColumn
= (INT32
) (MaxColumn
- 1);
871 } else if (This
->Mode
->CursorColumn
> 0) {
873 // If the cursor is not at the left edge of the display, then move the cursor
876 This
->Mode
->CursorColumn
--;
877 This
->OutputString (This
, SpaceStr
);
879 This
->Mode
->CursorColumn
--;
884 } else if (*WString
== CHAR_LINEFEED
) {
886 // If the cursor is at the bottom of the display, then scroll the display one
887 // row, and do not update the cursor position. Otherwise, move the cursor
890 if (This
->Mode
->CursorRow
== (INT32
) (MaxRow
- 1)) {
891 if (GraphicsOutput
!= NULL
) {
893 // Scroll Screen Up One Row
895 GraphicsOutput
->Blt (
900 DeltaY
+ GLYPH_HEIGHT
,
909 // Print Blank Line at last line
911 GraphicsOutput
->Blt (
925 // Scroll Screen Up One Row
932 DeltaY
+ GLYPH_HEIGHT
,
941 // Print Blank Line at last line
945 (EFI_UGA_PIXEL
*) (UINTN
) &Background
,
957 This
->Mode
->CursorRow
++;
962 } else if (*WString
== CHAR_CARRIAGE_RETURN
) {
964 // Move the cursor to the beginning of the current row.
966 This
->Mode
->CursorColumn
= 0;
969 } else if (*WString
== WIDE_CHAR
) {
971 This
->Mode
->Attribute
|= EFI_WIDE_ATTRIBUTE
;
974 } else if (*WString
== NARROW_CHAR
) {
976 This
->Mode
->Attribute
&= (~ (UINT32
) EFI_WIDE_ATTRIBUTE
);
981 // Print the character at the current cursor position and move the cursor
982 // right one column. If this moves the cursor past the right edge of the
983 // display, then the line should wrap to the beginning of the next line. This
984 // is equivalent to inserting a CR and an LF. Note that if the cursor is at the
985 // bottom of the display, and the line wraps, then the display will be scrolled
987 // If wide char is going to be displayed, need to display one character at a time
988 // Or, need to know the display length of a certain string.
990 // Index is used to determine how many character width units (wide = 2, narrow = 1)
991 // Count is used to determine how many characters are used regardless of their attributes
993 for (Count
= 0, Index
= 0; (This
->Mode
->CursorColumn
+ Index
) < MaxColumn
; Count
++, Index
++) {
994 if (WString
[Count
] == CHAR_NULL
) {
998 if (WString
[Count
] == CHAR_BACKSPACE
) {
1002 if (WString
[Count
] == CHAR_LINEFEED
) {
1006 if (WString
[Count
] == CHAR_CARRIAGE_RETURN
) {
1010 if (WString
[Count
] == WIDE_CHAR
) {
1014 if (WString
[Count
] == NARROW_CHAR
) {
1018 // Is the wide attribute on?
1020 if (This
->Mode
->Attribute
& EFI_WIDE_ATTRIBUTE
) {
1022 // If wide, add one more width unit than normal since we are going to increment at the end of the for loop
1026 // This is the end-case where if we are at column 79 and about to print a wide character
1027 // We should prevent this from happening because we will wrap inappropriately. We should
1028 // not print this character until the next line.
1030 if ((This
->Mode
->CursorColumn
+ Index
+ 1) > MaxColumn
) {
1037 Status
= DrawUnicodeWeightAtCursorN (This
, WString
, Count
);
1038 if (EFI_ERROR (Status
)) {
1042 // At the end of line, output carriage return and line feed
1045 This
->Mode
->CursorColumn
+= (INT32
) Index
;
1046 if (This
->Mode
->CursorColumn
> (INT32
) MaxColumn
) {
1047 This
->Mode
->CursorColumn
-= 2;
1048 This
->OutputString (This
, SpaceStr
);
1051 if (This
->Mode
->CursorColumn
>= (INT32
) MaxColumn
) {
1053 This
->OutputString (This
, mCrLfString
);
1059 This
->Mode
->Attribute
= OriginAttribute
;
1064 Status
= EFI_WARN_UNKNOWN_GLYPH
;
1067 gBS
->RestoreTPL (OldTpl
);
1074 GraphicsConsoleConOutTestString (
1075 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1079 Routine Description:
1081 Implements SIMPLE_TEXT_OUTPUT.TestString().
1082 If one of the characters in the *Wstring is
1083 neither valid valid Unicode drawing characters,
1084 not ASCII code, then this function will return
1090 This - Indicates the calling context.
1092 WString - The Null-terminated Unicode string to be tested.
1097 The Graphics Console is capable of rendering the output string.
1100 Some of the characters in the Unicode string cannot be rendered.
1107 EFI_IMAGE_OUTPUT
*Blt
= NULL
;
1111 while (WString
[Count
] != 0) {
1112 Status
= mHiiFont
->GetGlyph (
1123 if (EFI_ERROR (Status
)) {
1124 return EFI_UNSUPPORTED
;
1133 GraphicsConsoleConOutQueryMode (
1134 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1135 IN UINTN ModeNumber
,
1140 Routine Description:
1142 Implements SIMPLE_TEXT_OUTPUT.QueryMode().
1143 It returnes information for an available text mode
1144 that the Graphics Console supports.
1145 In this driver,we only support text mode 80x25, which is
1151 This - Indicates the calling context.
1153 ModeNumber - The mode number to return information on.
1155 Columns - The returned columns of the requested mode.
1157 Rows - The returned rows of the requested mode.
1162 The requested mode information is returned.
1165 The mode number is not valid.
1169 GRAPHICS_CONSOLE_DEV
*Private
;
1173 if (ModeNumber
>= (UINTN
) This
->Mode
->MaxMode
) {
1174 return EFI_UNSUPPORTED
;
1177 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1178 Status
= EFI_SUCCESS
;
1180 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1182 *Columns
= Private
->ModeData
[ModeNumber
].Columns
;
1183 *Rows
= Private
->ModeData
[ModeNumber
].Rows
;
1185 if (*Columns
<= 0 && *Rows
<= 0) {
1186 Status
= EFI_UNSUPPORTED
;
1192 gBS
->RestoreTPL (OldTpl
);
1198 GraphicsConsoleConOutSetMode (
1199 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1203 Routine Description:
1205 Implements SIMPLE_TEXT_OUTPUT.SetMode().
1206 Set the Graphics Console to a specified mode.
1207 In this driver, we only support mode 0.
1211 This - Indicates the calling context.
1213 ModeNumber - The text mode to set.
1218 The requested text mode is set.
1221 The requested text mode cannot be set because of Graphics Console device error.
1224 The text mode number is not valid.
1229 GRAPHICS_CONSOLE_DEV
*Private
;
1230 GRAPHICS_CONSOLE_MODE_DATA
*ModeData
;
1231 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*NewLineBuffer
;
1232 UINT32 HorizontalResolution
;
1233 UINT32 VerticalResolution
;
1234 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1235 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1240 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1242 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1243 GraphicsOutput
= Private
->GraphicsOutput
;
1244 UgaDraw
= Private
->UgaDraw
;
1245 ModeData
= &(Private
->ModeData
[ModeNumber
]);
1247 if (ModeData
->Columns
<= 0 && ModeData
->Rows
<= 0) {
1248 Status
= EFI_UNSUPPORTED
;
1253 // Make sure the requested mode number is supported
1255 if (ModeNumber
>= (UINTN
) This
->Mode
->MaxMode
) {
1256 Status
= EFI_UNSUPPORTED
;
1260 if (ModeData
->Columns
<= 0 && ModeData
->Rows
<= 0) {
1261 Status
= EFI_UNSUPPORTED
;
1265 // Attempt to allocate a line buffer for the requested mode number
1267 NewLineBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
) * ModeData
->Columns
* GLYPH_WIDTH
* GLYPH_HEIGHT
);
1269 if (NewLineBuffer
== NULL
) {
1271 // The new line buffer could not be allocated, so return an error.
1272 // No changes to the state of the current console have been made, so the current console is still valid
1274 Status
= EFI_OUT_OF_RESOURCES
;
1278 // If the mode has been set at least one other time, then LineBuffer will not be NULL
1280 if (Private
->LineBuffer
!= NULL
) {
1282 // Clear the current text window on the current graphics console
1284 This
->ClearScreen (This
);
1287 // If the new mode is the same as the old mode, then just return EFI_SUCCESS
1289 if ((INT32
) ModeNumber
== This
->Mode
->Mode
) {
1290 FreePool (NewLineBuffer
);
1291 Status
= EFI_SUCCESS
;
1295 // Otherwise, the size of the text console and/or the GOP/UGA mode will be changed,
1296 // so erase the cursor, and free the LineBuffer for the current mode
1300 FreePool (Private
->LineBuffer
);
1303 // Assign the current line buffer to the newly allocated line buffer
1305 Private
->LineBuffer
= NewLineBuffer
;
1307 if (GraphicsOutput
!= NULL
) {
1308 if (ModeData
->GopModeNumber
!= GraphicsOutput
->Mode
->Mode
) {
1310 // Either no graphics mode is currently set, or it is set to the wrong resolution, so set the new grapghics mode
1312 Status
= GraphicsOutput
->SetMode (GraphicsOutput
, ModeData
->GopModeNumber
);
1313 if (EFI_ERROR (Status
)) {
1315 // The mode set operation failed
1321 // The current graphics mode is correct, so simply clear the entire display
1323 Status
= GraphicsOutput
->Blt (
1332 ModeData
->GopHeight
,
1338 // Get the current UGA Draw mode information
1340 Status
= UgaDraw
->GetMode (
1342 &HorizontalResolution
,
1343 &VerticalResolution
,
1347 if (EFI_ERROR (Status
) || HorizontalResolution
!= ModeData
->GopWidth
|| VerticalResolution
!= ModeData
->GopHeight
) {
1349 // Either no graphics mode is currently set, or it is set to the wrong resolution, so set the new grapghics mode
1351 Status
= UgaDraw
->SetMode (
1354 ModeData
->GopHeight
,
1358 if (EFI_ERROR (Status
)) {
1360 // The mode set operation failed
1366 // The current graphics mode is correct, so simply clear the entire display
1368 Status
= UgaDraw
->Blt (
1370 (EFI_UGA_PIXEL
*) (UINTN
) &mEfiColors
[0],
1377 ModeData
->GopHeight
,
1384 // The new mode is valid, so commit the mode change
1386 This
->Mode
->Mode
= (INT32
) ModeNumber
;
1389 // Move the text cursor to the upper left hand corner of the displat and enable it
1391 This
->SetCursorPosition (This
, 0, 0);
1393 Status
= EFI_SUCCESS
;
1396 gBS
->RestoreTPL (OldTpl
);
1402 GraphicsConsoleConOutSetAttribute (
1403 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1407 Routine Description:
1409 Implements SIMPLE_TEXT_OUTPUT.SetAttribute().
1413 This - Indicates the calling context.
1415 Attrubute - The attribute to set. Only bit0..6 are valid, all other bits
1416 are undefined and must be zero.
1421 The requested attribute is set.
1424 The requested attribute cannot be set due to Graphics Console port error.
1427 The attribute requested is not defined by EFI spec.
1433 if ((Attribute
| 0xFF) != 0xFF) {
1434 return EFI_UNSUPPORTED
;
1437 if ((INT32
) Attribute
== This
->Mode
->Attribute
) {
1441 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1445 This
->Mode
->Attribute
= (INT32
) Attribute
;
1449 gBS
->RestoreTPL (OldTpl
);
1456 GraphicsConsoleConOutClearScreen (
1457 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
1460 Routine Description:
1462 Implements SIMPLE_TEXT_OUTPUT.ClearScreen().
1463 It clears the Graphics Console's display to the
1464 currently selected background color.
1469 This - Indicates the calling context.
1474 The operation completed successfully.
1477 The Graphics Console cannot be cleared due to Graphics Console device error.
1480 The Graphics Console is not in a valid text mode.
1485 GRAPHICS_CONSOLE_DEV
*Private
;
1486 GRAPHICS_CONSOLE_MODE_DATA
*ModeData
;
1487 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1488 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1489 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
1490 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
1493 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1495 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1496 GraphicsOutput
= Private
->GraphicsOutput
;
1497 UgaDraw
= Private
->UgaDraw
;
1498 ModeData
= &(Private
->ModeData
[This
->Mode
->Mode
]);
1500 GetTextColors (This
, &Foreground
, &Background
);
1501 if (GraphicsOutput
!= NULL
) {
1502 Status
= GraphicsOutput
->Blt (
1511 ModeData
->GopHeight
,
1515 Status
= UgaDraw
->Blt (
1517 (EFI_UGA_PIXEL
*) (UINTN
) &Background
,
1524 ModeData
->GopHeight
,
1529 This
->Mode
->CursorColumn
= 0;
1530 This
->Mode
->CursorRow
= 0;
1534 gBS
->RestoreTPL (OldTpl
);
1541 GraphicsConsoleConOutSetCursorPosition (
1542 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1547 Routine Description:
1549 Implements SIMPLE_TEXT_OUTPUT.SetCursorPosition().
1553 This - Indicates the calling context.
1555 Column - The row to set cursor to.
1557 Row - The column to set cursor to.
1562 The operation completed successfully.
1565 The request fails due to Graphics Console device error.
1568 The Graphics Console is not in a valid text mode, or the cursor position
1569 is invalid for current mode.
1573 GRAPHICS_CONSOLE_DEV
*Private
;
1574 GRAPHICS_CONSOLE_MODE_DATA
*ModeData
;
1578 Status
= EFI_SUCCESS
;
1580 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1582 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1583 ModeData
= &(Private
->ModeData
[This
->Mode
->Mode
]);
1585 if ((Column
>= ModeData
->Columns
) || (Row
>= ModeData
->Rows
)) {
1586 Status
= EFI_UNSUPPORTED
;
1590 if (((INT32
) Column
== This
->Mode
->CursorColumn
) && ((INT32
) Row
== This
->Mode
->CursorRow
)) {
1591 Status
= EFI_SUCCESS
;
1597 This
->Mode
->CursorColumn
= (INT32
) Column
;
1598 This
->Mode
->CursorRow
= (INT32
) Row
;
1603 gBS
->RestoreTPL (OldTpl
);
1610 GraphicsConsoleConOutEnableCursor (
1611 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1615 Routine Description:
1617 Implements SIMPLE_TEXT_OUTPUT.EnableCursor().
1618 In this driver, the cursor cannot be hidden.
1622 This - Indicates the calling context.
1624 Visible - If TRUE, the cursor is set to be visible,
1625 If FALSE, the cursor is set to be invisible.
1630 The request is valid.
1633 The Graphics Console does not support a hidden cursor.
1639 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1643 This
->Mode
->CursorVisible
= Visible
;
1647 gBS
->RestoreTPL (OldTpl
);
1654 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1655 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Foreground
,
1656 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Background
1661 Attribute
= This
->Mode
->Attribute
& 0x7F;
1663 *Foreground
= mEfiColors
[Attribute
& 0x0f];
1664 *Background
= mEfiColors
[Attribute
>> 4];
1670 DrawUnicodeWeightAtCursorN (
1671 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1672 IN CHAR16
*UnicodeWeight
,
1677 GRAPHICS_CONSOLE_DEV
*Private
;
1678 EFI_IMAGE_OUTPUT
*Blt
;
1680 EFI_FONT_DISPLAY_INFO
*FontInfo
;
1681 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1682 EFI_HII_ROW_INFO
*RowInfoArray
;
1683 UINTN RowInfoArraySize
;
1685 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1686 Blt
= (EFI_IMAGE_OUTPUT
*) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT
));
1688 return EFI_OUT_OF_RESOURCES
;
1691 Blt
->Width
= (UINT16
) (Private
->ModeData
[This
->Mode
->Mode
].GopWidth
);
1692 Blt
->Height
= (UINT16
) (Private
->ModeData
[This
->Mode
->Mode
].GopHeight
);
1694 String
= AllocateCopyPool ((Count
+ 1) * sizeof (CHAR16
), UnicodeWeight
);
1695 if (String
== NULL
) {
1697 return EFI_OUT_OF_RESOURCES
;
1699 *(String
+ Count
) = 0;
1701 FontInfo
= (EFI_FONT_DISPLAY_INFO
*) AllocateZeroPool (sizeof (EFI_FONT_DISPLAY_INFO
));
1702 if (FontInfo
== NULL
) {
1704 SafeFreePool (String
);
1705 return EFI_OUT_OF_RESOURCES
;
1707 GetTextColors (This
, &FontInfo
->ForegroundColor
, &FontInfo
->BackgroundColor
);
1709 if (Private
->GraphicsOutput
!= NULL
) {
1710 Blt
->Image
.Screen
= Private
->GraphicsOutput
;
1712 Status
= mHiiFont
->StringToImage (
1714 EFI_HII_IGNORE_IF_NO_GLYPH
| EFI_HII_DIRECT_TO_SCREEN
,
1718 This
->Mode
->CursorColumn
* GLYPH_WIDTH
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaX
,
1719 This
->Mode
->CursorRow
* GLYPH_HEIGHT
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaY
,
1726 ASSERT (Private
->UgaDraw
!= NULL
);
1728 UgaDraw
= Private
->UgaDraw
;
1730 Blt
->Image
.Bitmap
= AllocateZeroPool (Blt
->Width
* Blt
->Height
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
));
1731 if (Blt
->Image
.Bitmap
== NULL
) {
1733 SafeFreePool (String
);
1734 return EFI_OUT_OF_RESOURCES
;
1737 RowInfoArray
= NULL
;
1739 // StringToImage only support blt'ing image to device using GOP protocol. If GOP is not supported in this platform,
1740 // we ask StringToImage to print the string to blt buffer, then blt to device using UgaDraw.
1742 Status
= mHiiFont
->StringToImage (
1744 EFI_HII_IGNORE_IF_NO_GLYPH
,
1748 This
->Mode
->CursorColumn
* GLYPH_WIDTH
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaX
,
1749 This
->Mode
->CursorRow
* GLYPH_HEIGHT
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaY
,
1755 if (!EFI_ERROR (Status
)) {
1757 // Line breaks are handled by caller of DrawUnicodeWeightAtCursorN, so the updated parameter RowInfoArraySize by StringToImage will
1758 // always be 1. ASSERT here to make sure.
1760 ASSERT (RowInfoArraySize
== 1);
1762 Status
= UgaDraw
->Blt (
1764 (EFI_UGA_PIXEL
*) Blt
->Image
.Bitmap
,
1765 EfiUgaBltBufferToVideo
,
1766 This
->Mode
->CursorColumn
* GLYPH_WIDTH
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaX
,
1767 (This
->Mode
->CursorRow
) * GLYPH_HEIGHT
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaY
,
1768 This
->Mode
->CursorColumn
* GLYPH_WIDTH
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaX
,
1769 (This
->Mode
->CursorRow
) * GLYPH_HEIGHT
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaY
,
1770 RowInfoArray
[0].LineWidth
,
1771 RowInfoArray
[0].LineHeight
,
1772 Blt
->Width
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
1776 SafeFreePool (RowInfoArray
);
1777 SafeFreePool (Blt
->Image
.Bitmap
);
1781 SafeFreePool (String
);
1782 SafeFreePool (FontInfo
);
1790 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
1793 GRAPHICS_CONSOLE_DEV
*Private
;
1794 EFI_SIMPLE_TEXT_OUTPUT_MODE
*CurrentMode
;
1797 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1798 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1799 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Foreground
;
1800 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Background
;
1801 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION BltChar
[GLYPH_HEIGHT
][GLYPH_WIDTH
];
1805 CurrentMode
= This
->Mode
;
1807 if (!CurrentMode
->CursorVisible
) {
1811 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1812 GraphicsOutput
= Private
->GraphicsOutput
;
1813 UgaDraw
= Private
->UgaDraw
;
1816 // BUGBUG - we need to think about what to do with wide and narrow character deletions.
1819 // Blt a character to the screen
1821 GlyphX
= (CurrentMode
->CursorColumn
* GLYPH_WIDTH
) + Private
->ModeData
[CurrentMode
->Mode
].DeltaX
;
1822 GlyphY
= (CurrentMode
->CursorRow
* GLYPH_HEIGHT
) + Private
->ModeData
[CurrentMode
->Mode
].DeltaY
;
1823 if (GraphicsOutput
!= NULL
) {
1824 GraphicsOutput
->Blt (
1826 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*) BltChar
,
1827 EfiBltVideoToBltBuffer
,
1834 GLYPH_WIDTH
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
1839 (EFI_UGA_PIXEL
*) (UINTN
) BltChar
,
1840 EfiUgaVideoToBltBuffer
,
1847 GLYPH_WIDTH
* sizeof (EFI_UGA_PIXEL
)
1851 GetTextColors (This
, &Foreground
.Pixel
, &Background
.Pixel
);
1854 // Convert Monochrome bitmap of the Glyph to BltBuffer structure
1856 for (Y
= 0; Y
< GLYPH_HEIGHT
; Y
++) {
1857 for (X
= 0; X
< GLYPH_WIDTH
; X
++) {
1858 if ((mCursorGlyph
.GlyphCol1
[Y
] & (1 << X
)) != 0) {
1859 BltChar
[Y
][GLYPH_WIDTH
- X
- 1].Raw
^= Foreground
.Raw
;
1864 if (GraphicsOutput
!= NULL
) {
1865 GraphicsOutput
->Blt (
1867 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*) BltChar
,
1868 EfiBltBufferToVideo
,
1875 GLYPH_WIDTH
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
1880 (EFI_UGA_PIXEL
*) (UINTN
) BltChar
,
1881 EfiUgaBltBufferToVideo
,
1888 GLYPH_WIDTH
* sizeof (EFI_UGA_PIXEL
)
1896 The user Entry Point for module GraphicsConsole. The user code starts with this function.
1898 @param[in] ImageHandle The firmware allocated handle for the EFI image.
1899 @param[in] SystemTable A pointer to the EFI System Table.
1901 @retval EFI_SUCCESS The entry point is executed successfully.
1902 @retval other Some error occurs when executing this entry point.
1907 InitializeGraphicsConsole (
1908 IN EFI_HANDLE ImageHandle
,
1909 IN EFI_SYSTEM_TABLE
*SystemTable
1915 // Install driver model protocol(s).
1917 Status
= EfiLibInstallDriverBindingComponentName2 (
1920 &gGraphicsConsoleDriverBinding
,
1922 &gGraphicsConsoleComponentName
,
1923 &gGraphicsConsoleComponentName2
1925 ASSERT_EFI_ERROR (Status
);