All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/1] efi_loader: environment variables for terminal size
@ 2018-09-14  4:41 Heinrich Schuchardt
  2018-09-14  5:21 ` Alexander Graf
  0 siblings, 1 reply; 4+ messages in thread
From: Heinrich Schuchardt @ 2018-09-14  4:41 UTC (permalink / raw)
  To: u-boot

Correct scrolling in EFI applications like the EFI Shell requires correct
setting of the terminal size. Detecting the terminal size over the serial
interface is often not supported. The patch introduces the environment
variables LINES and COLUMNS to set the terminal size manually.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 doc/README.uefi              | 14 ++++++++++++++
 lib/efi_loader/efi_console.c | 15 ++++++++++++++-
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/doc/README.uefi b/doc/README.uefi
index 6b9759cfed..df0cf5b7ce 100644
--- a/doc/README.uefi
+++ b/doc/README.uefi
@@ -299,6 +299,20 @@ This driver is only available if U-Boot is configured with
     CONFIG_BLK=y
     CONFIG_PARTITIONS=y
 
+## Setting the terminal size
+
+For correct scrolling the terminal size has to be known.
+
+The default terminal size is 80x25.
+
+If the environment variable 'stdout' has the value 'vidconsole', the terminal
+size is determined by querying the video console driver. Else it is tried to
+determine the terminal size by sending ESC '[18t' to the console which may
+reply with an escape sequence indicating the terminal size.
+
+It is possible to override the terminal size by setting the environment
+variables 'LINES' and 'COLUMNS'.
+
 ## TODOs as of U-Boot 2018.07
 
 * unimplemented or incompletely implemented boot services
diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
index 73f7ecf919..40e33f9fd3 100644
--- a/lib/efi_loader/efi_console.c
+++ b/lib/efi_loader/efi_console.c
@@ -224,6 +224,7 @@ static void query_console_size(void)
 {
 	const char *stdout_name = env_get("stdout");
 	int rows = 25, cols = 80;
+	char *value;
 
 	if (stdout_name && !strcmp(stdout_name, "vidconsole") &&
 	    IS_ENABLED(CONFIG_DM_VIDEO)) {
@@ -235,9 +236,21 @@ static void query_console_size(void)
 		rows = priv->rows;
 		cols = priv->cols;
 	} else if (query_console_serial(&rows, &cols)) {
-		return;
+		rows = 25;
+		cols = 80;
 	}
 
+	value = env_get("LINES");
+	if (value)
+		rows = simple_strtoul(value, NULL, 10);
+	value = env_get("COLUMNS");
+	if (value)
+		cols = simple_strtoul(value, NULL, 10);
+	if (rows <= 0)
+		rows = 25;
+	if (cols <= 0)
+		cols = 80;
+
 	/* Test if we can have Mode 1 */
 	if (cols >= 80 && rows >= 50) {
 		efi_cout_modes[1].present = 1;
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH 1/1] efi_loader: environment variables for terminal size
  2018-09-14  4:41 [U-Boot] [PATCH 1/1] efi_loader: environment variables for terminal size Heinrich Schuchardt
@ 2018-09-14  5:21 ` Alexander Graf
  2018-09-14  5:48   ` Heinrich Schuchardt
  2018-09-14  8:21   ` Mark Kettenis
  0 siblings, 2 replies; 4+ messages in thread
From: Alexander Graf @ 2018-09-14  5:21 UTC (permalink / raw)
  To: u-boot



On 14.09.18 06:41, Heinrich Schuchardt wrote:
> Correct scrolling in EFI applications like the EFI Shell requires correct
> setting of the terminal size. Detecting the terminal size over the serial
> interface is often not supported. The patch introduces the environment

Can you give examples on when it's not supported? I think most cases
I've encountered in the last 10 years do support just reading them via
escape sequences.


Alex

> variables LINES and COLUMNS to set the terminal size manually.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
>  doc/README.uefi              | 14 ++++++++++++++
>  lib/efi_loader/efi_console.c | 15 ++++++++++++++-
>  2 files changed, 28 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/README.uefi b/doc/README.uefi
> index 6b9759cfed..df0cf5b7ce 100644
> --- a/doc/README.uefi
> +++ b/doc/README.uefi
> @@ -299,6 +299,20 @@ This driver is only available if U-Boot is configured with
>      CONFIG_BLK=y
>      CONFIG_PARTITIONS=y
>  
> +## Setting the terminal size
> +
> +For correct scrolling the terminal size has to be known.
> +
> +The default terminal size is 80x25.
> +
> +If the environment variable 'stdout' has the value 'vidconsole', the terminal
> +size is determined by querying the video console driver. Else it is tried to
> +determine the terminal size by sending ESC '[18t' to the console which may
> +reply with an escape sequence indicating the terminal size.
> +
> +It is possible to override the terminal size by setting the environment
> +variables 'LINES' and 'COLUMNS'.
> +
>  ## TODOs as of U-Boot 2018.07
>  
>  * unimplemented or incompletely implemented boot services
> diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
> index 73f7ecf919..40e33f9fd3 100644
> --- a/lib/efi_loader/efi_console.c
> +++ b/lib/efi_loader/efi_console.c
> @@ -224,6 +224,7 @@ static void query_console_size(void)
>  {
>  	const char *stdout_name = env_get("stdout");
>  	int rows = 25, cols = 80;
> +	char *value;
>  
>  	if (stdout_name && !strcmp(stdout_name, "vidconsole") &&
>  	    IS_ENABLED(CONFIG_DM_VIDEO)) {
> @@ -235,9 +236,21 @@ static void query_console_size(void)
>  		rows = priv->rows;
>  		cols = priv->cols;
>  	} else if (query_console_serial(&rows, &cols)) {
> -		return;
> +		rows = 25;
> +		cols = 80;
>  	}
>  
> +	value = env_get("LINES");
> +	if (value)
> +		rows = simple_strtoul(value, NULL, 10);
> +	value = env_get("COLUMNS");
> +	if (value)
> +		cols = simple_strtoul(value, NULL, 10);
> +	if (rows <= 0)
> +		rows = 25;
> +	if (cols <= 0)
> +		cols = 80;
> +
>  	/* Test if we can have Mode 1 */
>  	if (cols >= 80 && rows >= 50) {
>  		efi_cout_modes[1].present = 1;
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH 1/1] efi_loader: environment variables for terminal size
  2018-09-14  5:21 ` Alexander Graf
@ 2018-09-14  5:48   ` Heinrich Schuchardt
  2018-09-14  8:21   ` Mark Kettenis
  1 sibling, 0 replies; 4+ messages in thread
From: Heinrich Schuchardt @ 2018-09-14  5:48 UTC (permalink / raw)
  To: u-boot

On 09/14/2018 07:21 AM, Alexander Graf wrote:
> 
> 
> On 14.09.18 06:41, Heinrich Schuchardt wrote:
>> Correct scrolling in EFI applications like the EFI Shell requires correct
>> setting of the terminal size. Detecting the terminal size over the serial
>> interface is often not supported. The patch introduces the environment
> 
> Can you give examples on when it's not supported? I think most cases
> I've encountered in the last 10 years do support just reading them via
> escape sequences.
> 

I am using KDE. When running qemu-system-aarch64 in konsole or xterm
U-Boot never receives a response to the request.

Best regards

Heinrich

> 
> Alex
> 
>> variables LINES and COLUMNS to set the terminal size manually.
>>
>> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
>> ---
>>  doc/README.uefi              | 14 ++++++++++++++
>>  lib/efi_loader/efi_console.c | 15 ++++++++++++++-
>>  2 files changed, 28 insertions(+), 1 deletion(-)
>>
>> diff --git a/doc/README.uefi b/doc/README.uefi
>> index 6b9759cfed..df0cf5b7ce 100644
>> --- a/doc/README.uefi
>> +++ b/doc/README.uefi
>> @@ -299,6 +299,20 @@ This driver is only available if U-Boot is configured with
>>      CONFIG_BLK=y
>>      CONFIG_PARTITIONS=y
>>  
>> +## Setting the terminal size
>> +
>> +For correct scrolling the terminal size has to be known.
>> +
>> +The default terminal size is 80x25.
>> +
>> +If the environment variable 'stdout' has the value 'vidconsole', the terminal
>> +size is determined by querying the video console driver. Else it is tried to
>> +determine the terminal size by sending ESC '[18t' to the console which may
>> +reply with an escape sequence indicating the terminal size.
>> +
>> +It is possible to override the terminal size by setting the environment
>> +variables 'LINES' and 'COLUMNS'.
>> +
>>  ## TODOs as of U-Boot 2018.07
>>  
>>  * unimplemented or incompletely implemented boot services
>> diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
>> index 73f7ecf919..40e33f9fd3 100644
>> --- a/lib/efi_loader/efi_console.c
>> +++ b/lib/efi_loader/efi_console.c
>> @@ -224,6 +224,7 @@ static void query_console_size(void)
>>  {
>>  	const char *stdout_name = env_get("stdout");
>>  	int rows = 25, cols = 80;
>> +	char *value;
>>  
>>  	if (stdout_name && !strcmp(stdout_name, "vidconsole") &&
>>  	    IS_ENABLED(CONFIG_DM_VIDEO)) {
>> @@ -235,9 +236,21 @@ static void query_console_size(void)
>>  		rows = priv->rows;
>>  		cols = priv->cols;
>>  	} else if (query_console_serial(&rows, &cols)) {
>> -		return;
>> +		rows = 25;
>> +		cols = 80;
>>  	}
>>  
>> +	value = env_get("LINES");
>> +	if (value)
>> +		rows = simple_strtoul(value, NULL, 10);
>> +	value = env_get("COLUMNS");
>> +	if (value)
>> +		cols = simple_strtoul(value, NULL, 10);
>> +	if (rows <= 0)
>> +		rows = 25;
>> +	if (cols <= 0)
>> +		cols = 80;
>> +
>>  	/* Test if we can have Mode 1 */
>>  	if (cols >= 80 && rows >= 50) {
>>  		efi_cout_modes[1].present = 1;
>>
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH 1/1] efi_loader: environment variables for terminal size
  2018-09-14  5:21 ` Alexander Graf
  2018-09-14  5:48   ` Heinrich Schuchardt
@ 2018-09-14  8:21   ` Mark Kettenis
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Kettenis @ 2018-09-14  8:21 UTC (permalink / raw)
  To: u-boot

> From: Alexander Graf <agraf@suse.de>
> Date: Fri, 14 Sep 2018 07:21:56 +0200
> 
> On 14.09.18 06:41, Heinrich Schuchardt wrote:
> > Correct scrolling in EFI applications like the EFI Shell requires correct
> > setting of the terminal size. Detecting the terminal size over the serial
> > interface is often not supported. The patch introduces the environment
> 
> Can you give examples on when it's not supported? I think most cases
> I've encountered in the last 10 years do support just reading them via
> escape sequences.

There are multiple "standards" for these escape sequences so you can't
use them without knowing the terminal type.  So unless you implement a
way to set the terminal type in U-Boot that is a bad idea as sending
random control characters to a terminal that doesn't understand them
you invariably make it unusable.  This should then also include a
"dumb" setting since users may want to redirected the serial line
output to something that isn't a terminal at all.  At that point I
think Heinrich's solution is much simpler and better.

> > variables LINES and COLUMNS to set the terminal size manually.
> > 
> > Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> > ---
> >  doc/README.uefi              | 14 ++++++++++++++
> >  lib/efi_loader/efi_console.c | 15 ++++++++++++++-
> >  2 files changed, 28 insertions(+), 1 deletion(-)
> > 
> > diff --git a/doc/README.uefi b/doc/README.uefi
> > index 6b9759cfed..df0cf5b7ce 100644
> > --- a/doc/README.uefi
> > +++ b/doc/README.uefi
> > @@ -299,6 +299,20 @@ This driver is only available if U-Boot is configured with
> >      CONFIG_BLK=y
> >      CONFIG_PARTITIONS=y
> >  
> > +## Setting the terminal size
> > +
> > +For correct scrolling the terminal size has to be known.
> > +
> > +The default terminal size is 80x25.
> > +
> > +If the environment variable 'stdout' has the value 'vidconsole', the terminal
> > +size is determined by querying the video console driver. Else it is tried to
> > +determine the terminal size by sending ESC '[18t' to the console which may
> > +reply with an escape sequence indicating the terminal size.
> > +
> > +It is possible to override the terminal size by setting the environment
> > +variables 'LINES' and 'COLUMNS'.
> > +
> >  ## TODOs as of U-Boot 2018.07
> >  
> >  * unimplemented or incompletely implemented boot services
> > diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
> > index 73f7ecf919..40e33f9fd3 100644
> > --- a/lib/efi_loader/efi_console.c
> > +++ b/lib/efi_loader/efi_console.c
> > @@ -224,6 +224,7 @@ static void query_console_size(void)
> >  {
> >  	const char *stdout_name = env_get("stdout");
> >  	int rows = 25, cols = 80;
> > +	char *value;
> >  
> >  	if (stdout_name && !strcmp(stdout_name, "vidconsole") &&
> >  	    IS_ENABLED(CONFIG_DM_VIDEO)) {
> > @@ -235,9 +236,21 @@ static void query_console_size(void)
> >  		rows = priv->rows;
> >  		cols = priv->cols;
> >  	} else if (query_console_serial(&rows, &cols)) {
> > -		return;
> > +		rows = 25;
> > +		cols = 80;
> >  	}
> >  
> > +	value = env_get("LINES");
> > +	if (value)
> > +		rows = simple_strtoul(value, NULL, 10);
> > +	value = env_get("COLUMNS");
> > +	if (value)
> > +		cols = simple_strtoul(value, NULL, 10);
> > +	if (rows <= 0)
> > +		rows = 25;
> > +	if (cols <= 0)
> > +		cols = 80;
> > +
> >  	/* Test if we can have Mode 1 */
> >  	if (cols >= 80 && rows >= 50) {
> >  		efi_cout_modes[1].present = 1;
> > 
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> https://lists.denx.de/listinfo/u-boot
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-09-14  8:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-14  4:41 [U-Boot] [PATCH 1/1] efi_loader: environment variables for terminal size Heinrich Schuchardt
2018-09-14  5:21 ` Alexander Graf
2018-09-14  5:48   ` Heinrich Schuchardt
2018-09-14  8:21   ` Mark Kettenis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.