summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorBrian J. Johnson <bjohnson@sgi.com>2016-10-07 22:53:59 +0800
committerFeng Tian <feng.tian@intel.com>2016-10-27 09:11:15 +0800
commit27e804213149be99e4024fe3dcb4ea41b3f39717 (patch)
treef577e3ada85be741cd19db1962db30d30a09d3bb /MdeModulePkg
parent851b044f0a4b51101beae9214cf662308995ae1b (diff)
downloadedk2-27e804213149be99e4024fe3dcb4ea41b3f39717.tar.gz
edk2-27e804213149be99e4024fe3dcb4ea41b3f39717.tar.bz2
edk2-27e804213149be99e4024fe3dcb4ea41b3f39717.zip
MdeModulePkg/TerminalDxe: Optimize TtyTerm cursor motion
For TtyTerm terminals, output a shorter escape sequence when possible to move the cursor within the current line, and don't print any escape sequence if the cursor is already at the correct position. This removes extra cursor motion activity at the EFI shell prompt, improving performance. It also makes it possible in many cases to successfully use a terminal window which is taller than the driver's mode setting (eg. 80x25.) 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/Terminal.h2
-rw-r--r--MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c36
2 files changed, 33 insertions, 5 deletions
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
index 269d2aeb5a..3ee396984e 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
@@ -2,6 +2,7 @@
Header file for Terminal driver.
Copyright (c) 2006 - 2014, 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
@@ -157,6 +158,7 @@ typedef union {
#define BACKGROUND_CONTROL_OFFSET 11
#define ROW_OFFSET 2
#define COLUMN_OFFSET 5
+#define FW_BACK_OFFSET 2
typedef struct {
UINT16 Unicode;
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
index b11e83f4f2..e9b5ed07cf 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
@@ -83,6 +83,8 @@ CHAR16 mSetModeString[] = { ESC, '[', '=', '3', 'h', 0 };
CHAR16 mSetAttributeString[] = { ESC, '[', '0', 'm', ESC, '[', '4', '0', 'm', ESC, '[', '4', '0', 'm', 0 };
CHAR16 mClearScreenString[] = { ESC, '[', '2', 'J', 0 };
CHAR16 mSetCursorPositionString[] = { ESC, '[', '0', '0', ';', '0', '0', 'H', 0 };
+CHAR16 mCursorForwardString[] = { ESC, '[', '0', '0', 'C', 0 };
+CHAR16 mCursorBackwardString[] = { ESC, '[', '0', '0', 'D', 0 };
//
// Body of the ConOut functions
@@ -755,6 +757,7 @@ TerminalConOutSetCursorPosition (
UINTN MaxRow;
EFI_STATUS Status;
TERMINAL_DEV *TerminalDevice;
+ CHAR16 *String;
TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (This);
@@ -782,13 +785,36 @@ TerminalConOutSetCursorPosition (
//
// control sequence to move the cursor
//
- mSetCursorPositionString[ROW_OFFSET + 0] = (CHAR16) ('0' + ((Row + 1) / 10));
- mSetCursorPositionString[ROW_OFFSET + 1] = (CHAR16) ('0' + ((Row + 1) % 10));
- mSetCursorPositionString[COLUMN_OFFSET + 0] = (CHAR16) ('0' + ((Column + 1) / 10));
- mSetCursorPositionString[COLUMN_OFFSET + 1] = (CHAR16) ('0' + ((Column + 1) % 10));
+ // Optimize cursor motion control sequences for TtyTerm. Move
+ // within the current line if possible, and don't output anyting if
+ // it isn't necessary.
+ //
+ if (TerminalDevice->TerminalType == TTYTERMTYPE &&
+ Mode->CursorRow == Row) {
+ if (Mode->CursorColumn > Column) {
+ mCursorBackwardString[FW_BACK_OFFSET + 0] = (CHAR16) ('0' + ((Mode->CursorColumn - Column) / 10));
+ mCursorBackwardString[FW_BACK_OFFSET + 1] = (CHAR16) ('0' + ((Mode->CursorColumn - Column) % 10));
+ String = mCursorBackwardString;
+ }
+ else if (Column > Mode->CursorColumn) {
+ mCursorForwardString[FW_BACK_OFFSET + 0] = (CHAR16) ('0' + ((Column - Mode->CursorColumn) / 10));
+ mCursorForwardString[FW_BACK_OFFSET + 1] = (CHAR16) ('0' + ((Column - Mode->CursorColumn) % 10));
+ String = mCursorForwardString;
+ }
+ else {
+ String = L""; // No cursor motion necessary
+ }
+ }
+ else {
+ mSetCursorPositionString[ROW_OFFSET + 0] = (CHAR16) ('0' + ((Row + 1) / 10));
+ mSetCursorPositionString[ROW_OFFSET + 1] = (CHAR16) ('0' + ((Row + 1) % 10));
+ mSetCursorPositionString[COLUMN_OFFSET + 0] = (CHAR16) ('0' + ((Column + 1) / 10));
+ mSetCursorPositionString[COLUMN_OFFSET + 1] = (CHAR16) ('0' + ((Column + 1) % 10));
+ String = mSetCursorPositionString;
+ }
TerminalDevice->OutputEscChar = TRUE;
- Status = This->OutputString (This, mSetCursorPositionString);
+ Status = This->OutputString (This, String);
TerminalDevice->OutputEscChar = FALSE;
if (EFI_ERROR (Status)) {