render / rpms / edk2

Forked from rpms/edk2 2 months ago
Clone

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

fdb3e7
From 50b53194f7caea602e04df663358617c280f299c 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
294170
Subject: [PATCH] MdeModulePkg: TerminalDxe: set xterm resolution on mode
Paolo Bonzini 7ae6f1
 change (RH only)
Paolo Bonzini 348500
Paolo Bonzini 348500
The
Paolo Bonzini 348500
Paolo Bonzini 348500
  CSI Ps ; Ps ; Ps t
Paolo Bonzini 348500
Paolo Bonzini 348500
escape sequence serves for window manipulation. We can use the
Paolo Bonzini 348500
Paolo Bonzini 348500
  CSI 8 ; <rows> ; <columns> t
Paolo Bonzini 348500
Paolo Bonzini 348500
sequence to adapt eg. the xterm window size to the selected console mode.
Paolo Bonzini 348500
Paolo Bonzini 348500
Notes about the 20160608b-988715a -> 20170228-c325e41585e3 rebase:
Paolo Bonzini 348500
Paolo Bonzini 348500
- refresh commit 519b9751573e against various context changes
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
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)
Paolo Bonzini 7ae6f1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Paolo Bonzini 348500
---
Paolo Bonzini 7ae6f1
 MdeModulePkg/MdeModulePkg.dec                 |  4 +++
Paolo Bonzini 7ae6f1
 .../Console/TerminalDxe/TerminalConOut.c      | 30 +++++++++++++++++++
Paolo Bonzini 7ae6f1
 .../Console/TerminalDxe/TerminalDxe.inf       |  2 ++
Paolo Bonzini 348500
 3 files changed, 36 insertions(+)
Paolo Bonzini 348500
Paolo Bonzini 348500
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
fdb3e7
index cb30a79758..e562bed57e 100644
Paolo Bonzini 348500
--- a/MdeModulePkg/MdeModulePkg.dec
Paolo Bonzini 348500
+++ b/MdeModulePkg/MdeModulePkg.dec
fdb3e7
@@ -2013,6 +2013,10 @@
fdb3e7
   # @Prompt Enable StatusCode via memory.
fdb3e7
   gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory|FALSE|BOOLEAN|0x00010023
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.
Paolo Bonzini 348500
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
0a0d66
index aae470e956..26156857aa 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
 //
740797
@@ -80,6 +82,16 @@ CHAR16 mSetCursorPositionString[]  = { ESC, '[', '0', '0', ';', '0', '0', 'H', 0
Paolo Bonzini 7ae6f1
 CHAR16 mCursorForwardString[]      = { ESC, '[', '0', '0', 'C', 0 };
Paolo Bonzini 348500
 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
+//
Paolo Bonzini 348500
+CHAR8 mResizeTextAreaFormatString[] = "\x1B[8;%d;%dt";
Paolo Bonzini 348500
+#define RESIZE_SEQ_SIZE (sizeof mResizeTextAreaFormatString + 2 * (11 - 2))
Paolo Bonzini 348500
+
Paolo Bonzini 348500
+
Paolo Bonzini 7ae6f1
 //
Paolo Bonzini 348500
 // Body of the ConOut functions
Paolo Bonzini 348500
 //
0a0d66
@@ -506,6 +518,24 @@ TerminalConOutSetMode (
Paolo Bonzini 348500
     return EFI_DEVICE_ERROR;
Paolo Bonzini 348500
   }
Paolo Bonzini 348500
 
Paolo Bonzini 348500
+  if (PcdGetBool (PcdResizeXterm)) {
Paolo Bonzini 348500
+    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,
Paolo Bonzini 348500
+      (INT32) TerminalDevice->TerminalConsoleModeData[ModeNumber].Rows,
Paolo Bonzini 348500
+      (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
+
Paolo Bonzini 348500
   This->Mode->Mode  = (INT32) ModeNumber;
Paolo Bonzini 348500
 
Paolo Bonzini 348500
   Status            = This->ClearScreen (This);
Paolo Bonzini 348500
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
0a0d66
index b2a8aeba85..eff6253465 100644
Paolo Bonzini 348500
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
Paolo Bonzini 348500
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
740797
@@ -55,6 +55,7 @@
Paolo Bonzini 348500
   DebugLib
Paolo Bonzini 348500
   PcdLib
Paolo Bonzini 348500
   BaseLib
Paolo Bonzini 348500
+  PrintLib
Paolo Bonzini 348500
 
Paolo Bonzini 348500
 [Guids]
Paolo Bonzini 348500
   ## SOMETIMES_PRODUCES ## Variable:L"ConInDev"
0a0d66
@@ -87,6 +88,7 @@
Paolo Bonzini 348500
 [Pcd]
Paolo Bonzini 348500
   gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType           ## SOMETIMES_CONSUMES
Paolo Bonzini 348500
   gEfiMdeModulePkgTokenSpaceGuid.PcdErrorCodeSetVariable    ## CONSUMES
Paolo Bonzini 348500
+  gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm             ## CONSUMES
Paolo Bonzini 348500
 
Paolo Bonzini 348500
 # [Event]
Paolo Bonzini 348500
 # # Relative timer event set by UnicodeToEfiKey(), used to be one 2 seconds input timeout.