Blame SOURCES/0010-MdeModulePkg-TerminalDxe-set-xterm-resolution-on-mod.patch

c54fd1
From b9c5c901f25e48d68eef6e78a4abca00e153f574 Mon Sep 17 00:00:00 2001
c54fd1
From: Laszlo Ersek <lersek@redhat.com>
c54fd1
Date: Tue, 25 Feb 2014 22:40:01 +0100
c54fd1
Subject: MdeModulePkg: TerminalDxe: set xterm resolution on mode change (RH
c54fd1
 only)
c54fd1
c54fd1
The
c54fd1
c54fd1
  CSI Ps ; Ps ; Ps t
c54fd1
c54fd1
escape sequence serves for window manipulation. We can use the
c54fd1
c54fd1
  CSI 8 ; <rows> ; <columns> t
c54fd1
c54fd1
sequence to adapt eg. the xterm window size to the selected console mode.
c54fd1
c54fd1
Notes about the 20160608b-988715a -> 20170228-c325e41585e3 rebase:
c54fd1
c54fd1
- refresh commit 519b9751573e against various context changes
c54fd1
c54fd1
Notes about the 20170228-c325e41585e3 -> 20171011-92d07e48907f rebase:
c54fd1
c54fd1
- Refresh downstream-only commit 2909e025db68 against "MdeModulePkg.dec"
c54fd1
  context change from upstream commits e043f7895b83 ("MdeModulePkg: Add
c54fd1
  PCD PcdPteMemoryEncryptionAddressOrMask", 2017-02-27) and 76081dfcc5b2
c54fd1
  ("MdeModulePkg: Add PROMPT&HELP string of pcd to UNI file", 2017-03-03).
c54fd1
c54fd1
Reference: <http://rtfm.etla.org/xterm/ctlseq.html>
c54fd1
Contributed-under: TianoCore Contribution Agreement 1.0
c54fd1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
c54fd1
(cherry picked from commit 2909e025db6878723b49644a8a0cf160d07e6444)
c54fd1
---
c54fd1
 MdeModulePkg/MdeModulePkg.dec                      |  4 +++
c54fd1
 .../Universal/Console/TerminalDxe/TerminalConOut.c | 30 ++++++++++++++++++++++
c54fd1
 .../Universal/Console/TerminalDxe/TerminalDxe.inf  |  2 ++
c54fd1
 3 files changed, 36 insertions(+)
c54fd1
c54fd1
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
c54fd1
index a3c0633..cd0264e 100644
c54fd1
--- a/MdeModulePkg/MdeModulePkg.dec
c54fd1
+++ b/MdeModulePkg/MdeModulePkg.dec
c54fd1
@@ -1758,6 +1758,10 @@
c54fd1
   # @Prompt The address mask when memory encryption is enabled.
c54fd1
   gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask|0x0|UINT64|0x30001047
c54fd1
 
c54fd1
+  ## Controls whether TerminalDxe outputs an XTerm resize sequence on terminal
c54fd1
+  #  mode change.
c54fd1
+  gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm|FALSE|BOOLEAN|0x00010080
c54fd1
+
c54fd1
 [PcdsPatchableInModule]
c54fd1
   ## Specify memory size with page number for PEI code when
c54fd1
   #  Loading Module at Fixed Address feature is enabled.
c54fd1
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
c54fd1
index e677a76..e2bdc31 100644
c54fd1
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
c54fd1
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
c54fd1
@@ -13,6 +13,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
c54fd1
 
c54fd1
 **/
c54fd1
 
c54fd1
+#include <Library/PrintLib.h>
c54fd1
+
c54fd1
 #include "Terminal.h"
c54fd1
 
c54fd1
 //
c54fd1
@@ -87,6 +89,16 @@ CHAR16 mCursorForwardString[]      = { ESC, '[', '0', '0', 'C', 0 };
c54fd1
 CHAR16 mCursorBackwardString[]     = { ESC, '[', '0', '0', 'D', 0 };
c54fd1
 
c54fd1
 //
c54fd1
+// Note that this is an ASCII format string, taking two INT32 arguments:
c54fd1
+// rows, columns.
c54fd1
+//
c54fd1
+// A %d (INT32) format specification can expand to at most 11 characters.
c54fd1
+//
c54fd1
+CHAR8 mResizeTextAreaFormatString[] = "\x1B[8;%d;%dt";
c54fd1
+#define RESIZE_SEQ_SIZE (sizeof mResizeTextAreaFormatString + 2 * (11 - 2))
c54fd1
+
c54fd1
+
c54fd1
+//
c54fd1
 // Body of the ConOut functions
c54fd1
 //
c54fd1
 
c54fd1
@@ -508,6 +520,24 @@ TerminalConOutSetMode (
c54fd1
     return EFI_DEVICE_ERROR;
c54fd1
   }
c54fd1
 
c54fd1
+  if (PcdGetBool (PcdResizeXterm)) {
c54fd1
+    CHAR16 ResizeSequence[RESIZE_SEQ_SIZE];
c54fd1
+
c54fd1
+    UnicodeSPrintAsciiFormat (
c54fd1
+      ResizeSequence,
c54fd1
+      sizeof ResizeSequence,
c54fd1
+      mResizeTextAreaFormatString,
c54fd1
+      (INT32) TerminalDevice->TerminalConsoleModeData[ModeNumber].Rows,
c54fd1
+      (INT32) TerminalDevice->TerminalConsoleModeData[ModeNumber].Columns
c54fd1
+      );
c54fd1
+    TerminalDevice->OutputEscChar = TRUE;
c54fd1
+    Status                        = This->OutputString (This, ResizeSequence);
c54fd1
+    TerminalDevice->OutputEscChar = FALSE;
c54fd1
+    if (EFI_ERROR (Status)) {
c54fd1
+      return EFI_DEVICE_ERROR;
c54fd1
+    }
c54fd1
+  }
c54fd1
+
c54fd1
   This->Mode->Mode  = (INT32) ModeNumber;
c54fd1
 
c54fd1
   Status            = This->ClearScreen (This);
c54fd1
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
c54fd1
index 0780296..bd2ba82 100644
c54fd1
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
c54fd1
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
c54fd1
@@ -60,6 +60,7 @@
c54fd1
   DebugLib
c54fd1
   PcdLib
c54fd1
   BaseLib
c54fd1
+  PrintLib
c54fd1
 
c54fd1
 [Guids]
c54fd1
   ## SOMETIMES_PRODUCES ## Variable:L"ConInDev"
c54fd1
@@ -88,6 +89,7 @@
c54fd1
 [Pcd]
c54fd1
   gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType           ## SOMETIMES_CONSUMES
c54fd1
   gEfiMdeModulePkgTokenSpaceGuid.PcdErrorCodeSetVariable    ## CONSUMES
c54fd1
+  gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm             ## CONSUMES
c54fd1
 
c54fd1
 # [Event]
c54fd1
 # # Relative timer event set by UnicodeToEfiKey(), used to be one 2 seconds input timeout.
c54fd1
-- 
c54fd1
1.8.3.1
c54fd1