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 };
88 // Body of the ConOut functions
92 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.Reset().
94 If ExtendeVerification is TRUE, then perform dependent serial device reset,
95 and set display mode to mode 0.
96 If ExtendedVerification is FALSE, only set display mode to mode 0.
98 @param This Indicates the calling context.
99 @param ExtendedVerification Indicates that the driver may perform a more
100 exhaustive verification operation of the device
103 @retval EFI_SUCCESS The reset operation succeeds.
104 @retval EFI_DEVICE_ERROR The terminal is not functioning correctly or the serial port reset fails.
109 TerminalConOutReset (
110 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
111 IN BOOLEAN ExtendedVerification
115 TERMINAL_DEV
*TerminalDevice
;
117 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
120 // Perform a more exhaustive reset by resetting the serial port.
122 if (ExtendedVerification
) {
124 // Report progress code here
126 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
128 (EFI_PERIPHERAL_REMOTE_CONSOLE
| EFI_P_PC_RESET
),
129 TerminalDevice
->DevicePath
132 Status
= TerminalDevice
->SerialIo
->Reset (TerminalDevice
->SerialIo
);
133 if (EFI_ERROR (Status
)) {
135 // Report error code here
137 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
138 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
139 (EFI_PERIPHERAL_REMOTE_CONSOLE
| EFI_P_EC_CONTROLLER_ERROR
),
140 TerminalDevice
->DevicePath
147 This
->SetAttribute (This
, EFI_TEXT_ATTR (This
->Mode
->Attribute
& 0x0F, EFI_BLACK
));
149 Status
= This
->SetMode (This
, 0);
156 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString().
158 The Unicode string will be converted to terminal expressible data stream
159 and send to terminal via serial port.
161 @param This Indicates the calling context.
162 @param WString The Null-terminated Unicode string to be displayed
163 on the terminal screen.
165 @retval EFI_SUCCESS The string is output successfully.
166 @retval EFI_DEVICE_ERROR The serial port fails to send the string out.
167 @retval EFI_WARN_UNKNOWN_GLYPH Indicates that some of the characters in the Unicode string could not
168 be rendered and are skipped.
169 @retval EFI_UNSUPPORTED If current display mode is out of range.
174 TerminalConOutOutputString (
175 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
179 TERMINAL_DEV
*TerminalDevice
;
180 EFI_SIMPLE_TEXT_OUTPUT_MODE
*Mode
;
190 // flag used to indicate whether condition happens which will cause
191 // return EFI_WARN_UNKNOWN_GLYPH
200 // get Terminal device data structure pointer.
202 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
205 // Get current display mode
209 if (Mode
->Mode
>= Mode
->MaxMode
) {
210 return EFI_UNSUPPORTED
;
220 for (; *WString
!= CHAR_NULL
; WString
++) {
222 switch (TerminalDevice
->TerminalType
) {
229 if (!TerminalIsValidTextGraphics (*WString
, &GraphicChar
, &AsciiChar
)) {
231 // If it's not a graphic character convert Unicode to ASCII.
233 GraphicChar
= (CHAR8
) *WString
;
235 if (!(TerminalIsValidAscii (GraphicChar
) || TerminalIsValidEfiCntlChar (GraphicChar
))) {
237 // when this driver use the OutputString to output control string,
238 // TerminalDevice->OutputEscChar is set to let the Esc char
239 // to be output to the terminal emulation software.
241 if ((GraphicChar
== 27) && TerminalDevice
->OutputEscChar
) {
249 AsciiChar
= GraphicChar
;
253 if (TerminalDevice
->TerminalType
!= PCANSITYPE
) {
254 GraphicChar
= AsciiChar
;
259 Status
= TerminalDevice
->SerialIo
->Write (
260 TerminalDevice
->SerialIo
,
265 if (EFI_ERROR (Status
)) {
272 UnicodeToUtf8 (*WString
, &Utf8Char
, &ValidBytes
);
274 Status
= TerminalDevice
->SerialIo
->Write (
275 TerminalDevice
->SerialIo
,
279 if (EFI_ERROR (Status
)) {
285 // Update cursor position.
290 if (Mode
->CursorColumn
> 0) {
291 Mode
->CursorColumn
--;
296 if (Mode
->CursorRow
< (INT32
) (MaxRow
- 1)) {
301 case CHAR_CARRIAGE_RETURN
:
302 Mode
->CursorColumn
= 0;
306 if (Mode
->CursorColumn
< (INT32
) (MaxColumn
- 1)) {
308 Mode
->CursorColumn
++;
312 Mode
->CursorColumn
= 0;
313 if (Mode
->CursorRow
< (INT32
) (MaxRow
- 1)) {
317 if (TerminalDevice
->TerminalType
== TTYTERMTYPE
&&
318 !TerminalDevice
->OutputEscChar
) {
320 // We've written the last character on the line. The
321 // terminal doesn't actually wrap its cursor until we print
322 // the next character, but the driver thinks it has wrapped
323 // already. Print CR LF to synchronize the terminal with
324 // the driver, but only if we're not in the middle of
325 // printing an escape sequence.
327 CHAR8 CrLfStr
[] = {'\r', '\n'};
329 Length
= sizeof(CrLfStr
);
331 Status
= TerminalDevice
->SerialIo
->Write (
332 TerminalDevice
->SerialIo
,
337 if (EFI_ERROR (Status
)) {
349 return EFI_WARN_UNKNOWN_GLYPH
;
355 REPORT_STATUS_CODE_WITH_DEVICE_PATH (
356 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
357 (EFI_PERIPHERAL_REMOTE_CONSOLE
| EFI_P_EC_OUTPUT_ERROR
),
358 TerminalDevice
->DevicePath
361 return EFI_DEVICE_ERROR
;
366 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.TestString().
368 If one of the characters in the *Wstring is
369 neither valid Unicode drawing characters,
370 not ASCII code, then this function will return
373 @param This Indicates the calling context.
374 @param WString The Null-terminated Unicode string to be tested.
376 @retval EFI_SUCCESS The terminal is capable of rendering the output string.
377 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string cannot be rendered.
382 TerminalConOutTestString (
383 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
387 TERMINAL_DEV
*TerminalDevice
;
391 // get Terminal device data structure pointer.
393 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
395 switch (TerminalDevice
->TerminalType
) {
401 Status
= AnsiTestString (TerminalDevice
, WString
);
405 Status
= VTUTF8TestString (TerminalDevice
, WString
);
409 Status
= EFI_UNSUPPORTED
;
418 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode().
420 It returns information for an available text mode
421 that the terminal supports.
423 @param This Indicates the calling context.
424 @param ModeNumber The mode number to return information on.
425 @param Columns The returned columns of the requested mode.
426 @param Rows The returned rows of the requested mode.
428 @retval EFI_SUCCESS The requested mode information is returned.
429 @retval EFI_UNSUPPORTED The mode number is not valid.
434 TerminalConOutQueryMode (
435 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
441 TERMINAL_DEV
*TerminalDevice
;
443 if (ModeNumber
>= (UINTN
) This
->Mode
->MaxMode
) {
444 return EFI_UNSUPPORTED
;
448 // Get Terminal device data structure pointer.
450 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
451 *Columns
= TerminalDevice
->TerminalConsoleModeData
[ModeNumber
].Columns
;
452 *Rows
= TerminalDevice
->TerminalConsoleModeData
[ModeNumber
].Rows
;
459 Implements EFI_SIMPLE_TEXT_OUT.SetMode().
461 Set the terminal to a specified display mode.
462 In this driver, we only support mode 0.
464 @param This Indicates the calling context.
465 @param ModeNumber The text mode to set.
467 @retval EFI_SUCCESS The requested text mode is set.
468 @retval EFI_DEVICE_ERROR The requested text mode cannot be set
469 because of serial device error.
470 @retval EFI_UNSUPPORTED The text mode number is not valid.
475 TerminalConOutSetMode (
476 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
481 TERMINAL_DEV
*TerminalDevice
;
484 // get Terminal device data structure pointer.
486 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
488 if (ModeNumber
>= (UINTN
) This
->Mode
->MaxMode
) {
489 return EFI_UNSUPPORTED
;
493 // Set the current mode
495 This
->Mode
->Mode
= (INT32
) ModeNumber
;
497 This
->ClearScreen (This
);
499 TerminalDevice
->OutputEscChar
= TRUE
;
500 Status
= This
->OutputString (This
, mSetModeString
);
501 TerminalDevice
->OutputEscChar
= FALSE
;
503 if (EFI_ERROR (Status
)) {
504 return EFI_DEVICE_ERROR
;
507 This
->Mode
->Mode
= (INT32
) ModeNumber
;
509 Status
= This
->ClearScreen (This
);
510 if (EFI_ERROR (Status
)) {
511 return EFI_DEVICE_ERROR
;
520 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetAttribute().
522 @param This Indicates the calling context.
523 @param Attribute The attribute to set. Only bit0..6 are valid, all other bits
524 are undefined and must be zero.
526 @retval EFI_SUCCESS The requested attribute is set.
527 @retval EFI_DEVICE_ERROR The requested attribute cannot be set due to serial port error.
528 @retval EFI_UNSUPPORTED The attribute requested is not defined by EFI spec.
533 TerminalConOutSetAttribute (
534 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
538 UINT8 ForegroundControl
;
539 UINT8 BackgroundControl
;
544 TERMINAL_DEV
*TerminalDevice
;
550 // get Terminal device data structure pointer.
552 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
555 // only the bit0..6 of the Attribute is valid
557 if ((Attribute
| 0x7f) != 0x7f) {
558 return EFI_UNSUPPORTED
;
562 // Skip outputting the command string for the same attribute
563 // It improves the terminal performance significantly
565 if (This
->Mode
->Attribute
== (INT32
) Attribute
) {
570 // convert Attribute value to terminal emulator
571 // understandable foreground color
573 switch (Attribute
& 0x07) {
576 ForegroundControl
= 30;
580 ForegroundControl
= 34;
584 ForegroundControl
= 32;
588 ForegroundControl
= 36;
592 ForegroundControl
= 31;
596 ForegroundControl
= 35;
600 ForegroundControl
= 33;
606 ForegroundControl
= 37;
611 // bit4 of the Attribute indicates bright control
612 // of terminal emulator.
614 BrightControl
= (UINT8
) ((Attribute
>> 3) & 1);
617 // convert Attribute value to terminal emulator
618 // understandable background color.
620 switch ((Attribute
>> 4) & 0x07) {
623 BackgroundControl
= 40;
627 BackgroundControl
= 44;
631 BackgroundControl
= 42;
635 BackgroundControl
= 46;
639 BackgroundControl
= 41;
643 BackgroundControl
= 45;
647 BackgroundControl
= 43;
653 BackgroundControl
= 47;
657 // terminal emulator's control sequence to set attributes
659 mSetAttributeString
[BRIGHT_CONTROL_OFFSET
] = (CHAR16
) ('0' + BrightControl
);
660 mSetAttributeString
[FOREGROUND_CONTROL_OFFSET
+ 0] = (CHAR16
) ('0' + (ForegroundControl
/ 10));
661 mSetAttributeString
[FOREGROUND_CONTROL_OFFSET
+ 1] = (CHAR16
) ('0' + (ForegroundControl
% 10));
662 mSetAttributeString
[BACKGROUND_CONTROL_OFFSET
+ 0] = (CHAR16
) ('0' + (BackgroundControl
/ 10));
663 mSetAttributeString
[BACKGROUND_CONTROL_OFFSET
+ 1] = (CHAR16
) ('0' + (BackgroundControl
% 10));
666 // save current column and row
667 // for future scrolling back use.
669 SavedColumn
= This
->Mode
->CursorColumn
;
670 SavedRow
= This
->Mode
->CursorRow
;
672 TerminalDevice
->OutputEscChar
= TRUE
;
673 Status
= This
->OutputString (This
, mSetAttributeString
);
674 TerminalDevice
->OutputEscChar
= FALSE
;
676 if (EFI_ERROR (Status
)) {
677 return EFI_DEVICE_ERROR
;
680 // scroll back to saved cursor position.
682 This
->Mode
->CursorColumn
= SavedColumn
;
683 This
->Mode
->CursorRow
= SavedRow
;
685 This
->Mode
->Attribute
= (INT32
) Attribute
;
693 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.ClearScreen().
694 It clears the ANSI terminal's display to the
695 currently selected background color.
697 @param This Indicates the calling context.
699 @retval EFI_SUCCESS The operation completed successfully.
700 @retval EFI_DEVICE_ERROR The terminal screen cannot be cleared due to serial port error.
701 @retval EFI_UNSUPPORTED The terminal is not in a valid display mode.
706 TerminalConOutClearScreen (
707 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
711 TERMINAL_DEV
*TerminalDevice
;
713 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
716 // control sequence for clear screen request
718 TerminalDevice
->OutputEscChar
= TRUE
;
719 Status
= This
->OutputString (This
, mClearScreenString
);
720 TerminalDevice
->OutputEscChar
= FALSE
;
722 if (EFI_ERROR (Status
)) {
723 return EFI_DEVICE_ERROR
;
726 Status
= This
->SetCursorPosition (This
, 0, 0);
733 Implements EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetCursorPosition().
735 @param This Indicates the calling context.
736 @param Column The row to set cursor to.
737 @param Row The column to set cursor to.
739 @retval EFI_SUCCESS The operation completed successfully.
740 @retval EFI_DEVICE_ERROR The request fails due to serial port error.
741 @retval EFI_UNSUPPORTED The terminal is not in a valid text mode, or the cursor position
742 is invalid for current mode.
747 TerminalConOutSetCursorPosition (
748 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
753 EFI_SIMPLE_TEXT_OUTPUT_MODE
*Mode
;
757 TERMINAL_DEV
*TerminalDevice
;
759 TerminalDevice
= TERMINAL_CON_OUT_DEV_FROM_THIS (This
);
767 // get geometry of current mode
769 Status
= This
->QueryMode (
775 if (EFI_ERROR (Status
)) {
776 return EFI_UNSUPPORTED
;
779 if (Column
>= MaxColumn
|| Row
>= MaxRow
) {
780 return EFI_UNSUPPORTED
;
783 // control sequence to move the cursor
785 mSetCursorPositionString
[ROW_OFFSET
+ 0] = (CHAR16
) ('0' + ((Row
+ 1) / 10));
786 mSetCursorPositionString
[ROW_OFFSET
+ 1] = (CHAR16
) ('0' + ((Row
+ 1) % 10));
787 mSetCursorPositionString
[COLUMN_OFFSET
+ 0] = (CHAR16
) ('0' + ((Column
+ 1) / 10));
788 mSetCursorPositionString
[COLUMN_OFFSET
+ 1] = (CHAR16
) ('0' + ((Column
+ 1) % 10));
790 TerminalDevice
->OutputEscChar
= TRUE
;
791 Status
= This
->OutputString (This
, mSetCursorPositionString
);
792 TerminalDevice
->OutputEscChar
= FALSE
;
794 if (EFI_ERROR (Status
)) {
795 return EFI_DEVICE_ERROR
;
798 // update current cursor position
799 // in the Mode data structure.
801 Mode
->CursorColumn
= (INT32
) Column
;
802 Mode
->CursorRow
= (INT32
) Row
;
809 Implements SIMPLE_TEXT_OUTPUT.EnableCursor().
811 In this driver, the cursor cannot be hidden.
813 @param This Indicates the calling context.
814 @param Visible If TRUE, the cursor is set to be visible,
815 If FALSE, the cursor is set to be invisible.
817 @retval EFI_SUCCESS The request is valid.
818 @retval EFI_UNSUPPORTED The terminal does not support cursor hidden.
823 TerminalConOutEnableCursor (
824 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
829 return EFI_UNSUPPORTED
;
837 Detects if a Unicode char is for Box Drawing text graphics.
839 @param Graphic Unicode char to test.
840 @param PcAnsi Optional pointer to return PCANSI equivalent of
842 @param Ascii Optional pointer to return ASCII equivalent of
845 @retval TRUE If Graphic is a supported Unicode Box Drawing character.
849 TerminalIsValidTextGraphics (
851 OUT CHAR8
*PcAnsi
, OPTIONAL
852 OUT CHAR8
*Ascii OPTIONAL
855 UNICODE_TO_CHAR
*Table
;
857 if ((((Graphic
& 0xff00) != 0x2500) && ((Graphic
& 0xff00) != 0x2100))) {
859 // Unicode drawing code charts are all in the 0x25xx range,
865 for (Table
= UnicodeToPcAnsiOrAscii
; Table
->Unicode
!= 0x0000; Table
++) {
866 if (Graphic
== Table
->Unicode
) {
867 if (PcAnsi
!= NULL
) {
868 *PcAnsi
= Table
->PcAnsi
;
872 *Ascii
= Table
->Ascii
;
883 Detects if a valid ASCII char.
885 @param Ascii An ASCII character.
887 @retval TRUE If it is a valid ASCII character.
888 @retval FALSE If it is not a valid ASCII character.
892 TerminalIsValidAscii (
897 // valid ascii code lies in the extent of 0x20 ~ 0x7f
899 if ((Ascii
>= 0x20) && (Ascii
<= 0x7f)) {
907 Detects if a valid EFI control character.
909 @param CharC An input EFI Control character.
911 @retval TRUE If it is a valid EFI control character.
912 @retval FALSE If it is not a valid EFI control character.
916 TerminalIsValidEfiCntlChar (
921 // only support four control characters.
923 if (CharC
== CHAR_NULL
||
924 CharC
== CHAR_BACKSPACE
||
925 CharC
== CHAR_LINEFEED
||
926 CharC
== CHAR_CARRIAGE_RETURN
||