mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/5] EFI fixes
@ 2017-01-23 17:02 Michael Olbrich
  2017-01-23 17:02 ` [PATCH 1/5] readkey: keys are unsigned char Michael Olbrich
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Michael Olbrich @ 2017-01-23 17:02 UTC (permalink / raw)
  To: barebox; +Cc: Michael Olbrich

A few small fixes to improve the barebox experience on EFI. Not all are
strictly EFI specific, but that's where I came across the problems.

Regards,
Michael

Michael Olbrich (5):
  readkey: keys are unsigned char
  serial: efi: improve input handling
  output: use '[0m' to reset colors
  efi: include and execute exit calls
  efi: don't unload drivers

 arch/efi/Makefile                 | 4 ++--
 arch/efi/efi/efi-image.c          | 9 ++++++++-
 arch/efi/lib/elf_x86_64_efi.lds.S | 1 +
 commands/2048.c                   | 2 +-
 common/menu.c                     | 2 +-
 drivers/serial/efi-stdio.c        | 3 ++-
 include/readkey.h                 | 4 ++--
 lib/readkey.c                     | 4 ++--
 8 files changed, 19 insertions(+), 10 deletions(-)

-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 1/5] readkey: keys are unsigned char
  2017-01-23 17:02 [PATCH 0/5] EFI fixes Michael Olbrich
@ 2017-01-23 17:02 ` Michael Olbrich
  2017-01-23 17:02 ` [PATCH 2/5] serial: efi: improve input handling Michael Olbrich
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Michael Olbrich @ 2017-01-23 17:02 UTC (permalink / raw)
  To: barebox; +Cc: Michael Olbrich

Otherwise values > 127 will become negative and are dropped.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
---
 lib/readkey.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/readkey.c b/lib/readkey.c
index 2870a5a9fee5..e72da0066bdc 100644
--- a/lib/readkey.c
+++ b/lib/readkey.c
@@ -51,8 +51,8 @@ static const struct esc_cmds esccmds[] = {
 
 int read_key(void)
 {
-	char c;
-	char esc[5];
+	unsigned char c;
+	unsigned char esc[5];
 	c = getchar();
 
 	if (c == 27) {
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 2/5] serial: efi: improve input handling
  2017-01-23 17:02 [PATCH 0/5] EFI fixes Michael Olbrich
  2017-01-23 17:02 ` [PATCH 1/5] readkey: keys are unsigned char Michael Olbrich
@ 2017-01-23 17:02 ` Michael Olbrich
  2017-01-23 17:02 ` [PATCH 3/5] output: use '[0m' to reset colors Michael Olbrich
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Michael Olbrich @ 2017-01-23 17:02 UTC (permalink / raw)
  To: barebox; +Cc: Michael Olbrich

0x08 is the scan-code for 'backspace' not 'delete'.
0x17 indicates the start of an escape sequence, such as "[3~" for
'delete'.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
---
 drivers/serial/efi-stdio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/serial/efi-stdio.c b/drivers/serial/efi-stdio.c
index bf14c5e24aa5..5ab917386e60 100644
--- a/drivers/serial/efi-stdio.c
+++ b/drivers/serial/efi-stdio.c
@@ -99,9 +99,10 @@ static struct efi_ctrlkey ctrlkeys[] = {
 	{ 0x05, BB_KEY_HOME },
 	{ 0x06, BB_KEY_END },
 	{ 0x07, BB_KEY_INSERT },
-	{ 0x08, BB_KEY_DEL },
+	{ 0x08, BB_KEY_DEL7 },
 	{ 0x09, BB_KEY_PAGEUP },
 	{ 0x0a, BB_KEY_PAGEDOWN },
+	{ 0x17, 27 /* escape key */ },
 };
 
 static int efi_read_key(struct efi_console_priv *priv, bool wait)
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 3/5] output: use '[0m' to reset colors
  2017-01-23 17:02 [PATCH 0/5] EFI fixes Michael Olbrich
  2017-01-23 17:02 ` [PATCH 1/5] readkey: keys are unsigned char Michael Olbrich
  2017-01-23 17:02 ` [PATCH 2/5] serial: efi: improve input handling Michael Olbrich
@ 2017-01-23 17:02 ` Michael Olbrich
  2017-01-23 17:02 ` [PATCH 4/5] efi: include and execute exit calls Michael Olbrich
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Michael Olbrich @ 2017-01-23 17:02 UTC (permalink / raw)
  To: barebox; +Cc: Michael Olbrich

'[m' is supposed to have the same effect as '[0m'. However, some EFI
implementations seem to ignore '[m', so use '[0m' everywhere to avoid
rendering issues.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
---
 commands/2048.c   | 2 +-
 common/menu.c     | 2 +-
 include/readkey.h | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/commands/2048.c b/commands/2048.c
index 5ceb5cfb7d12..865803a5a616 100644
--- a/commands/2048.c
+++ b/commands/2048.c
@@ -53,7 +53,7 @@ static void getColor(uint16_t value, char *color, size_t length)
 static void drawBoard(uint16_t board[SIZE][SIZE])
 {
 	int8_t x,y;
-	char color[40], reset[] = "\033[m";
+	char color[40], reset[] = "\033[0m";
 	printf("\033[H");
 
 	printf("2048.c %17d pts\n\n",score);
diff --git a/common/menu.c b/common/menu.c
index e757216c5adf..31e5c90a0f27 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -185,7 +185,7 @@ static void print_menu_entry(struct menu *m, struct menu_entry *me,
 	__print_entry(me->display);
 
 	if (selected)
-		puts("\e[m");
+		puts("\e[0m");
 }
 
 int menu_set_selected_entry(struct menu *m, struct menu_entry* me)
diff --git a/include/readkey.h b/include/readkey.h
index 8398ec2e516e..ed1cd1542d6f 100644
--- a/include/readkey.h
+++ b/include/readkey.h
@@ -26,8 +26,8 @@
 
 #define ANSI_CLEAR_SCREEN "\e[2J\e[;H"
 
-#define printf_reverse(fmt,args...)	printf("\e[7m" fmt "\e[m",##args)
-#define puts_reverse(fmt)		puts("\e[7m" fmt "\e[m")
+#define printf_reverse(fmt,args...)	printf("\e[7m" fmt "\e[0m",##args)
+#define puts_reverse(fmt)		puts("\e[7m" fmt "\e[0m")
 #define gotoXY(row, col)		printf("\e[%d;%dH", col, row)
 #define clear()				puts("\e[2J")
 
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 4/5] efi: include and execute exit calls
  2017-01-23 17:02 [PATCH 0/5] EFI fixes Michael Olbrich
                   ` (2 preceding siblings ...)
  2017-01-23 17:02 ` [PATCH 3/5] output: use '[0m' to reset colors Michael Olbrich
@ 2017-01-23 17:02 ` Michael Olbrich
  2017-01-23 17:02 ` [PATCH 5/5] efi: don't unload drivers Michael Olbrich
  2017-01-24  8:35 ` [PATCH 0/5] EFI fixes Sascha Hauer
  5 siblings, 0 replies; 7+ messages in thread
From: Michael Olbrich @ 2017-01-23 17:02 UTC (permalink / raw)
  To: barebox; +Cc: Michael Olbrich

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
---
 arch/efi/Makefile                 | 4 ++--
 arch/efi/efi/efi-image.c          | 2 ++
 arch/efi/lib/elf_x86_64_efi.lds.S | 1 +
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/efi/Makefile b/arch/efi/Makefile
index b078bd0e356d..32a1c152b791 100644
--- a/arch/efi/Makefile
+++ b/arch/efi/Makefile
@@ -28,8 +28,8 @@ cmd_barebox__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_barebox) -o $@	\
 quiet_cmd_efi_image = EFI-IMG $@
       cmd_efi_image = $(OBJCOPY) -j .text -j .sdata -j .data -j .dynamic \
 		      -j .dynsym -j .rel -j .rela -j .reloc -j __barebox_initcalls \
-		      -j __barebox_cmd -j .barebox_magicvar -j .bbenv.* \
-		      --target=$(TARGET) $< $@
+		      -j __barebox_exitcalls -j __barebox_cmd -j .barebox_magicvar \
+		      -j .bbenv.* --target=$(TARGET) $< $@
 
 KBUILD_BINARY := barebox
 
diff --git a/arch/efi/efi/efi-image.c b/arch/efi/efi/efi-image.c
index 32e060886a33..c780cad6d447 100644
--- a/arch/efi/efi/efi-image.c
+++ b/arch/efi/efi/efi-image.c
@@ -145,6 +145,7 @@ static int efi_execute_image(const char *file)
 		loaded_image->load_options = xstrdup_char_to_wchar(options);
 		loaded_image->load_options_size =
 			(strlen(options) + 1) * sizeof(wchar_t);
+		shutdown_barebox();
 	}
 
 	efiret = BS->start_image(handle, NULL, NULL);
@@ -255,6 +256,7 @@ static int do_bootm_efi(struct image_data *data)
 	efi_set_variable_usec("LoaderTimeExecUSec", &efi_systemd_vendor_guid,
 			      get_time_ns()/1000);
 
+	shutdown_barebox();
 	linux_efi_handover(handle, boot_header);
 
 	return 0;
diff --git a/arch/efi/lib/elf_x86_64_efi.lds.S b/arch/efi/lib/elf_x86_64_efi.lds.S
index e1bc2120fabc..93d34d17ab1f 100644
--- a/arch/efi/lib/elf_x86_64_efi.lds.S
+++ b/arch/efi/lib/elf_x86_64_efi.lds.S
@@ -80,6 +80,7 @@ SECTIONS
 		*(.rela.data*)
 		*(.rela.barebox*)
 		*(.rela.initcall*)
+		*(.rela.exitcall*)
 		*(.rela.got)
 		*(.rela.stab)
 	}
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 5/5] efi: don't unload drivers
  2017-01-23 17:02 [PATCH 0/5] EFI fixes Michael Olbrich
                   ` (3 preceding siblings ...)
  2017-01-23 17:02 ` [PATCH 4/5] efi: include and execute exit calls Michael Olbrich
@ 2017-01-23 17:02 ` Michael Olbrich
  2017-01-24  8:35 ` [PATCH 0/5] EFI fixes Sascha Hauer
  5 siblings, 0 replies; 7+ messages in thread
From: Michael Olbrich @ 2017-01-23 17:02 UTC (permalink / raw)
  To: barebox; +Cc: Michael Olbrich

EFI applications should be unloaded to avoid leaking memory. However, boot
or runtime services continue in the background. So they must not be
unloaded.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
---
 arch/efi/efi/efi-image.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/efi/efi/efi-image.c b/arch/efi/efi/efi-image.c
index c780cad6d447..27f3c1b39c22 100644
--- a/arch/efi/efi/efi-image.c
+++ b/arch/efi/efi/efi-image.c
@@ -130,12 +130,16 @@ static int efi_execute_image(const char *file)
 	efi_status_t efiret;
 	struct linux_kernel_header *image_header;
 	const char *options;
+	bool is_driver;
 	int ret;
 
 	ret = efi_load_image(file, &loaded_image, &handle);
 	if (ret)
 		return ret;
 
+	is_driver = (loaded_image->image_code_type == EFI_BOOT_SERVICES_CODE) ||
+		(loaded_image->image_code_type == EFI_RUNTIME_SERVICES_CODE);
+
 	image_header = (struct linux_kernel_header *)loaded_image->image_base;
 	if (image_header->boot_flag == 0xAA55 &&
 	    image_header->header == 0x53726448) {
@@ -152,7 +156,8 @@ static int efi_execute_image(const char *file)
 	if (EFI_ERROR(efiret))
 		pr_err("failed to StartImage: %s\n", efi_strerror(efiret));
 
-	BS->unload_image(handle);
+	if (!is_driver)
+		BS->unload_image(handle);
 
 	efi_connect_all();
 	efi_register_devices();
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 0/5] EFI fixes
  2017-01-23 17:02 [PATCH 0/5] EFI fixes Michael Olbrich
                   ` (4 preceding siblings ...)
  2017-01-23 17:02 ` [PATCH 5/5] efi: don't unload drivers Michael Olbrich
@ 2017-01-24  8:35 ` Sascha Hauer
  5 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2017-01-24  8:35 UTC (permalink / raw)
  To: Michael Olbrich; +Cc: barebox

On Mon, Jan 23, 2017 at 06:02:13PM +0100, Michael Olbrich wrote:
> A few small fixes to improve the barebox experience on EFI. Not all are
> strictly EFI specific, but that's where I came across the problems.
> 
> Regards,
> Michael
> 
> Michael Olbrich (5):
>   readkey: keys are unsigned char
>   serial: efi: improve input handling
>   output: use '[0m' to reset colors
>   efi: include and execute exit calls
>   efi: don't unload drivers

Applied, thanks

Sascha

> 
>  arch/efi/Makefile                 | 4 ++--
>  arch/efi/efi/efi-image.c          | 9 ++++++++-
>  arch/efi/lib/elf_x86_64_efi.lds.S | 1 +
>  commands/2048.c                   | 2 +-
>  common/menu.c                     | 2 +-
>  drivers/serial/efi-stdio.c        | 3 ++-
>  include/readkey.h                 | 4 ++--
>  lib/readkey.c                     | 4 ++--
>  8 files changed, 19 insertions(+), 10 deletions(-)
> 
> -- 
> 2.11.0
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2017-01-24  8:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-23 17:02 [PATCH 0/5] EFI fixes Michael Olbrich
2017-01-23 17:02 ` [PATCH 1/5] readkey: keys are unsigned char Michael Olbrich
2017-01-23 17:02 ` [PATCH 2/5] serial: efi: improve input handling Michael Olbrich
2017-01-23 17:02 ` [PATCH 3/5] output: use '[0m' to reset colors Michael Olbrich
2017-01-23 17:02 ` [PATCH 4/5] efi: include and execute exit calls Michael Olbrich
2017-01-23 17:02 ` [PATCH 5/5] efi: don't unload drivers Michael Olbrich
2017-01-24  8:35 ` [PATCH 0/5] EFI fixes Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox