Skip to contentSkip to conversation

efi_loader: environment variables for terminal size

PATCH New Heinrich Schuchardt 3 participants 4 messages Sep 14, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 efi_loader: environment variables for terminal size

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.

---
 doc/README.uefi              | 14 ++++++++++++++
 lib/efi_loader/efi_console.c | 15 ++++++++++++++-
 2 files changed, 28 insertions(+), 1 deletion(-)
doc/README.uefi +14 -0
index 6b9759cfed..df0cf5b7ce 100644
@@ -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
lib/efi_loader/efi_console.c +14 -1
index 73f7ecf919..40e33f9fd3 100644
@@ -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;
Signature · 1 line
2.18.0
#1 lore raw

PATCH 1/1 efi_loader: environment variables for terminal size

Quoted 3 lines · Heinrich Schuchardt

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

Quoted 69 lines

variables LINES and COLUMNS to set the terminal size manually.

---
 doc/README.uefi              | 14 ++++++++++++++
 lib/efi_loader/efi_console.c | 15 ++++++++++++++-
 2 files changed, 28 insertions(+), 1 deletion(-)
doc/README.uefi +14 -0
index 6b9759cfed..df0cf5b7ce 100644
@@ -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
lib/efi_loader/efi_console.c +14 -1
index 73f7ecf919..40e33f9fd3 100644
@@ -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 lore raw

PATCH 1/1 efi_loader: environment variables for terminal size

Quoted 11 lines · Alexander Graf
Quoted 3 lines · Heinrich Schuchardt

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

Quoted 73 lines

Alex

Quoted 69 lines

variables LINES and COLUMNS to set the terminal size manually.

---
 doc/README.uefi              | 14 ++++++++++++++
 lib/efi_loader/efi_console.c | 15 ++++++++++++++-
 2 files changed, 28 insertions(+), 1 deletion(-)
doc/README.uefi +14 -0
index 6b9759cfed..df0cf5b7ce 100644
@@ -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
lib/efi_loader/efi_console.c +14 -1
index 73f7ecf919..40e33f9fd3 100644
@@ -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;
#3 lore raw

PATCH 1/1 efi_loader: environment variables for terminal size

In reply to Alexander Graf
Quoted 11 lines

From: Alexander Graf <[email protected]>
Date: Fri, 14 Sep 2018 07:21:56 +0200

Quoted 3 lines · Heinrich Schuchardt

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.

Quoted 74 lines
Quoted 59 lines

variables LINES and COLUMNS to set the terminal size manually.

---
 doc/README.uefi              | 14 ++++++++++++++
 lib/efi_loader/efi_console.c | 15 ++++++++++++++-
 2 files changed, 28 insertions(+), 1 deletion(-)
doc/README.uefi +14 -0
index 6b9759cfed..df0cf5b7ce 100644
@@ -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
lib/efi_loader/efi_console.c +7 -1
index 73f7ecf919..40e33f9fd3 100644
@@ -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");

lib/efi_loader/efi_console.c static void query_console_size(void) · line 256

Quoted 10 lines
lib/efi_loader/efi_console.c +7 -0
+	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