Blame 0005-MdeModulePkg-TerminalDxe-set-xterm-resolution-on-mod.patch

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