2 VGA Class Driver that managers VGA devices and produces Simple Text Output Protocol.
4 Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 // EFI Driver Binding Protocol for the VGA Class Driver
20 EFI_DRIVER_BINDING_PROTOCOL gVgaClassDriverBinding
= {
21 VgaClassDriverBindingSupported
,
22 VgaClassDriverBindingStart
,
23 VgaClassDriverBindingStop
,
32 CHAR16 CrLfString
[3] = { CHAR_CARRIAGE_RETURN
, CHAR_LINEFEED
, CHAR_NULL
};
35 // This list is used to define the valid extend chars.
36 // It also provides a mapping from Unicode to PCANSI or
37 // ASCII. The ASCII mapping we just made up.
40 UNICODE_TO_CHAR UnicodeToPcAnsiOrAscii
[] = {
72 BOXDRAW_VERTICAL_RIGHT
,
77 BOXDRAW_VERTICAL_LEFT
,
82 BOXDRAW_DOWN_HORIZONTAL
,
87 BOXDRAW_UP_HORIZONTAL
,
92 BOXDRAW_VERTICAL_HORIZONTAL
,
97 BOXDRAW_DOUBLE_HORIZONTAL
,
102 BOXDRAW_DOUBLE_VERTICAL
,
107 BOXDRAW_DOWN_RIGHT_DOUBLE
,
112 BOXDRAW_DOWN_DOUBLE_RIGHT
,
117 BOXDRAW_DOUBLE_DOWN_RIGHT
,
122 BOXDRAW_DOWN_LEFT_DOUBLE
,
127 BOXDRAW_DOWN_DOUBLE_LEFT
,
132 BOXDRAW_DOUBLE_DOWN_LEFT
,
137 BOXDRAW_UP_RIGHT_DOUBLE
,
142 BOXDRAW_UP_DOUBLE_RIGHT
,
147 BOXDRAW_DOUBLE_UP_RIGHT
,
152 BOXDRAW_UP_LEFT_DOUBLE
,
157 BOXDRAW_UP_DOUBLE_LEFT
,
162 BOXDRAW_DOUBLE_UP_LEFT
,
167 BOXDRAW_VERTICAL_RIGHT_DOUBLE
,
172 BOXDRAW_VERTICAL_DOUBLE_RIGHT
,
177 BOXDRAW_DOUBLE_VERTICAL_RIGHT
,
182 BOXDRAW_VERTICAL_LEFT_DOUBLE
,
187 BOXDRAW_VERTICAL_DOUBLE_LEFT
,
192 BOXDRAW_DOUBLE_VERTICAL_LEFT
,
197 BOXDRAW_DOWN_HORIZONTAL_DOUBLE
,
202 BOXDRAW_DOWN_DOUBLE_HORIZONTAL
,
207 BOXDRAW_DOUBLE_DOWN_HORIZONTAL
,
212 BOXDRAW_UP_HORIZONTAL_DOUBLE
,
217 BOXDRAW_UP_DOUBLE_HORIZONTAL
,
222 BOXDRAW_DOUBLE_UP_HORIZONTAL
,
227 BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE
,
232 BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL
,
237 BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL
,
243 BLOCKELEMENT_FULL_BLOCK
,
248 BLOCKELEMENT_LIGHT_SHADE
,
254 GEOMETRICSHAPE_UP_TRIANGLE
,
259 GEOMETRICSHAPE_RIGHT_TRIANGLE
,
264 GEOMETRICSHAPE_DOWN_TRIANGLE
,
269 GEOMETRICSHAPE_LEFT_TRIANGLE
,
306 Entrypoint of this VGA Class Driver.
308 This function is the entrypoint of this VGA Class Driver. It installs Driver Binding
309 Protocols together with Component Name Protocols.
311 @param ImageHandle The firmware allocated handle for the EFI image.
312 @param SystemTable A pointer to the EFI System Table.
314 @retval EFI_SUCCESS The entry point is executed successfully.
320 IN EFI_HANDLE ImageHandle
,
321 IN EFI_SYSTEM_TABLE
*SystemTable
327 // Install driver model protocol(s).
329 Status
= EfiLibInstallDriverBindingComponentName2 (
332 &gVgaClassDriverBinding
,
334 &gVgaClassComponentName
,
335 &gVgaClassComponentName2
337 ASSERT_EFI_ERROR (Status
);
343 Internal worker function to program CRTC register via PCI I/O Protocol.
345 @param VgaClassDev device instance object
346 @param Address Address of register to write
347 @param Data Data to write to register.
352 IN VGA_CLASS_DEV
*VgaClassDev
,
357 VgaClassDev
->PciIo
->Io
.Write (
360 VgaClassDev
->VgaMiniPort
->CrtcAddressRegisterBar
,
361 VgaClassDev
->VgaMiniPort
->CrtcAddressRegisterOffset
,
366 VgaClassDev
->PciIo
->Io
.Write (
369 VgaClassDev
->VgaMiniPort
->CrtcDataRegisterBar
,
370 VgaClassDev
->VgaMiniPort
->CrtcDataRegisterOffset
,
377 Internal worker function to set cursor's position to VgaClass device
379 @param VgaClassDev Private data structure for device instance.
380 @param Column Colomn of position to set cursor to.
381 @param Row Row of position to set cursor to.
382 @param MaxColumn Max value of column.
386 SetVideoCursorPosition (
387 IN VGA_CLASS_DEV
*VgaClassDev
,
393 Column
= Column
& 0xff;
395 MaxColumn
= MaxColumn
& 0xff;
399 CRTC_CURSOR_LOCATION_HIGH
,
400 (UINT8
) ((Row
* MaxColumn
+ Column
) >> 8)
404 CRTC_CURSOR_LOCATION_LOW
,
405 (UINT8
) ((Row
* MaxColumn
+ Column
) & 0xff)
410 Internal worker function to detect if a Unicode char is for Box Drawing text graphics.
412 @param Graphic Unicode char to test.
413 @param PcAnsi Pointer to PCANSI equivalent of Graphic for output.
414 If NULL, then PCANSI value is not returned.
415 @param Ascii Pointer to ASCII equivalent of Graphic for output.
416 If NULL, then ASCII value is not returned.
418 @retval TRUE Gpaphic is a supported Unicode Box Drawing character.
419 @retval FALSE Gpaphic is not a supported Unicode Box Drawing character.
423 LibIsValidTextGraphics (
425 OUT CHAR8
*PcAnsi
, OPTIONAL
426 OUT CHAR8
*Ascii OPTIONAL
429 UNICODE_TO_CHAR
*Table
;
432 // Unicode drawing code charts are all in the 0x25xx range, arrows are 0x21xx.
433 // So first filter out values not in these 2 ranges.
435 if ((((Graphic
& 0xff00) != 0x2500) && ((Graphic
& 0xff00) != 0x2100))) {
440 // Search UnicodeToPcAnsiOrAscii table for matching entry.
442 for (Table
= UnicodeToPcAnsiOrAscii
; Table
->Unicode
!= 0x0000; Table
++) {
443 if (Graphic
== Table
->Unicode
) {
444 if (PcAnsi
!= NULL
) {
445 *PcAnsi
= Table
->PcAnsi
;
449 *Ascii
= Table
->Ascii
;
457 // If value is not found in UnicodeToPcAnsiOrAscii table, then return FALSE.
463 Internal worker function to check whether input value is an ASCII char.
465 @param Char Character to check.
467 @retval TRUE Input value is an ASCII char.
468 @retval FALSE Input value is not an ASCII char.
476 if ((Char
>= 0x20) && (Char
<= 0x7f)) {
484 Internal worker function to check whether input value is a unicode control char.
486 @param Char Character to check.
488 @retval TRUE Input value is a unicode control char.
489 @retval FALSE Input value is not a unicode control char.
497 if (Char
== CHAR_NULL
|| Char
== CHAR_BACKSPACE
|| Char
== CHAR_LINEFEED
|| Char
== CHAR_CARRIAGE_RETURN
) {
505 Tests to see if this driver supports a given controller.
507 This function implments EFI_DRIVER_BINDING_PROTOCOL.Supported().
508 It Checks if this driver supports the controller specified. Any Controller
509 with VgaMiniPort Protocol and Pci I/O protocol can be supported.
511 @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
512 @param ControllerHandle Handle of device to test
513 @param RemainingDevicePath Optional parameter use to pick a specific child
516 @retval EFI_SUCCESS This driver supports this device.
517 @retval EFI_ALREADY_STARTED This driver is already running on this device.
518 @retval EFI_UNSUPPORTED This driver does not support this device.
523 VgaClassDriverBindingSupported (
524 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
525 IN EFI_HANDLE Controller
,
526 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
532 // Checks if Abstraction(s) needed to perform the supported test
534 Status
= gBS
->OpenProtocol (
536 &gEfiVgaMiniPortProtocolGuid
,
538 This
->DriverBindingHandle
,
540 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
542 if (EFI_ERROR (Status
)) {
546 // Open the IO Abstraction(s) needed to perform the supported test
548 Status
= gBS
->OpenProtocol (
550 &gEfiPciIoProtocolGuid
,
552 This
->DriverBindingHandle
,
554 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
556 if (EFI_ERROR (Status
)) {
564 Starts the device controller.
566 This function implments EFI_DRIVER_BINDING_PROTOCOL.Start().
567 It starts the device specified by Controller with the driver based on PCI I/O Protocol
568 and VgaMiniPort Protocol. It creates context for device instance and install EFI_SIMPLE_TEXT_OUT_PROTOCOL.
570 @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
571 @param ControllerHandle Handle of device to bind driver to
572 @param RemainingDevicePath Optional parameter use to pick a specific child
575 @retval EFI_SUCCESS The device was started.
576 @retval other Fail to start the device.
581 VgaClassDriverBindingStart (
582 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
583 IN EFI_HANDLE Controller
,
584 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
588 EFI_VGA_MINI_PORT_PROTOCOL
*VgaMiniPort
;
589 EFI_PCI_IO_PROTOCOL
*PciIo
;
590 VGA_CLASS_DEV
*VgaClassPrivate
;
591 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
593 Status
= gBS
->HandleProtocol (
595 &gEfiDevicePathProtocolGuid
,
596 (VOID
**) &DevicePath
598 if (EFI_ERROR (Status
)) {
602 // Report that VGA Class driver is being enabled
604 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
606 EFI_PERIPHERAL_LOCAL_CONSOLE
| EFI_P_PC_ENABLE
,
611 // Open the PCI I/O Protocol
613 Status
= gBS
->OpenProtocol (
615 &gEfiPciIoProtocolGuid
,
617 This
->DriverBindingHandle
,
619 EFI_OPEN_PROTOCOL_GET_PROTOCOL
621 if (EFI_ERROR (Status
)) {
625 // Open the VGA Mini Port Protocol
627 Status
= gBS
->OpenProtocol (
629 &gEfiVgaMiniPortProtocolGuid
,
630 (VOID
**) &VgaMiniPort
,
631 This
->DriverBindingHandle
,
633 EFI_OPEN_PROTOCOL_BY_DRIVER
635 if (EFI_ERROR (Status
)) {
639 // Allocate the private device structure
641 VgaClassPrivate
= AllocateZeroPool (sizeof (VGA_CLASS_DEV
));
642 ASSERT (VgaClassPrivate
!= NULL
);
645 // Initialize the private device structure
647 VgaClassPrivate
->Signature
= VGA_CLASS_DEV_SIGNATURE
;
648 VgaClassPrivate
->Handle
= Controller
;
649 VgaClassPrivate
->VgaMiniPort
= VgaMiniPort
;
650 VgaClassPrivate
->PciIo
= PciIo
;
652 VgaClassPrivate
->SimpleTextOut
.Reset
= VgaClassReset
;
653 VgaClassPrivate
->SimpleTextOut
.OutputString
= VgaClassOutputString
;
654 VgaClassPrivate
->SimpleTextOut
.TestString
= VgaClassTestString
;
655 VgaClassPrivate
->SimpleTextOut
.ClearScreen
= VgaClassClearScreen
;
656 VgaClassPrivate
->SimpleTextOut
.SetAttribute
= VgaClassSetAttribute
;
657 VgaClassPrivate
->SimpleTextOut
.SetCursorPosition
= VgaClassSetCursorPosition
;
658 VgaClassPrivate
->SimpleTextOut
.EnableCursor
= VgaClassEnableCursor
;
659 VgaClassPrivate
->SimpleTextOut
.QueryMode
= VgaClassQueryMode
;
660 VgaClassPrivate
->SimpleTextOut
.SetMode
= VgaClassSetMode
;
662 VgaClassPrivate
->SimpleTextOut
.Mode
= &VgaClassPrivate
->SimpleTextOutputMode
;
663 VgaClassPrivate
->SimpleTextOutputMode
.MaxMode
= VgaMiniPort
->MaxMode
;
664 VgaClassPrivate
->DevicePath
= DevicePath
;
667 // Initialize the VGA device.
669 Status
= VgaClassPrivate
->SimpleTextOut
.SetAttribute (
670 &VgaClassPrivate
->SimpleTextOut
,
671 EFI_TEXT_ATTR (EFI_WHITE
, EFI_BLACK
)
673 if (EFI_ERROR (Status
)) {
677 Status
= VgaClassPrivate
->SimpleTextOut
.Reset (
678 &VgaClassPrivate
->SimpleTextOut
,
681 if (EFI_ERROR (Status
)) {
685 Status
= VgaClassPrivate
->SimpleTextOut
.EnableCursor (
686 &VgaClassPrivate
->SimpleTextOut
,
689 if (EFI_ERROR (Status
)) {
693 Status
= gBS
->InstallMultipleProtocolInterfaces (
695 &gEfiSimpleTextOutProtocolGuid
,
696 &VgaClassPrivate
->SimpleTextOut
,
703 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
704 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
705 EFI_PERIPHERAL_LOCAL_CONSOLE
| EFI_P_EC_CONTROLLER_ERROR
,
714 Starts the device controller.
716 This function implments EFI_DRIVER_BINDING_PROTOCOL.Stop().
717 It stops this driver on Controller. Support stoping any child handles
718 created by this driver.
720 @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
721 @param ControllerHandle A handle to the device being stopped.
722 @param NumberOfChildren The number of child device handles in ChildHandleBuffer.
723 @param ChildHandleBuffer An array of child handles to be freed.
725 @retval EFI_SUCCESS This driver is removed ControllerHandle
726 @retval other This driver was not removed from this device
731 VgaClassDriverBindingStop (
732 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
733 IN EFI_HANDLE Controller
,
734 IN UINTN NumberOfChildren
,
735 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
739 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*SimpleTextOut
;
740 VGA_CLASS_DEV
*VgaClassPrivate
;
742 Status
= gBS
->OpenProtocol (
744 &gEfiSimpleTextOutProtocolGuid
,
745 (VOID
**) &SimpleTextOut
,
746 This
->DriverBindingHandle
,
748 EFI_OPEN_PROTOCOL_GET_PROTOCOL
750 if (EFI_ERROR (Status
)) {
754 VgaClassPrivate
= VGA_CLASS_DEV_FROM_THIS (SimpleTextOut
);
757 // Report that VGA Class driver is being disabled
759 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
761 EFI_PERIPHERAL_LOCAL_CONSOLE
| EFI_P_PC_DISABLE
,
762 VgaClassPrivate
->DevicePath
765 Status
= gBS
->UninstallProtocolInterface (
767 &gEfiSimpleTextOutProtocolGuid
,
768 &VgaClassPrivate
->SimpleTextOut
770 if (EFI_ERROR (Status
)) {
774 // Release PCI I/O and VGA Mini Port Protocols on the controller handle.
778 &gEfiPciIoProtocolGuid
,
779 This
->DriverBindingHandle
,
785 &gEfiVgaMiniPortProtocolGuid
,
786 This
->DriverBindingHandle
,
790 FreePool (VgaClassPrivate
);
796 Resets the text output device hardware.
798 This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset().
799 It resets the text output device hardware. The cursor position is set to (0, 0),
800 and the screen is cleared to the default background color for the output device.
802 @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
803 @param ExtendedVerification Indicates that the driver may perform a more exhaustive
804 verification operation of the device during reset.
806 @retval EFI_SUCCESS The text output device was reset.
807 @retval EFI_DEVICE_ERROR The text output device is not functioning correctly and could not be reset.
813 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
814 IN BOOLEAN ExtendedVerification
818 VGA_CLASS_DEV
*VgaClassPrivate
;
820 VgaClassPrivate
= VGA_CLASS_DEV_FROM_THIS (This
);
822 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
824 EFI_PERIPHERAL_LOCAL_CONSOLE
| EFI_P_PC_RESET
,
825 VgaClassPrivate
->DevicePath
828 This
->SetAttribute (This
, EFI_TEXT_ATTR (This
->Mode
->Attribute
& 0x0F, EFI_BACKGROUND_BLACK
));
830 Status
= This
->SetMode (This
, 0);
831 if (EFI_ERROR (Status
)) {
835 return This
->ClearScreen (This
);
839 Writes a Unicode string to the output device.
841 This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString().
842 It writes a Unicode string to the output device. This is the most basic output mechanism
845 @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
846 @param String The Null-terminated Unicode string to be displayed on the output device(s).
848 @retval EFI_SUCCESS The string was output to the device.
849 @retval EFI_DEVICE_ERROR The device reported an error while attempting to output the text.
850 @retval EFI_UNSUPPORTED The output device's mode is not currently in a defined text mode.
851 @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the characters in
852 the Unicode string could not be rendered and were skipped.
857 VgaClassOutputString (
858 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
863 VGA_CLASS_DEV
*VgaClassDev
;
864 EFI_SIMPLE_TEXT_OUTPUT_MODE
*Mode
;
870 VgaClassDev
= VGA_CLASS_DEV_FROM_THIS (This
);
873 Status
= This
->QueryMode (
879 if (EFI_ERROR (Status
)) {
884 // Parse each character of the string to output
886 for (; *String
!= CHAR_NULL
; String
++) {
890 if (Mode
->CursorColumn
> 0) {
891 Mode
->CursorColumn
--;
896 if (Mode
->CursorRow
== (INT32
) (MaxRow
- 1)) {
898 // Scroll the screen by copying the contents
899 // of the VGA display up one line
901 VgaClassDev
->PciIo
->CopyMem (
904 VgaClassDev
->VgaMiniPort
->VgaMemoryBar
,
905 VgaClassDev
->VgaMiniPort
->VgaMemoryOffset
,
906 VgaClassDev
->VgaMiniPort
->VgaMemoryBar
,
907 VgaClassDev
->VgaMiniPort
->VgaMemoryOffset
+ MaxColumn
* 2,
908 ((MaxRow
- 1) * MaxColumn
) >> 1
912 // Print Blank Line of spaces with the current color attributes
914 VideoChar
= (Mode
->Attribute
<< 8) | ' ';
915 VideoChar
= (VideoChar
<< 16) | VideoChar
;
916 VgaClassDev
->PciIo
->Mem
.Write (
918 EfiPciIoWidthFillUint32
,
919 VgaClassDev
->VgaMiniPort
->VgaMemoryBar
,
920 VgaClassDev
->VgaMiniPort
->VgaMemoryOffset
+ (MaxRow
- 1) * MaxColumn
* 2,
926 if (Mode
->CursorRow
< (INT32
) (MaxRow
- 1)) {
931 case CHAR_CARRIAGE_RETURN
:
932 Mode
->CursorColumn
= 0;
936 if (!LibIsValidTextGraphics (*String
, &GraphicChar
, NULL
)) {
938 // If this character is not ,Box Drawing text graphics, then convert it to ASCII.
940 GraphicChar
= (CHAR8
) *String
;
941 if (!IsValidAscii (GraphicChar
)) {
943 // If not valid ASCII char, convert it to "?"
949 VideoChar
= (Mode
->Attribute
<< 8) | GraphicChar
;
950 VgaClassDev
->PciIo
->Mem
.Write (
953 VgaClassDev
->VgaMiniPort
->VgaMemoryBar
,
954 VgaClassDev
->VgaMiniPort
->VgaMemoryOffset
+ ((Mode
->CursorRow
* MaxColumn
+ Mode
->CursorColumn
) * 2),
959 if (Mode
->CursorColumn
>= (INT32
) (MaxColumn
- 1)) {
960 This
->OutputString (This
, CrLfString
);
962 Mode
->CursorColumn
++;
968 SetVideoCursorPosition (
970 (UINTN
) Mode
->CursorColumn
,
971 (UINTN
) Mode
->CursorRow
,
979 Verifies that all characters in a Unicode string can be output to the target device.
981 This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.TestString().
982 It verifies that all characters in a Unicode string can be output to the target device.
984 @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
985 @param String The Null-terminated Unicode string to be examined for the output device(s).
987 @retval EFI_SUCCESS The device(s) are capable of rendering the output string.
988 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string cannot be rendered by
989 one or more of the output devices mapped by the EFI handle.
995 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
999 while (*String
!= CHAR_NULL
) {
1000 if (!(IsValidAscii (*String
) || IsValidEfiCntlChar (*String
) || LibIsValidTextGraphics (*String
, NULL
, NULL
))) {
1001 return EFI_UNSUPPORTED
;
1011 Clears the output device(s) display to the currently selected background color.
1013 This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.ClearScreen().
1014 The ClearScreen() function clears the output device(s) display to the currently
1015 selected background color. The cursor position is set to (0, 0).
1017 @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
1019 @retval EFI_SUCESS The operation completed successfully.
1020 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
1021 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
1026 VgaClassClearScreen (
1027 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
1031 VGA_CLASS_DEV
*VgaClassDev
;
1036 VgaClassDev
= VGA_CLASS_DEV_FROM_THIS (This
);
1038 Status
= This
->QueryMode (
1044 if (EFI_ERROR (Status
)) {
1048 VideoChar
= (This
->Mode
->Attribute
<< 8) | ' ';
1049 VideoChar
= (VideoChar
<< 16) | VideoChar
;
1050 VgaClassDev
->PciIo
->Mem
.Write (
1052 EfiPciIoWidthFillUint32
,
1053 VgaClassDev
->VgaMiniPort
->VgaMemoryBar
,
1054 VgaClassDev
->VgaMiniPort
->VgaMemoryOffset
,
1055 (MaxRow
* MaxColumn
) >> 1,
1059 This
->SetCursorPosition (This
, 0, 0);
1065 Sets the background and foreground colors for theOutputString() and ClearScreen() functions.
1067 This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetAttribute().
1068 It sets the background and foreground colors for the OutputString() and ClearScreen() functions.
1069 The color mask can be set even when the device is in an invalid text mode.
1070 Devices supporting a different number of text colors are required to emulate the above colors
1071 to the best of the device's capabilities.
1073 @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
1074 @param Attribute The attribute to set.
1075 Bits 0..3 are the foreground color,
1076 and bits 4..6 are the background color.
1078 @retval EFI_SUCCESS The requested attributes were set.
1079 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
1084 VgaClassSetAttribute (
1085 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1089 if (Attribute
<= EFI_MAX_ATTRIBUTE
) {
1090 This
->Mode
->Attribute
= (INT32
) Attribute
;
1094 return EFI_UNSUPPORTED
;
1098 Sets the current coordinates of the cursor position.
1100 This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetCursorPosition().
1101 It sets the current coordinates of the cursor position.
1102 The upper left corner of the screen is defined as coordinate (0, 0).
1104 @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
1105 @param Column Column of position to set the cursor to.
1106 @param Row Row of position to set the cursor to.
1108 @retval EFI_SUCCESS The operation completed successfully.
1109 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
1110 @retval EFI_UNSUPPORTED The output device is not in a valid text mode, or the cursor
1111 position is invalid for the current mode.
1116 VgaClassSetCursorPosition (
1117 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1123 VGA_CLASS_DEV
*VgaClassDev
;
1127 VgaClassDev
= VGA_CLASS_DEV_FROM_THIS (This
);
1129 Status
= This
->QueryMode (
1135 if (EFI_ERROR (Status
)) {
1139 if (Column
>= MaxColumn
|| Row
>= MaxRow
) {
1140 return EFI_UNSUPPORTED
;
1143 SetVideoCursorPosition (VgaClassDev
, Column
, Row
, MaxColumn
);
1145 This
->Mode
->CursorColumn
= (INT32
) Column
;
1146 This
->Mode
->CursorRow
= (INT32
) Row
;
1152 Makes the cursor visible or invisible.
1154 This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.EnableCursor().
1155 It makes the cursor visible or invisible.
1157 @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
1158 @param Visible If TRUE, the cursor is set to be visible.
1159 If FALSE, the cursor is set to be invisible.
1161 @retval EFI_SUCESS The operation completed successfully.
1162 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request or the
1163 device does not support changing the cursor mode.
1164 @retval EFI_UNSUPPORTED The output device does not support visibility control of the cursor.
1169 VgaClassEnableCursor (
1170 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1174 VGA_CLASS_DEV
*VgaClassDev
;
1176 VgaClassDev
= VGA_CLASS_DEV_FROM_THIS (This
);
1178 if (This
->Mode
->Mode
== 1) {
1182 WriteCrtc (VgaClassDev
, CRTC_CURSOR_START
, 0x06);
1183 WriteCrtc (VgaClassDev
, CRTC_CURSOR_END
, 0x07);
1188 WriteCrtc (VgaClassDev
, CRTC_CURSOR_START
, 0x0e);
1189 WriteCrtc (VgaClassDev
, CRTC_CURSOR_END
, 0x0f);
1192 WriteCrtc (VgaClassDev
, CRTC_CURSOR_START
, 0x20);
1195 This
->Mode
->CursorVisible
= Visible
;
1200 Returns information for an available text mode that the output device(s) supports.
1202 This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode().
1203 It returns information for an available text mode that the output device(s) supports.
1204 It is required that all output devices support at least 80x25 text mode. This mode is defined to be mode 0.
1205 If the output devices support 80x50, that is defined to be mode 1.
1207 @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
1208 @param ModeNumber The mode number to return information on.
1209 @param Columns Columen in current mode number
1210 @param Rows Row in current mode number.
1212 @retval EFI_SUCCESS The requested mode information was returned.
1213 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
1214 @retval EFI_UNSUPPORTED The mode number was not valid.
1220 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1221 IN UINTN ModeNumber
,
1226 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
1229 return EFI_UNSUPPORTED
;
1232 switch (ModeNumber
) {
1246 return EFI_UNSUPPORTED
;
1253 Sets the output device(s) to a specified mode.
1255 This function implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode().
1256 It sets the output device(s) to the requested mode.
1257 On success the device is in the geometry for the requested mode,
1258 and the device has been cleared to the current background color with the cursor at (0,0).
1260 @param This Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
1261 @param ModeNumber The text mode to set.
1263 @retval EFI_SUCCESS The requested text mode was set.
1264 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
1265 @retval EFI_UNSUPPORTED The mode number was not valid.
1271 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
1275 VGA_CLASS_DEV
*VgaClassDev
;
1277 VgaClassDev
= VGA_CLASS_DEV_FROM_THIS (This
);
1279 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
1280 return EFI_UNSUPPORTED
;
1283 This
->ClearScreen (This
);
1285 This
->Mode
->Mode
= (INT32
) ModeNumber
;
1287 return VgaClassDev
->VgaMiniPort
->SetMode (VgaClassDev
->VgaMiniPort
, ModeNumber
);