* Copyright (c) 2016 Alexander Graf
*/
+#define LOG_CATEGORY LOGC_EFI
+
#include <common.h>
#include <charset.h>
#include <command.h>
#include <env.h>
#include <errno.h>
#include <image.h>
+#include <log.h>
#include <malloc.h>
#include <linux/libfdt.h>
#include <linux/libfdt_env.h>
size = utf8_utf16_strlen(env) + 1;
loaded_image_info->load_options = calloc(size, sizeof(u16));
if (!loaded_image_info->load_options) {
- printf("ERROR: Out of memory\n");
+ log_err("ERROR: Out of memory\n");
EFI_CALL(systab.boottime->close_protocol(handle,
&efi_guid_loaded_image,
efi_root, NULL));
EFI_ACPI_RECLAIM_MEMORY, fdt_pages,
&new_fdt_addr);
if (ret != EFI_SUCCESS) {
- printf("ERROR: Failed to reserve space for FDT\n");
+ log_err("ERROR: Failed to reserve space for FDT\n");
goto done;
}
}
addr = (uintptr_t)map_sysmem(addr, 0);
if (efi_add_memory_map(addr, size,
EFI_RESERVED_MEMORY_TYPE) != EFI_SUCCESS)
- printf("Reserved memory mapping failed addr %llx size %llx\n",
- addr, size);
+ log_err("Reserved memory mapping failed addr %llx size %llx\n",
+ addr, size);
}
/**
*/
#if CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE)
if (fdt) {
- printf("ERROR: can't have ACPI table and device tree.\n");
+ log_err("ERROR: can't have ACPI table and device tree.\n");
return EFI_LOAD_ERROR;
}
#else
if (!fdt_opt) {
fdt_opt = env_get("fdtcontroladdr");
if (!fdt_opt) {
- printf("ERROR: need device tree\n");
+ log_err("ERROR: need device tree\n");
return EFI_NOT_FOUND;
}
}
fdt_addr = simple_strtoul(fdt_opt, NULL, 16);
if (!fdt_addr) {
- printf("ERROR: invalid $fdt_addr or $fdtcontroladdr\n");
+ log_err("ERROR: invalid $fdt_addr or $fdtcontroladdr\n");
return EFI_LOAD_ERROR;
}
fdt = map_sysmem(fdt_addr, 0);
/* Install device tree */
if (fdt_check_header(fdt)) {
- printf("ERROR: invalid device tree\n");
+ log_err("ERROR: invalid device tree\n");
return EFI_LOAD_ERROR;
}
/* Prepare device tree for payload */
ret = copy_fdt(&fdt);
if (ret) {
- printf("ERROR: out of memory\n");
+ log_err("ERROR: out of memory\n");
return EFI_OUT_OF_RESOURCES;
}
if (image_setup_libfdt(&img, fdt, 0, NULL)) {
- printf("ERROR: failed to process device tree\n");
+ log_err("ERROR: failed to process device tree\n");
return EFI_LOAD_ERROR;
}
/* Install device tree as UEFI table */
ret = efi_install_configuration_table(&efi_guid_fdt, fdt);
if (ret != EFI_SUCCESS) {
- printf("ERROR: failed to install device tree\n");
+ log_err("ERROR: failed to install device tree\n");
return ret;
}
#endif /* GENERATE_ACPI_TABLE */
/* Call our payload! */
ret = EFI_CALL(efi_start_image(handle, &exit_data_size, &exit_data));
- printf("## Application terminated, r = %lu\n", ret & ~EFI_ERROR_MASK);
- if (ret && exit_data) {
- printf("## %ls\n", exit_data);
- efi_free_pool(exit_data);
+ if (ret != EFI_SUCCESS) {
+ log_err("## Application failed, r = %lu\n",
+ ret & ~EFI_ERROR_MASK);
+ if (exit_data) {
+ log_err("## %ls\n", exit_data);
+ efi_free_pool(exit_data);
+ }
}
efi_restore_gd();
ret = efi_bootmgr_load(&handle);
if (ret != EFI_SUCCESS) {
- printf("EFI boot manager: Cannot load any image\n");
+ log_notice("EFI boot manager: Cannot load any image\n");
return CMD_RET_FAILURE;
}
/* Initialize EFI drivers */
ret = efi_init_obj_list();
if (ret != EFI_SUCCESS) {
- printf("Error: Cannot initialize UEFI sub-system, r = %lu\n",
- ret & ~EFI_ERROR_MASK);
+ log_err("Error: Cannot initialize UEFI sub-system, r = %lu\n",
+ ret & ~EFI_ERROR_MASK);
return CMD_RET_FAILURE;
}
output = u_boot_console.run_command('bootefi %x' % addr)
expected_text = 'Hello, world'
assert expected_text in output
- expected_text = '## Application terminated, r = 0'
- assert expected_text in output
+ expected_text = '## Application failed'
+ assert expected_text not in output
@pytest.mark.buildconfigspec('cmd_bootefi_hello')
def test_efi_helloworld_builtin(u_boot_console):
# Then exit cleanly
u_boot_console.wait_for('grub>')
- output = u_boot_console.run_command('exit', wait_for_prompt=False, wait_for_echo=False)
- u_boot_console.wait_for('r = 0')
-
+ u_boot_console.run_command('exit', wait_for_prompt=False, wait_for_echo=False)
+ u_boot_console.wait_for('=>')
# And give us our U-Boot prompt back
u_boot_console.run_command('')