
From: Simon Glass <sjg@chromium.org> This command is useful for the app, so enable it. For now most of the subcommands don't work, so provide a message in that case. This seems better than silently pretending that the subcommand doesn't exist. Signed-off-by: Simon Glass <sjg@chromium.org> --- cmd/Kconfig | 5 +++-- cmd/efidebug.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/cmd/Kconfig b/cmd/Kconfig index b7b80cbe59f..fe9fb11ff95 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -2228,8 +2228,9 @@ config CMD_CLS config CMD_EFIDEBUG bool "efidebug - display/configure UEFI environment" - depends on EFI_LOADER - select EFI_DEVICE_PATH_TO_TEXT + depends on EFI_LOADER || EFI_APP + default y if EFI_APP + select EFI_DEVICE_PATH_TO_TEXT if EFI_LOADER help Enable the 'efidebug' command which provides a subset of UEFI shell utility with simplified functionality. It will be useful diff --git a/cmd/efidebug.c b/cmd/efidebug.c index f52ba8de279..2e156fef525 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -28,6 +28,16 @@ #define BS systab.boottime +static bool app_not_supported(const char *cmd) +{ + if (!IS_ENABLED(CONFIG_EFI_APP)) + return false; + + printf("Command '%s' is not yet supported in the app\n", cmd); + + return true; +} + #ifdef CONFIG_EFI_HAVE_CAPSULE_SUPPORT /** * do_efi_capsule_update() - process a capsule update @@ -405,6 +415,9 @@ static int do_efi_show_drivers(struct cmd_tbl *cmdtp, int flag, u16 *driver_name, *image_path_text; efi_status_t ret; + if (app_not_supported("show_drivers")) + return CMD_RET_FAILURE; + ret = EFI_CALL(efi_locate_handle_buffer( BY_PROTOCOL, &efi_guid_driver_binding_protocol, NULL, &num, &handles)); @@ -458,6 +471,9 @@ static int do_efi_show_handles(struct cmd_tbl *cmdtp, int flag, efi_uintn_t num, count, i, j; efi_status_t ret; + if (app_not_supported("show_handles")) + return CMD_RET_FAILURE; + ret = EFI_CALL(efi_locate_handle_buffer(ALL_HANDLES, NULL, NULL, &num, &handles)); if (ret != EFI_SUCCESS) @@ -646,6 +662,9 @@ static int do_efi_show_memmap(struct cmd_tbl *cmdtp, int flag, int i; efi_status_t ret; + if (app_not_supported("memmap")) + return CMD_RET_FAILURE; + ret = efi_get_memory_map_alloc(&map_size, &memmap); if (ret != EFI_SUCCESS) return CMD_RET_FAILURE; @@ -698,6 +717,9 @@ static int do_efi_show_memmap(struct cmd_tbl *cmdtp, int flag, static int do_efi_show_tables(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { + if (app_not_supported("show tables")) + return CMD_RET_FAILURE; + efi_show_tables(&systab); return CMD_RET_SUCCESS; @@ -893,6 +915,9 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag, efi_status_t ret; int r = CMD_RET_SUCCESS; + if (app_not_supported("boot add")) + return CMD_RET_FAILURE; + guid = efi_global_variable_guid; /* attributes */ @@ -1073,6 +1098,9 @@ static int do_efi_boot_rm(struct cmd_tbl *cmdtp, int flag, u16 var_name16[9]; efi_status_t ret; + if (app_not_supported("boot rm")) + return CMD_RET_FAILURE; + if (argc == 1) return CMD_RET_USAGE; @@ -1199,6 +1227,9 @@ static int do_efi_boot_dump(struct cmd_tbl *cmdtp, int flag, efi_guid_t guid; efi_status_t ret; + if (app_not_supported("boot dump")) + return CMD_RET_FAILURE; + if (argc > 1) return CMD_RET_USAGE; @@ -1255,6 +1286,9 @@ static int show_efi_boot_order(void) struct efi_load_option lo; efi_status_t ret; + if (app_not_supported("show_boot_order")) + return CMD_RET_FAILURE; + size = 0; ret = efi_get_variable_int(u"BootOrder", &efi_global_variable_guid, NULL, &size, NULL, NULL); @@ -1574,6 +1608,9 @@ static int do_efi_query_info(struct cmd_tbl *cmdtp, int flag, u64 max_variable_size; int i; + if (app_not_supported("query")) + return CMD_RET_FAILURE; + for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-bs")) attr |= EFI_VARIABLE_BOOTSERVICE_ACCESS; -- 2.43.0