From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SqgXHCy7; spf=pass (domain: redhat.com, ip: 170.10.133.124, mailfrom: ppolawsk@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676638936; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SRA2S8zimLx1AnDpqAeTSQ3hnMP8Q5hj9X7gfd7djpU=; b=SqgXHCy7WATmdNROR+schT7L3F7nodjD4yewmjT2Ury0ZwNhb9UB5N7jsdVJOcS8P8tx6V kLTmNSU5hIgNT/ctetA9FxZT+Ug+IEspmrH053ohUBa0a206+xe1jbhMd1GLf0AKNw/wAA m3u7huYsxMK8IN4/Z7apoX/3h1chCrs= 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 Received: by mail-lj1-f197.google.com with SMTP id a38-20020a05651c212600b002931e335f88so247023ljq.11 for ; Fri, 17 Feb 2023 05:02:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SRA2S8zimLx1AnDpqAeTSQ3hnMP8Q5hj9X7gfd7djpU=; b=HSqQ8CYgp4dyhe/2gLc2lJk5BwWZok4kOxJSIwWA0e1ExEzcwix1eTWlwsbaVLOmcq nc5Gmz+sKL9gH8p+mlpWhE6XzJiTt6PJxjPaDc5cssxZvMCujZ8GqS+sH9Z8/tPiTErH sBaf/ouUtP/rK9KV3XlX+jvaMBBjzrQnO8JO2Iecp8K1ktBqf3BJwWmJfWVzdRMK3BVn BA0LtKXO8AcxYh8Cq2mDv3m6jH/WLJJpbE+Jk+zNy3jSUwzbDOFziYVk2uvneHoGgQKE c43dJq6IHpHAKnD/Sy17klpWf3ypJkpGiSVWWGK+Is+39jeL3QMplaW57U8O0HZ32Ov9 PDow== X-Gm-Message-State: AO0yUKUsjcmmS0qtNJSiJXFEC5BtC6h7xRo1TZTlrSKfunvkQaMkbFdB xVzM08OZdz4c7ZXTp3qPyZzcZK8zI3nS8Im9Wna4I4fWRztBOeXZHeboUbgWsGBG8BI76WShygT yZMfEi9xhGOE61joGjUxyGejh05GerJRcXBtohQVyyX2jdPJvLJ8ETaZrUT93v3eCTH1LnCo= 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) Return-Path: 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: X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ł Poławski --- 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, PcdsDynamic, PcdsDynamicEx] # @Prompt The shared bit mask when Intel Tdx is enabled. gEfiMdeModulePkgTokenSpaceGuid.PcdTdxSharedBitMask|0x0|UINT64|0x10000025 + ## Controls whether TerminalDxe outputs an XTerm resize sequence on terminal + # 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/MdeModulePkg/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 [Guids] ## SOMETIMES_PRODUCES ## Variable:L"ConInDev" @@ -87,6 +88,7 @@ [Protocols] [Pcd] gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType ## SOMETIMES_CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdErrorCodeSetVariable ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm ## CONSUMES # [Event] # # Relative timer event set by UnicodeToEfiKey(), used to be one 2 seconds 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 **/ +#include + #include "Terminal.h" // @@ -80,6 +82,15 @@ CHAR16 mSetCursorPositionString[] = { ESC, '[', '0', '0', ';', '0', '0', 'H', 0 CHAR16 mCursorForwardString[] = { ESC, '[', '0', '0', 'C', 0 }; CHAR16 mCursorBackwardString[] = { ESC, '[', '0', '0', 'D', 0 }; +// +// 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[] = "\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; } + 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 = TRUE; + Status = This->OutputString (This, ResizeSequence); + TerminalDevice->OutputEscChar = FALSE; + if (EFI_ERROR (Status)) { + return EFI_DEVICE_ERROR; + } + } + This->Mode->Mode = (INT32)ModeNumber; Status = This->ClearScreen (This); -- 2.39.1