2 Implementation for EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL protocol.
4 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
5 Copyright (C) 2016 Silicon Graphics, Inc. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 // This list is used to define the valid extend chars.
20 // It also provides a mapping from Unicode to PCANSI or
21 // ASCII. The ASCII mapping we just made up.
24 UNICODE_TO_CHAR UnicodeToPcAnsiOrAscii
[] = {
25 { BOXDRAW_HORIZONTAL
, 0xc4, L
'-' },
26 { BOXDRAW_VERTICAL
, 0xb3, L
'|' },
27 { BOXDRAW_DOWN_RIGHT
, 0xda, L
'/' },
28 { BOXDRAW_DOWN_LEFT
, 0xbf, L
'\\' },
29 { BOXDRAW_UP_RIGHT
, 0xc0, L
'\\' },
30 { BOXDRAW_UP_LEFT
, 0xd9, L
'/' },
31 { BOXDRAW_VERTICAL_RIGHT
, 0xc3, L
'|' },
32 { BOXDRAW_VERTICAL_LEFT
, 0xb4, L
'|' },
33 { BOXDRAW_DOWN_HORIZONTAL
, 0xc2, L
'+' },
34 { BOXDRAW_UP_HORIZONTAL
, 0xc1, L
'+' },
35 { BOXDRAW_VERTICAL_HORIZONTAL
, 0xc5, L
'+' },
36 { BOXDRAW_DOUBLE_HORIZONTAL
, 0xcd, L
'-' },
37 { BOXDRAW_DOUBLE_VERTICAL
, 0xba, L
'|' },
38 { BOXDRAW_DOWN_RIGHT_DOUBLE
, 0xd5, L
'/' },
39 { BOXDRAW_DOWN_DOUBLE_RIGHT
, 0xd6, L
'/' },
40 { BOXDRAW_DOUBLE_DOWN_RIGHT
, 0xc9, L
'/' },
41 { BOXDRAW_DOWN_LEFT_DOUBLE
, 0xb8, L
'\\' },
42 { BOXDRAW_DOWN_DOUBLE_LEFT
, 0xb7, L
'\\' },
43 { BOXDRAW_DOUBLE_DOWN_LEFT
, 0xbb, L
'\\' },
44 { BOXDRAW_UP_RIGHT_DOUBLE
, 0xd4, L
'\\' },
45 { BOXDRAW_UP_DOUBLE_RIGHT
, 0xd3, L
'\\' },
46 { BOXDRAW_DOUBLE_UP_RIGHT
, 0xc8, L
'\\' },
47 { BOXDRAW_UP_LEFT_DOUBLE
, 0xbe, L
'/' },
48 { BOXDRAW_UP_DOUBLE_LEFT
, 0xbd, L
'/' },
49 { BOXDRAW_DOUBLE_UP_LEFT
, 0xbc, L
'/' },
50 { BOXDRAW_VERTICAL_RIGHT_DOUBLE
, 0xc6, L
'|' },
51 { BOXDRAW_VERTICAL_DOUBLE_RIGHT
, 0xc7, L
'|' },
52 { BOXDRAW_DOUBLE_VERTICAL_RIGHT
, 0xcc, L
'|' },
53 { BOXDRAW_VERTICAL_LEFT_DOUBLE
, 0xb5, L
'|' },
54 { BOXDRAW_VERTICAL_DOUBLE_LEFT
, 0xb6, L
'|' },
55 { BOXDRAW_DOUBLE_VERTICAL_LEFT
, 0xb9, L
'|' },
56 { BOXDRAW_DOWN_HORIZONTAL_DOUBLE
, 0xd1, L
'+' },
57 { BOXDRAW_DOWN_DOUBLE_HORIZONTAL
, 0xd2, L
'+' },
58 { BOXDRAW_DOUBLE_DOWN_HORIZONTAL
, 0xcb, L
'+' },
59 { BOXDRAW_UP_HORIZONTAL_DOUBLE
, 0xcf, L
'+' },
60 { BOXDRAW_UP_DOUBLE_HORIZONTAL
, 0xd0, L
'+' },
61 { BOXDRAW_DOUBLE_UP_HORIZONTAL
, 0xca, L
'+' },
62 { BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE
, 0xd8, L
'+' },
63 { BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL
, 0xd7, L
'+' },
64 { BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL
, 0xce, L
'+' },
66 { BLOCKELEMENT_FULL_BLOCK
, 0xdb, L
'*' },
67 { BLOCKELEMENT_LIGHT_SHADE
, 0xb0, L
'+' },
69 { GEOMETRICSHAPE_UP_TRIANGLE
, 0x1e, L
'^' },
70 { GEOMETRICSHAPE_RIGHT_TRIANGLE
, 0x10, L
'>' },
71 { GEOMETRICSHAPE_DOWN_TRIANGLE
, 0x1f, L
'v' },
72 { GEOMETRICSHAPE_LEFT_TRIANGLE
, 0x11, L
'<' },
74 { ARROW_LEFT
, 0x3c, L
'<' },
75 { ARROW_UP
, 0x18, L
'^' },
76 { ARROW_RIGHT
, 0x3e, L
'>' },
77 { ARROW_DOWN
, 0x19, L
'v' },
79 { 0x0000, 0x00, L
'\0' }
82 CHAR16 mSetModeString
[] = { ESC
, '[', '=', '3', 'h', 0 };
83 CHAR16 mSetAttributeString
[] = { ESC
, '[', '0', 'm', ESC
, '[', '4', '0', 'm', ESC
, '[', '4', '0', 'm', 0 };
84 CHAR16 mClearScreenString
[] = { ESC
, '[', '2', 'J', 0 };
85 CHAR16 mSetCursorPositionString
[] = { ESC
, '[', '0', '0', ';', '0', '0', 'H', 0 };
86 CHAR16 mCursorForwardString
[] = { ESC
, '[', '0', '0', 'C', 0 };
87 CHAR16 mCursorBackwardString
[] = { ESC
, '[', '0', '0', 'D', 0 };
90 // Body of the ConOut functions
94 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset().
96 If ExtendeVerification is TRUE, then perform dependent serial device reset,
97 and set display mode to mode 0.
98 If ExtendedVerification is FALSE, only set display mode to mode 0.
100 @param This Indicates the calling context.
101 @param ExtendedVerification Indicates that the driver may perform a more
102 exhaustive verification operation of the device
105 @retval EFI_SUCCESS The reset operation succeeds.
106 @retval EFI_DEVICE_ERROR The terminal is not functioning correctly or the serial port reset fails.
111 TerminalConOutReset (
112 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
113 IN BOOLEAN ExtendedVerification
117 TERMINAL_DEV
*TerminalDevice
;
119 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
122 // Perform a more exhaustive reset by resetting the serial port.
124 if (ExtendedVerification
) {
126 // Report progress code here
128 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
130 (EFI_PERIPHERAL_REMOTE_CONSOLE
| EFI_P_PC_RESET
),
131 TerminalDevice
->DevicePath
134 Status
= TerminalDevice
->SerialIo
->Reset (TerminalDevice
->SerialIo
);
135 if (EFI_ERROR (Status
)) {
137 // Report error code here
139 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
140 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
141 (EFI_PERIPHERAL_REMOTE_CONSOLE
| EFI_P_EC_CONTROLLER_ERROR
),
142 TerminalDevice
->DevicePath
149 This
->SetAttribute (This
, EFI_TEXT_ATTR (This
->Mode
->Attribute
& 0x0F, EFI_BLACK
));
151 Status
= This
->SetMode (This
, 0);
158 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString().
160 The Unicode string will be converted to terminal expressible data stream
161 and send to terminal via serial port.
163 @param This Indicates the calling context.
164 @param WString The Null-terminated Unicode string to be displayed
165 on the terminal screen.
167 @retval EFI_SUCCESS The string is output successfully.
168 @retval EFI_DEVICE_ERROR The serial port fails to send the string out.
169 @retval EFI_WARN_UNKNOWN_GLYPH Indicates that some of the characters in the Unicode string could not
170 be rendered and are skipped.
171 @retval EFI_UNSUPPORTED If current display mode is out of range.
176 TerminalConOutOutputString (
177 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
181 TERMINAL_DEV
*TerminalDevice
;
182 EFI_SIMPLE_TEXT_OUTPUT_MODE
*Mode
;
192 // flag used to indicate whether condition happens which will cause
193 // return EFI_WARN_UNKNOWN_GLYPH
202 // get Terminal device data structure pointer.
204 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
207 // Get current display mode
211 if (Mode
->Mode
>= Mode
->MaxMode
) {
212 return EFI_UNSUPPORTED
;
222 for (; *WString
!= CHAR_NULL
; WString
++) {
224 switch (TerminalDevice
->TerminalType
) {
231 if (!TerminalIsValidTextGraphics (*WString
, &GraphicChar
, &AsciiChar
)) {
233 // If it's not a graphic character convert Unicode to ASCII.
235 GraphicChar
= (CHAR8
) *WString
;
237 if (!(TerminalIsValidAscii (GraphicChar
) || TerminalIsValidEfiCntlChar (GraphicChar
))) {
239 // when this driver use the OutputString to output control string,
240 // TerminalDevice->OutputEscChar is set to let the Esc char
241 // to be output to the terminal emulation software.
243 if ((GraphicChar
== 27) && TerminalDevice
->OutputEscChar
) {
251 AsciiChar
= GraphicChar
;
255 if (TerminalDevice
->TerminalType
!= PCANSITYPE
) {
256 GraphicChar
= AsciiChar
;
261 Status
= TerminalDevice
->SerialIo
->Write (
262 TerminalDevice
->SerialIo
,
267 if (EFI_ERROR (Status
)) {
274 UnicodeToUtf8 (*WString
, &Utf8Char
, &ValidBytes
);
276 Status
= TerminalDevice
->SerialIo
->Write (
277 TerminalDevice
->SerialIo
,
281 if (EFI_ERROR (Status
)) {
287 // Update cursor position.
292 if (Mode
->CursorColumn
> 0) {
293 Mode
->CursorColumn
--;
298 if (Mode
->CursorRow
< (INT32
) (MaxRow
- 1)) {
303 case CHAR_CARRIAGE_RETURN
:
304 Mode
->CursorColumn
= 0;
308 if (Mode
->CursorColumn
< (INT32
) (MaxColumn
- 1)) {
310 Mode
->CursorColumn
++;
314 Mode
->CursorColumn
= 0;
315 if (Mode
->CursorRow
< (INT32
) (MaxRow
- 1)) {
319 if (TerminalDevice
->TerminalType
== TTYTERMTYPE
&&
320 !TerminalDevice
->OutputEscChar
) {
322 // We've written the last character on the line. The
323 // terminal doesn't actually wrap its cursor until we print
324 // the next character, but the driver thinks it has wrapped
325 // already. Print CR LF to synchronize the terminal with
326 // the driver, but only if we're not in the middle of
327 // printing an escape sequence.
329 CHAR8 CrLfStr
[] = {'\r', '\n'};
331 Length
= sizeof(CrLfStr
);
333 Status
= TerminalDevice
->SerialIo
->Write (
334 TerminalDevice
->SerialIo
,
339 if (EFI_ERROR (Status
)) {
351 return EFI_WARN_UNKNOWN_GLYPH
;
357 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
358 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
359 (EFI_PERIPHERAL_REMOTE_CONSOLE
| EFI_P_EC_OUTPUT_ERROR
),
360 TerminalDevice
->DevicePath
363 return EFI_DEVICE_ERROR
;
368 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.TestString().
370 If one of the characters in the *Wstring is
371 neither valid Unicode drawing characters,
372 not ASCII code, then this function will return
375 @param This Indicates the calling context.
376 @param WString The Null-terminated Unicode string to be tested.
378 @retval EFI_SUCCESS The terminal is capable of rendering the output string.
379 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string cannot be rendered.
384 TerminalConOutTestString (
385 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
389 TERMINAL_DEV
*TerminalDevice
;
393 // get Terminal device data structure pointer.
395 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
397 switch (TerminalDevice
->TerminalType
) {
403 Status
= AnsiTestString (TerminalDevice
, WString
);
407 Status
= VTUTF8TestString (TerminalDevice
, WString
);
411 Status
= EFI_UNSUPPORTED
;
420 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode().
422 It returns information for an available text mode
423 that the terminal supports.
425 @param This Indicates the calling context.
426 @param ModeNumber The mode number to return information on.
427 @param Columns The returned columns of the requested mode.
428 @param Rows The returned rows of the requested mode.
430 @retval EFI_SUCCESS The requested mode information is returned.
431 @retval EFI_UNSUPPORTED The mode number is not valid.
436 TerminalConOutQueryMode (
437 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
443 TERMINAL_DEV
*TerminalDevice
;
445 if (ModeNumber
>= (UINTN
) This
->Mode
->MaxMode
) {
446 return EFI_UNSUPPORTED
;
450 // Get Terminal device data structure pointer.
452 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
453 *Columns
= TerminalDevice
->TerminalConsoleModeData
[ModeNumber
].Columns
;
454 *Rows
= TerminalDevice
->TerminalConsoleModeData
[ModeNumber
].Rows
;
461 Implements EFI_SIMPLE_TEXT_OUT.SetMode().
463 Set the terminal to a specified display mode.
464 In this driver, we only support mode 0.
466 @param This Indicates the calling context.
467 @param ModeNumber The text mode to set.
469 @retval EFI_SUCCESS The requested text mode is set.
470 @retval EFI_DEVICE_ERROR The requested text mode cannot be set
471 because of serial device error.
472 @retval EFI_UNSUPPORTED The text mode number is not valid.
477 TerminalConOutSetMode (
478 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
483 TERMINAL_DEV
*TerminalDevice
;
486 // get Terminal device data structure pointer.
488 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
490 if (ModeNumber
>= (UINTN
) This
->Mode
->MaxMode
) {
491 return EFI_UNSUPPORTED
;
495 // Set the current mode
497 This
->Mode
->Mode
= (INT32
) ModeNumber
;
499 This
->ClearScreen (This
);
501 TerminalDevice
->OutputEscChar
= TRUE
;
502 Status
= This
->OutputString (This
, mSetModeString
);
503 TerminalDevice
->OutputEscChar
= FALSE
;
505 if (EFI_ERROR (Status
)) {
506 return EFI_DEVICE_ERROR
;
509 This
->Mode
->Mode
= (INT32
) ModeNumber
;
511 Status
= This
->ClearScreen (This
);
512 if (EFI_ERROR (Status
)) {
513 return EFI_DEVICE_ERROR
;
522 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetAttribute().
524 @param This Indicates the calling context.
525 @param Attribute The attribute to set. Only bit0..6 are valid, all other bits
526 are undefined and must be zero.
528 @retval EFI_SUCCESS The requested attribute is set.
529 @retval EFI_DEVICE_ERROR The requested attribute cannot be set due to serial port error.
530 @retval EFI_UNSUPPORTED The attribute requested is not defined by EFI spec.
535 TerminalConOutSetAttribute (
536 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
540 UINT8 ForegroundControl
;
541 UINT8 BackgroundControl
;
546 TERMINAL_DEV
*TerminalDevice
;
552 // get Terminal device data structure pointer.
554 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
557 // only the bit0..6 of the Attribute is valid
559 if ((Attribute
| 0x7f) != 0x7f) {
560 return EFI_UNSUPPORTED
;
564 // Skip outputting the command string for the same attribute
565 // It improves the terminal performance significantly
567 if (This
->Mode
->Attribute
== (INT32
) Attribute
) {
572 // convert Attribute value to terminal emulator
573 // understandable foreground color
575 switch (Attribute
& 0x07) {
578 ForegroundControl
= 30;
582 ForegroundControl
= 34;
586 ForegroundControl
= 32;
590 ForegroundControl
= 36;
594 ForegroundControl
= 31;
598 ForegroundControl
= 35;
602 ForegroundControl
= 33;
608 ForegroundControl
= 37;
613 // bit4 of the Attribute indicates bright control
614 // of terminal emulator.
616 BrightControl
= (UINT8
) ((Attribute
>> 3) & 1);
619 // convert Attribute value to terminal emulator
620 // understandable background color.
622 switch ((Attribute
>> 4) & 0x07) {
625 BackgroundControl
= 40;
629 BackgroundControl
= 44;
633 BackgroundControl
= 42;
637 BackgroundControl
= 46;
641 BackgroundControl
= 41;
645 BackgroundControl
= 45;
649 BackgroundControl
= 43;
655 BackgroundControl
= 47;
659 // terminal emulator's control sequence to set attributes
661 mSetAttributeString
[BRIGHT_CONTROL_OFFSET
] = (CHAR16
) ('0' + BrightControl
);
662 mSetAttributeString
[FOREGROUND_CONTROL_OFFSET
+ 0] = (CHAR16
) ('0' + (ForegroundControl
/ 10));
663 mSetAttributeString
[FOREGROUND_CONTROL_OFFSET
+ 1] = (CHAR16
) ('0' + (ForegroundControl
% 10));
664 mSetAttributeString
[BACKGROUND_CONTROL_OFFSET
+ 0] = (CHAR16
) ('0' + (BackgroundControl
/ 10));
665 mSetAttributeString
[BACKGROUND_CONTROL_OFFSET
+ 1] = (CHAR16
) ('0' + (BackgroundControl
% 10));
668 // save current column and row
669 // for future scrolling back use.
671 SavedColumn
= This
->Mode
->CursorColumn
;
672 SavedRow
= This
->Mode
->CursorRow
;
674 TerminalDevice
->OutputEscChar
= TRUE
;
675 Status
= This
->OutputString (This
, mSetAttributeString
);
676 TerminalDevice
->OutputEscChar
= FALSE
;
678 if (EFI_ERROR (Status
)) {
679 return EFI_DEVICE_ERROR
;
682 // scroll back to saved cursor position.
684 This
->Mode
->CursorColumn
= SavedColumn
;
685 This
->Mode
->CursorRow
= SavedRow
;
687 This
->Mode
->Attribute
= (INT32
) Attribute
;
695 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.ClearScreen().
696 It clears the ANSI terminal's display to the
697 currently selected background color.
699 @param This Indicates the calling context.
701 @retval EFI_SUCCESS The operation completed successfully.
702 @retval EFI_DEVICE_ERROR The terminal screen cannot be cleared due to serial port error.
703 @retval EFI_UNSUPPORTED The terminal is not in a valid display mode.
708 TerminalConOutClearScreen (
709 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
713 TERMINAL_DEV
*TerminalDevice
;
715 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
718 // control sequence for clear screen request
720 TerminalDevice
->OutputEscChar
= TRUE
;
721 Status
= This
->OutputString (This
, mClearScreenString
);
722 TerminalDevice
->OutputEscChar
= FALSE
;
724 if (EFI_ERROR (Status
)) {
725 return EFI_DEVICE_ERROR
;
728 Status
= This
->SetCursorPosition (This
, 0, 0);
735 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetCursorPosition().
737 @param This Indicates the calling context.
738 @param Column The row to set cursor to.
739 @param Row The column to set cursor to.
741 @retval EFI_SUCCESS The operation completed successfully.
742 @retval EFI_DEVICE_ERROR The request fails due to serial port error.
743 @retval EFI_UNSUPPORTED The terminal is not in a valid text mode, or the cursor position
744 is invalid for current mode.
749 TerminalConOutSetCursorPosition (
750 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
755 EFI_SIMPLE_TEXT_OUTPUT_MODE
*Mode
;
759 TERMINAL_DEV
*TerminalDevice
;
762 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
770 // get geometry of current mode
772 Status
= This
->QueryMode (
778 if (EFI_ERROR (Status
)) {
779 return EFI_UNSUPPORTED
;
782 if (Column
>= MaxColumn
|| Row
>= MaxRow
) {
783 return EFI_UNSUPPORTED
;
786 // control sequence to move the cursor
788 // Optimize cursor motion control sequences for TtyTerm. Move
789 // within the current line if possible, and don't output anyting if
790 // it isn't necessary.
792 if (TerminalDevice
->TerminalType
== TTYTERMTYPE
&&
793 (UINTN
)Mode
->CursorRow
== Row
) {
794 if ((UINTN
)Mode
->CursorColumn
> Column
) {
795 mCursorBackwardString
[FW_BACK_OFFSET
+ 0] = (CHAR16
) ('0' + ((Mode
->CursorColumn
- Column
) / 10));
796 mCursorBackwardString
[FW_BACK_OFFSET
+ 1] = (CHAR16
) ('0' + ((Mode
->CursorColumn
- Column
) % 10));
797 String
= mCursorBackwardString
;
799 else if (Column
> (UINTN
)Mode
->CursorColumn
) {
800 mCursorForwardString
[FW_BACK_OFFSET
+ 0] = (CHAR16
) ('0' + ((Column
- Mode
->CursorColumn
) / 10));
801 mCursorForwardString
[FW_BACK_OFFSET
+ 1] = (CHAR16
) ('0' + ((Column
- Mode
->CursorColumn
) % 10));
802 String
= mCursorForwardString
;
805 String
= L
""; // No cursor motion necessary
809 mSetCursorPositionString
[ROW_OFFSET
+ 0] = (CHAR16
) ('0' + ((Row
+ 1) / 10));
810 mSetCursorPositionString
[ROW_OFFSET
+ 1] = (CHAR16
) ('0' + ((Row
+ 1) % 10));
811 mSetCursorPositionString
[COLUMN_OFFSET
+ 0] = (CHAR16
) ('0' + ((Column
+ 1) / 10));
812 mSetCursorPositionString
[COLUMN_OFFSET
+ 1] = (CHAR16
) ('0' + ((Column
+ 1) % 10));
813 String
= mSetCursorPositionString
;
816 TerminalDevice
->OutputEscChar
= TRUE
;
817 Status
= This
->OutputString (This
, String
);
818 TerminalDevice
->OutputEscChar
= FALSE
;
820 if (EFI_ERROR (Status
)) {
821 return EFI_DEVICE_ERROR
;
824 // update current cursor position
825 // in the Mode data structure.
827 Mode
->CursorColumn
= (INT32
) Column
;
828 Mode
->CursorRow
= (INT32
) Row
;
835 Implements SIMPLE_TEXT_OUTPUT.EnableCursor().
837 In this driver, the cursor cannot be hidden.
839 @param This Indicates the calling context.
840 @param Visible If TRUE, the cursor is set to be visible,
841 If FALSE, the cursor is set to be invisible.
843 @retval EFI_SUCCESS The request is valid.
844 @retval EFI_UNSUPPORTED The terminal does not support cursor hidden.
849 TerminalConOutEnableCursor (
850 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
855 return EFI_UNSUPPORTED
;
863 Detects if a Unicode char is for Box Drawing text graphics.
865 @param Graphic Unicode char to test.
866 @param PcAnsi Optional pointer to return PCANSI equivalent of
868 @param Ascii Optional pointer to return ASCII equivalent of
871 @retval TRUE If Graphic is a supported Unicode Box Drawing character.
875 TerminalIsValidTextGraphics (
877 OUT CHAR8
*PcAnsi
, OPTIONAL
878 OUT CHAR8
*Ascii OPTIONAL
881 UNICODE_TO_CHAR
*Table
;
883 if ((((Graphic
& 0xff00) != 0x2500) && ((Graphic
& 0xff00) != 0x2100))) {
885 // Unicode drawing code charts are all in the 0x25xx range,
891 for (Table
= UnicodeToPcAnsiOrAscii
; Table
->Unicode
!= 0x0000; Table
++) {
892 if (Graphic
== Table
->Unicode
) {
893 if (PcAnsi
!= NULL
) {
894 *PcAnsi
= Table
->PcAnsi
;
898 *Ascii
= Table
->Ascii
;
909 Detects if a valid ASCII char.
911 @param Ascii An ASCII character.
913 @retval TRUE If it is a valid ASCII character.
914 @retval FALSE If it is not a valid ASCII character.
918 TerminalIsValidAscii (
923 // valid ascii code lies in the extent of 0x20 ~ 0x7f
925 if ((Ascii
>= 0x20) && (Ascii
<= 0x7f)) {
933 Detects if a valid EFI control character.
935 @param CharC An input EFI Control character.
937 @retval TRUE If it is a valid EFI control character.
938 @retval FALSE If it is not a valid EFI control character.
942 TerminalIsValidEfiCntlChar (
947 // only support four control characters.
949 if (CharC
== CHAR_NULL
||
950 CharC
== CHAR_BACKSPACE
||
951 CharC
== CHAR_LINEFEED
||
952 CharC
== CHAR_CARRIAGE_RETURN
||