From nobody Thu May 16 05:36:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+100316+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+100316+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1676638938; cv=none; d=zohomail.com; s=zohoarc; b=QTWcbNoJW3GYdvk3eVBLJ3zdDbTsEcjeyeGzgUXCDQoek4D83QFnX2BkjxqTNtEqDTsSqTZvfxN2pevED8ifZ9IpWO/IH9r5eY61DLyQP9+Ah/2/CX/+lMJksuXBufu5NKQ6a30wpOHrlqL4QspQB6Qu0zMPJVbRv0/OOndr6Lw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676638938; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=U4GQ1EYKpMvT0ZuBmx/XU2tEEU2JQgx0EzaKCJn87Ig=; b=XdH3sCUw0iUNJspfl38RypI8GeDoeNxYHdy3t3H9RGUDMAf8BWcB2D5C+tINkMXEizP1Vbi5i3xfHjVEB6h3CnZkXkxbdofXKQw1OJ3Ee5E0zmzKmgAl5pFmJnZPXPXXRt7+8bDmy8dl7KU00cVDnIuCcRSqrm9GnK8/Vb+vSIo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+100316+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1676638938413797.7719287449748; Fri, 17 Feb 2023 05:02:18 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id PMGyYY1788612xFrVCbPPVF8; Fri, 17 Feb 2023 05:02:18 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web10.5790.1676638937108449980 for ; Fri, 17 Feb 2023 05:02:17 -0800 X-Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-494-Xmljb_mVPOOV65Xy9e4tGQ-1; Fri, 17 Feb 2023 08:02:15 -0500 X-MC-Unique: Xmljb_mVPOOV65Xy9e4tGQ-1 X-Received: by mail-lj1-f197.google.com with SMTP id a38-20020a05651c212600b002931e335f88so247023ljq.11 for ; Fri, 17 Feb 2023 05:02:14 -0800 (PST) X-Gm-Message-State: ylV0KVKXc1I8LTUb6DhObnhAx1787277AA= X-Received: by 2002:a05:6512:244:b0:4cc:7282:702b with SMTP id b4-20020a056512024400b004cc7282702bmr112117lfo.2.1676638932806; Fri, 17 Feb 2023 05:02:12 -0800 (PST) X-Google-Smtp-Source: AK7set+YzlLRvnYOTbMgIcHuD//NqwJ+HjYuweiZItCTrLAM8COxvHLw61NPr9zz8R+v+DctQwNLIg== X-Received: by 2002:a05:6512:244:b0:4cc:7282:702b with SMTP id b4-20020a056512024400b004cc7282702bmr112096lfo.2.1676638932336; Fri, 17 Feb 2023 05:02:12 -0800 (PST) X-Received: from czapka.. ([93.177.91.185]) by smtp.gmail.com with ESMTPSA id f20-20020a2e9194000000b002935006e487sm589767ljg.122.2023.02.17.05.02.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Feb 2023 05:02:12 -0800 (PST) From: =?UTF-8?B?UGF3ZcWCIFBvxYJhd3NraQ==?= To: devel@edk2.groups.io Cc: Jian J Wang , Liming Gao Subject: [edk2-devel] PATCH v3 1/3 MdeModulePkg: TerminalDxe: set xterm resolution on mode change Date: Fri, 17 Feb 2023 14:01:37 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ppolawsk@redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1676638938; bh=DpQV5C2Gn+HUHplHE6tfC3kxtjbu5lhc2Pw+xSanWj4=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=a6pHVxA1+AntRslQzDHh+JUfcPx6dj/6SaSB+pl1a8JSMPh490NcO8xL/auGIgwfOzl ohtz1lXYk4uzZSOStWwsj0cb5Kl0UX0ogrG2khslaHadlPcQigb1tM41FwqCR+upMU3Bo y1W8LVzXCczeRNmpHb0gCAJ2wJNNnrs/cn0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1676638939707100004 From: Laszlo Ersek TerminalDxe driver can send xterm control sequences. Reference: This way it can trigger client window resize (xterm, gnome-terminal etc.) accordingly, to a specified number of rows and columns. It improves user experience when handling text mode based operations. New PcdResizeXterm config switch has been added to enable or disable this behaviour. Signed-off-by: Laszlo Ersek Pawel Polawski: Updated commit message for re-submission Cc: Jian J Wang Cc: Liming Gao Signed-off-by: Pawe=C5=82 Po=C5=82awski Acked-by: Ard Biesheuvel --- MdeModulePkg/MdeModulePkg.dec | 4 +++ MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf | 2 ++ MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c | 29 +++++++++= +++++++++++ 3 files changed, 35 insertions(+) diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 9605c617b7a8..76007e0af42a 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -2107,6 +2107,10 @@ [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynami= c, PcdsDynamicEx] # @Prompt The shared bit mask when Intel Tdx is enabled. gEfiMdeModulePkgTokenSpaceGuid.PcdTdxSharedBitMask|0x0|UINT64|0x10000025 =20 + ## Controls whether TerminalDxe outputs an XTerm resize sequence on term= inal + # mode change. + gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm|FALSE|BOOLEAN|0x00010080 + [PcdsPatchableInModule] ## Specify memory size with page number for PEI code when # Loading Module at Fixed Address feature is enabled. diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf b/M= deModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf index b2a8aeba8510..eff625346539 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf +++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf @@ -55,6 +55,7 @@ [LibraryClasses] DebugLib PcdLib BaseLib + PrintLib =20 [Guids] ## SOMETIMES_PRODUCES ## Variable:L"ConInDev" @@ -87,6 +88,7 @@ [Protocols] [Pcd] gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType ## SOMETIMES_C= ONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdErrorCodeSetVariable ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm ## CONSUMES =20 # [Event] # # Relative timer event set by UnicodeToEfiKey(), used to be one 2 second= s input timeout. diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c b/= MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c index 7809869e7d49..496849458db4 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c +++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c @@ -7,6 +7,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 +#include + #include "Terminal.h" =20 // @@ -80,6 +82,15 @@ CHAR16 mSetCursorPositionString[] =3D { ESC, '[', '0', = '0', ';', '0', '0', 'H', 0 CHAR16 mCursorForwardString[] =3D { ESC, '[', '0', '0', 'C', 0 }; CHAR16 mCursorBackwardString[] =3D { ESC, '[', '0', '0', 'D', 0 }; =20 +// +// Note that this is an ASCII format string, taking two INT32 arguments: +// rows, columns. +// +// A %d (INT32) format specification can expand to at most 11 characters. +// +CHAR8 mResizeTextAreaFormatString[] =3D "\x1B[8;%d;%dt"; +#define RESIZE_SEQ_SIZE (sizeof mResizeTextAreaFormatString + 2 * (11 - 2= )) + // // Body of the ConOut functions // @@ -498,6 +509,24 @@ TerminalConOutSetMode ( return EFI_DEVICE_ERROR; } =20 + if (PcdGetBool (PcdResizeXterm)) { + CHAR16 ResizeSequence[RESIZE_SEQ_SIZE]; + + UnicodeSPrintAsciiFormat ( + ResizeSequence, + sizeof ResizeSequence, + mResizeTextAreaFormatString, + (INT32)TerminalDevice->TerminalConsoleModeData[ModeNumber].Rows, + (INT32)TerminalDevice->TerminalConsoleModeData[ModeNumber].Columns + ); + TerminalDevice->OutputEscChar =3D TRUE; + Status =3D This->OutputString (This, ResizeSequ= ence); + TerminalDevice->OutputEscChar =3D FALSE; + if (EFI_ERROR (Status)) { + return EFI_DEVICE_ERROR; + } + } + This->Mode->Mode =3D (INT32)ModeNumber; =20 Status =3D This->ClearScreen (This); --=20 2.39.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#100316): https://edk2.groups.io/g/devel/message/100316 Mute This Topic: https://groups.io/mt/97027219/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-