[U-Boot] [PATCH v3 3/3] efi_loader: provide meaningful status code

Heinrich Schuchardt xypron.glpk at gmx.de
Tue Jul 4 21:15:23 UTC 2017


Currenty any EFI status other than EFI_SUCCESS is reported as
Application terminated, r = -22

With the patch the status code returned by the EFI application
is printed.

Cc: Alexander Graf <agraf at suse.de>
Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
v3:	Use constant EFI_ERROR_MASK to convert status code to
	remove hight bit.
v2:
	Do not output status code mnemonic.
	Alexander suggested this to reduce code size.
	We may add a CONFIG option for mnemonic output later.
---
 cmd/bootefi.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 4df468307c..802b5f245f 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -252,8 +252,7 @@ static unsigned long do_bootefi_exec(void *efi, void *fdt)
 	debug("%s:%d Jumping to 0x%lx\n", __func__, __LINE__, (long)entry);
 
 	if (setjmp(&loaded_image_info.exit_jmp)) {
-		efi_status_t status = loaded_image_info.exit_status;
-		return status == EFI_SUCCESS ? 0 : -EINVAL;
+		return loaded_image_info.exit_status;
 	}
 
 #ifdef CONFIG_ARM64
@@ -281,7 +280,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	char *saddr, *sfdt;
 	unsigned long addr, fdt_addr = 0;
-	int r = 0;
+	unsigned long r;
 
 	if (argc < 2)
 		return CMD_RET_USAGE;
@@ -306,12 +305,13 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 	printf("## Starting EFI application at %08lx ...\n", addr);
 	r = do_bootefi_exec((void *)addr, (void*)fdt_addr);
-	printf("## Application terminated, r = %d\n", r);
+	printf("## Application terminated, r = %lu\n",
+	       r & ~EFI_ERROR_MASK);
 
-	if (r != 0)
-		r = 1;
-
-	return r;
+	if (r != EFI_SUCCESS)
+		return 1;
+	else
+		return 0;
 }
 
 #ifdef CONFIG_SYS_LONGHELP
-- 
2.11.0



More information about the U-Boot mailing list