aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/Kconfig1
-rw-r--r--cmd/bootefi.c17
-rw-r--r--cmd/efidebug.c108
-rw-r--r--cmd/fastboot.c2
-rw-r--r--cmd/nvedit_efi.c11
5 files changed, 28 insertions, 111 deletions
diff --git a/cmd/Kconfig b/cmd/Kconfig
index bfa12ce12a..6f00bd9307 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1914,7 +1914,6 @@ config CMD_CONITRACE
config CMD_CLS
bool "Enable clear screen command 'cls'"
- depends on DM_VIDEO || LCD || VIDEO
default y if LCD
help
Enable the 'cls' command which clears the screen contents
diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 3041873afb..b93c0d3d4c 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -492,7 +492,7 @@ efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size)
efi_handle_t mem_handle = NULL, handle;
struct efi_device_path *file_path = NULL;
struct efi_device_path *msg_path;
- efi_status_t ret;
+ efi_status_t ret, ret2;
u16 *load_options;
if (!bootefi_device_path || !bootefi_image_path) {
@@ -509,12 +509,9 @@ efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size)
* Make sure that device for device_path exist
* in load_image(). Otherwise, shell and grub will fail.
*/
- ret = efi_create_handle(&mem_handle);
- if (ret != EFI_SUCCESS)
- goto out;
-
- ret = efi_add_protocol(mem_handle, &efi_guid_device_path,
- file_path);
+ ret = efi_install_multiple_protocol_interfaces(&mem_handle,
+ &efi_guid_device_path,
+ file_path, NULL);
if (ret != EFI_SUCCESS)
goto out;
msg_path = file_path;
@@ -542,9 +539,11 @@ efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size)
ret = do_bootefi_exec(handle, load_options);
out:
- efi_delete_handle(mem_handle);
+ ret2 = efi_uninstall_multiple_protocol_interfaces(mem_handle,
+ &efi_guid_device_path,
+ file_path, NULL);
efi_free_pool(file_path);
- return ret;
+ return (ret != EFI_SUCCESS) ? ret : ret2;
}
#ifdef CONFIG_CMD_BOOTEFI_SELFTEST
diff --git a/cmd/efidebug.c b/cmd/efidebug.c
index 84e6ff5565..4b49f30d93 100644
--- a/cmd/efidebug.c
+++ b/cmd/efidebug.c
@@ -8,6 +8,7 @@
#include <charset.h>
#include <common.h>
#include <command.h>
+#include <dm/device.h>
#include <efi_dt_fixup.h>
#include <efi_load_initrd.h>
#include <efi_loader.h>
@@ -344,80 +345,12 @@ static int do_efi_capsule(struct cmd_tbl *cmdtp, int flag,
}
#endif /* CONFIG_EFI_HAVE_CAPSULE_SUPPORT */
-/**
- * efi_get_device_path_text() - get device path text
- *
- * Return the text representation of the device path of a handle.
- *
- * @handle: handle of UEFI device
- * Return:
- * Pointer to the device path text or NULL.
- * The caller is responsible for calling FreePool().
- */
-static u16 *efi_get_device_path_text(efi_handle_t handle)
-{
- struct efi_handler *handler;
- efi_status_t ret;
-
- ret = efi_search_protocol(handle, &efi_guid_device_path, &handler);
- if (ret == EFI_SUCCESS && handler->protocol_interface) {
- struct efi_device_path *dp = handler->protocol_interface;
-
- return efi_dp_str(dp);
- } else {
- return NULL;
- }
-}
-
#define EFI_HANDLE_WIDTH ((int)sizeof(efi_handle_t) * 2)
static const char spc[] = " ";
static const char sep[] = "================";
/**
- * do_efi_show_devices() - show UEFI devices
- *
- * @cmdtp: Command table
- * @flag: Command flag
- * @argc: Number of arguments
- * @argv: Argument array
- * Return: CMD_RET_SUCCESS on success, CMD_RET_RET_FAILURE on failure
- *
- * Implement efidebug "devices" sub-command.
- * Show all UEFI devices and their information.
- */
-static int do_efi_show_devices(struct cmd_tbl *cmdtp, int flag,
- int argc, char *const argv[])
-{
- efi_handle_t *handles;
- efi_uintn_t num, i;
- u16 *dev_path_text;
- efi_status_t ret;
-
- ret = EFI_CALL(efi_locate_handle_buffer(ALL_HANDLES, NULL, NULL,
- &num, &handles));
- if (ret != EFI_SUCCESS)
- return CMD_RET_FAILURE;
-
- if (!num)
- return CMD_RET_SUCCESS;
-
- printf("Device%.*s Device Path\n", EFI_HANDLE_WIDTH - 6, spc);
- printf("%.*s ====================\n", EFI_HANDLE_WIDTH, sep);
- for (i = 0; i < num; i++) {
- dev_path_text = efi_get_device_path_text(handles[i]);
- if (dev_path_text) {
- printf("%p %ls\n", handles[i], dev_path_text);
- efi_free_pool(dev_path_text);
- }
- }
-
- efi_free_pool(handles);
-
- return CMD_RET_SUCCESS;
-}
-
-/**
* efi_get_driver_handle_info() - get information of UEFI driver
*
* @handle: Handle of UEFI device
@@ -535,26 +468,25 @@ static int do_efi_show_handles(struct cmd_tbl *cmdtp, int flag,
if (!num)
return CMD_RET_SUCCESS;
- printf("Handle%.*s Protocols\n", EFI_HANDLE_WIDTH - 6, spc);
- printf("%.*s ====================\n", EFI_HANDLE_WIDTH, sep);
for (i = 0; i < num; i++) {
- printf("%p", handles[i]);
+ struct efi_handler *handler;
+
+ printf("\n%p", handles[i]);
+ if (handles[i]->dev)
+ printf(" (%s)", handles[i]->dev->name);
+ printf("\n");
+ /* Print device path */
+ ret = efi_search_protocol(handles[i], &efi_guid_device_path,
+ &handler);
+ if (ret == EFI_SUCCESS)
+ printf(" %pD\n", handler->protocol_interface);
ret = EFI_CALL(BS->protocols_per_handle(handles[i], &guid,
&count));
- if (ret || !count) {
- putc('\n');
- continue;
- }
-
+ /* Print other protocols */
for (j = 0; j < count; j++) {
- if (j)
- printf(", ");
- else
- putc(' ');
-
- printf("%pUs", guid[j]);
+ if (guidcmp(guid[j], &efi_guid_device_path))
+ printf(" %pUs\n", guid[j]);
}
- putc('\n');
}
efi_free_pool(handles);
@@ -812,7 +744,6 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag,
char *endp;
u16 var_name16[9];
efi_guid_t guid;
- size_t label_len, label_len16;
u16 *label;
struct efi_device_path *file_path = NULL;
struct efi_device_path *fp_free = NULL;
@@ -859,13 +790,10 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag,
"Boot", id);
/* label */
- label_len = strlen(argv[2]);
- label_len16 = utf8_utf16_strnlen(argv[2], label_len);
- label = malloc((label_len16 + 1) * sizeof(u16));
+ label = efi_convert_string(argv[2]);
if (!label)
return CMD_RET_FAILURE;
lo.label = label; /* label will be changed below */
- utf8_utf16_strncpy(&label, argv[2], label_len);
/* file path */
ret = efi_dp_from_name(argv[3], argv[4], argv[5],
@@ -1539,8 +1467,6 @@ static struct cmd_tbl cmd_efidebug_sub[] = {
U_BOOT_CMD_MKENT(capsule, CONFIG_SYS_MAXARGS, 1, do_efi_capsule,
"", ""),
#endif
- U_BOOT_CMD_MKENT(devices, CONFIG_SYS_MAXARGS, 1, do_efi_show_devices,
- "", ""),
U_BOOT_CMD_MKENT(drivers, CONFIG_SYS_MAXARGS, 1, do_efi_show_drivers,
"", ""),
U_BOOT_CMD_MKENT(dh, CONFIG_SYS_MAXARGS, 1, do_efi_show_handles,
@@ -1630,8 +1556,6 @@ static char efidebug_help_text[] =
#endif
"\n"
#endif
- "efidebug devices\n"
- " - show UEFI devices\n"
"efidebug drivers\n"
" - show UEFI drivers\n"
"efidebug dh\n"
diff --git a/cmd/fastboot.c b/cmd/fastboot.c
index dd223b1554..b498e4b22b 100644
--- a/cmd/fastboot.c
+++ b/cmd/fastboot.c
@@ -83,9 +83,9 @@ static int do_fastboot_usb(int argc, char *const argv[],
ret = CMD_RET_SUCCESS;
exit:
+ usb_gadget_release(controller_index);
g_dnl_unregister();
g_dnl_clear_detach();
- usb_gadget_release(controller_index);
return ret;
#else
diff --git a/cmd/nvedit_efi.c b/cmd/nvedit_efi.c
index 770877c527..24944ab81e 100644
--- a/cmd/nvedit_efi.c
+++ b/cmd/nvedit_efi.c
@@ -382,8 +382,7 @@ int do_env_set_efi(struct cmd_tbl *cmdtp, int flag, int argc,
efi_guid_t guid;
u32 attributes;
bool default_guid, verbose, value_on_memory;
- u16 *var_name16 = NULL, *p;
- size_t len;
+ u16 *var_name16;
efi_status_t ret;
if (argc == 1)
@@ -487,18 +486,15 @@ int do_env_set_efi(struct cmd_tbl *cmdtp, int flag, int argc,
16, 1, value, size, true);
}
- len = utf8_utf16_strnlen(var_name, strlen(var_name));
- var_name16 = malloc((len + 1) * 2);
+ var_name16 = efi_convert_string(var_name);
if (!var_name16) {
printf("## Out of memory\n");
ret = CMD_RET_FAILURE;
goto out;
}
- p = var_name16;
- utf8_utf16_strncpy(&p, var_name, len + 1);
-
ret = efi_set_variable_int(var_name16, &guid, attributes, size, value,
true);
+ free(var_name16);
unmap_sysmem(value);
if (ret == EFI_SUCCESS) {
ret = CMD_RET_SUCCESS;
@@ -533,7 +529,6 @@ out:
unmap_sysmem(value);
else
free(value);
- free(var_name16);
return ret;
}