/** @file\r
Implementation for EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL protocol.\r
\r
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (C) 2016 Silicon Graphics, Inc. All rights reserved.<BR>\r
+This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
http://opensource.org/licenses/bsd-license.php\r
CHAR16 mSetAttributeString[] = { ESC, '[', '0', 'm', ESC, '[', '4', '0', 'm', ESC, '[', '4', '0', 'm', 0 };\r
CHAR16 mClearScreenString[] = { ESC, '[', '2', 'J', 0 };\r
CHAR16 mSetCursorPositionString[] = { ESC, '[', '0', '0', ';', '0', '0', 'H', 0 };\r
+CHAR16 mCursorForwardString[] = { ESC, '[', '0', '0', 'C', 0 };\r
+CHAR16 mCursorBackwardString[] = { ESC, '[', '0', '0', 'D', 0 };\r
\r
//\r
// Body of the ConOut functions\r
exhaustive verification operation of the device\r
during reset.\r
\r
- @return EFI_SUCCESS The reset operation succeeds.\r
- @return EFI_DEVICE_ERROR The terminal is not functioning correctly or the serial port reset fails.\r
+ @retval EFI_SUCCESS The reset operation succeeds.\r
+ @retval EFI_DEVICE_ERROR The terminal is not functioning correctly or the serial port reset fails.\r
\r
**/\r
EFI_STATUS\r
//\r
REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
EFI_PROGRESS_CODE,\r
- PcdGet32 (PcdStatusCodeValueRemoteConsoleReset),\r
+ (EFI_PERIPHERAL_REMOTE_CONSOLE | EFI_P_PC_RESET),\r
TerminalDevice->DevicePath\r
);\r
\r
//\r
REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
- PcdGet32 (PcdStatusCodeValueRemoteConsoleError),\r
+ (EFI_PERIPHERAL_REMOTE_CONSOLE | EFI_P_EC_CONTROLLER_ERROR),\r
TerminalDevice->DevicePath\r
);\r
\r
\r
ValidBytes = 0;\r
Warning = FALSE;\r
+ AsciiChar = 0;\r
\r
//\r
// get Terminal device data structure pointer.\r
//\r
Mode = This->Mode;\r
\r
- if (Mode->Mode > 2) {\r
+ if (Mode->Mode >= Mode->MaxMode) {\r
return EFI_UNSUPPORTED;\r
}\r
\r
case PCANSITYPE:\r
case VT100TYPE:\r
case VT100PLUSTYPE:\r
+ case TTYTERMTYPE:\r
\r
if (!TerminalIsValidTextGraphics (*WString, &GraphicChar, &AsciiChar)) {\r
//\r
Mode->CursorRow++;\r
}\r
\r
+ if (TerminalDevice->TerminalType == TTYTERMTYPE &&\r
+ !TerminalDevice->OutputEscChar) {\r
+ //\r
+ // We've written the last character on the line. The\r
+ // terminal doesn't actually wrap its cursor until we print\r
+ // the next character, but the driver thinks it has wrapped\r
+ // already. Print CR LF to synchronize the terminal with\r
+ // the driver, but only if we're not in the middle of\r
+ // printing an escape sequence.\r
+ //\r
+ CHAR8 CrLfStr[] = {'\r', '\n'};\r
+\r
+ Length = sizeof(CrLfStr);\r
+\r
+ Status = TerminalDevice->SerialIo->Write (\r
+ TerminalDevice->SerialIo,\r
+ &Length,\r
+ CrLfStr\r
+ );\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ goto OutputError;\r
+ }\r
+ }\r
}\r
break;\r
\r
OutputError:\r
REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
- PcdGet32 (PcdStatusCodeValueRemoteConsoleOutputError),\r
+ (EFI_PERIPHERAL_REMOTE_CONSOLE | EFI_P_EC_OUTPUT_ERROR),\r
TerminalDevice->DevicePath\r
);\r
\r
@param This Indicates the calling context.\r
@param WString The Null-terminated Unicode string to be tested.\r
\r
- @return EFI_SUCCESS The terminal is capable of rendering the output string.\r
- @return EFI_UNSUPPORTED Some of the characters in the Unicode string cannot be rendered.\r
+ @retval EFI_SUCCESS The terminal is capable of rendering the output string.\r
+ @retval EFI_UNSUPPORTED Some of the characters in the Unicode string cannot be rendered.\r
\r
**/\r
EFI_STATUS\r
case PCANSITYPE:\r
case VT100TYPE:\r
case VT100PLUSTYPE:\r
+ case TTYTERMTYPE:\r
Status = AnsiTestString (TerminalDevice, WString);\r
break;\r
\r
\r
It returns information for an available text mode\r
that the terminal supports.\r
- In this driver, we support text mode 80x25 (mode 0),\r
- 80x50 (mode 1), 100x31 (mode 2).\r
\r
@param This Indicates the calling context.\r
@param ModeNumber The mode number to return information on.\r
@param Columns The returned columns of the requested mode.\r
@param Rows The returned rows of the requested mode.\r
\r
- @return EFI_SUCCESS The requested mode information is returned.\r
- @return EFI_UNSUPPORTED The mode number is not valid.\r
- @return EFI_DEVICE_ERROR\r
+ @retval EFI_SUCCESS The requested mode information is returned.\r
+ @retval EFI_UNSUPPORTED The mode number is not valid.\r
\r
**/\r
EFI_STATUS\r
OUT UINTN *Rows\r
)\r
{\r
- if (This->Mode->MaxMode > 3) {\r
- return EFI_DEVICE_ERROR;\r
- }\r
+ TERMINAL_DEV *TerminalDevice;\r
\r
- if (ModeNumber == 0) {\r
- *Columns = MODE0_COLUMN_COUNT;\r
- *Rows = MODE0_ROW_COUNT;\r
- return EFI_SUCCESS;\r
- } else if (ModeNumber == 1) {\r
- *Columns = MODE1_COLUMN_COUNT;\r
- *Rows = MODE1_ROW_COUNT;\r
- return EFI_SUCCESS;\r
- } else if (ModeNumber == 2) {\r
- *Columns = MODE2_COLUMN_COUNT;\r
- *Rows = MODE2_ROW_COUNT;\r
- return EFI_SUCCESS;\r
+ if (ModeNumber >= (UINTN) This->Mode->MaxMode) {\r
+ return EFI_UNSUPPORTED;\r
}\r
\r
- return EFI_UNSUPPORTED;\r
+ //\r
+ // Get Terminal device data structure pointer.\r
+ //\r
+ TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (This); \r
+ *Columns = TerminalDevice->TerminalConsoleModeData[ModeNumber].Columns;\r
+ *Rows = TerminalDevice->TerminalConsoleModeData[ModeNumber].Rows;\r
+\r
+ return EFI_SUCCESS;\r
}\r
\r
\r
@param This Indicates the calling context.\r
@param ModeNumber The text mode to set.\r
\r
- @return EFI_SUCCESS The requested text mode is set.\r
- @return EFI_DEVICE_ERROR The requested text mode cannot be set \r
+ @retval EFI_SUCCESS The requested text mode is set.\r
+ @retval EFI_DEVICE_ERROR The requested text mode cannot be set \r
because of serial device error.\r
- @return EFI_UNSUPPORTED The text mode number is not valid.\r
+ @retval EFI_UNSUPPORTED The text mode number is not valid.\r
\r
**/\r
EFI_STATUS\r
//\r
TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (This);\r
\r
- if (ModeNumber > 2) {\r
+ if (ModeNumber >= (UINTN) This->Mode->MaxMode) {\r
return EFI_UNSUPPORTED;\r
}\r
\r
@param Attribute The attribute to set. Only bit0..6 are valid, all other bits\r
are undefined and must be zero.\r
\r
- @return EFI_SUCCESS The requested attribute is set.\r
- @return EFI_DEVICE_ERROR The requested attribute cannot be set due to serial port error.\r
- @return EFI_UNSUPPORTED The attribute requested is not defined by EFI spec.\r
+ @retval EFI_SUCCESS The requested attribute is set.\r
+ @retval EFI_DEVICE_ERROR The requested attribute cannot be set due to serial port error.\r
+ @retval EFI_UNSUPPORTED The attribute requested is not defined by EFI spec.\r
\r
**/\r
EFI_STATUS\r
\r
//\r
// Skip outputting the command string for the same attribute\r
- // It improves the terminal performance siginificantly\r
+ // It improves the terminal performance significantly\r
//\r
if (This->Mode->Attribute == (INT32) Attribute) {\r
return EFI_SUCCESS;\r
\r
@param This Indicates the calling context.\r
\r
- @return EFI_SUCCESS The operation completed successfully.\r
- @return EFI_DEVICE_ERROR The terminal screen cannot be cleared due to serial port error.\r
- @return EFI_UNSUPPORTED The terminal is not in a valid display mode.\r
+ @retval EFI_SUCCESS The operation completed successfully.\r
+ @retval EFI_DEVICE_ERROR The terminal screen cannot be cleared due to serial port error.\r
+ @retval EFI_UNSUPPORTED The terminal is not in a valid display mode.\r
\r
**/\r
EFI_STATUS\r
@param Column The row to set cursor to.\r
@param Row The column to set cursor to.\r
\r
- @return EFI_SUCCESS The operation completed successfully.\r
- @return EFI_DEVICE_ERROR The request fails due to serial port error.\r
- @return EFI_UNSUPPORTED The terminal is not in a valid text mode, or the cursor position\r
+ @retval EFI_SUCCESS The operation completed successfully.\r
+ @retval EFI_DEVICE_ERROR The request fails due to serial port error.\r
+ @retval EFI_UNSUPPORTED The terminal is not in a valid text mode, or the cursor position\r
is invalid for current mode.\r
\r
**/\r
UINTN MaxRow;\r
EFI_STATUS Status;\r
TERMINAL_DEV *TerminalDevice;\r
+ CHAR16 *String;\r
\r
TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (This);\r
\r
//\r
// control sequence to move the cursor\r
//\r
- mSetCursorPositionString[ROW_OFFSET + 0] = (CHAR16) ('0' + ((Row + 1) / 10));\r
- mSetCursorPositionString[ROW_OFFSET + 1] = (CHAR16) ('0' + ((Row + 1) % 10));\r
- mSetCursorPositionString[COLUMN_OFFSET + 0] = (CHAR16) ('0' + ((Column + 1) / 10));\r
- mSetCursorPositionString[COLUMN_OFFSET + 1] = (CHAR16) ('0' + ((Column + 1) % 10));\r
+ // Optimize cursor motion control sequences for TtyTerm. Move\r
+ // within the current line if possible, and don't output anyting if\r
+ // it isn't necessary.\r
+ //\r
+ if (TerminalDevice->TerminalType == TTYTERMTYPE &&\r
+ (UINTN)Mode->CursorRow == Row) {\r
+ if ((UINTN)Mode->CursorColumn > Column) {\r
+ mCursorBackwardString[FW_BACK_OFFSET + 0] = (CHAR16) ('0' + ((Mode->CursorColumn - Column) / 10));\r
+ mCursorBackwardString[FW_BACK_OFFSET + 1] = (CHAR16) ('0' + ((Mode->CursorColumn - Column) % 10));\r
+ String = mCursorBackwardString;\r
+ }\r
+ else if (Column > (UINTN)Mode->CursorColumn) {\r
+ mCursorForwardString[FW_BACK_OFFSET + 0] = (CHAR16) ('0' + ((Column - Mode->CursorColumn) / 10));\r
+ mCursorForwardString[FW_BACK_OFFSET + 1] = (CHAR16) ('0' + ((Column - Mode->CursorColumn) % 10));\r
+ String = mCursorForwardString;\r
+ }\r
+ else {\r
+ String = L""; // No cursor motion necessary\r
+ }\r
+ }\r
+ else {\r
+ mSetCursorPositionString[ROW_OFFSET + 0] = (CHAR16) ('0' + ((Row + 1) / 10));\r
+ mSetCursorPositionString[ROW_OFFSET + 1] = (CHAR16) ('0' + ((Row + 1) % 10));\r
+ mSetCursorPositionString[COLUMN_OFFSET + 0] = (CHAR16) ('0' + ((Column + 1) / 10));\r
+ mSetCursorPositionString[COLUMN_OFFSET + 1] = (CHAR16) ('0' + ((Column + 1) % 10));\r
+ String = mSetCursorPositionString;\r
+ }\r
\r
TerminalDevice->OutputEscChar = TRUE;\r
- Status = This->OutputString (This, mSetCursorPositionString);\r
+ Status = This->OutputString (This, String);\r
TerminalDevice->OutputEscChar = FALSE;\r
\r
if (EFI_ERROR (Status)) {\r
@param Visible If TRUE, the cursor is set to be visible,\r
If FALSE, the cursor is set to be invisible.\r
\r
- @return EFI_SUCCESS The request is valid.\r
- @return EFI_UNSUPPORTED The terminal does not support cursor hidden.\r
+ @retval EFI_SUCCESS The request is valid.\r
+ @retval EFI_UNSUPPORTED The terminal does not support cursor hidden.\r
\r
**/\r
EFI_STATUS\r
@param Ascii Optional pointer to return ASCII equivalent of\r
Graphic.\r
\r
- @return TRUE If Graphic is a supported Unicode Box Drawing character.\r
+ @retval TRUE If Graphic is a supported Unicode Box Drawing character.\r
\r
**/\r
BOOLEAN\r