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

8ff9b3
From dc40fd64b7b3bc9bb53a7d4a95b3e80f8cfe5152 Mon Sep 17 00:00:00 2001
7439a5
From: Laszlo Ersek <lersek@redhat.com>
7439a5
Date: Tue, 25 Feb 2014 22:40:01 +0100
7439a5
Subject: MdeModulePkg: TerminalDxe: set xterm resolution on mode change (RH
7439a5
 only)
7439a5
be6997
Notes for rebase to edk2-stable202205:
be6997
be6997
- Minor context changes due to fd306d1dbc MdeModulePkg: Add PcdTdxSharedBitMask
be6997
be6997
Notes for rebase to edk2-stable202202:
be6997
be6997
- Minor context changes due to 1436aea4d MdeModulePkg: Apply uncrustify changes
be6997
7439a5
Notes about the RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] ->
7439a5
RHEL-8.5/20210520-e1999b264f1f [edk2-stable202105] rebase:
7439a5
7439a5
- Resolve harmless conflict in "MdeModulePkg/MdeModulePkg.dec",
7439a5
  originating from new upstream commits
7439a5
  - 45bc28172fbf ("MdeModulePkg.dec: Change PCDs for status code.",
7439a5
                  2020-06-18),
7439a5
  - 0785c619a58a ("MdeModulePkg/Bus/Pci/PciBusDxe: Support PCIe Resizable
7439a5
                  BAR Capability", 2021-01-04),
7439a5
  - ef23012e5439 ("MdeModulePkg: Change default value of
7439a5
                  PcdPcieResizableBarSupport to FALSE", 2021-01-14).
7439a5
7439a5
Notes about the RHEL-8.2/20190904-37eef91017ad [edk2-stable201908] ->
7439a5
RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] rebase:
7439a5
7439a5
- Resolve trivial conflict in "MdeModulePkg/MdeModulePkg.dec", arising
7439a5
  from upstream commit 166830d8f7ca ("MdeModulePkg/dec: add
7439a5
  PcdTcgPfpMeasurementRevision PCD", 2020-01-06).
7439a5
7439a5
Notes about the RHEL-8.1/20190308-89910a39dcfd [edk2-stable201903] ->
7439a5
RHEL-8.2/20190904-37eef91017ad [edk2-stable201908] rebase:
7439a5
7439a5
- Conflict in "MdeModulePkg/MdeModulePkg.dec" due to upstream commits
7439a5
  - 1103ba946aee ("MdeModulePkg: Add Capsule On Disk related definition.",
7439a5
    2019-06-26),
7439a5
  - 1c7b3eb84631 ("MdeModulePkg/DxeIpl: Introduce PCD
7439a5
    PcdUse5LevelPageTable", 2019-08-09),
7439a5
  with easy manual resolution.
7439a5
7439a5
Notes about the RHEL-8.0/20180508-ee3198e672e2 ->
7439a5
RHEL-8.1/20190308-89910a39dcfd rebase:
7439a5
7439a5
- no change
7439a5
7439a5
Notes about the RHEL-7.6/ovmf-20180508-2.gitee3198e672e2.el7 ->
7439a5
RHEL-8.0/20180508-ee3198e672e2 rebase:
7439a5
7439a5
- reorder the rebase changelog in the commit message so that it reads like
7439a5
  a blog: place more recent entries near the top
7439a5
- no changes to the patch body
7439a5
7439a5
Notes about the 20171011-92d07e48907f -> 20180508-ee3198e672e2 rebase:
7439a5
7439a5
- no change
7439a5
7439a5
Notes about the 20170228-c325e41585e3 -> 20171011-92d07e48907f rebase:
7439a5
7439a5
- Refresh downstream-only commit 2909e025db68 against "MdeModulePkg.dec"
7439a5
  context change from upstream commits e043f7895b83 ("MdeModulePkg: Add
7439a5
  PCD PcdPteMemoryEncryptionAddressOrMask", 2017-02-27) and 76081dfcc5b2
7439a5
  ("MdeModulePkg: Add PROMPT&HELP string of pcd to UNI file", 2017-03-03).
7439a5
7439a5
Notes about the 20160608b-988715a -> 20170228-c325e41585e3 rebase:
7439a5
7439a5
- refresh commit 519b9751573e against various context changes
7439a5
7439a5
The
7439a5
7439a5
  CSI Ps ; Ps ; Ps t
7439a5
7439a5
escape sequence serves for window manipulation. We can use the
7439a5
7439a5
  CSI 8 ; <rows> ; <columns> t
7439a5
7439a5
sequence to adapt eg. the xterm window size to the selected console mode.
7439a5
7439a5
Reference: <http://rtfm.etla.org/xterm/ctlseq.html>
7439a5
Contributed-under: TianoCore Contribution Agreement 1.0
7439a5
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
7439a5
(cherry picked from commit 2909e025db6878723b49644a8a0cf160d07e6444)
7439a5
(cherry picked from commit b9c5c901f25e48d68eef6e78a4abca00e153f574)
7439a5
(cherry picked from commit b7f6115b745de8cbc5214b6ede33c9a8558beb90)
7439a5
(cherry picked from commit 67415982afdc77922aa37496c981adeb4351acdb)
7439a5
(cherry picked from commit cfccb98d13e955beb0b93b4a75a973f30c273ffc)
7439a5
(cherry picked from commit a11602f5e2ef930be5b693ddfd0c789a1bd4c60c)
7439a5
(cherry picked from commit bc2266f20de5db1636e09a07e4a72c8dbf505f5a)
7439a5
---
7439a5
 MdeModulePkg/MdeModulePkg.dec                 |  4 +++
7439a5
 .../Console/TerminalDxe/TerminalConOut.c      | 30 +++++++++++++++++++
7439a5
 .../Console/TerminalDxe/TerminalDxe.inf       |  2 ++
7439a5
 3 files changed, 36 insertions(+)
7439a5
7439a5
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
8ff9b3
index 775f1b27af..94f3394cef 100644
7439a5
--- a/MdeModulePkg/MdeModulePkg.dec
7439a5
+++ b/MdeModulePkg/MdeModulePkg.dec
8ff9b3
@@ -2099,6 +2099,10 @@
be6997
   # @Prompt The shared bit mask when Intel Tdx is enabled.
be6997
   gEfiMdeModulePkgTokenSpaceGuid.PcdTdxSharedBitMask|0x0|UINT64|0x10000025
7439a5
 
7439a5
+  ## Controls whether TerminalDxe outputs an XTerm resize sequence on terminal
7439a5
+  #  mode change.
7439a5
+  gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm|FALSE|BOOLEAN|0x00010080
7439a5
+
7439a5
 [PcdsPatchableInModule]
7439a5
   ## Specify memory size with page number for PEI code when
7439a5
   #  Loading Module at Fixed Address feature is enabled.
7439a5
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
be6997
index 7809869e7d..0ce931d644 100644
7439a5
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
7439a5
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
7439a5
@@ -7,6 +7,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
7439a5
 
7439a5
 **/
7439a5
 
7439a5
+#include <Library/PrintLib.h>
7439a5
+
7439a5
 #include "Terminal.h"
7439a5
 
7439a5
 //
be6997
@@ -80,6 +82,16 @@ CHAR16  mSetCursorPositionString[] = { ESC, '[', '0', '0', ';', '0', '0', 'H', 0
be6997
 CHAR16  mCursorForwardString[]     = { ESC, '[', '0', '0', 'C', 0 };
be6997
 CHAR16  mCursorBackwardString[]    = { ESC, '[', '0', '0', 'D', 0 };
7439a5
 
7439a5
+//
7439a5
+// Note that this is an ASCII format string, taking two INT32 arguments:
7439a5
+// rows, columns.
7439a5
+//
7439a5
+// A %d (INT32) format specification can expand to at most 11 characters.
7439a5
+//
7439a5
+CHAR8 mResizeTextAreaFormatString[] = "\x1B[8;%d;%dt";
7439a5
+#define RESIZE_SEQ_SIZE (sizeof mResizeTextAreaFormatString + 2 * (11 - 2))
7439a5
+
7439a5
+
7439a5
 //
7439a5
 // Body of the ConOut functions
7439a5
 //
be6997
@@ -498,6 +510,24 @@ TerminalConOutSetMode (
7439a5
     return EFI_DEVICE_ERROR;
7439a5
   }
7439a5
 
7439a5
+  if (PcdGetBool (PcdResizeXterm)) {
7439a5
+    CHAR16 ResizeSequence[RESIZE_SEQ_SIZE];
7439a5
+
7439a5
+    UnicodeSPrintAsciiFormat (
7439a5
+      ResizeSequence,
7439a5
+      sizeof ResizeSequence,
7439a5
+      mResizeTextAreaFormatString,
7439a5
+      (INT32) TerminalDevice->TerminalConsoleModeData[ModeNumber].Rows,
7439a5
+      (INT32) TerminalDevice->TerminalConsoleModeData[ModeNumber].Columns
7439a5
+      );
7439a5
+    TerminalDevice->OutputEscChar = TRUE;
7439a5
+    Status                        = This->OutputString (This, ResizeSequence);
7439a5
+    TerminalDevice->OutputEscChar = FALSE;
7439a5
+    if (EFI_ERROR (Status)) {
7439a5
+      return EFI_DEVICE_ERROR;
7439a5
+    }
7439a5
+  }
7439a5
+
be6997
   This->Mode->Mode = (INT32)ModeNumber;
7439a5
 
be6997
   Status = This->ClearScreen (This);
7439a5
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
7439a5
index b2a8aeba85..eff6253465 100644
7439a5
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
7439a5
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
7439a5
@@ -55,6 +55,7 @@
7439a5
   DebugLib
7439a5
   PcdLib
7439a5
   BaseLib
7439a5
+  PrintLib
7439a5
 
7439a5
 [Guids]
7439a5
   ## SOMETIMES_PRODUCES ## Variable:L"ConInDev"
7439a5
@@ -87,6 +88,7 @@
7439a5
 [Pcd]
7439a5
   gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType           ## SOMETIMES_CONSUMES
7439a5
   gEfiMdeModulePkgTokenSpaceGuid.PcdErrorCodeSetVariable    ## CONSUMES
7439a5
+  gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm             ## CONSUMES
7439a5
 
7439a5
 # [Event]
7439a5
 # # Relative timer event set by UnicodeToEfiKey(), used to be one 2 seconds input timeout.
7439a5
-- 
8ff9b3
2.38.1
7439a5