summaryrefslogtreecommitdiff
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorBrian J. Johnson <bjohnson@sgi.com>2016-10-07 22:53:58 +0800
committerFeng Tian <feng.tian@intel.com>2016-10-27 09:11:14 +0800
commit851b044f0a4b51101beae9214cf662308995ae1b (patch)
tree239b2bf47246f02e60f726eb5d3e43312ba26700 /MdeModulePkg
parent2d90b74d027b457615c0739ac9114a976be9eaed (diff)
downloadedk2-platforms-851b044f0a4b51101beae9214cf662308995ae1b.tar.xz
MdeModulePkg/TerminalDxe: Improve TtyTerm cursor position tracking
When we print the last character on a line, the terminal driver wraps CursorRow/CursorColumn to the beginning of the next line. But the terminal itself doesn't wrap its cursor until the next character is printed. That throws off the driver's cursor position tracking. So when we have printed the last character on a line, and are not in the middle of outputing an escape sequence, synchronize the terminal with the driver by outputing CR+LF. This matches the expected behavior, and the behavior of the VGA console driver. Only change the behavior of TtyTerm, not the other terminal types. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Brian Johnson <bjohnson@sgi.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Star Zeng <star.zeng@intel.com> Tested-by: Ryan Harkin <ryan.harkin@linaro.org> Reviewed-by: Feng Tian <feng.tian@intel.com>
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
index 9fa952ad2a..b11e83f4f2 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
@@ -2,6 +2,7 @@
Implementation for EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL protocol.
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (C) 2016 Silicon Graphics, Inc. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -313,6 +314,30 @@ TerminalConOutOutputString (
Mode->CursorRow++;
}
+ if (TerminalDevice->TerminalType == TTYTERMTYPE &&
+ !TerminalDevice->OutputEscChar) {
+ //
+ // We've written the last character on the line. The
+ // terminal doesn't actually wrap its cursor until we print
+ // the next character, but the driver thinks it has wrapped
+ // already. Print CR LF to synchronize the terminal with
+ // the driver, but only if we're not in the middle of
+ // printing an escape sequence.
+ //
+ CHAR8 CrLfStr[] = {'\r', '\n'};
+
+ Length = sizeof(CrLfStr);
+
+ Status = TerminalDevice->SerialIo->Write (
+ TerminalDevice->SerialIo,
+ &Length,
+ CrLfStr
+ );
+
+ if (EFI_ERROR (Status)) {
+ goto OutputError;
+ }
+ }
}
break;