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);
152 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString().
154 The Unicode string will be converted to terminal expressible data stream
155 and send to terminal via serial port.
157 @param This Indicates the calling context.
158 @param WString The Null-terminated Unicode string to be displayed
159 on the terminal screen.
161 @retval EFI_SUCCESS The string is output successfully.
162 @retval EFI_DEVICE_ERROR The serial port fails to send the string out.
163 @retval EFI_WARN_UNKNOWN_GLYPH Indicates that some of the characters in the Unicode string could not
164 be rendered and are skipped.
165 @retval EFI_UNSUPPORTED If current display mode is out of range.
170 TerminalConOutOutputString (
171 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
175 TERMINAL_DEV
*TerminalDevice
;
176 EFI_SIMPLE_TEXT_OUTPUT_MODE
*Mode
;
187 // flag used to indicate whether condition happens which will cause
188 // return EFI_WARN_UNKNOWN_GLYPH
197 // get Terminal device data structure pointer.
199 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
202 // Get current display mode
206 if (Mode
->Mode
>= Mode
->MaxMode
) {
207 return EFI_UNSUPPORTED
;
217 for (; *WString
!= CHAR_NULL
; WString
++) {
219 switch (TerminalDevice
->TerminalType
) {
221 case TerminalTypePcAnsi
:
222 case TerminalTypeVt100
:
223 case TerminalTypeVt100Plus
:
224 case TerminalTypeTtyTerm
:
226 if (!TerminalIsValidTextGraphics (*WString
, &GraphicChar
, &AsciiChar
)) {
228 // If it's not a graphic character convert Unicode to ASCII.
230 GraphicChar
= (CHAR8
) *WString
;
232 if (!(TerminalIsValidAscii (GraphicChar
) || TerminalIsValidEfiCntlChar (GraphicChar
))) {
234 // when this driver use the OutputString to output control string,
235 // TerminalDevice->OutputEscChar is set to let the Esc char
236 // to be output to the terminal emulation software.
238 if ((GraphicChar
== 27) && TerminalDevice
->OutputEscChar
) {
246 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
)) {
282 // Update cursor position.
287 if (Mode
->CursorColumn
> 0) {
288 Mode
->CursorColumn
--;
293 if (Mode
->CursorRow
< (INT32
) (MaxRow
- 1)) {
298 case CHAR_CARRIAGE_RETURN
:
299 Mode
->CursorColumn
= 0;
303 if (Mode
->CursorColumn
< (INT32
) (MaxColumn
- 1)) {
305 Mode
->CursorColumn
++;
309 Mode
->CursorColumn
= 0;
310 if (Mode
->CursorRow
< (INT32
) (MaxRow
- 1)) {
314 if (TerminalDevice
->TerminalType
== TerminalTypeTtyTerm
&&
315 !TerminalDevice
->OutputEscChar
) {
317 // We've written the last character on the line. The
318 // terminal doesn't actually wrap its cursor until we print
319 // the next character, but the driver thinks it has wrapped
320 // already. Print CR LF to synchronize the terminal with
321 // the driver, but only if we're not in the middle of
322 // printing an escape sequence.
327 Length
= sizeof(CrLfStr
);
329 Status
= TerminalDevice
->SerialIo
->Write (
330 TerminalDevice
->SerialIo
,
335 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
;
364 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.TestString().
366 If one of the characters in the *Wstring is
367 neither valid Unicode drawing characters,
368 not ASCII code, then this function will return
371 @param This Indicates the calling context.
372 @param WString The Null-terminated Unicode string to be tested.
374 @retval EFI_SUCCESS The terminal is capable of rendering the output string.
375 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string cannot be rendered.
380 TerminalConOutTestString (
381 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
385 TERMINAL_DEV
*TerminalDevice
;
389 // get Terminal device data structure pointer.
391 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
393 switch (TerminalDevice
->TerminalType
) {
395 case TerminalTypePcAnsi
:
396 case TerminalTypeVt100
:
397 case TerminalTypeVt100Plus
:
398 case TerminalTypeTtyTerm
:
399 Status
= AnsiTestString (TerminalDevice
, WString
);
402 case TerminalTypeVtUtf8
:
403 Status
= VTUTF8TestString (TerminalDevice
, WString
);
407 Status
= EFI_UNSUPPORTED
;
416 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode().
418 It returns information for an available text mode
419 that the terminal supports.
421 @param This Indicates the calling context.
422 @param ModeNumber The mode number to return information on.
423 @param Columns The returned columns of the requested mode.
424 @param Rows The returned rows of the requested mode.
426 @retval EFI_SUCCESS The requested mode information is returned.
427 @retval EFI_UNSUPPORTED The mode number is not valid.
432 TerminalConOutQueryMode (
433 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
439 TERMINAL_DEV
*TerminalDevice
;
441 if (ModeNumber
>= (UINTN
) This
->Mode
->MaxMode
) {
442 return EFI_UNSUPPORTED
;
446 // Get Terminal device data structure pointer.
448 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
449 *Columns
= TerminalDevice
->TerminalConsoleModeData
[ModeNumber
].Columns
;
450 *Rows
= TerminalDevice
->TerminalConsoleModeData
[ModeNumber
].Rows
;
457 Implements EFI_SIMPLE_TEXT_OUT.SetMode().
459 Set the terminal to a specified display mode.
460 In this driver, we only support mode 0.
462 @param This Indicates the calling context.
463 @param ModeNumber The text mode to set.
465 @retval EFI_SUCCESS The requested text mode is set.
466 @retval EFI_DEVICE_ERROR The requested text mode cannot be set
467 because of serial device error.
468 @retval EFI_UNSUPPORTED The text mode number is not valid.
473 TerminalConOutSetMode (
474 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
479 TERMINAL_DEV
*TerminalDevice
;
482 // get Terminal device data structure pointer.
484 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
486 if (ModeNumber
>= (UINTN
) This
->Mode
->MaxMode
) {
487 return EFI_UNSUPPORTED
;
491 // Set the current mode
493 This
->Mode
->Mode
= (INT32
) ModeNumber
;
495 This
->ClearScreen (This
);
497 TerminalDevice
->OutputEscChar
= TRUE
;
498 Status
= This
->OutputString (This
, mSetModeString
);
499 TerminalDevice
->OutputEscChar
= FALSE
;
501 if (EFI_ERROR (Status
)) {
502 return EFI_DEVICE_ERROR
;
505 This
->Mode
->Mode
= (INT32
) ModeNumber
;
507 Status
= This
->ClearScreen (This
);
508 if (EFI_ERROR (Status
)) {
509 return EFI_DEVICE_ERROR
;
518 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetAttribute().
520 @param This Indicates the calling context.
521 @param Attribute The attribute to set. Only bit0..6 are valid, all other bits
522 are undefined and must be zero.
524 @retval EFI_SUCCESS The requested attribute is set.
525 @retval EFI_DEVICE_ERROR The requested attribute cannot be set due to serial port error.
526 @retval EFI_UNSUPPORTED The attribute requested is not defined by EFI spec.
531 TerminalConOutSetAttribute (
532 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
536 UINT8 ForegroundControl
;
537 UINT8 BackgroundControl
;
542 TERMINAL_DEV
*TerminalDevice
;
548 // get Terminal device data structure pointer.
550 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
553 // only the bit0..6 of the Attribute is valid
555 if ((Attribute
| 0x7f) != 0x7f) {
556 return EFI_UNSUPPORTED
;
560 // Skip outputting the command string for the same attribute
561 // It improves the terminal performance significantly
563 if (This
->Mode
->Attribute
== (INT32
) Attribute
) {
568 // convert Attribute value to terminal emulator
569 // understandable foreground color
571 switch (Attribute
& 0x07) {
574 ForegroundControl
= 30;
578 ForegroundControl
= 34;
582 ForegroundControl
= 32;
586 ForegroundControl
= 36;
590 ForegroundControl
= 31;
594 ForegroundControl
= 35;
598 ForegroundControl
= 33;
604 ForegroundControl
= 37;
609 // bit4 of the Attribute indicates bright control
610 // of terminal emulator.
612 BrightControl
= (UINT8
) ((Attribute
>> 3) & 1);
615 // convert Attribute value to terminal emulator
616 // understandable background color.
618 switch ((Attribute
>> 4) & 0x07) {
621 BackgroundControl
= 40;
625 BackgroundControl
= 44;
629 BackgroundControl
= 42;
633 BackgroundControl
= 46;
637 BackgroundControl
= 41;
641 BackgroundControl
= 45;
645 BackgroundControl
= 43;
651 BackgroundControl
= 47;
655 // terminal emulator's control sequence to set attributes
657 mSetAttributeString
[BRIGHT_CONTROL_OFFSET
] = (CHAR16
) ('0' + BrightControl
);
658 mSetAttributeString
[FOREGROUND_CONTROL_OFFSET
+ 0] = (CHAR16
) ('0' + (ForegroundControl
/ 10));
659 mSetAttributeString
[FOREGROUND_CONTROL_OFFSET
+ 1] = (CHAR16
) ('0' + (ForegroundControl
% 10));
660 mSetAttributeString
[BACKGROUND_CONTROL_OFFSET
+ 0] = (CHAR16
) ('0' + (BackgroundControl
/ 10));
661 mSetAttributeString
[BACKGROUND_CONTROL_OFFSET
+ 1] = (CHAR16
) ('0' + (BackgroundControl
% 10));
664 // save current column and row
665 // for future scrolling back use.
667 SavedColumn
= This
->Mode
->CursorColumn
;
668 SavedRow
= This
->Mode
->CursorRow
;
670 TerminalDevice
->OutputEscChar
= TRUE
;
671 Status
= This
->OutputString (This
, mSetAttributeString
);
672 TerminalDevice
->OutputEscChar
= FALSE
;
674 if (EFI_ERROR (Status
)) {
675 return EFI_DEVICE_ERROR
;
678 // scroll back to saved cursor position.
680 This
->Mode
->CursorColumn
= SavedColumn
;
681 This
->Mode
->CursorRow
= SavedRow
;
683 This
->Mode
->Attribute
= (INT32
) Attribute
;
691 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.ClearScreen().
692 It clears the ANSI terminal's display to the
693 currently selected background color.
695 @param This Indicates the calling context.
697 @retval EFI_SUCCESS The operation completed successfully.
698 @retval EFI_DEVICE_ERROR The terminal screen cannot be cleared due to serial port error.
699 @retval EFI_UNSUPPORTED The terminal is not in a valid display mode.
704 TerminalConOutClearScreen (
705 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
709 TERMINAL_DEV
*TerminalDevice
;
711 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
714 // control sequence for clear screen request
716 TerminalDevice
->OutputEscChar
= TRUE
;
717 Status
= This
->OutputString (This
, mClearScreenString
);
718 TerminalDevice
->OutputEscChar
= FALSE
;
720 if (EFI_ERROR (Status
)) {
721 return EFI_DEVICE_ERROR
;
724 Status
= This
->SetCursorPosition (This
, 0, 0);
731 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetCursorPosition().
733 @param This Indicates the calling context.
734 @param Column The row to set cursor to.
735 @param Row The column to set cursor to.
737 @retval EFI_SUCCESS The operation completed successfully.
738 @retval EFI_DEVICE_ERROR The request fails due to serial port error.
739 @retval EFI_UNSUPPORTED The terminal is not in a valid text mode, or the cursor position
740 is invalid for current mode.
745 TerminalConOutSetCursorPosition (
746 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
751 EFI_SIMPLE_TEXT_OUTPUT_MODE
*Mode
;
755 TERMINAL_DEV
*TerminalDevice
;
758 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
766 // get geometry of current mode
768 Status
= This
->QueryMode (
774 if (EFI_ERROR (Status
)) {
775 return EFI_UNSUPPORTED
;
778 if (Column
>= MaxColumn
|| Row
>= MaxRow
) {
779 return EFI_UNSUPPORTED
;
782 // control sequence to move the cursor
784 // Optimize cursor motion control sequences for TtyTerm. Move
785 // within the current line if possible, and don't output anyting if
786 // it isn't necessary.
788 if (TerminalDevice
->TerminalType
== TerminalTypeTtyTerm
&&
789 (UINTN
)Mode
->CursorRow
== Row
) {
790 if ((UINTN
)Mode
->CursorColumn
> Column
) {
791 mCursorBackwardString
[FW_BACK_OFFSET
+ 0] = (CHAR16
) ('0' + ((Mode
->CursorColumn
- Column
) / 10));
792 mCursorBackwardString
[FW_BACK_OFFSET
+ 1] = (CHAR16
) ('0' + ((Mode
->CursorColumn
- Column
) % 10));
793 String
= mCursorBackwardString
;
795 else if (Column
> (UINTN
)Mode
->CursorColumn
) {
796 mCursorForwardString
[FW_BACK_OFFSET
+ 0] = (CHAR16
) ('0' + ((Column
- Mode
->CursorColumn
) / 10));
797 mCursorForwardString
[FW_BACK_OFFSET
+ 1] = (CHAR16
) ('0' + ((Column
- Mode
->CursorColumn
) % 10));
798 String
= mCursorForwardString
;
801 String
= L
""; // No cursor motion necessary
805 mSetCursorPositionString
[ROW_OFFSET
+ 0] = (CHAR16
) ('0' + ((Row
+ 1) / 10));
806 mSetCursorPositionString
[ROW_OFFSET
+ 1] = (CHAR16
) ('0' + ((Row
+ 1) % 10));
807 mSetCursorPositionString
[COLUMN_OFFSET
+ 0] = (CHAR16
) ('0' + ((Column
+ 1) / 10));
808 mSetCursorPositionString
[COLUMN_OFFSET
+ 1] = (CHAR16
) ('0' + ((Column
+ 1) % 10));
809 String
= mSetCursorPositionString
;
812 TerminalDevice
->OutputEscChar
= TRUE
;
813 Status
= This
->OutputString (This
, String
);
814 TerminalDevice
->OutputEscChar
= FALSE
;
816 if (EFI_ERROR (Status
)) {
817 return EFI_DEVICE_ERROR
;
820 // update current cursor position
821 // in the Mode data structure.
823 Mode
->CursorColumn
= (INT32
) Column
;
824 Mode
->CursorRow
= (INT32
) Row
;
831 Implements SIMPLE_TEXT_OUTPUT.EnableCursor().
833 In this driver, the cursor cannot be hidden.
835 @param This Indicates the calling context.
836 @param Visible If TRUE, the cursor is set to be visible,
837 If FALSE, the cursor is set to be invisible.
839 @retval EFI_SUCCESS The request is valid.
840 @retval EFI_UNSUPPORTED The terminal does not support cursor hidden.
845 TerminalConOutEnableCursor (
846 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
851 return EFI_UNSUPPORTED
;
859 Detects if a Unicode char is for Box Drawing text graphics.
861 @param Graphic Unicode char to test.
862 @param PcAnsi Optional pointer to return PCANSI equivalent of
864 @param Ascii Optional pointer to return ASCII equivalent of
867 @retval TRUE If Graphic is a supported Unicode Box Drawing character.
871 TerminalIsValidTextGraphics (
873 OUT CHAR8
*PcAnsi
, OPTIONAL
874 OUT CHAR8
*Ascii OPTIONAL
877 UNICODE_TO_CHAR
*Table
;
879 if ((((Graphic
& 0xff00) != 0x2500) && ((Graphic
& 0xff00) != 0x2100))) {
881 // Unicode drawing code charts are all in the 0x25xx range,
887 for (Table
= UnicodeToPcAnsiOrAscii
; Table
->Unicode
!= 0x0000; Table
++) {
888 if (Graphic
== Table
->Unicode
) {
889 if (PcAnsi
!= NULL
) {
890 *PcAnsi
= Table
->PcAnsi
;
894 *Ascii
= Table
->Ascii
;
905 Detects if a valid ASCII char.
907 @param Ascii An ASCII character.
909 @retval TRUE If it is a valid ASCII character.
910 @retval FALSE If it is not a valid ASCII character.
914 TerminalIsValidAscii (
919 // valid ascii code lies in the extent of 0x20 ~ 0x7f
921 if ((Ascii
>= 0x20) && (Ascii
<= 0x7f)) {
929 Detects if a valid EFI control character.
931 @param CharC An input EFI Control character.
933 @retval TRUE If it is a valid EFI control character.
934 @retval FALSE If it is not a valid EFI control character.
938 TerminalIsValidEfiCntlChar (
943 // only support four control characters.
945 if (CharC
== CHAR_NULL
||
946 CharC
== CHAR_BACKSPACE
||
947 CharC
== CHAR_LINEFEED
||
948 CharC
== CHAR_CARRIAGE_RETURN
||