efi_loader: use log function in boot manager

When booting via the boot manager use log function for user messages
instead of printf() and debug().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
This commit is contained in:
Heinrich Schuchardt 2020-05-31 10:07:31 +02:00
parent cb7116030a
commit 7a373e5435

View file

@ -5,6 +5,8 @@
* Copyright (c) 2017 Rob Clark * Copyright (c) 2017 Rob Clark
*/ */
#define LOG_CATEGORY LOGC_EFI
#include <common.h> #include <common.h>
#include <charset.h> #include <charset.h>
#include <log.h> #include <log.h>
@ -203,14 +205,14 @@ static efi_status_t try_load_entry(u16 n, efi_handle_t *handle)
if (lo.attributes & LOAD_OPTION_ACTIVE) { if (lo.attributes & LOAD_OPTION_ACTIVE) {
u32 attributes; u32 attributes;
debug("%s: trying to load \"%ls\" from %pD\n", log_debug("%s: trying to load \"%ls\" from %pD\n",
__func__, lo.label, lo.file_path); __func__, lo.label, lo.file_path);
ret = EFI_CALL(efi_load_image(true, efi_root, lo.file_path, ret = EFI_CALL(efi_load_image(true, efi_root, lo.file_path,
NULL, 0, handle)); NULL, 0, handle));
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
printf("Loading from Boot%04X '%ls' failed\n", n, log_warning("Loading %ls '%ls' failed\n",
lo.label); varname, lo.label);
goto error; goto error;
} }
@ -224,11 +226,11 @@ static efi_status_t try_load_entry(u16 n, efi_handle_t *handle)
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
if (EFI_CALL(efi_unload_image(*handle)) if (EFI_CALL(efi_unload_image(*handle))
!= EFI_SUCCESS) != EFI_SUCCESS)
printf("Unloading image failed\n"); log_err("Unloading image failed\n");
goto error; goto error;
} }
printf("Booting: %ls\n", lo.label); log_info("Booting: %ls\n", lo.label);
} else { } else {
ret = EFI_LOAD_ERROR; ret = EFI_LOAD_ERROR;
} }
@ -268,7 +270,7 @@ efi_status_t efi_bootmgr_load(efi_handle_t *handle)
if (ret == EFI_SUCCESS || ret == EFI_BUFFER_TOO_SMALL) { if (ret == EFI_SUCCESS || ret == EFI_BUFFER_TOO_SMALL) {
/* BootNext does exist here */ /* BootNext does exist here */
if (ret == EFI_BUFFER_TOO_SMALL || size != sizeof(u16)) if (ret == EFI_BUFFER_TOO_SMALL || size != sizeof(u16))
printf("BootNext must be 16-bit integer\n"); log_err("BootNext must be 16-bit integer\n");
/* delete BootNext */ /* delete BootNext */
ret = EFI_CALL(efi_set_variable( ret = EFI_CALL(efi_set_variable(
@ -283,24 +285,26 @@ efi_status_t efi_bootmgr_load(efi_handle_t *handle)
ret = try_load_entry(bootnext, handle); ret = try_load_entry(bootnext, handle);
if (ret == EFI_SUCCESS) if (ret == EFI_SUCCESS)
return ret; return ret;
printf("Loading from BootNext failed, falling back to BootOrder\n"); log_warning(
"Loading from BootNext failed, falling back to BootOrder\n");
} }
} else { } else {
printf("Deleting BootNext failed\n"); log_err("Deleting BootNext failed\n");
} }
} }
/* BootOrder */ /* BootOrder */
bootorder = get_var(L"BootOrder", &efi_global_variable_guid, &size); bootorder = get_var(L"BootOrder", &efi_global_variable_guid, &size);
if (!bootorder) { if (!bootorder) {
printf("BootOrder not defined\n"); log_info("BootOrder not defined\n");
ret = EFI_NOT_FOUND; ret = EFI_NOT_FOUND;
goto error; goto error;
} }
num = size / sizeof(uint16_t); num = size / sizeof(uint16_t);
for (i = 0; i < num; i++) { for (i = 0; i < num; i++) {
debug("%s: trying to load Boot%04X\n", __func__, bootorder[i]); log_debug("%s trying to load Boot%04X\n", __func__,
bootorder[i]);
ret = try_load_entry(bootorder[i], handle); ret = try_load_entry(bootorder[i], handle);
if (ret == EFI_SUCCESS) if (ret == EFI_SUCCESS)
break; break;