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

63d87e
From a11602f5e2ef930be5b693ddfd0c789a1bd4c60c Mon Sep 17 00:00:00 2001
cc9195
From: Laszlo Ersek <lersek@redhat.com>
cc9195
Date: Tue, 25 Feb 2014 22:40:01 +0100
cc9195
Subject: MdeModulePkg: TerminalDxe: set xterm resolution on mode change (RH
cc9195
 only)
cc9195
63d87e
Notes about the RHEL-8.1/20190308-89910a39dcfd [edk2-stable201903] ->
63d87e
RHEL-8.2/20190904-37eef91017ad [edk2-stable201908] rebase:
63d87e
63d87e
- Conflict in "MdeModulePkg/MdeModulePkg.dec" due to upstream commits
63d87e
  - 1103ba946aee ("MdeModulePkg: Add Capsule On Disk related definition.",
63d87e
    2019-06-26),
63d87e
  - 1c7b3eb84631 ("MdeModulePkg/DxeIpl: Introduce PCD
63d87e
    PcdUse5LevelPageTable", 2019-08-09),
63d87e
  with easy manual resolution.
63d87e
fcd20d
Notes about the RHEL-8.0/20180508-ee3198e672e2 ->
fcd20d
RHEL-8.1/20190308-89910a39dcfd rebase:
fcd20d
fcd20d
- no change
fcd20d
cc9195
Notes about the RHEL-7.6/ovmf-20180508-2.gitee3198e672e2.el7 ->
cc9195
RHEL-8.0/20180508-ee3198e672e2 rebase:
cc9195
cc9195
- reorder the rebase changelog in the commit message so that it reads like
cc9195
  a blog: place more recent entries near the top
cc9195
- no changes to the patch body
cc9195
cc9195
Notes about the 20171011-92d07e48907f -> 20180508-ee3198e672e2 rebase:
cc9195
cc9195
- no change
cc9195
cc9195
Notes about the 20170228-c325e41585e3 -> 20171011-92d07e48907f rebase:
cc9195
cc9195
- Refresh downstream-only commit 2909e025db68 against "MdeModulePkg.dec"
cc9195
  context change from upstream commits e043f7895b83 ("MdeModulePkg: Add
cc9195
  PCD PcdPteMemoryEncryptionAddressOrMask", 2017-02-27) and 76081dfcc5b2
cc9195
  ("MdeModulePkg: Add PROMPT&HELP string of pcd to UNI file", 2017-03-03).
cc9195
cc9195
Notes about the 20160608b-988715a -> 20170228-c325e41585e3 rebase:
cc9195
cc9195
- refresh commit 519b9751573e against various context changes
cc9195
cc9195
The
cc9195
cc9195
  CSI Ps ; Ps ; Ps t
cc9195
cc9195
escape sequence serves for window manipulation. We can use the
cc9195
cc9195
  CSI 8 ; <rows> ; <columns> t
cc9195
cc9195
sequence to adapt eg. the xterm window size to the selected console mode.
cc9195
cc9195
Reference: <http://rtfm.etla.org/xterm/ctlseq.html>
cc9195
Contributed-under: TianoCore Contribution Agreement 1.0
cc9195
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
cc9195
(cherry picked from commit 2909e025db6878723b49644a8a0cf160d07e6444)
cc9195
(cherry picked from commit b9c5c901f25e48d68eef6e78a4abca00e153f574)
cc9195
(cherry picked from commit b7f6115b745de8cbc5214b6ede33c9a8558beb90)
fcd20d
(cherry picked from commit 67415982afdc77922aa37496c981adeb4351acdb)
63d87e
(cherry picked from commit cfccb98d13e955beb0b93b4a75a973f30c273ffc)
cc9195
---
fcd20d
 MdeModulePkg/MdeModulePkg.dec                 |  4 +++
fcd20d
 .../Console/TerminalDxe/TerminalConOut.c      | 30 +++++++++++++++++++
fcd20d
 .../Console/TerminalDxe/TerminalDxe.inf       |  2 ++
cc9195
 3 files changed, 36 insertions(+)
cc9195
cc9195
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
63d87e
index 19935c88fa..5690bbd8b3 100644
cc9195
--- a/MdeModulePkg/MdeModulePkg.dec
cc9195
+++ b/MdeModulePkg/MdeModulePkg.dec
63d87e
@@ -2002,6 +2002,10 @@
63d87e
   # @Prompt Capsule On Disk relocation device path.
63d87e
   gEfiMdeModulePkgTokenSpaceGuid.PcdCodRelocationDevPath|{0xFF}|VOID*|0x0000002f
cc9195
 
cc9195
+  ## Controls whether TerminalDxe outputs an XTerm resize sequence on terminal
cc9195
+  #  mode change.
cc9195
+  gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm|FALSE|BOOLEAN|0x00010080
cc9195
+
cc9195
 [PcdsPatchableInModule]
cc9195
   ## Specify memory size with page number for PEI code when
cc9195
   #  Loading Module at Fixed Address feature is enabled.
cc9195
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
63d87e
index 7ef655cca5..1113252df2 100644
cc9195
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
cc9195
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
63d87e
@@ -7,6 +7,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
cc9195
 
cc9195
 **/
cc9195
 
cc9195
+#include <Library/PrintLib.h>
cc9195
+
cc9195
 #include "Terminal.h"
cc9195
 
cc9195
 //
63d87e
@@ -80,6 +82,16 @@ CHAR16 mSetCursorPositionString[]  = { ESC, '[', '0', '0', ';', '0', '0', 'H', 0
fcd20d
 CHAR16 mCursorForwardString[]      = { ESC, '[', '0', '0', 'C', 0 };
cc9195
 CHAR16 mCursorBackwardString[]     = { ESC, '[', '0', '0', 'D', 0 };
cc9195
 
fcd20d
+//
cc9195
+// Note that this is an ASCII format string, taking two INT32 arguments:
cc9195
+// rows, columns.
cc9195
+//
cc9195
+// A %d (INT32) format specification can expand to at most 11 characters.
cc9195
+//
cc9195
+CHAR8 mResizeTextAreaFormatString[] = "\x1B[8;%d;%dt";
cc9195
+#define RESIZE_SEQ_SIZE (sizeof mResizeTextAreaFormatString + 2 * (11 - 2))
cc9195
+
cc9195
+
fcd20d
 //
cc9195
 // Body of the ConOut functions
cc9195
 //
63d87e
@@ -502,6 +514,24 @@ TerminalConOutSetMode (
cc9195
     return EFI_DEVICE_ERROR;
cc9195
   }
cc9195
 
cc9195
+  if (PcdGetBool (PcdResizeXterm)) {
cc9195
+    CHAR16 ResizeSequence[RESIZE_SEQ_SIZE];
cc9195
+
cc9195
+    UnicodeSPrintAsciiFormat (
cc9195
+      ResizeSequence,
cc9195
+      sizeof ResizeSequence,
cc9195
+      mResizeTextAreaFormatString,
cc9195
+      (INT32) TerminalDevice->TerminalConsoleModeData[ModeNumber].Rows,
cc9195
+      (INT32) TerminalDevice->TerminalConsoleModeData[ModeNumber].Columns
cc9195
+      );
cc9195
+    TerminalDevice->OutputEscChar = TRUE;
cc9195
+    Status                        = This->OutputString (This, ResizeSequence);
cc9195
+    TerminalDevice->OutputEscChar = FALSE;
cc9195
+    if (EFI_ERROR (Status)) {
cc9195
+      return EFI_DEVICE_ERROR;
cc9195
+    }
cc9195
+  }
cc9195
+
cc9195
   This->Mode->Mode  = (INT32) ModeNumber;
cc9195
 
cc9195
   Status            = This->ClearScreen (This);
cc9195
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
63d87e
index 24e164ef4d..d1160ed1c7 100644
cc9195
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
cc9195
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
63d87e
@@ -55,6 +55,7 @@
cc9195
   DebugLib
cc9195
   PcdLib
cc9195
   BaseLib
cc9195
+  PrintLib
cc9195
 
cc9195
 [Guids]
cc9195
   ## SOMETIMES_PRODUCES ## Variable:L"ConInDev"
63d87e
@@ -83,6 +84,7 @@
cc9195
 [Pcd]
cc9195
   gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType           ## SOMETIMES_CONSUMES
cc9195
   gEfiMdeModulePkgTokenSpaceGuid.PcdErrorCodeSetVariable    ## CONSUMES
cc9195
+  gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm             ## CONSUMES
cc9195
 
cc9195
 # [Event]
cc9195
 # # Relative timer event set by UnicodeToEfiKey(), used to be one 2 seconds input timeout.
cc9195
-- 
fcd20d
2.18.1
cc9195