+
+ return ret;
+}
+
+/**
+ * do_efibootmgr() - execute EFI boot manager
+ *
+ * Return: status code
+ */
+static int do_efibootmgr(void)
+{
+ efi_handle_t handle;
+ efi_status_t ret;
+
+ ret = efi_bootmgr_load(&handle);
+ if (ret != EFI_SUCCESS) {
+ printf("EFI boot manager: Cannot load any image\n");
+ return CMD_RET_FAILURE;
+ }
+
+ ret = do_bootefi_exec(handle);
+
+ if (ret != EFI_SUCCESS)
+ return CMD_RET_FAILURE;
+
+ return CMD_RET_SUCCESS;
+}
+
+/**
+ * do_bootefi_image() - execute EFI binary
+ *
+ * Set up memory image for the binary to be loaded, prepare device path, and
+ * then call do_bootefi_exec() to execute it.
+ *
+ * @image_opt: string of image start address
+ * Return: status code
+ */
+static int do_bootefi_image(const char *image_opt)
+{
+ void *image_buf;
+ struct efi_device_path *device_path, *image_path;
+ struct efi_device_path *file_path = NULL;
+ unsigned long addr, size;
+ const char *size_str;
+ efi_handle_t mem_handle = NULL, handle;
+ efi_status_t ret;
+
+#ifdef CONFIG_CMD_BOOTEFI_HELLO
+ if (!strcmp(image_opt, "hello")) {
+ char *saddr;
+
+ saddr = env_get("loadaddr");
+ size = __efi_helloworld_end - __efi_helloworld_begin;
+
+ if (saddr)
+ addr = simple_strtoul(saddr, NULL, 16);
+ else
+ addr = CONFIG_SYS_LOAD_ADDR;
+
+ image_buf = map_sysmem(addr, size);
+ memcpy(image_buf, __efi_helloworld_begin, size);
+
+ device_path = NULL;
+ image_path = NULL;
+ } else
+#endif
+ {
+ size_str = env_get("filesize");
+ if (size_str)
+ size = simple_strtoul(size_str, NULL, 16);
+ else
+ size = 0;
+
+ addr = simple_strtoul(image_opt, NULL, 16);
+ /* Check that a numeric value was passed */
+ if (!addr && *image_opt != '0')
+ return CMD_RET_USAGE;
+
+ image_buf = map_sysmem(addr, size);
+
+ device_path = bootefi_device_path;
+ image_path = bootefi_image_path;
+ }
+