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' }
76CHAR16 mSetModeString[] = { ESC,
'[',
'=',
'3',
'h', 0 };
77CHAR16 mSetAttributeString[] = { ESC,
'[',
'0',
'm', ESC,
'[',
'4',
'0',
'm', ESC,
'[',
'4',
'0',
'm', 0 };
78CHAR16 mClearScreenString[] = { ESC,
'[',
'2',
'J', 0 };
79CHAR16 mSetCursorPositionString[] = { ESC,
'[',
'0',
'0',
';',
'0',
'0',
'H', 0 };
80CHAR16 mCursorForwardString[] = { ESC,
'[',
'0',
'0',
'C', 0 };
81CHAR16 mCursorBackwardString[] = { ESC,
'[',
'0',
'0',
'D', 0 };
107 IN BOOLEAN ExtendedVerification
113 TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (This);
118 if (ExtendedVerification) {
124 (EFI_PERIPHERAL_REMOTE_CONSOLE | EFI_P_PC_RESET),
125 TerminalDevice->DevicePath
128 Status = TerminalDevice->SerialIo->Reset (TerminalDevice->SerialIo);
129 if (EFI_ERROR (Status)) {
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);
198 TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (This);
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:
231 GraphicChar = (CHAR8)*WString;
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:
271 Status = TerminalDevice->SerialIo->Write (
272 TerminalDevice->SerialIo,
276 if (EFI_ERROR (Status)) {
295 if (Mode->
CursorRow < (INT32)(MaxRow - 1)) {
301 case CHAR_CARRIAGE_RETURN:
310 if (Mode->
CursorRow < (INT32)(MaxRow - 1)) {
314 if ((TerminalDevice->TerminalType == TerminalTypeTtyTerm) &&
315 !TerminalDevice->OutputEscChar)
328 Length =
sizeof (CrLfStr);
330 Status = TerminalDevice->SerialIo->Write (
331 TerminalDevice->SerialIo,
336 if (EFI_ERROR (Status)) {
347 return EFI_WARN_UNKNOWN_GLYPH;
355 (EFI_PERIPHERAL_REMOTE_CONSOLE | EFI_P_EC_OUTPUT_ERROR),
356 TerminalDevice->DevicePath
359 return EFI_DEVICE_ERROR;
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:
400 case TerminalTypeVtUtf8:
405 Status = EFI_UNSUPPORTED;
438 if (ModeNumber >= (
UINTN)This->Mode->MaxMode) {
439 return EFI_UNSUPPORTED;
445 TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (This);
446 *Columns = TerminalDevice->TerminalConsoleModeData[ModeNumber].Columns;
447 *Rows = TerminalDevice->TerminalConsoleModeData[ModeNumber].Rows;
480 TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (This);
482 if (ModeNumber >= (
UINTN)This->Mode->MaxMode) {
483 return EFI_UNSUPPORTED;
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;
530 UINT8 ForegroundControl;
531 UINT8 BackgroundControl;
544 TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (This);
549 if ((Attribute | 0x7f) != 0x7f) {
550 return EFI_UNSUPPORTED;
557 if (This->Mode->Attribute == (INT32)Attribute) {
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;
605 BrightControl = (UINT8)((Attribute >> 3) & 1);
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;
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));
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;
674 This->Mode->CursorColumn = SavedColumn;
675 This->Mode->CursorRow = SavedRow;
677 This->Mode->Attribute = (INT32)Attribute;
703 TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (This);
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);
749 TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (This);
759 Status = This->QueryMode (
765 if (EFI_ERROR (Status)) {
766 return EFI_UNSUPPORTED;
769 if ((Column >= MaxColumn) || (Row >= MaxRow)) {
770 return EFI_UNSUPPORTED;
780 if ((TerminalDevice->TerminalType == TerminalTypeTtyTerm) &&
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;
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;
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;
841 return EFI_UNSUPPORTED;
862 OUT CHAR8 *PcAnsi OPTIONAL,
863 OUT CHAR8 *Ascii OPTIONAL
868 if ((((Graphic & 0xff00) != 0x2500) && ((Graphic & 0xff00) != 0x2100))) {
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;
910 if ((Ascii >= 0x20) && (Ascii <= 0x7f)) {
934 if ((CharC == CHAR_NULL) ||
935 (CharC == CHAR_BACKSPACE) ||
936 (CharC == CHAR_LINEFEED) ||
937 (CharC == CHAR_CARRIAGE_RETURN) ||
EFI_STATUS AnsiTestString(IN TERMINAL_DEV *TerminalDevice, IN CHAR16 *WString)
#define REPORT_STATUS_CODE_WITH_DEVICE_PATH(Type, Value, DevicePathParameter)
#define EFI_PROGRESS_CODE
EFI_STATUS VTUTF8TestString(IN TERMINAL_DEV *TerminalDevice, IN CHAR16 *WString)
VOID UnicodeToUtf8(IN CHAR16 Unicode, OUT UTF8_CHAR *Utf8Char, OUT UINT8 *ValidBytes)
BOOLEAN TerminalIsValidAscii(IN CHAR16 Ascii)
EFI_STATUS EFIAPI TerminalConOutReset(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
EFI_STATUS EFIAPI TerminalConOutSetAttribute(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN UINTN Attribute)
EFI_STATUS EFIAPI TerminalConOutTestString(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN CHAR16 *WString)
EFI_STATUS EFIAPI TerminalConOutSetMode(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN UINTN ModeNumber)
EFI_STATUS EFIAPI TerminalConOutClearScreen(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This)
BOOLEAN TerminalIsValidEfiCntlChar(IN CHAR16 CharC)
EFI_STATUS EFIAPI TerminalConOutSetCursorPosition(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN UINTN Column, IN UINTN Row)
EFI_STATUS EFIAPI TerminalConOutOutputString(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN CHAR16 *WString)
EFI_STATUS EFIAPI TerminalConOutEnableCursor(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN BOOLEAN Visible)
EFI_STATUS EFIAPI TerminalConOutQueryMode(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN UINTN ModeNumber, OUT UINTN *Columns, OUT UINTN *Rows)
BOOLEAN TerminalIsValidTextGraphics(IN CHAR16 Graphic, OUT CHAR8 *PcAnsi OPTIONAL, OUT CHAR8 *Ascii OPTIONAL)