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

cc9195
From 67415982afdc77922aa37496c981adeb4351acdb 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
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)
cc9195
---
cc9195
 MdeModulePkg/MdeModulePkg.dec                      |  4 +++
cc9195
 .../Universal/Console/TerminalDxe/TerminalConOut.c | 30 ++++++++++++++++++++++
cc9195
 .../Universal/Console/TerminalDxe/TerminalDxe.inf  |  2 ++
cc9195
 3 files changed, 36 insertions(+)
cc9195
cc9195
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
cc9195
index cc39718..384d901 100644
cc9195
--- a/MdeModulePkg/MdeModulePkg.dec
cc9195
+++ b/MdeModulePkg/MdeModulePkg.dec
cc9195
@@ -1914,6 +1914,10 @@
cc9195
   # @Prompt The address mask when memory encryption is enabled.
cc9195
   gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask|0x0|UINT64|0x30001047
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
cc9195
index 5a83431..fbc1e0a 100644
cc9195
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
cc9195
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
cc9195
@@ -13,6 +13,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
cc9195
 
cc9195
 **/
cc9195
 
cc9195
+#include <Library/PrintLib.h>
cc9195
+
cc9195
 #include "Terminal.h"
cc9195
 
cc9195
 //
cc9195
@@ -87,6 +89,16 @@ CHAR16 mCursorForwardString[]      = { ESC, '[', '0', '0', 'C', 0 };
cc9195
 CHAR16 mCursorBackwardString[]     = { ESC, '[', '0', '0', 'D', 0 };
cc9195
 
cc9195
 //
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
+
cc9195
+//
cc9195
 // Body of the ConOut functions
cc9195
 //
cc9195
 
cc9195
@@ -508,6 +520,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
cc9195
index 0780296..bd2ba82 100644
cc9195
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
cc9195
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
cc9195
@@ -60,6 +60,7 @@
cc9195
   DebugLib
cc9195
   PcdLib
cc9195
   BaseLib
cc9195
+  PrintLib
cc9195
 
cc9195
 [Guids]
cc9195
   ## SOMETIMES_PRODUCES ## Variable:L"ConInDev"
cc9195
@@ -88,6 +89,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
-- 
cc9195
1.8.3.1
cc9195