From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E70E9C433F5 for ; Thu, 28 Apr 2022 11:53:02 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A4D8C831CA; Thu, 28 Apr 2022 13:52:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="FJdPIg/V"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 471E5811A6; Thu, 28 Apr 2022 13:52:54 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E51C383EC6 for ; Thu, 28 Apr 2022 13:52:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1651146739; bh=jA+fLKLYStUnCatwUOTojWHrhSWu613Ld9N8dVn+k+s=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=FJdPIg/VK5jUXjElFA2w+Sc8yWxjtREK4Hgs8ijhUllOlM4oTgy1TT3K8sEm4r9WA caEme6G3csPqlJd1KKmqG0o8x5D/3DyKLRfeg+9i/ESBMOd15AlFqioSCMQlb9kRq+ 6DcQqQ5gyfLDnRRl6B7kpdOI8GMSe7QIerhaCV2c= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.123.67] ([62.143.94.109]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N3bSt-1nsb574BaV-010Zrx; Thu, 28 Apr 2022 13:52:19 +0200 Message-ID: Date: Thu, 28 Apr 2022 13:52:18 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH] efi_loader: Improve console screen clearing and reset Content-Language: en-US To: Jan Kiszka Cc: U-Boot Mailing List References: <5fc52b9e-8e04-4bbc-86c5-3adcd213d1c6@siemens.com> From: Heinrich Schuchardt In-Reply-To: <5fc52b9e-8e04-4bbc-86c5-3adcd213d1c6@siemens.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:hf97px9vr/ETgN4xvSVf7qbyb0G7hJuSkc/pvsAZ/OoAxSxcGJp wjsuThofbFxy4XNZ15++GQYXlG1i9rcvJOfM8lxFlmquVfdiYrMznVWtqWZsCi10l1xKtLN Fuf1POriVvVj4sFUOIA6DWErer9AtzldD9GyW/PZdhiDsLLCVDcXCz0UuIGbPNyoqtQ2bbA wyl5chHdiCp7eWub6thrw== X-UI-Out-Filterresults: notjunk:1;V03:K0:EfZqdGO0Zu8=:/XQTiqSFPAgtL0QuOiNSha uwQ6xB4xMoiSBstVryJy7i0t6DhTnLrB4RgapnTDyz6yg773E+zp5MF7KLpIFXEtKGM36NTeJ M49BT4elJJt0b+WLgF50ftK0uc5pCmPHIJJxs3V7KTZgNCe7bY/9SVEborts4daaJJu51VwkG y/z1h6CuMIqKup5n6gNCnn2AEimHHB4BkRk8PGHaYgf3jxxjOTKh6hKq6VhcaSGNXr4MAqs6F Q8k40PG13cJC8ZoI5aUO5Skl2A35xUq32ph0WpiipMdgAGPM9qmcOsiVabDM3BEBqje8DHby8 Qh5NNJtjGDq4MOmtxFlEsEn6k7svEEW+PGyGUuD+rkFDSuNbc16uq3jJkY/Kksnqcf9Y+qEl8 vqlxEOnSYevbgrC2zfmXQeOEDie53fu1D0m43DdLfdYYuTTsNf2MB6l40MpMRL9P9QuyBC5jP a31thcN1AQRB/htNu/q8CyryKm90zH1lGv02sh11UIF7fSUdLDsrKNMwwAliUdYNwe68Ig3Hx 2UuZIt0/p1/Zdwd06uQiGtwrL7DLWX/txfiIWbFUo2yu+oD5J+VokJwHIYcoSO9jfkeBfVNrJ 819dDpE2ft53JRZcA2p2ECKBhgReQkAQ0wc8STefftG7VYE6fZzkEJ9SvUiduoDbX5WlxSAak ThqBYIpDr4+EvagPqDtlSzifbvtlbtlouOEV5IzKMyJ2lpuODJ1IgaFwWX5voV4WbghlpolwR mRDuCohMoQ1U/+gFUPUKf1OhK9aq5Ze4C9NUj7uv9hfT0jF4dfJcHiP6Z66UfnEX3CVyvo23g bUKcLU8O1m19NMyYxkbkTkGK9WH/edSIIN8L3zKCrA+ayDzrPGYQ9+ItJYQglp1gJBgIi0R3b PPBX5MkuTII1avP5/og/ZxWCwo+pwtNQG7bpN0zbI9Y590RMcTpduuXnsOkcyLajG2+GPrHJf hwmBvYYU912ZtYigzOf99VOwdAzThHH4VF6+MsDEDrv5RnbQHHEOZzrL7BrJJpiS8+HuNnTfX yYGj8N9zwYsWY1K0Zb3Zp6PgzoMTk7xW0h4bNh7a8PlHIhRN7o4Jg+StoTXS3nKjG2VyAtiG5 YKiM7WtNXBi/J8= X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean On 4/25/22 11:23, Jan Kiszka wrote: > From: Jan Kiszka > > Ensure that the default colors are set when clearing the screen so that > the background is properly filled and succeeding colored outputs will > have no differently colored trail. > > Before clearing, ensure that no previous output of firmware or UEFI > programs will overwritten on serial devices or other streaming consoles. > This helps generating complete boot logs. > > Signed-off-by: Jan Kiszka > --- > lib/efi_loader/efi_console.c | 16 +++++++++++++--- > 1 file changed, 13 insertions(+), 3 deletions(-) > > diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c > index ba68a150172..0270b20bafe 100644 > --- a/lib/efi_loader/efi_console.c > +++ b/lib/efi_loader/efi_console.c > @@ -463,8 +463,18 @@ static efi_status_t EFIAPI efi_cout_set_attribute( > static efi_status_t EFIAPI efi_cout_clear_screen( > struct efi_simple_text_output_protocol *this) > { > + unsigned int row; > + > EFI_ENTRY("%p", this); > > + /* Avoid overwriting previous outputs on streaming consoles */ Thank you for addressing the inconvenience of the partially deleted scrollback buffer. Don't assume that the cursor is in the last line. You first have to move it there: printf(ESC "%d;1H", efi_cout_modes[efi_con_mode.mode].rows); > + for (row =3D 1; row < efi_cout_modes[efi_con_mode.mode].rows; row++) > + printf("\n"); We may have both video output and serial output. The proposed logic may not work out correctly if the video screen size differs from the screen size of the serial console. Your solution does not cover the cls command. It will not work with the proposed UEFI boot menu (https://patchwork.ozlabs.org/project/uboot/list/?series=3D297320). A complete solution would have to reside in _serial_puts(). But I doubt that we want to enlarge the code size there. Therefore I am a bit skeptical about the suggested change. > + > + /* Set default colors if not done yet */ > + if (efi_con_mode.attribute =3D=3D 0) > + efi_cout_set_attribute(this, 0x07); The UEFI specification has this sentence: "The ClearScreen() function clears the output device(s) display to the currently selected background color." So we should not switch colors here. The currently selected background when starting the first UEFI application depends on CONFIG_SYS_WHITE_ON_BLACK. > + > /* > * The Linux console wants both a clear and a home command. The video > * uclass does not support [H without coordinates, yet. > @@ -522,11 +532,11 @@ static efi_status_t EFIAPI efi_cout_reset( > { > EFI_ENTRY("%p, %d", this, extended_verification); > > + /* Trigger reset to default colors */ > + efi_con_mode.attribute =3D 0; > + > /* Clear screen */ > EFI_CALL(efi_cout_clear_screen(this)); > - /* Set default colors */ > - efi_con_mode.attribute =3D 0x07; This value should depend on CONFIG_SYS_WHITE_ON_BLACK: Also efi_cout_set_attribute(efi_con_out, 0) should consider CONFIG_SYS_WHITE_ON_BLACK. The best thing to do is fixing efi_cout_set_attribute() and invoking EFI_CALL(efi_cout_set_attributed(efi_con_out, 0)); But this is a subject for a separate patch. Best regards Heinrich > - printf(ESC "[0;37;40m"); > > return EFI_EXIT(EFI_SUCCESS); > }