bootefi.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * EFI application loader
  4. *
  5. * Copyright (c) 2016 Alexander Graf
  6. */
  7. #define LOG_CATEGORY LOGC_EFI
  8. #include <common.h>
  9. #include <bootm.h>
  10. #include <charset.h>
  11. #include <command.h>
  12. #include <dm.h>
  13. #include <efi_loader.h>
  14. #include <efi_selftest.h>
  15. #include <env.h>
  16. #include <errno.h>
  17. #include <image.h>
  18. #include <log.h>
  19. #include <malloc.h>
  20. #include <asm/global_data.h>
  21. #include <linux/libfdt.h>
  22. #include <linux/libfdt_env.h>
  23. #include <mapmem.h>
  24. #include <memalign.h>
  25. #include <asm-generic/sections.h>
  26. #include <linux/linkage.h>
  27. DECLARE_GLOBAL_DATA_PTR;
  28. static struct efi_device_path *bootefi_image_path;
  29. static struct efi_device_path *bootefi_device_path;
  30. static void *image_addr;
  31. static size_t image_size;
  32. /**
  33. * efi_clear_bootdev() - clear boot device
  34. */
  35. static void efi_clear_bootdev(void)
  36. {
  37. efi_free_pool(bootefi_device_path);
  38. efi_free_pool(bootefi_image_path);
  39. bootefi_device_path = NULL;
  40. bootefi_image_path = NULL;
  41. image_addr = NULL;
  42. image_size = 0;
  43. }
  44. /**
  45. * efi_set_bootdev() - set boot device
  46. *
  47. * This function is called when a file is loaded, e.g. via the 'load' command.
  48. * We use the path to this file to inform the UEFI binary about the boot device.
  49. *
  50. * @dev: device, e.g. "MMC"
  51. * @devnr: number of the device, e.g. "1:2"
  52. * @path: path to file loaded
  53. * @buffer: buffer with file loaded
  54. * @buffer_size: size of file loaded
  55. */
  56. void efi_set_bootdev(const char *dev, const char *devnr, const char *path,
  57. void *buffer, size_t buffer_size)
  58. {
  59. struct efi_device_path *device, *image;
  60. efi_status_t ret;
  61. /* Forget overwritten image */
  62. if (buffer + buffer_size >= image_addr &&
  63. image_addr + image_size >= buffer)
  64. efi_clear_bootdev();
  65. /* Remember only PE-COFF and FIT images */
  66. if (efi_check_pe(buffer, buffer_size, NULL) != EFI_SUCCESS) {
  67. #ifdef CONFIG_FIT
  68. if (fit_check_format(buffer, IMAGE_SIZE_INVAL))
  69. return;
  70. /*
  71. * FIT images of type EFI_OS are started via command bootm.
  72. * We should not use their boot device with the bootefi command.
  73. */
  74. buffer = 0;
  75. buffer_size = 0;
  76. #else
  77. return;
  78. #endif
  79. }
  80. /* efi_set_bootdev() is typically called repeatedly, recover memory */
  81. efi_clear_bootdev();
  82. image_addr = buffer;
  83. image_size = buffer_size;
  84. ret = efi_dp_from_name(dev, devnr, path, &device, &image);
  85. if (ret == EFI_SUCCESS) {
  86. bootefi_device_path = device;
  87. if (image) {
  88. /* FIXME: image should not contain device */
  89. struct efi_device_path *image_tmp = image;
  90. efi_dp_split_file_path(image, &device, &image);
  91. efi_free_pool(image_tmp);
  92. }
  93. bootefi_image_path = image;
  94. } else {
  95. efi_clear_bootdev();
  96. }
  97. }
  98. /**
  99. * efi_env_set_load_options() - set load options from environment variable
  100. *
  101. * @handle: the image handle
  102. * @env_var: name of the environment variable
  103. * @load_options: pointer to load options (output)
  104. * Return: status code
  105. */
  106. static efi_status_t efi_env_set_load_options(efi_handle_t handle,
  107. const char *env_var,
  108. u16 **load_options)
  109. {
  110. const char *env = env_get(env_var);
  111. size_t size;
  112. u16 *pos;
  113. efi_status_t ret;
  114. *load_options = NULL;
  115. if (!env)
  116. return EFI_SUCCESS;
  117. size = sizeof(u16) * (utf8_utf16_strlen(env) + 1);
  118. pos = calloc(size, 1);
  119. if (!pos)
  120. return EFI_OUT_OF_RESOURCES;
  121. *load_options = pos;
  122. utf8_utf16_strcpy(&pos, env);
  123. ret = efi_set_load_options(handle, size, *load_options);
  124. if (ret != EFI_SUCCESS) {
  125. free(*load_options);
  126. *load_options = NULL;
  127. }
  128. return ret;
  129. }
  130. #if !CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE)
  131. /**
  132. * copy_fdt() - Copy the device tree to a new location available to EFI
  133. *
  134. * The FDT is copied to a suitable location within the EFI memory map.
  135. * Additional 12 KiB are added to the space in case the device tree needs to be
  136. * expanded later with fdt_open_into().
  137. *
  138. * @fdtp: On entry a pointer to the flattened device tree.
  139. * On exit a pointer to the copy of the flattened device tree.
  140. * FDT start
  141. * Return: status code
  142. */
  143. static efi_status_t copy_fdt(void **fdtp)
  144. {
  145. unsigned long fdt_ram_start = -1L, fdt_pages;
  146. efi_status_t ret = 0;
  147. void *fdt, *new_fdt;
  148. u64 new_fdt_addr;
  149. uint fdt_size;
  150. int i;
  151. for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
  152. u64 ram_start = gd->bd->bi_dram[i].start;
  153. u64 ram_size = gd->bd->bi_dram[i].size;
  154. if (!ram_size)
  155. continue;
  156. if (ram_start < fdt_ram_start)
  157. fdt_ram_start = ram_start;
  158. }
  159. /*
  160. * Give us at least 12 KiB of breathing room in case the device tree
  161. * needs to be expanded later.
  162. */
  163. fdt = *fdtp;
  164. fdt_pages = efi_size_in_pages(fdt_totalsize(fdt) + 0x3000);
  165. fdt_size = fdt_pages << EFI_PAGE_SHIFT;
  166. /*
  167. * Safe fdt location is at 127 MiB.
  168. * On the sandbox convert from the sandbox address space.
  169. */
  170. new_fdt_addr = (uintptr_t)map_sysmem(fdt_ram_start + 0x7f00000 +
  171. fdt_size, 0);
  172. ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
  173. EFI_ACPI_RECLAIM_MEMORY, fdt_pages,
  174. &new_fdt_addr);
  175. if (ret != EFI_SUCCESS) {
  176. /* If we can't put it there, put it somewhere */
  177. new_fdt_addr = (ulong)memalign(EFI_PAGE_SIZE, fdt_size);
  178. ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
  179. EFI_ACPI_RECLAIM_MEMORY, fdt_pages,
  180. &new_fdt_addr);
  181. if (ret != EFI_SUCCESS) {
  182. log_err("ERROR: Failed to reserve space for FDT\n");
  183. goto done;
  184. }
  185. }
  186. new_fdt = (void *)(uintptr_t)new_fdt_addr;
  187. memcpy(new_fdt, fdt, fdt_totalsize(fdt));
  188. fdt_set_totalsize(new_fdt, fdt_size);
  189. *fdtp = (void *)(uintptr_t)new_fdt_addr;
  190. done:
  191. return ret;
  192. }
  193. /**
  194. * get_config_table() - get configuration table
  195. *
  196. * @guid: GUID of the configuration table
  197. * Return: pointer to configuration table or NULL
  198. */
  199. static void *get_config_table(const efi_guid_t *guid)
  200. {
  201. size_t i;
  202. for (i = 0; i < systab.nr_tables; i++) {
  203. if (!guidcmp(guid, &systab.tables[i].guid))
  204. return systab.tables[i].table;
  205. }
  206. return NULL;
  207. }
  208. #endif /* !CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE) */
  209. /**
  210. * efi_install_fdt() - install device tree
  211. *
  212. * If fdt is not EFI_FDT_USE_INTERNAL, the device tree located at that memory
  213. * address will will be installed as configuration table, otherwise the device
  214. * tree located at the address indicated by environment variable fdt_addr or as
  215. * fallback fdtcontroladdr will be used.
  216. *
  217. * On architectures using ACPI tables device trees shall not be installed as
  218. * configuration table.
  219. *
  220. * @fdt: address of device tree or EFI_FDT_USE_INTERNAL to use the
  221. * the hardware device tree as indicated by environment variable
  222. * fdt_addr or as fallback the internal device tree as indicated by
  223. * the environment variable fdtcontroladdr
  224. * Return: status code
  225. */
  226. efi_status_t efi_install_fdt(void *fdt)
  227. {
  228. /*
  229. * The EBBR spec requires that we have either an FDT or an ACPI table
  230. * but not both.
  231. */
  232. #if CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE)
  233. if (fdt) {
  234. log_err("ERROR: can't have ACPI table and device tree.\n");
  235. return EFI_LOAD_ERROR;
  236. }
  237. #else
  238. bootm_headers_t img = { 0 };
  239. efi_status_t ret;
  240. if (fdt == EFI_FDT_USE_INTERNAL) {
  241. const char *fdt_opt;
  242. uintptr_t fdt_addr;
  243. /* Look for device tree that is already installed */
  244. if (get_config_table(&efi_guid_fdt))
  245. return EFI_SUCCESS;
  246. /* Check if there is a hardware device tree */
  247. fdt_opt = env_get("fdt_addr");
  248. /* Use our own device tree as fallback */
  249. if (!fdt_opt) {
  250. fdt_opt = env_get("fdtcontroladdr");
  251. if (!fdt_opt) {
  252. log_err("ERROR: need device tree\n");
  253. return EFI_NOT_FOUND;
  254. }
  255. }
  256. fdt_addr = hextoul(fdt_opt, NULL);
  257. if (!fdt_addr) {
  258. log_err("ERROR: invalid $fdt_addr or $fdtcontroladdr\n");
  259. return EFI_LOAD_ERROR;
  260. }
  261. fdt = map_sysmem(fdt_addr, 0);
  262. }
  263. /* Install device tree */
  264. if (fdt_check_header(fdt)) {
  265. log_err("ERROR: invalid device tree\n");
  266. return EFI_LOAD_ERROR;
  267. }
  268. /* Prepare device tree for payload */
  269. ret = copy_fdt(&fdt);
  270. if (ret) {
  271. log_err("ERROR: out of memory\n");
  272. return EFI_OUT_OF_RESOURCES;
  273. }
  274. if (image_setup_libfdt(&img, fdt, 0, NULL)) {
  275. log_err("ERROR: failed to process device tree\n");
  276. return EFI_LOAD_ERROR;
  277. }
  278. /* Create memory reservations as indicated by the device tree */
  279. efi_carve_out_dt_rsv(fdt);
  280. /* Install device tree as UEFI table */
  281. ret = efi_install_configuration_table(&efi_guid_fdt, fdt);
  282. if (ret != EFI_SUCCESS) {
  283. log_err("ERROR: failed to install device tree\n");
  284. return ret;
  285. }
  286. #endif /* GENERATE_ACPI_TABLE */
  287. return EFI_SUCCESS;
  288. }
  289. /**
  290. * do_bootefi_exec() - execute EFI binary
  291. *
  292. * The image indicated by @handle is started. When it returns the allocated
  293. * memory for the @load_options is freed.
  294. *
  295. * @handle: handle of loaded image
  296. * @load_options: load options
  297. * Return: status code
  298. *
  299. * Load the EFI binary into a newly assigned memory unwinding the relocation
  300. * information, install the loaded image protocol, and call the binary.
  301. */
  302. static efi_status_t do_bootefi_exec(efi_handle_t handle, void *load_options)
  303. {
  304. efi_status_t ret;
  305. efi_uintn_t exit_data_size = 0;
  306. u16 *exit_data = NULL;
  307. /* On ARM switch from EL3 or secure mode to EL2 or non-secure mode */
  308. switch_to_non_secure_mode();
  309. /* Call our payload! */
  310. ret = EFI_CALL(efi_start_image(handle, &exit_data_size, &exit_data));
  311. if (ret != EFI_SUCCESS) {
  312. log_err("## Application failed, r = %lu\n",
  313. ret & ~EFI_ERROR_MASK);
  314. if (exit_data) {
  315. log_err("## %ls\n", exit_data);
  316. efi_free_pool(exit_data);
  317. }
  318. }
  319. efi_restore_gd();
  320. free(load_options);
  321. if (IS_ENABLED(CONFIG_EFI_LOAD_FILE2_INITRD))
  322. efi_initrd_deregister();
  323. return ret;
  324. }
  325. /**
  326. * do_efibootmgr() - execute EFI boot manager
  327. *
  328. * Return: status code
  329. */
  330. static int do_efibootmgr(void)
  331. {
  332. efi_handle_t handle;
  333. efi_status_t ret;
  334. void *load_options;
  335. ret = efi_bootmgr_load(&handle, &load_options);
  336. if (ret != EFI_SUCCESS) {
  337. log_notice("EFI boot manager: Cannot load any image\n");
  338. return CMD_RET_FAILURE;
  339. }
  340. ret = do_bootefi_exec(handle, load_options);
  341. if (ret != EFI_SUCCESS)
  342. return CMD_RET_FAILURE;
  343. return CMD_RET_SUCCESS;
  344. }
  345. /**
  346. * do_bootefi_image() - execute EFI binary
  347. *
  348. * Set up memory image for the binary to be loaded, prepare device path, and
  349. * then call do_bootefi_exec() to execute it.
  350. *
  351. * @image_opt: string of image start address
  352. * Return: status code
  353. */
  354. static int do_bootefi_image(const char *image_opt)
  355. {
  356. void *image_buf;
  357. unsigned long addr, size;
  358. efi_status_t ret;
  359. #ifdef CONFIG_CMD_BOOTEFI_HELLO
  360. if (!strcmp(image_opt, "hello")) {
  361. image_buf = __efi_helloworld_begin;
  362. size = __efi_helloworld_end - __efi_helloworld_begin;
  363. efi_clear_bootdev();
  364. } else
  365. #endif
  366. {
  367. addr = strtoul(image_opt, NULL, 16);
  368. /* Check that a numeric value was passed */
  369. if (!addr)
  370. return CMD_RET_USAGE;
  371. image_buf = map_sysmem(addr, 0);
  372. if (image_buf != image_addr) {
  373. log_err("No UEFI binary known at %s\n", image_opt);
  374. return CMD_RET_FAILURE;
  375. }
  376. size = image_size;
  377. }
  378. ret = efi_run_image(image_buf, size);
  379. if (ret != EFI_SUCCESS)
  380. return CMD_RET_FAILURE;
  381. return CMD_RET_SUCCESS;
  382. }
  383. /**
  384. * efi_run_image() - run loaded UEFI image
  385. *
  386. * @source_buffer: memory address of the UEFI image
  387. * @source_size: size of the UEFI image
  388. * Return: status code
  389. */
  390. efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size)
  391. {
  392. efi_handle_t mem_handle = NULL, handle;
  393. struct efi_device_path *file_path = NULL;
  394. struct efi_device_path *msg_path;
  395. efi_status_t ret;
  396. u16 *load_options;
  397. if (!bootefi_device_path || !bootefi_image_path) {
  398. /*
  399. * Special case for efi payload not loaded from disk,
  400. * such as 'bootefi hello' or for example payload
  401. * loaded directly into memory via JTAG, etc:
  402. */
  403. file_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE,
  404. (uintptr_t)source_buffer,
  405. source_size);
  406. /*
  407. * Make sure that device for device_path exist
  408. * in load_image(). Otherwise, shell and grub will fail.
  409. */
  410. ret = efi_create_handle(&mem_handle);
  411. if (ret != EFI_SUCCESS)
  412. goto out;
  413. ret = efi_add_protocol(mem_handle, &efi_guid_device_path,
  414. file_path);
  415. if (ret != EFI_SUCCESS)
  416. goto out;
  417. msg_path = file_path;
  418. } else {
  419. file_path = efi_dp_append(bootefi_device_path,
  420. bootefi_image_path);
  421. msg_path = bootefi_image_path;
  422. }
  423. log_info("Booting %pD\n", msg_path);
  424. ret = EFI_CALL(efi_load_image(false, efi_root, file_path, source_buffer,
  425. source_size, &handle));
  426. if (ret != EFI_SUCCESS) {
  427. log_err("Loading image failed\n");
  428. goto out;
  429. }
  430. /* Transfer environment variable as load options */
  431. ret = efi_env_set_load_options(handle, "bootargs", &load_options);
  432. if (ret != EFI_SUCCESS)
  433. goto out;
  434. ret = do_bootefi_exec(handle, load_options);
  435. out:
  436. efi_delete_handle(mem_handle);
  437. efi_free_pool(file_path);
  438. return ret;
  439. }
  440. #ifdef CONFIG_CMD_BOOTEFI_SELFTEST
  441. static efi_status_t bootefi_run_prepare(const char *load_options_path,
  442. struct efi_device_path *device_path,
  443. struct efi_device_path *image_path,
  444. struct efi_loaded_image_obj **image_objp,
  445. struct efi_loaded_image **loaded_image_infop)
  446. {
  447. efi_status_t ret;
  448. u16 *load_options;
  449. ret = efi_setup_loaded_image(device_path, image_path, image_objp,
  450. loaded_image_infop);
  451. if (ret != EFI_SUCCESS)
  452. return ret;
  453. /* Transfer environment variable as load options */
  454. return efi_env_set_load_options((efi_handle_t)*image_objp,
  455. load_options_path,
  456. &load_options);
  457. }
  458. /**
  459. * bootefi_test_prepare() - prepare to run an EFI test
  460. *
  461. * Prepare to run a test as if it were provided by a loaded image.
  462. *
  463. * @image_objp: pointer to be set to the loaded image handle
  464. * @loaded_image_infop: pointer to be set to the loaded image protocol
  465. * @path: dummy file path used to construct the device path
  466. * set in the loaded image protocol
  467. * @load_options_path: name of a U-Boot environment variable. Its value is
  468. * set as load options in the loaded image protocol.
  469. * Return: status code
  470. */
  471. static efi_status_t bootefi_test_prepare
  472. (struct efi_loaded_image_obj **image_objp,
  473. struct efi_loaded_image **loaded_image_infop, const char *path,
  474. const char *load_options_path)
  475. {
  476. efi_status_t ret;
  477. /* Construct a dummy device path */
  478. bootefi_device_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE, 0, 0);
  479. if (!bootefi_device_path)
  480. return EFI_OUT_OF_RESOURCES;
  481. bootefi_image_path = efi_dp_from_file(NULL, 0, path);
  482. if (!bootefi_image_path) {
  483. ret = EFI_OUT_OF_RESOURCES;
  484. goto failure;
  485. }
  486. ret = bootefi_run_prepare(load_options_path, bootefi_device_path,
  487. bootefi_image_path, image_objp,
  488. loaded_image_infop);
  489. if (ret == EFI_SUCCESS)
  490. return ret;
  491. failure:
  492. efi_clear_bootdev();
  493. return ret;
  494. }
  495. /**
  496. * bootefi_run_finish() - finish up after running an EFI test
  497. *
  498. * @loaded_image_info: Pointer to a struct which holds the loaded image info
  499. * @image_obj: Pointer to a struct which holds the loaded image object
  500. */
  501. static void bootefi_run_finish(struct efi_loaded_image_obj *image_obj,
  502. struct efi_loaded_image *loaded_image_info)
  503. {
  504. efi_restore_gd();
  505. free(loaded_image_info->load_options);
  506. efi_delete_handle(&image_obj->header);
  507. }
  508. /**
  509. * do_efi_selftest() - execute EFI selftest
  510. *
  511. * Return: status code
  512. */
  513. static int do_efi_selftest(void)
  514. {
  515. struct efi_loaded_image_obj *image_obj;
  516. struct efi_loaded_image *loaded_image_info;
  517. efi_status_t ret;
  518. ret = bootefi_test_prepare(&image_obj, &loaded_image_info,
  519. "\\selftest", "efi_selftest");
  520. if (ret != EFI_SUCCESS)
  521. return CMD_RET_FAILURE;
  522. /* Execute the test */
  523. ret = EFI_CALL(efi_selftest(&image_obj->header, &systab));
  524. bootefi_run_finish(image_obj, loaded_image_info);
  525. return ret != EFI_SUCCESS;
  526. }
  527. #endif /* CONFIG_CMD_BOOTEFI_SELFTEST */
  528. /**
  529. * do_bootefi() - execute `bootefi` command
  530. *
  531. * @cmdtp: table entry describing command
  532. * @flag: bitmap indicating how the command was invoked
  533. * @argc: number of arguments
  534. * @argv: command line arguments
  535. * Return: status code
  536. */
  537. static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc,
  538. char *const argv[])
  539. {
  540. efi_status_t ret;
  541. void *fdt;
  542. if (argc < 2)
  543. return CMD_RET_USAGE;
  544. /* Initialize EFI drivers */
  545. ret = efi_init_obj_list();
  546. if (ret != EFI_SUCCESS) {
  547. log_err("Error: Cannot initialize UEFI sub-system, r = %lu\n",
  548. ret & ~EFI_ERROR_MASK);
  549. return CMD_RET_FAILURE;
  550. }
  551. if (argc > 2) {
  552. uintptr_t fdt_addr;
  553. fdt_addr = hextoul(argv[2], NULL);
  554. fdt = map_sysmem(fdt_addr, 0);
  555. } else {
  556. fdt = EFI_FDT_USE_INTERNAL;
  557. }
  558. ret = efi_install_fdt(fdt);
  559. if (ret == EFI_INVALID_PARAMETER)
  560. return CMD_RET_USAGE;
  561. else if (ret != EFI_SUCCESS)
  562. return CMD_RET_FAILURE;
  563. if (IS_ENABLED(CONFIG_CMD_BOOTEFI_BOOTMGR)) {
  564. if (!strcmp(argv[1], "bootmgr"))
  565. return do_efibootmgr();
  566. }
  567. #ifdef CONFIG_CMD_BOOTEFI_SELFTEST
  568. if (!strcmp(argv[1], "selftest"))
  569. return do_efi_selftest();
  570. #endif
  571. return do_bootefi_image(argv[1]);
  572. }
  573. #ifdef CONFIG_SYS_LONGHELP
  574. static char bootefi_help_text[] =
  575. "<image address> [fdt address]\n"
  576. " - boot EFI payload stored at address <image address>.\n"
  577. " If specified, the device tree located at <fdt address> gets\n"
  578. " exposed as EFI configuration table.\n"
  579. #ifdef CONFIG_CMD_BOOTEFI_HELLO
  580. "bootefi hello\n"
  581. " - boot a sample Hello World application stored within U-Boot\n"
  582. #endif
  583. #ifdef CONFIG_CMD_BOOTEFI_SELFTEST
  584. "bootefi selftest [fdt address]\n"
  585. " - boot an EFI selftest application stored within U-Boot\n"
  586. " Use environment variable efi_selftest to select a single test.\n"
  587. " Use 'setenv efi_selftest list' to enumerate all tests.\n"
  588. #endif
  589. #ifdef CONFIG_CMD_BOOTEFI_BOOTMGR
  590. "bootefi bootmgr [fdt address]\n"
  591. " - load and boot EFI payload based on BootOrder/BootXXXX variables.\n"
  592. "\n"
  593. " If specified, the device tree located at <fdt address> gets\n"
  594. " exposed as EFI configuration table.\n"
  595. #endif
  596. ;
  597. #endif
  598. U_BOOT_CMD(
  599. bootefi, 3, 0, do_bootefi,
  600. "Boots an EFI payload from memory",
  601. bootefi_help_text
  602. );