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 - 2008 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"
24 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
25 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Foreground
,
26 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Background
30 DrawUnicodeWeightAtCursorN (
31 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
32 IN CHAR16
*UnicodeWeight
,
38 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
43 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
44 IN UINT32 HorizontalResolution
,
45 IN UINT32 VerticalResolution
,
46 OUT UINT32
*CurrentModeNumber
52 GRAPHICS_CONSOLE_DEV mGraphicsConsoleDevTemplate
= {
53 GRAPHICS_CONSOLE_DEV_SIGNATURE
,
54 (EFI_GRAPHICS_OUTPUT_PROTOCOL
*) NULL
,
55 (EFI_UGA_DRAW_PROTOCOL
*) NULL
,
57 GraphicsConsoleConOutReset
,
58 GraphicsConsoleConOutOutputString
,
59 GraphicsConsoleConOutTestString
,
60 GraphicsConsoleConOutQueryMode
,
61 GraphicsConsoleConOutSetMode
,
62 GraphicsConsoleConOutSetAttribute
,
63 GraphicsConsoleConOutClearScreen
,
64 GraphicsConsoleConOutSetCursorPosition
,
65 GraphicsConsoleConOutEnableCursor
,
66 (EFI_SIMPLE_TEXT_OUTPUT_MODE
*) NULL
71 EFI_TEXT_ATTR(EFI_LIGHTGRAY
, EFI_BLACK
),
77 { 80, 25, 0, 0, 0, 0 }, // Mode 0
78 { 80, 50, 0, 0, 0, 0 }, // Mode 1
79 { 100,31, 0, 0, 0, 0 }, // Mode 2
80 { 0, 0, 0, 0, 0, 0 } // Mode 3
82 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*) NULL
,
86 EFI_HII_DATABASE_PROTOCOL
*mHiiDatabase
;
87 EFI_HII_FONT_PROTOCOL
*mHiiFont
;
88 BOOLEAN mFirstAccessFlag
= TRUE
;
90 STATIC EFI_GUID mFontPackageListGuid
= {0xf5f219d3, 0x7006, 0x4648, 0xac, 0x8d, 0xd6, 0x1d, 0xfb, 0x7b, 0xc6, 0xad};
92 STATIC CHAR16 mCrLfString
[3] = { CHAR_CARRIAGE_RETURN
, CHAR_LINEFEED
, CHAR_NULL
};
94 STATIC EFI_GRAPHICS_OUTPUT_BLT_PIXEL mEfiColors
[16] = {
98 {0x00, 0x00, 0x00, 0x00}, // BLACK
99 {0x98, 0x00, 0x00, 0x00}, // BLUE
100 {0x00, 0x98, 0x00, 0x00}, // GREEN
101 {0x98, 0x98, 0x00, 0x00}, // CYAN
102 {0x00, 0x00, 0x98, 0x00}, // RED
103 {0x98, 0x00, 0x98, 0x00}, // MAGENTA
104 {0x00, 0x98, 0x98, 0x00}, // BROWN
105 {0x98, 0x98, 0x98, 0x00}, // LIGHTGRAY
106 {0x30, 0x30, 0x30, 0x00}, // DARKGRAY - BRIGHT BLACK
107 {0xff, 0x00, 0x00, 0x00}, // LIGHTBLUE - ?
108 {0x00, 0xff, 0x00, 0x00}, // LIGHTGREEN - ?
109 {0xff, 0xff, 0x00, 0x00}, // LIGHTCYAN
110 {0x00, 0x00, 0xff, 0x00}, // LIGHTRED
111 {0xff, 0x00, 0xff, 0x00}, // LIGHTMAGENTA
112 {0x00, 0xff, 0xff, 0x00}, // LIGHTBROWN
113 {0xff, 0xff, 0xff, 0x00} // WHITE
116 STATIC EFI_NARROW_GLYPH mCursorGlyph
= {
119 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF }
122 STATIC CHAR16 SpaceStr
[] = { NARROW_CHAR
, ' ', 0 };
124 EFI_DRIVER_BINDING_PROTOCOL gGraphicsConsoleDriverBinding
= {
125 GraphicsConsoleControllerDriverSupported
,
126 GraphicsConsoleControllerDriverStart
,
127 GraphicsConsoleControllerDriverStop
,
135 GraphicsConsoleControllerDriverSupported (
136 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
137 IN EFI_HANDLE Controller
,
138 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
142 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
143 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
144 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
146 GraphicsOutput
= NULL
;
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
) && FeaturePcdGet (PcdUgaConsumeSupport
)) {
162 // Open Graphics Output Protocol failed, try to open UGA Draw Protocol
164 Status
= gBS
->OpenProtocol (
166 &gEfiUgaDrawProtocolGuid
,
168 This
->DriverBindingHandle
,
170 EFI_OPEN_PROTOCOL_BY_DRIVER
173 if (EFI_ERROR (Status
)) {
178 // We need to ensure that we do not layer on top of a virtual handle.
179 // We need to ensure that the handles produced by the conspliter do not
182 Status
= gBS
->OpenProtocol (
184 &gEfiDevicePathProtocolGuid
,
185 (VOID
**) &DevicePath
,
186 This
->DriverBindingHandle
,
188 EFI_OPEN_PROTOCOL_BY_DRIVER
190 if (!EFI_ERROR (Status
)) {
193 &gEfiDevicePathProtocolGuid
,
194 This
->DriverBindingHandle
,
202 // Does Hii Exist? If not, we aren't ready to run
204 Status
= EfiLocateHiiProtocol ();
207 // Close the I/O Abstraction(s) used to perform the supported test
210 if (GraphicsOutput
!= NULL
) {
213 &gEfiGraphicsOutputProtocolGuid
,
214 This
->DriverBindingHandle
,
217 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
220 &gEfiUgaDrawProtocolGuid
,
221 This
->DriverBindingHandle
,
230 Start the controller.
232 @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL
234 @param Controller The handle of the controller to start.
235 @param RemainingDevicePath A pointer to the remaining portion of a devcie
238 @retval EFI_SUCCESS Return successfully.
239 @retval EFI_OUT_OF_RESOURCES Out of resources.
244 GraphicsConsoleControllerDriverStart (
245 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
246 IN EFI_HANDLE Controller
,
247 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
251 GRAPHICS_CONSOLE_DEV
*Private
;
252 UINTN NarrowFontSize
;
253 UINT32 HorizontalResolution
;
254 UINT32 VerticalResolution
;
261 EFI_HII_SIMPLE_FONT_PACKAGE_HDR
*SimplifiedFont
;
263 EFI_HII_PACKAGE_LIST_HEADER
*PackageList
;
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
291 if (EFI_ERROR(Status
) && FeaturePcdGet (PcdUgaConsumeSupport
)) {
292 Status
= gBS
->OpenProtocol (
294 &gEfiUgaDrawProtocolGuid
,
295 (VOID
**) &Private
->UgaDraw
,
296 This
->DriverBindingHandle
,
298 EFI_OPEN_PROTOCOL_BY_DRIVER
302 if (EFI_ERROR (Status
)) {
306 NarrowFontSize
= ReturnNarrowFontSize ();
308 if (mFirstAccessFlag
) {
310 // Add 4 bytes to the header for entire length for HiiLibPreparePackageList use only.
311 // Looks ugly. Might be updated when font tool is ready.
313 PackageLength
= sizeof (EFI_HII_SIMPLE_FONT_PACKAGE_HDR
) + NarrowFontSize
+ 4;
314 Package
= AllocateZeroPool (PackageLength
);
315 if (Package
== NULL
) {
316 return EFI_OUT_OF_RESOURCES
;
318 CopyMem (Package
, &PackageLength
, 4);
319 SimplifiedFont
= (EFI_HII_SIMPLE_FONT_PACKAGE_HDR
*) (Package
+ 4);
320 SimplifiedFont
->Header
.Length
= (UINT32
) (PackageLength
- 4);
321 SimplifiedFont
->Header
.Type
= EFI_HII_PACKAGE_SIMPLE_FONTS
;
322 SimplifiedFont
->NumberOfNarrowGlyphs
= (UINT16
) (NarrowFontSize
/ sizeof (EFI_NARROW_GLYPH
));
324 Location
= (UINT8
*) (&SimplifiedFont
->NumberOfWideGlyphs
+ 1);
325 CopyMem (Location
, UsStdNarrowGlyphData
, NarrowFontSize
);
328 // Add this simplified font package to a package list then install it.
330 PackageList
= HiiLibPreparePackageList (1, &mFontPackageListGuid
, Package
);
331 Status
= mHiiDatabase
->NewPackageList (mHiiDatabase
, PackageList
, NULL
, &(Private
->HiiHandle
));
332 ASSERT_EFI_ERROR (Status
);
333 SafeFreePool (PackageList
);
334 SafeFreePool (Package
);
336 mFirstAccessFlag
= FALSE
;
339 // If the current mode information can not be retrieved, then attemp to set the default mode
340 // of 800x600, 32 bit colot, 60 Hz refresh.
342 HorizontalResolution
= 800;
343 VerticalResolution
= 600;
345 if (Private
->GraphicsOutput
!= NULL
) {
347 // The console is build on top of Graphics Output Protocol, find the mode number
348 // for the user-defined mode; if there are multiple video devices,
349 // graphic console driver will set all the video devices to the same mode.
351 Status
= CheckModeSupported (
352 Private
->GraphicsOutput
,
353 CURRENT_HORIZONTAL_RESOLUTION
,
354 CURRENT_VERTICAL_RESOLUTION
,
357 if (!EFI_ERROR(Status
)) {
359 // Update default mode to current mode
361 HorizontalResolution
= CURRENT_HORIZONTAL_RESOLUTION
;
362 VerticalResolution
= CURRENT_VERTICAL_RESOLUTION
;
365 // if not supporting current mode, try 800x600 which is required by UEFI/EFI spec
367 Status
= CheckModeSupported (
368 Private
->GraphicsOutput
,
375 if (EFI_ERROR (Status
) || (ModeNumber
== Private
->GraphicsOutput
->Mode
->MaxMode
)) {
377 // Set default mode failed or device don't support default mode, then get the current mode information
379 HorizontalResolution
= Private
->GraphicsOutput
->Mode
->Info
->HorizontalResolution
;
380 VerticalResolution
= Private
->GraphicsOutput
->Mode
->Info
->VerticalResolution
;
381 ModeNumber
= Private
->GraphicsOutput
->Mode
->Mode
;
383 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
385 // At first try to set user-defined resolution
389 Status
= Private
->UgaDraw
->SetMode (
391 CURRENT_HORIZONTAL_RESOLUTION
,
392 CURRENT_VERTICAL_RESOLUTION
,
396 if (!EFI_ERROR (Status
)) {
397 HorizontalResolution
= CURRENT_HORIZONTAL_RESOLUTION
;
398 VerticalResolution
= CURRENT_VERTICAL_RESOLUTION
;
399 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
401 // Try to set 800*600 which is required by UEFI/EFI spec
403 Status
= Private
->UgaDraw
->SetMode (
405 HorizontalResolution
,
410 if (EFI_ERROR (Status
)) {
411 Status
= Private
->UgaDraw
->GetMode (
413 &HorizontalResolution
,
418 if (EFI_ERROR (Status
)) {
423 Status
= EFI_UNSUPPORTED
;
429 // Compute the maximum number of text Rows and Columns that this current graphics mode can support
431 Columns
= HorizontalResolution
/ EFI_GLYPH_WIDTH
;
432 Rows
= VerticalResolution
/ EFI_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 * EFI_GLYPH_WIDTH
)) >> 1;
448 Private
->ModeData
[MaxMode
].DeltaY
= (VerticalResolution
- (25 * EFI_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 * EFI_GLYPH_WIDTH
)) >> 1;
459 Private
->ModeData
[MaxMode
].DeltaY
= (VerticalResolution
- (50 * EFI_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 * EFI_GLYPH_WIDTH
)) >> 1;
485 Private
->ModeData
[MaxMode
].DeltaY
= (VerticalResolution
- (31 * EFI_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
/EFI_GLYPH_WIDTH
;
494 Private
->ModeData
[MaxMode
].Rows
= VerticalResolution
/EFI_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
% EFI_GLYPH_WIDTH
) >> 1;
499 Private
->ModeData
[MaxMode
].DeltaY
= (VerticalResolution
% EFI_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
,
542 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
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
,
609 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
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
;
683 Locate HII protocols for future usage.
689 EfiLocateHiiProtocol (
698 // There should only be one - so buffer size is this
700 Size
= sizeof (EFI_HANDLE
);
702 Status
= gBS
->LocateHandle (
704 &gEfiHiiDatabaseProtocolGuid
,
710 if (EFI_ERROR (Status
)) {
714 Status
= gBS
->HandleProtocol (
716 &gEfiHiiDatabaseProtocolGuid
,
717 (VOID
**) &mHiiDatabase
720 if (EFI_ERROR (Status
)) {
724 Status
= gBS
->HandleProtocol (
726 &gEfiHiiFontProtocolGuid
,
733 // Body of the STO functions
737 Implements SIMPLE_TEXT_OUTPUT.Reset().
738 If ExtendeVerification is TRUE, then perform dependent Graphics Console
739 device reset, and set display mode to mode 0.
740 If ExtendedVerification is FALSE, only set display mode to mode 0.
742 @param This Indicates the calling context.
743 @param ExtendedVerification Indicates that the driver may perform a more
744 exhaustive verification operation of the device
748 @return The reset operation succeeds.
749 @return EFI_DEVICE_ERROR
750 @return The Graphics Console is not functioning correctly
755 GraphicsConsoleConOutReset (
756 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
757 IN BOOLEAN ExtendedVerification
760 This
->SetAttribute (This
, EFI_TEXT_ATTR (This
->Mode
->Attribute
& 0x0F, EFI_BACKGROUND_BLACK
));
761 return This
->SetMode (This
, 0);
766 Implements SIMPLE_TEXT_OUTPUT.OutputString().
767 The Unicode string will be converted to Glyphs and will be
768 sent to the Graphics Console.
770 @param This Indicates the calling context.
771 @param WString The Null-terminated Unicode string to be displayed
772 on the Graphics Console.
775 @return The string is output successfully.
776 @return EFI_DEVICE_ERROR
777 @return The Graphics Console failed to send the string out.
778 @return EFI_WARN_UNKNOWN_GLYPH
779 @return Indicates that some of the characters in the Unicode string could not
780 @return be rendered and are skipped.
785 GraphicsConsoleConOutOutputString (
786 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
790 GRAPHICS_CONSOLE_DEV
*Private
;
791 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
792 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
801 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
802 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
807 INT32 OriginAttribute
;
810 Status
= EFI_SUCCESS
;
812 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
816 Mode
= This
->Mode
->Mode
;
817 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
818 GraphicsOutput
= Private
->GraphicsOutput
;
819 UgaDraw
= Private
->UgaDraw
;
821 MaxColumn
= Private
->ModeData
[Mode
].Columns
;
822 MaxRow
= Private
->ModeData
[Mode
].Rows
;
823 DeltaX
= Private
->ModeData
[Mode
].DeltaX
;
824 DeltaY
= Private
->ModeData
[Mode
].DeltaY
;
825 Width
= MaxColumn
* EFI_GLYPH_WIDTH
;
826 Height
= (MaxRow
- 1) * EFI_GLYPH_HEIGHT
;
827 Delta
= Width
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
);
830 // The Attributes won't change when during the time OutputString is called
832 GetTextColors (This
, &Foreground
, &Background
);
841 OriginAttribute
= This
->Mode
->Attribute
;
843 while (*WString
!= L
'\0') {
845 if (*WString
== CHAR_BACKSPACE
) {
847 // If the cursor is at the left edge of the display, then move the cursor
850 if (This
->Mode
->CursorColumn
== 0 && This
->Mode
->CursorRow
> 0) {
851 This
->Mode
->CursorRow
--;
852 This
->Mode
->CursorColumn
= (INT32
) (MaxColumn
- 1);
853 This
->OutputString (This
, SpaceStr
);
855 This
->Mode
->CursorRow
--;
856 This
->Mode
->CursorColumn
= (INT32
) (MaxColumn
- 1);
857 } else if (This
->Mode
->CursorColumn
> 0) {
859 // If the cursor is not at the left edge of the display, then move the cursor
862 This
->Mode
->CursorColumn
--;
863 This
->OutputString (This
, SpaceStr
);
865 This
->Mode
->CursorColumn
--;
870 } else if (*WString
== CHAR_LINEFEED
) {
872 // If the cursor is at the bottom of the display, then scroll the display one
873 // row, and do not update the cursor position. Otherwise, move the cursor
876 if (This
->Mode
->CursorRow
== (INT32
) (MaxRow
- 1)) {
877 if (GraphicsOutput
!= NULL
) {
879 // Scroll Screen Up One Row
881 GraphicsOutput
->Blt (
886 DeltaY
+ EFI_GLYPH_HEIGHT
,
895 // Print Blank Line at last line
897 GraphicsOutput
->Blt (
909 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
911 // Scroll Screen Up One Row
918 DeltaY
+ EFI_GLYPH_HEIGHT
,
927 // Print Blank Line at last line
931 (EFI_UGA_PIXEL
*) (UINTN
) &Background
,
943 This
->Mode
->CursorRow
++;
948 } else if (*WString
== CHAR_CARRIAGE_RETURN
) {
950 // Move the cursor to the beginning of the current row.
952 This
->Mode
->CursorColumn
= 0;
955 } else if (*WString
== WIDE_CHAR
) {
957 This
->Mode
->Attribute
|= EFI_WIDE_ATTRIBUTE
;
960 } else if (*WString
== NARROW_CHAR
) {
962 This
->Mode
->Attribute
&= (~ (UINT32
) EFI_WIDE_ATTRIBUTE
);
967 // Print the character at the current cursor position and move the cursor
968 // right one column. If this moves the cursor past the right edge of the
969 // display, then the line should wrap to the beginning of the next line. This
970 // is equivalent to inserting a CR and an LF. Note that if the cursor is at the
971 // bottom of the display, and the line wraps, then the display will be scrolled
973 // If wide char is going to be displayed, need to display one character at a time
974 // Or, need to know the display length of a certain string.
976 // Index is used to determine how many character width units (wide = 2, narrow = 1)
977 // Count is used to determine how many characters are used regardless of their attributes
979 for (Count
= 0, Index
= 0; (This
->Mode
->CursorColumn
+ Index
) < MaxColumn
; Count
++, Index
++) {
980 if (WString
[Count
] == CHAR_NULL
) {
984 if (WString
[Count
] == CHAR_BACKSPACE
) {
988 if (WString
[Count
] == CHAR_LINEFEED
) {
992 if (WString
[Count
] == CHAR_CARRIAGE_RETURN
) {
996 if (WString
[Count
] == WIDE_CHAR
) {
1000 if (WString
[Count
] == NARROW_CHAR
) {
1004 // Is the wide attribute on?
1006 if (This
->Mode
->Attribute
& EFI_WIDE_ATTRIBUTE
) {
1008 // If wide, add one more width unit than normal since we are going to increment at the end of the for loop
1012 // This is the end-case where if we are at column 79 and about to print a wide character
1013 // We should prevent this from happening because we will wrap inappropriately. We should
1014 // not print this character until the next line.
1016 if ((This
->Mode
->CursorColumn
+ Index
+ 1) > MaxColumn
) {
1023 Status
= DrawUnicodeWeightAtCursorN (This
, WString
, Count
);
1024 if (EFI_ERROR (Status
)) {
1028 // At the end of line, output carriage return and line feed
1031 This
->Mode
->CursorColumn
+= (INT32
) Index
;
1032 if (This
->Mode
->CursorColumn
> (INT32
) MaxColumn
) {
1033 This
->Mode
->CursorColumn
-= 2;
1034 This
->OutputString (This
, SpaceStr
);
1037 if (This
->Mode
->CursorColumn
>= (INT32
) MaxColumn
) {
1039 This
->OutputString (This
, mCrLfString
);
1045 This
->Mode
->Attribute
= OriginAttribute
;
1050 Status
= EFI_WARN_UNKNOWN_GLYPH
;
1053 gBS
->RestoreTPL (OldTpl
);
1060 Implements SIMPLE_TEXT_OUTPUT.TestString().
1061 If one of the characters in the *Wstring is
1062 neither valid valid Unicode drawing characters,
1063 not ASCII code, then this function will return
1066 @param This Indicates the calling context.
1067 @param WString The Null-terminated Unicode string to be tested.
1070 @return The Graphics Console is capable of rendering the output string.
1071 @return EFI_UNSUPPORTED
1072 @return Some of the characters in the Unicode string cannot be rendered.
1077 GraphicsConsoleConOutTestString (
1078 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1085 EFI_IMAGE_OUTPUT
*Blt
;
1090 while (WString
[Count
] != 0) {
1091 Status
= mHiiFont
->GetGlyph (
1102 if (EFI_ERROR (Status
)) {
1103 return EFI_UNSUPPORTED
;
1112 Implements SIMPLE_TEXT_OUTPUT.QueryMode().
1113 It returnes information for an available text mode
1114 that the Graphics Console supports.
1115 In this driver,we only support text mode 80x25, which is
1118 @param This Indicates the calling context.
1119 @param ModeNumber The mode number to return information on.
1120 @param Columns The returned columns of the requested mode.
1121 @param Rows The returned rows of the requested mode.
1124 @return The requested mode information is returned.
1125 @return EFI_UNSUPPORTED
1126 @return The mode number is not valid.
1131 GraphicsConsoleConOutQueryMode (
1132 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1133 IN UINTN ModeNumber
,
1138 GRAPHICS_CONSOLE_DEV
*Private
;
1142 if (ModeNumber
>= (UINTN
) This
->Mode
->MaxMode
) {
1143 return EFI_UNSUPPORTED
;
1146 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1147 Status
= EFI_SUCCESS
;
1149 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1151 *Columns
= Private
->ModeData
[ModeNumber
].Columns
;
1152 *Rows
= Private
->ModeData
[ModeNumber
].Rows
;
1154 if (*Columns
<= 0 && *Rows
<= 0) {
1155 Status
= EFI_UNSUPPORTED
;
1161 gBS
->RestoreTPL (OldTpl
);
1167 Implements SIMPLE_TEXT_OUTPUT.SetMode().
1168 Set the Graphics Console to a specified mode.
1169 In this driver, we only support mode 0.
1171 @param This Indicates the calling context.
1172 @param ModeNumber The text mode to set.
1175 @return The requested text mode is set.
1176 @return EFI_DEVICE_ERROR
1177 @return The requested text mode cannot be set because of Graphics Console device error.
1178 @return EFI_UNSUPPORTED
1179 @return The text mode number is not valid.
1184 GraphicsConsoleConOutSetMode (
1185 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1190 GRAPHICS_CONSOLE_DEV
*Private
;
1191 GRAPHICS_CONSOLE_MODE_DATA
*ModeData
;
1192 EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*NewLineBuffer
;
1193 UINT32 HorizontalResolution
;
1194 UINT32 VerticalResolution
;
1195 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1196 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1201 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1203 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1204 GraphicsOutput
= Private
->GraphicsOutput
;
1205 UgaDraw
= Private
->UgaDraw
;
1206 ModeData
= &(Private
->ModeData
[ModeNumber
]);
1208 if (ModeData
->Columns
<= 0 && ModeData
->Rows
<= 0) {
1209 Status
= EFI_UNSUPPORTED
;
1214 // Make sure the requested mode number is supported
1216 if (ModeNumber
>= (UINTN
) This
->Mode
->MaxMode
) {
1217 Status
= EFI_UNSUPPORTED
;
1221 if (ModeData
->Columns
<= 0 && ModeData
->Rows
<= 0) {
1222 Status
= EFI_UNSUPPORTED
;
1226 // Attempt to allocate a line buffer for the requested mode number
1228 NewLineBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
) * ModeData
->Columns
* EFI_GLYPH_WIDTH
* EFI_GLYPH_HEIGHT
);
1230 if (NewLineBuffer
== NULL
) {
1232 // The new line buffer could not be allocated, so return an error.
1233 // No changes to the state of the current console have been made, so the current console is still valid
1235 Status
= EFI_OUT_OF_RESOURCES
;
1239 // If the mode has been set at least one other time, then LineBuffer will not be NULL
1241 if (Private
->LineBuffer
!= NULL
) {
1243 // Clear the current text window on the current graphics console
1245 This
->ClearScreen (This
);
1248 // If the new mode is the same as the old mode, then just return EFI_SUCCESS
1250 if ((INT32
) ModeNumber
== This
->Mode
->Mode
) {
1251 FreePool (NewLineBuffer
);
1252 Status
= EFI_SUCCESS
;
1256 // Otherwise, the size of the text console and/or the GOP/UGA mode will be changed,
1257 // so erase the cursor, and free the LineBuffer for the current mode
1261 FreePool (Private
->LineBuffer
);
1264 // Assign the current line buffer to the newly allocated line buffer
1266 Private
->LineBuffer
= NewLineBuffer
;
1268 if (GraphicsOutput
!= NULL
) {
1269 if (ModeData
->GopModeNumber
!= GraphicsOutput
->Mode
->Mode
) {
1271 // Either no graphics mode is currently set, or it is set to the wrong resolution, so set the new grapghics mode
1273 Status
= GraphicsOutput
->SetMode (GraphicsOutput
, ModeData
->GopModeNumber
);
1274 if (EFI_ERROR (Status
)) {
1276 // The mode set operation failed
1282 // The current graphics mode is correct, so simply clear the entire display
1284 Status
= GraphicsOutput
->Blt (
1293 ModeData
->GopHeight
,
1297 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
1299 // Get the current UGA Draw mode information
1301 Status
= UgaDraw
->GetMode (
1303 &HorizontalResolution
,
1304 &VerticalResolution
,
1308 if (EFI_ERROR (Status
) || HorizontalResolution
!= ModeData
->GopWidth
|| VerticalResolution
!= ModeData
->GopHeight
) {
1310 // Either no graphics mode is currently set, or it is set to the wrong resolution, so set the new grapghics mode
1312 Status
= UgaDraw
->SetMode (
1315 ModeData
->GopHeight
,
1319 if (EFI_ERROR (Status
)) {
1321 // The mode set operation failed
1327 // The current graphics mode is correct, so simply clear the entire display
1329 Status
= UgaDraw
->Blt (
1331 (EFI_UGA_PIXEL
*) (UINTN
) &mEfiColors
[0],
1338 ModeData
->GopHeight
,
1345 // The new mode is valid, so commit the mode change
1347 This
->Mode
->Mode
= (INT32
) ModeNumber
;
1350 // Move the text cursor to the upper left hand corner of the displat and enable it
1352 This
->SetCursorPosition (This
, 0, 0);
1354 Status
= EFI_SUCCESS
;
1357 gBS
->RestoreTPL (OldTpl
);
1363 Implements SIMPLE_TEXT_OUTPUT.SetAttribute().
1365 @param This Indicates the calling context.
1366 @param Attribute The attribute to set. Only bit0..6 are valid, all
1367 other bits are undefined and must be zero.
1369 @return EFI_SUCCESS The requested attribute is set.
1370 @return EFI_DEVICE_ERROR The requested attribute cannot be set due to Graphics Console port error.
1371 @return EFI_UNSUPPORTED The attribute requested is not defined by EFI spec.
1376 GraphicsConsoleConOutSetAttribute (
1377 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1383 if ((Attribute
| 0xFF) != 0xFF) {
1384 return EFI_UNSUPPORTED
;
1387 if ((INT32
) Attribute
== This
->Mode
->Attribute
) {
1391 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1395 This
->Mode
->Attribute
= (INT32
) Attribute
;
1399 gBS
->RestoreTPL (OldTpl
);
1406 Implements SIMPLE_TEXT_OUTPUT.ClearScreen().
1407 It clears the Graphics Console's display to the
1408 currently selected background color.
1410 @param This Indicates the calling context.
1413 @return The operation completed successfully.
1414 @return EFI_DEVICE_ERROR
1415 @return The Graphics Console cannot be cleared due to Graphics Console device error.
1416 @return EFI_UNSUPPORTED
1417 @return The Graphics Console is not in a valid text mode.
1422 GraphicsConsoleConOutClearScreen (
1423 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
1427 GRAPHICS_CONSOLE_DEV
*Private
;
1428 GRAPHICS_CONSOLE_MODE_DATA
*ModeData
;
1429 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1430 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1431 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
1432 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
1435 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1437 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1438 GraphicsOutput
= Private
->GraphicsOutput
;
1439 UgaDraw
= Private
->UgaDraw
;
1440 ModeData
= &(Private
->ModeData
[This
->Mode
->Mode
]);
1442 GetTextColors (This
, &Foreground
, &Background
);
1443 if (GraphicsOutput
!= NULL
) {
1444 Status
= GraphicsOutput
->Blt (
1453 ModeData
->GopHeight
,
1456 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
1457 Status
= UgaDraw
->Blt (
1459 (EFI_UGA_PIXEL
*) (UINTN
) &Background
,
1466 ModeData
->GopHeight
,
1470 Status
= EFI_UNSUPPORTED
;
1473 This
->Mode
->CursorColumn
= 0;
1474 This
->Mode
->CursorRow
= 0;
1478 gBS
->RestoreTPL (OldTpl
);
1485 Implements SIMPLE_TEXT_OUTPUT.SetCursorPosition().
1487 @param This Indicates the calling context.
1488 @param Column The row to set cursor to.
1489 @param Row The column to set cursor to.
1492 @return The operation completed successfully.
1493 @return EFI_DEVICE_ERROR
1494 @return The request fails due to Graphics Console device error.
1495 @return EFI_UNSUPPORTED
1496 @return The Graphics Console is not in a valid text mode, or the cursor position
1497 @return is invalid for current mode.
1502 GraphicsConsoleConOutSetCursorPosition (
1503 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1508 GRAPHICS_CONSOLE_DEV
*Private
;
1509 GRAPHICS_CONSOLE_MODE_DATA
*ModeData
;
1513 Status
= EFI_SUCCESS
;
1515 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1517 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1518 ModeData
= &(Private
->ModeData
[This
->Mode
->Mode
]);
1520 if ((Column
>= ModeData
->Columns
) || (Row
>= ModeData
->Rows
)) {
1521 Status
= EFI_UNSUPPORTED
;
1525 if (((INT32
) Column
== This
->Mode
->CursorColumn
) && ((INT32
) Row
== This
->Mode
->CursorRow
)) {
1526 Status
= EFI_SUCCESS
;
1532 This
->Mode
->CursorColumn
= (INT32
) Column
;
1533 This
->Mode
->CursorRow
= (INT32
) Row
;
1538 gBS
->RestoreTPL (OldTpl
);
1545 Implements SIMPLE_TEXT_OUTPUT.EnableCursor().
1546 In this driver, the cursor cannot be hidden.
1548 @param This Indicates the calling context.
1549 @param Visible If TRUE, the cursor is set to be visible, If FALSE,
1550 the cursor is set to be invisible.
1553 @return The request is valid.
1554 @return EFI_UNSUPPORTED
1555 @return The Graphics Console does not support a hidden cursor.
1560 GraphicsConsoleConOutEnableCursor (
1561 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1567 OldTpl
= gBS
->RaiseTPL (TPL_NOTIFY
);
1571 This
->Mode
->CursorVisible
= Visible
;
1575 gBS
->RestoreTPL (OldTpl
);
1581 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1582 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Foreground
,
1583 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Background
1588 Attribute
= This
->Mode
->Attribute
& 0x7F;
1590 *Foreground
= mEfiColors
[Attribute
& 0x0f];
1591 *Background
= mEfiColors
[Attribute
>> 4];
1597 DrawUnicodeWeightAtCursorN (
1598 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1599 IN CHAR16
*UnicodeWeight
,
1604 GRAPHICS_CONSOLE_DEV
*Private
;
1605 EFI_IMAGE_OUTPUT
*Blt
;
1607 EFI_FONT_DISPLAY_INFO
*FontInfo
;
1608 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1609 EFI_HII_ROW_INFO
*RowInfoArray
;
1610 UINTN RowInfoArraySize
;
1612 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1613 Blt
= (EFI_IMAGE_OUTPUT
*) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT
));
1615 return EFI_OUT_OF_RESOURCES
;
1618 Blt
->Width
= (UINT16
) (Private
->ModeData
[This
->Mode
->Mode
].GopWidth
);
1619 Blt
->Height
= (UINT16
) (Private
->ModeData
[This
->Mode
->Mode
].GopHeight
);
1621 String
= AllocateCopyPool ((Count
+ 1) * sizeof (CHAR16
), UnicodeWeight
);
1622 if (String
== NULL
) {
1624 return EFI_OUT_OF_RESOURCES
;
1626 *(String
+ Count
) = 0;
1628 FontInfo
= (EFI_FONT_DISPLAY_INFO
*) AllocateZeroPool (sizeof (EFI_FONT_DISPLAY_INFO
));
1629 if (FontInfo
== NULL
) {
1631 SafeFreePool (String
);
1632 return EFI_OUT_OF_RESOURCES
;
1634 GetTextColors (This
, &FontInfo
->ForegroundColor
, &FontInfo
->BackgroundColor
);
1636 if (Private
->GraphicsOutput
!= NULL
) {
1637 Blt
->Image
.Screen
= Private
->GraphicsOutput
;
1639 Status
= mHiiFont
->StringToImage (
1641 EFI_HII_IGNORE_IF_NO_GLYPH
| EFI_HII_DIRECT_TO_SCREEN
,
1645 This
->Mode
->CursorColumn
* EFI_GLYPH_WIDTH
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaX
,
1646 This
->Mode
->CursorRow
* EFI_GLYPH_HEIGHT
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaY
,
1652 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
1653 ASSERT (Private
->UgaDraw
!= NULL
);
1655 UgaDraw
= Private
->UgaDraw
;
1657 Blt
->Image
.Bitmap
= AllocateZeroPool (Blt
->Width
* Blt
->Height
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
));
1658 if (Blt
->Image
.Bitmap
== NULL
) {
1660 SafeFreePool (String
);
1661 return EFI_OUT_OF_RESOURCES
;
1664 RowInfoArray
= NULL
;
1666 // StringToImage only support blt'ing image to device using GOP protocol. If GOP is not supported in this platform,
1667 // we ask StringToImage to print the string to blt buffer, then blt to device using UgaDraw.
1669 Status
= mHiiFont
->StringToImage (
1671 EFI_HII_IGNORE_IF_NO_GLYPH
,
1675 This
->Mode
->CursorColumn
* EFI_GLYPH_WIDTH
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaX
,
1676 This
->Mode
->CursorRow
* EFI_GLYPH_HEIGHT
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaY
,
1682 if (!EFI_ERROR (Status
)) {
1684 // Line breaks are handled by caller of DrawUnicodeWeightAtCursorN, so the updated parameter RowInfoArraySize by StringToImage will
1685 // always be 1 or 0 (if there is no valid Unicode Char can be printed). ASSERT here to make sure.
1687 ASSERT (RowInfoArraySize
<= 1);
1689 Status
= UgaDraw
->Blt (
1691 (EFI_UGA_PIXEL
*) Blt
->Image
.Bitmap
,
1692 EfiUgaBltBufferToVideo
,
1693 This
->Mode
->CursorColumn
* EFI_GLYPH_WIDTH
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaX
,
1694 (This
->Mode
->CursorRow
) * EFI_GLYPH_HEIGHT
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaY
,
1695 This
->Mode
->CursorColumn
* EFI_GLYPH_WIDTH
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaX
,
1696 (This
->Mode
->CursorRow
) * EFI_GLYPH_HEIGHT
+ Private
->ModeData
[This
->Mode
->Mode
].DeltaY
,
1697 RowInfoArray
[0].LineWidth
,
1698 RowInfoArray
[0].LineHeight
,
1699 Blt
->Width
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
1703 SafeFreePool (RowInfoArray
);
1704 SafeFreePool (Blt
->Image
.Bitmap
);
1706 Status
= EFI_UNSUPPORTED
;
1710 SafeFreePool (String
);
1711 SafeFreePool (FontInfo
);
1718 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
1721 GRAPHICS_CONSOLE_DEV
*Private
;
1722 EFI_SIMPLE_TEXT_OUTPUT_MODE
*CurrentMode
;
1725 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1726 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1727 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Foreground
;
1728 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Background
;
1729 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION BltChar
[EFI_GLYPH_HEIGHT
][EFI_GLYPH_WIDTH
];
1733 CurrentMode
= This
->Mode
;
1735 if (!CurrentMode
->CursorVisible
) {
1739 Private
= GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This
);
1740 GraphicsOutput
= Private
->GraphicsOutput
;
1741 UgaDraw
= Private
->UgaDraw
;
1744 // BUGBUG - we need to think about what to do with wide and narrow character deletions.
1747 // Blt a character to the screen
1749 GlyphX
= (CurrentMode
->CursorColumn
* EFI_GLYPH_WIDTH
) + Private
->ModeData
[CurrentMode
->Mode
].DeltaX
;
1750 GlyphY
= (CurrentMode
->CursorRow
* EFI_GLYPH_HEIGHT
) + Private
->ModeData
[CurrentMode
->Mode
].DeltaY
;
1751 if (GraphicsOutput
!= NULL
) {
1752 GraphicsOutput
->Blt (
1754 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*) BltChar
,
1755 EfiBltVideoToBltBuffer
,
1762 EFI_GLYPH_WIDTH
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
1764 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
1767 (EFI_UGA_PIXEL
*) (UINTN
) BltChar
,
1768 EfiUgaVideoToBltBuffer
,
1775 EFI_GLYPH_WIDTH
* sizeof (EFI_UGA_PIXEL
)
1779 GetTextColors (This
, &Foreground
.Pixel
, &Background
.Pixel
);
1782 // Convert Monochrome bitmap of the Glyph to BltBuffer structure
1784 for (PosY
= 0; PosY
< EFI_GLYPH_HEIGHT
; PosY
++) {
1785 for (PosX
= 0; PosX
< EFI_GLYPH_WIDTH
; PosX
++) {
1786 if ((mCursorGlyph
.GlyphCol1
[PosY
] & (1 << PosX
)) != 0) {
1787 BltChar
[PosY
][EFI_GLYPH_WIDTH
- PosX
- 1].Raw
^= Foreground
.Raw
;
1792 if (GraphicsOutput
!= NULL
) {
1793 GraphicsOutput
->Blt (
1795 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*) BltChar
,
1796 EfiBltBufferToVideo
,
1803 EFI_GLYPH_WIDTH
* sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
)
1805 } else if (FeaturePcdGet (PcdUgaConsumeSupport
)) {
1808 (EFI_UGA_PIXEL
*) (UINTN
) BltChar
,
1809 EfiUgaBltBufferToVideo
,
1816 EFI_GLYPH_WIDTH
* sizeof (EFI_UGA_PIXEL
)
1824 The user Entry Point for module GraphicsConsole. The user code starts with this function.
1826 @param[in] ImageHandle The firmware allocated handle for the EFI image.
1827 @param[in] SystemTable A pointer to the EFI System Table.
1829 @retval EFI_SUCCESS The entry point is executed successfully.
1830 @retval other Some error occurs when executing this entry point.
1835 InitializeGraphicsConsole (
1836 IN EFI_HANDLE ImageHandle
,
1837 IN EFI_SYSTEM_TABLE
*SystemTable
1843 // Install driver model protocol(s).
1845 Status
= EfiLibInstallDriverBindingComponentName2 (
1848 &gGraphicsConsoleDriverBinding
,
1850 &gGraphicsConsoleComponentName
,
1851 &gGraphicsConsoleComponentName2
1853 ASSERT_EFI_ERROR (Status
);