2 Implementation for EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL protocol.
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 Copyright (C) 2016 Silicon Graphics, Inc. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
13 // This list is used to define the valid extend chars.
14 // It also provides a mapping from Unicode to PCANSI or
15 // ASCII. The ASCII mapping we just made up.
18 UNICODE_TO_CHAR UnicodeToPcAnsiOrAscii
[] = {
19 { BOXDRAW_HORIZONTAL
, 0xc4, L
'-' },
20 { BOXDRAW_VERTICAL
, 0xb3, L
'|' },
21 { BOXDRAW_DOWN_RIGHT
, 0xda, L
'/' },
22 { BOXDRAW_DOWN_LEFT
, 0xbf, L
'\\' },
23 { BOXDRAW_UP_RIGHT
, 0xc0, L
'\\' },
24 { BOXDRAW_UP_LEFT
, 0xd9, L
'/' },
25 { BOXDRAW_VERTICAL_RIGHT
, 0xc3, L
'|' },
26 { BOXDRAW_VERTICAL_LEFT
, 0xb4, L
'|' },
27 { BOXDRAW_DOWN_HORIZONTAL
, 0xc2, L
'+' },
28 { BOXDRAW_UP_HORIZONTAL
, 0xc1, L
'+' },
29 { BOXDRAW_VERTICAL_HORIZONTAL
, 0xc5, L
'+' },
30 { BOXDRAW_DOUBLE_HORIZONTAL
, 0xcd, L
'-' },
31 { BOXDRAW_DOUBLE_VERTICAL
, 0xba, L
'|' },
32 { BOXDRAW_DOWN_RIGHT_DOUBLE
, 0xd5, L
'/' },
33 { BOXDRAW_DOWN_DOUBLE_RIGHT
, 0xd6, L
'/' },
34 { BOXDRAW_DOUBLE_DOWN_RIGHT
, 0xc9, L
'/' },
35 { BOXDRAW_DOWN_LEFT_DOUBLE
, 0xb8, L
'\\' },
36 { BOXDRAW_DOWN_DOUBLE_LEFT
, 0xb7, L
'\\' },
37 { BOXDRAW_DOUBLE_DOWN_LEFT
, 0xbb, L
'\\' },
38 { BOXDRAW_UP_RIGHT_DOUBLE
, 0xd4, L
'\\' },
39 { BOXDRAW_UP_DOUBLE_RIGHT
, 0xd3, L
'\\' },
40 { BOXDRAW_DOUBLE_UP_RIGHT
, 0xc8, L
'\\' },
41 { BOXDRAW_UP_LEFT_DOUBLE
, 0xbe, L
'/' },
42 { BOXDRAW_UP_DOUBLE_LEFT
, 0xbd, L
'/' },
43 { BOXDRAW_DOUBLE_UP_LEFT
, 0xbc, L
'/' },
44 { BOXDRAW_VERTICAL_RIGHT_DOUBLE
, 0xc6, L
'|' },
45 { BOXDRAW_VERTICAL_DOUBLE_RIGHT
, 0xc7, L
'|' },
46 { BOXDRAW_DOUBLE_VERTICAL_RIGHT
, 0xcc, L
'|' },
47 { BOXDRAW_VERTICAL_LEFT_DOUBLE
, 0xb5, L
'|' },
48 { BOXDRAW_VERTICAL_DOUBLE_LEFT
, 0xb6, L
'|' },
49 { BOXDRAW_DOUBLE_VERTICAL_LEFT
, 0xb9, L
'|' },
50 { BOXDRAW_DOWN_HORIZONTAL_DOUBLE
, 0xd1, L
'+' },
51 { BOXDRAW_DOWN_DOUBLE_HORIZONTAL
, 0xd2, L
'+' },
52 { BOXDRAW_DOUBLE_DOWN_HORIZONTAL
, 0xcb, L
'+' },
53 { BOXDRAW_UP_HORIZONTAL_DOUBLE
, 0xcf, L
'+' },
54 { BOXDRAW_UP_DOUBLE_HORIZONTAL
, 0xd0, L
'+' },
55 { BOXDRAW_DOUBLE_UP_HORIZONTAL
, 0xca, L
'+' },
56 { BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE
, 0xd8, L
'+' },
57 { BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL
, 0xd7, L
'+' },
58 { BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL
, 0xce, L
'+' },
60 { BLOCKELEMENT_FULL_BLOCK
, 0xdb, L
'*' },
61 { BLOCKELEMENT_LIGHT_SHADE
, 0xb0, L
'+' },
63 { GEOMETRICSHAPE_UP_TRIANGLE
, '^', L
'^' },
64 { GEOMETRICSHAPE_RIGHT_TRIANGLE
, '>', L
'>' },
65 { GEOMETRICSHAPE_DOWN_TRIANGLE
, 'v', L
'v' },
66 { GEOMETRICSHAPE_LEFT_TRIANGLE
, '<', L
'<' },
68 { ARROW_LEFT
, '<', L
'<' },
69 { ARROW_UP
, '^', L
'^' },
70 { ARROW_RIGHT
, '>', L
'>' },
71 { ARROW_DOWN
, 'v', L
'v' },
73 { 0x0000, 0x00, L
'\0' }
76 CHAR16 mSetModeString
[] = { ESC
, '[', '=', '3', 'h', 0 };
77 CHAR16 mSetAttributeString
[] = { ESC
, '[', '0', 'm', ESC
, '[', '4', '0', 'm', ESC
, '[', '4', '0', 'm', 0 };
78 CHAR16 mClearScreenString
[] = { ESC
, '[', '2', 'J', 0 };
79 CHAR16 mSetCursorPositionString
[] = { ESC
, '[', '0', '0', ';', '0', '0', 'H', 0 };
80 CHAR16 mCursorForwardString
[] = { ESC
, '[', '0', '0', 'C', 0 };
81 CHAR16 mCursorBackwardString
[] = { ESC
, '[', '0', '0', 'D', 0 };
84 // Body of the ConOut functions
88 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset().
90 If ExtendeVerification is TRUE, then perform dependent serial device reset,
91 and set display mode to mode 0.
92 If ExtendedVerification is FALSE, only set display mode to mode 0.
94 @param This Indicates the calling context.
95 @param ExtendedVerification Indicates that the driver may perform a more
96 exhaustive verification operation of the device
99 @retval EFI_SUCCESS The reset operation succeeds.
100 @retval EFI_DEVICE_ERROR The terminal is not functioning correctly or the serial port reset fails.
105 TerminalConOutReset (
106 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
107 IN BOOLEAN ExtendedVerification
111 TERMINAL_DEV
*TerminalDevice
;
113 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
116 // Perform a more exhaustive reset by resetting the serial port.
118 if (ExtendedVerification
) {
120 // Report progress code here
122 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
124 (EFI_PERIPHERAL_REMOTE_CONSOLE
| EFI_P_PC_RESET
),
125 TerminalDevice
->DevicePath
128 Status
= TerminalDevice
->SerialIo
->Reset (TerminalDevice
->SerialIo
);
129 if (EFI_ERROR (Status
)) {
131 // Report error code here
133 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
134 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
135 (EFI_PERIPHERAL_REMOTE_CONSOLE
| EFI_P_EC_CONTROLLER_ERROR
),
136 TerminalDevice
->DevicePath
143 This
->SetAttribute (This
, EFI_TEXT_ATTR (This
->Mode
->Attribute
& 0x0F, EFI_BLACK
));
145 Status
= This
->SetMode (This
, 0);
151 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString().
153 The Unicode string will be converted to terminal expressible data stream
154 and send to terminal via serial port.
156 @param This Indicates the calling context.
157 @param WString The Null-terminated Unicode string to be displayed
158 on the terminal screen.
160 @retval EFI_SUCCESS The string is output successfully.
161 @retval EFI_DEVICE_ERROR The serial port fails to send the string out.
162 @retval EFI_WARN_UNKNOWN_GLYPH Indicates that some of the characters in the Unicode string could not
163 be rendered and are skipped.
164 @retval EFI_UNSUPPORTED If current display mode is out of range.
169 TerminalConOutOutputString (
170 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
174 TERMINAL_DEV
*TerminalDevice
;
175 EFI_SIMPLE_TEXT_OUTPUT_MODE
*Mode
;
186 // flag used to indicate whether condition happens which will cause
187 // return EFI_WARN_UNKNOWN_GLYPH
196 // get Terminal device data structure pointer.
198 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
201 // Get current display mode
205 if (Mode
->Mode
>= Mode
->MaxMode
) {
206 return EFI_UNSUPPORTED
;
216 for ( ; *WString
!= CHAR_NULL
; WString
++) {
217 switch (TerminalDevice
->TerminalType
) {
218 case TerminalTypePcAnsi
:
219 case TerminalTypeVt100
:
220 case TerminalTypeVt100Plus
:
221 case TerminalTypeTtyTerm
:
222 case TerminalTypeLinux
:
223 case TerminalTypeXtermR6
:
224 case TerminalTypeVt400
:
225 case TerminalTypeSCO
:
227 if (!TerminalIsValidTextGraphics (*WString
, &GraphicChar
, &AsciiChar
)) {
229 // If it's not a graphic character convert Unicode to ASCII.
231 GraphicChar
= (CHAR8
)*WString
;
233 if (!(TerminalIsValidAscii (GraphicChar
) || TerminalIsValidEfiCntlChar (GraphicChar
))) {
235 // when this driver use the OutputString to output control string,
236 // TerminalDevice->OutputEscChar is set to let the Esc char
237 // to be output to the terminal emulation software.
239 if ((GraphicChar
== 27) && TerminalDevice
->OutputEscChar
) {
247 AsciiChar
= GraphicChar
;
250 if (TerminalDevice
->TerminalType
!= TerminalTypePcAnsi
) {
251 GraphicChar
= AsciiChar
;
256 Status
= TerminalDevice
->SerialIo
->Write (
257 TerminalDevice
->SerialIo
,
262 if (EFI_ERROR (Status
)) {
268 case TerminalTypeVtUtf8
:
269 UnicodeToUtf8 (*WString
, &Utf8Char
, &ValidBytes
);
271 Status
= TerminalDevice
->SerialIo
->Write (
272 TerminalDevice
->SerialIo
,
276 if (EFI_ERROR (Status
)) {
284 // Update cursor position.
288 if (Mode
->CursorColumn
> 0) {
289 Mode
->CursorColumn
--;
295 if (Mode
->CursorRow
< (INT32
)(MaxRow
- 1)) {
301 case CHAR_CARRIAGE_RETURN
:
302 Mode
->CursorColumn
= 0;
306 if (Mode
->CursorColumn
< (INT32
)(MaxColumn
- 1)) {
307 Mode
->CursorColumn
++;
309 Mode
->CursorColumn
= 0;
310 if (Mode
->CursorRow
< (INT32
)(MaxRow
- 1)) {
314 if ((TerminalDevice
->TerminalType
== TerminalTypeTtyTerm
) &&
315 !TerminalDevice
->OutputEscChar
)
318 // We've written the last character on the line. The
319 // terminal doesn't actually wrap its cursor until we print
320 // the next character, but the driver thinks it has wrapped
321 // already. Print CR LF to synchronize the terminal with
322 // the driver, but only if we're not in the middle of
323 // printing an escape sequence.
328 Length
= sizeof (CrLfStr
);
330 Status
= TerminalDevice
->SerialIo
->Write (
331 TerminalDevice
->SerialIo
,
336 if (EFI_ERROR (Status
)) {
347 return EFI_WARN_UNKNOWN_GLYPH
;
353 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
354 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
355 (EFI_PERIPHERAL_REMOTE_CONSOLE
| EFI_P_EC_OUTPUT_ERROR
),
356 TerminalDevice
->DevicePath
359 return EFI_DEVICE_ERROR
;
363 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.TestString().
365 If one of the characters in the *Wstring is
366 neither valid Unicode drawing characters,
367 not ASCII code, then this function will return
370 @param This Indicates the calling context.
371 @param WString The Null-terminated Unicode string to be tested.
373 @retval EFI_SUCCESS The terminal is capable of rendering the output string.
374 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string cannot be rendered.
379 TerminalConOutTestString (
380 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
384 TERMINAL_DEV
*TerminalDevice
;
388 // get Terminal device data structure pointer.
390 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
392 switch (TerminalDevice
->TerminalType
) {
393 case TerminalTypePcAnsi
:
394 case TerminalTypeVt100
:
395 case TerminalTypeVt100Plus
:
396 case TerminalTypeTtyTerm
:
397 Status
= AnsiTestString (TerminalDevice
, WString
);
400 case TerminalTypeVtUtf8
:
401 Status
= VTUTF8TestString (TerminalDevice
, WString
);
405 Status
= EFI_UNSUPPORTED
;
413 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode().
415 It returns information for an available text mode
416 that the terminal supports.
418 @param This Indicates the calling context.
419 @param ModeNumber The mode number to return information on.
420 @param Columns The returned columns of the requested mode.
421 @param Rows The returned rows of the requested mode.
423 @retval EFI_SUCCESS The requested mode information is returned.
424 @retval EFI_UNSUPPORTED The mode number is not valid.
429 TerminalConOutQueryMode (
430 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
436 TERMINAL_DEV
*TerminalDevice
;
438 if (ModeNumber
>= (UINTN
)This
->Mode
->MaxMode
) {
439 return EFI_UNSUPPORTED
;
443 // Get Terminal device data structure pointer.
445 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
446 *Columns
= TerminalDevice
->TerminalConsoleModeData
[ModeNumber
].Columns
;
447 *Rows
= TerminalDevice
->TerminalConsoleModeData
[ModeNumber
].Rows
;
453 Implements EFI_SIMPLE_TEXT_OUT.SetMode().
455 Set the terminal to a specified display mode.
456 In this driver, we only support mode 0.
458 @param This Indicates the calling context.
459 @param ModeNumber The text mode to set.
461 @retval EFI_SUCCESS The requested text mode is set.
462 @retval EFI_DEVICE_ERROR The requested text mode cannot be set
463 because of serial device error.
464 @retval EFI_UNSUPPORTED The text mode number is not valid.
469 TerminalConOutSetMode (
470 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
475 TERMINAL_DEV
*TerminalDevice
;
478 // get Terminal device data structure pointer.
480 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
482 if (ModeNumber
>= (UINTN
)This
->Mode
->MaxMode
) {
483 return EFI_UNSUPPORTED
;
487 // Set the current mode
489 This
->Mode
->Mode
= (INT32
)ModeNumber
;
491 This
->ClearScreen (This
);
493 TerminalDevice
->OutputEscChar
= TRUE
;
494 Status
= This
->OutputString (This
, mSetModeString
);
495 TerminalDevice
->OutputEscChar
= FALSE
;
497 if (EFI_ERROR (Status
)) {
498 return EFI_DEVICE_ERROR
;
501 This
->Mode
->Mode
= (INT32
)ModeNumber
;
503 Status
= This
->ClearScreen (This
);
504 if (EFI_ERROR (Status
)) {
505 return EFI_DEVICE_ERROR
;
512 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetAttribute().
514 @param This Indicates the calling context.
515 @param Attribute The attribute to set. Only bit0..6 are valid, all other bits
516 are undefined and must be zero.
518 @retval EFI_SUCCESS The requested attribute is set.
519 @retval EFI_DEVICE_ERROR The requested attribute cannot be set due to serial port error.
520 @retval EFI_UNSUPPORTED The attribute requested is not defined by EFI spec.
525 TerminalConOutSetAttribute (
526 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
530 UINT8 ForegroundControl
;
531 UINT8 BackgroundControl
;
536 TERMINAL_DEV
*TerminalDevice
;
542 // get Terminal device data structure pointer.
544 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
547 // only the bit0..6 of the Attribute is valid
549 if ((Attribute
| 0x7f) != 0x7f) {
550 return EFI_UNSUPPORTED
;
554 // Skip outputting the command string for the same attribute
555 // It improves the terminal performance significantly
557 if (This
->Mode
->Attribute
== (INT32
)Attribute
) {
562 // convert Attribute value to terminal emulator
563 // understandable foreground color
565 switch (Attribute
& 0x07) {
567 ForegroundControl
= 30;
571 ForegroundControl
= 34;
575 ForegroundControl
= 32;
579 ForegroundControl
= 36;
583 ForegroundControl
= 31;
587 ForegroundControl
= 35;
591 ForegroundControl
= 33;
597 ForegroundControl
= 37;
602 // bit4 of the Attribute indicates bright control
603 // of terminal emulator.
605 BrightControl
= (UINT8
)((Attribute
>> 3) & 1);
608 // convert Attribute value to terminal emulator
609 // understandable background color.
611 switch ((Attribute
>> 4) & 0x07) {
613 BackgroundControl
= 40;
617 BackgroundControl
= 44;
621 BackgroundControl
= 42;
625 BackgroundControl
= 46;
629 BackgroundControl
= 41;
633 BackgroundControl
= 45;
637 BackgroundControl
= 43;
643 BackgroundControl
= 47;
648 // terminal emulator's control sequence to set attributes
650 mSetAttributeString
[BRIGHT_CONTROL_OFFSET
] = (CHAR16
)('0' + BrightControl
);
651 mSetAttributeString
[FOREGROUND_CONTROL_OFFSET
+ 0] = (CHAR16
)('0' + (ForegroundControl
/ 10));
652 mSetAttributeString
[FOREGROUND_CONTROL_OFFSET
+ 1] = (CHAR16
)('0' + (ForegroundControl
% 10));
653 mSetAttributeString
[BACKGROUND_CONTROL_OFFSET
+ 0] = (CHAR16
)('0' + (BackgroundControl
/ 10));
654 mSetAttributeString
[BACKGROUND_CONTROL_OFFSET
+ 1] = (CHAR16
)('0' + (BackgroundControl
% 10));
657 // save current column and row
658 // for future scrolling back use.
660 SavedColumn
= This
->Mode
->CursorColumn
;
661 SavedRow
= This
->Mode
->CursorRow
;
663 TerminalDevice
->OutputEscChar
= TRUE
;
664 Status
= This
->OutputString (This
, mSetAttributeString
);
665 TerminalDevice
->OutputEscChar
= FALSE
;
667 if (EFI_ERROR (Status
)) {
668 return EFI_DEVICE_ERROR
;
672 // scroll back to saved cursor position.
674 This
->Mode
->CursorColumn
= SavedColumn
;
675 This
->Mode
->CursorRow
= SavedRow
;
677 This
->Mode
->Attribute
= (INT32
)Attribute
;
683 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.ClearScreen().
684 It clears the ANSI terminal's display to the
685 currently selected background color.
687 @param This Indicates the calling context.
689 @retval EFI_SUCCESS The operation completed successfully.
690 @retval EFI_DEVICE_ERROR The terminal screen cannot be cleared due to serial port error.
691 @retval EFI_UNSUPPORTED The terminal is not in a valid display mode.
696 TerminalConOutClearScreen (
697 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
701 TERMINAL_DEV
*TerminalDevice
;
703 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
706 // control sequence for clear screen request
708 TerminalDevice
->OutputEscChar
= TRUE
;
709 Status
= This
->OutputString (This
, mClearScreenString
);
710 TerminalDevice
->OutputEscChar
= FALSE
;
712 if (EFI_ERROR (Status
)) {
713 return EFI_DEVICE_ERROR
;
716 Status
= This
->SetCursorPosition (This
, 0, 0);
722 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetCursorPosition().
724 @param This Indicates the calling context.
725 @param Column The row to set cursor to.
726 @param Row The column to set cursor to.
728 @retval EFI_SUCCESS The operation completed successfully.
729 @retval EFI_DEVICE_ERROR The request fails due to serial port error.
730 @retval EFI_UNSUPPORTED The terminal is not in a valid text mode, or the cursor position
731 is invalid for current mode.
736 TerminalConOutSetCursorPosition (
737 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
742 EFI_SIMPLE_TEXT_OUTPUT_MODE
*Mode
;
746 TERMINAL_DEV
*TerminalDevice
;
749 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
757 // get geometry of current mode
759 Status
= This
->QueryMode (
765 if (EFI_ERROR (Status
)) {
766 return EFI_UNSUPPORTED
;
769 if ((Column
>= MaxColumn
) || (Row
>= MaxRow
)) {
770 return EFI_UNSUPPORTED
;
774 // control sequence to move the cursor
776 // Optimize cursor motion control sequences for TtyTerm. Move
777 // within the current line if possible, and don't output anyting if
778 // it isn't necessary.
780 if ((TerminalDevice
->TerminalType
== TerminalTypeTtyTerm
) &&
781 ((UINTN
)Mode
->CursorRow
== Row
))
783 if ((UINTN
)Mode
->CursorColumn
> Column
) {
784 mCursorBackwardString
[FW_BACK_OFFSET
+ 0] = (CHAR16
)('0' + ((Mode
->CursorColumn
- Column
) / 10));
785 mCursorBackwardString
[FW_BACK_OFFSET
+ 1] = (CHAR16
)('0' + ((Mode
->CursorColumn
- Column
) % 10));
786 String
= mCursorBackwardString
;
787 } else if (Column
> (UINTN
)Mode
->CursorColumn
) {
788 mCursorForwardString
[FW_BACK_OFFSET
+ 0] = (CHAR16
)('0' + ((Column
- Mode
->CursorColumn
) / 10));
789 mCursorForwardString
[FW_BACK_OFFSET
+ 1] = (CHAR16
)('0' + ((Column
- Mode
->CursorColumn
) % 10));
790 String
= mCursorForwardString
;
792 String
= L
""; // No cursor motion necessary
795 mSetCursorPositionString
[ROW_OFFSET
+ 0] = (CHAR16
)('0' + ((Row
+ 1) / 10));
796 mSetCursorPositionString
[ROW_OFFSET
+ 1] = (CHAR16
)('0' + ((Row
+ 1) % 10));
797 mSetCursorPositionString
[COLUMN_OFFSET
+ 0] = (CHAR16
)('0' + ((Column
+ 1) / 10));
798 mSetCursorPositionString
[COLUMN_OFFSET
+ 1] = (CHAR16
)('0' + ((Column
+ 1) % 10));
799 String
= mSetCursorPositionString
;
802 TerminalDevice
->OutputEscChar
= TRUE
;
803 Status
= This
->OutputString (This
, String
);
804 TerminalDevice
->OutputEscChar
= FALSE
;
806 if (EFI_ERROR (Status
)) {
807 return EFI_DEVICE_ERROR
;
811 // update current cursor position
812 // in the Mode data structure.
814 Mode
->CursorColumn
= (INT32
)Column
;
815 Mode
->CursorRow
= (INT32
)Row
;
821 Implements SIMPLE_TEXT_OUTPUT.EnableCursor().
823 In this driver, the cursor cannot be hidden.
825 @param This Indicates the calling context.
826 @param Visible If TRUE, the cursor is set to be visible,
827 If FALSE, the cursor is set to be invisible.
829 @retval EFI_SUCCESS The request is valid.
830 @retval EFI_UNSUPPORTED The terminal does not support cursor hidden.
835 TerminalConOutEnableCursor (
836 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
841 return EFI_UNSUPPORTED
;
848 Detects if a Unicode char is for Box Drawing text graphics.
850 @param Graphic Unicode char to test.
851 @param PcAnsi Optional pointer to return PCANSI equivalent of
853 @param Ascii Optional pointer to return ASCII equivalent of
856 @retval TRUE If Graphic is a supported Unicode Box Drawing character.
860 TerminalIsValidTextGraphics (
862 OUT CHAR8
*PcAnsi OPTIONAL
,
863 OUT CHAR8
*Ascii OPTIONAL
866 UNICODE_TO_CHAR
*Table
;
868 if ((((Graphic
& 0xff00) != 0x2500) && ((Graphic
& 0xff00) != 0x2100))) {
870 // Unicode drawing code charts are all in the 0x25xx range,
876 for (Table
= UnicodeToPcAnsiOrAscii
; Table
->Unicode
!= 0x0000; Table
++) {
877 if (Graphic
== Table
->Unicode
) {
878 if (PcAnsi
!= NULL
) {
879 *PcAnsi
= Table
->PcAnsi
;
883 *Ascii
= Table
->Ascii
;
894 Detects if a valid ASCII char.
896 @param Ascii An ASCII character.
898 @retval TRUE If it is a valid ASCII character.
899 @retval FALSE If it is not a valid ASCII character.
903 TerminalIsValidAscii (
908 // valid ascii code lies in the extent of 0x20 ~ 0x7f
910 if ((Ascii
>= 0x20) && (Ascii
<= 0x7f)) {
918 Detects if a valid EFI control character.
920 @param CharC An input EFI Control character.
922 @retval TRUE If it is a valid EFI control character.
923 @retval FALSE If it is not a valid EFI control character.
927 TerminalIsValidEfiCntlChar (
932 // only support four control characters.
934 if ((CharC
== CHAR_NULL
) ||
935 (CharC
== CHAR_BACKSPACE
) ||
936 (CharC
== CHAR_LINEFEED
) ||
937 (CharC
== CHAR_CARRIAGE_RETURN
) ||