render / rpms / edk2

Forked from rpms/edk2 2 months ago
Clone

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

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