bootefi.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * EFI application loader
  4. *
  5. * Copyright (c) 2016 Alexander Graf
  6. */
  7. #include <charset.h>
  8. #include <common.h>
  9. #include <command.h>
  10. #include <dm.h>
  11. #include <efi_loader.h>
  12. #include <efi_selftest.h>
  13. #include <errno.h>
  14. #include <linux/libfdt.h>
  15. #include <linux/libfdt_env.h>
  16. #include <mapmem.h>
  17. #include <memalign.h>
  18. #include <asm/global_data.h>
  19. #include <asm-generic/sections.h>
  20. #include <asm-generic/unaligned.h>
  21. #include <linux/linkage.h>
  22. #ifdef CONFIG_ARMV7_NONSEC
  23. #include <asm/armv7.h>
  24. #include <asm/secure.h>
  25. #endif
  26. DECLARE_GLOBAL_DATA_PTR;
  27. #define OBJ_LIST_NOT_INITIALIZED 1
  28. static efi_status_t efi_obj_list_initialized = OBJ_LIST_NOT_INITIALIZED;
  29. static struct efi_device_path *bootefi_image_path;
  30. static struct efi_device_path *bootefi_device_path;
  31. /* Initialize and populate EFI object list */
  32. efi_status_t efi_init_obj_list(void)
  33. {
  34. efi_status_t ret = EFI_SUCCESS;
  35. /* Initialize once only */
  36. if (efi_obj_list_initialized != OBJ_LIST_NOT_INITIALIZED)
  37. return efi_obj_list_initialized;
  38. /* Initialize system table */
  39. ret = efi_initialize_system_table();
  40. if (ret != EFI_SUCCESS)
  41. goto out;
  42. /* Initialize EFI driver uclass */
  43. ret = efi_driver_init();
  44. if (ret != EFI_SUCCESS)
  45. goto out;
  46. ret = efi_console_register();
  47. if (ret != EFI_SUCCESS)
  48. goto out;
  49. #ifdef CONFIG_PARTITIONS
  50. ret = efi_disk_register();
  51. if (ret != EFI_SUCCESS)
  52. goto out;
  53. #endif
  54. #if defined(CONFIG_LCD) || defined(CONFIG_DM_VIDEO)
  55. ret = efi_gop_register();
  56. if (ret != EFI_SUCCESS)
  57. goto out;
  58. #endif
  59. #ifdef CONFIG_NET
  60. ret = efi_net_register();
  61. if (ret != EFI_SUCCESS)
  62. goto out;
  63. #endif
  64. #ifdef CONFIG_GENERATE_ACPI_TABLE
  65. ret = efi_acpi_register();
  66. if (ret != EFI_SUCCESS)
  67. goto out;
  68. #endif
  69. #ifdef CONFIG_GENERATE_SMBIOS_TABLE
  70. ret = efi_smbios_register();
  71. if (ret != EFI_SUCCESS)
  72. goto out;
  73. #endif
  74. ret = efi_watchdog_register();
  75. if (ret != EFI_SUCCESS)
  76. goto out;
  77. /* Initialize EFI runtime services */
  78. ret = efi_reset_system_init();
  79. if (ret != EFI_SUCCESS)
  80. goto out;
  81. out:
  82. efi_obj_list_initialized = ret;
  83. return ret;
  84. }
  85. /*
  86. * Allow unaligned memory access.
  87. *
  88. * This routine is overridden by architectures providing this feature.
  89. */
  90. void __weak allow_unaligned(void)
  91. {
  92. }
  93. /*
  94. * Set the load options of an image from an environment variable.
  95. *
  96. * @loaded_image_info: the image
  97. * @env_var: name of the environment variable
  98. */
  99. static void set_load_options(struct efi_loaded_image *loaded_image_info,
  100. const char *env_var)
  101. {
  102. size_t size;
  103. const char *env = env_get(env_var);
  104. u16 *pos;
  105. loaded_image_info->load_options = NULL;
  106. loaded_image_info->load_options_size = 0;
  107. if (!env)
  108. return;
  109. size = utf8_utf16_strlen(env) + 1;
  110. loaded_image_info->load_options = calloc(size, sizeof(u16));
  111. if (!loaded_image_info->load_options) {
  112. printf("ERROR: Out of memory\n");
  113. return;
  114. }
  115. pos = loaded_image_info->load_options;
  116. utf8_utf16_strcpy(&pos, env);
  117. loaded_image_info->load_options_size = size * 2;
  118. }
  119. /**
  120. * copy_fdt() - Copy the device tree to a new location available to EFI
  121. *
  122. * The FDT is relocated into a suitable location within the EFI memory map.
  123. * An additional 12KB is added to the space in case the device tree needs to be
  124. * expanded later with fdt_open_into().
  125. *
  126. * @fdt_addr: On entry, address of start of FDT. On exit, address of relocated
  127. * FDT start
  128. * @fdt_sizep: Returns new size of FDT, including
  129. * @return new relocated address of FDT
  130. */
  131. static efi_status_t copy_fdt(ulong *fdt_addrp, ulong *fdt_sizep)
  132. {
  133. unsigned long fdt_ram_start = -1L, fdt_pages;
  134. efi_status_t ret = 0;
  135. void *fdt, *new_fdt;
  136. u64 new_fdt_addr;
  137. uint fdt_size;
  138. int i;
  139. for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
  140. u64 ram_start = gd->bd->bi_dram[i].start;
  141. u64 ram_size = gd->bd->bi_dram[i].size;
  142. if (!ram_size)
  143. continue;
  144. if (ram_start < fdt_ram_start)
  145. fdt_ram_start = ram_start;
  146. }
  147. /*
  148. * Give us at least 4KB of breathing room in case the device tree needs
  149. * to be expanded later. Round up to the nearest EFI page boundary.
  150. */
  151. fdt = map_sysmem(*fdt_addrp, 0);
  152. fdt_size = fdt_totalsize(fdt);
  153. fdt_size += 4096 * 3;
  154. fdt_size = ALIGN(fdt_size + EFI_PAGE_SIZE - 1, EFI_PAGE_SIZE);
  155. fdt_pages = fdt_size >> EFI_PAGE_SHIFT;
  156. /* Safe fdt location is at 127MB */
  157. new_fdt_addr = fdt_ram_start + (127 * 1024 * 1024) + fdt_size;
  158. ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
  159. EFI_RUNTIME_SERVICES_DATA, fdt_pages,
  160. &new_fdt_addr);
  161. if (ret != EFI_SUCCESS) {
  162. /* If we can't put it there, put it somewhere */
  163. new_fdt_addr = (ulong)memalign(EFI_PAGE_SIZE, fdt_size);
  164. ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
  165. EFI_RUNTIME_SERVICES_DATA, fdt_pages,
  166. &new_fdt_addr);
  167. if (ret != EFI_SUCCESS) {
  168. printf("ERROR: Failed to reserve space for FDT\n");
  169. goto done;
  170. }
  171. }
  172. new_fdt = map_sysmem(new_fdt_addr, fdt_size);
  173. memcpy(new_fdt, fdt, fdt_totalsize(fdt));
  174. fdt_set_totalsize(new_fdt, fdt_size);
  175. *fdt_addrp = new_fdt_addr;
  176. *fdt_sizep = fdt_size;
  177. done:
  178. return ret;
  179. }
  180. static efi_status_t efi_do_enter(
  181. efi_handle_t image_handle, struct efi_system_table *st,
  182. EFIAPI efi_status_t (*entry)(
  183. efi_handle_t image_handle,
  184. struct efi_system_table *st))
  185. {
  186. efi_status_t ret = EFI_LOAD_ERROR;
  187. if (entry)
  188. ret = entry(image_handle, st);
  189. st->boottime->exit(image_handle, ret, 0, NULL);
  190. return ret;
  191. }
  192. #ifdef CONFIG_ARM64
  193. static efi_status_t efi_run_in_el2(EFIAPI efi_status_t (*entry)(
  194. efi_handle_t image_handle, struct efi_system_table *st),
  195. efi_handle_t image_handle, struct efi_system_table *st)
  196. {
  197. /* Enable caches again */
  198. dcache_enable();
  199. return efi_do_enter(image_handle, st, entry);
  200. }
  201. #endif
  202. #ifdef CONFIG_ARMV7_NONSEC
  203. static bool is_nonsec;
  204. static efi_status_t efi_run_in_hyp(EFIAPI efi_status_t (*entry)(
  205. efi_handle_t image_handle, struct efi_system_table *st),
  206. efi_handle_t image_handle, struct efi_system_table *st)
  207. {
  208. /* Enable caches again */
  209. dcache_enable();
  210. is_nonsec = true;
  211. return efi_do_enter(image_handle, st, entry);
  212. }
  213. #endif
  214. /*
  215. * efi_carve_out_dt_rsv() - Carve out DT reserved memory ranges
  216. *
  217. * The mem_rsv entries of the FDT are added to the memory map. Any failures are
  218. * ignored because this is not critical and we would rather continue to try to
  219. * boot.
  220. *
  221. * @fdt: Pointer to device tree
  222. */
  223. static void efi_carve_out_dt_rsv(void *fdt)
  224. {
  225. int nr_rsv, i;
  226. uint64_t addr, size, pages;
  227. nr_rsv = fdt_num_mem_rsv(fdt);
  228. /* Look for an existing entry and add it to the efi mem map. */
  229. for (i = 0; i < nr_rsv; i++) {
  230. if (fdt_get_mem_rsv(fdt, i, &addr, &size) != 0)
  231. continue;
  232. pages = ALIGN(size, EFI_PAGE_SIZE) >> EFI_PAGE_SHIFT;
  233. if (!efi_add_memory_map(addr, pages, EFI_RESERVED_MEMORY_TYPE,
  234. false))
  235. printf("FDT memrsv map %d: Failed to add to map\n", i);
  236. }
  237. }
  238. static efi_status_t efi_install_fdt(ulong fdt_addr)
  239. {
  240. bootm_headers_t img = { 0 };
  241. ulong fdt_pages, fdt_size, fdt_start;
  242. efi_status_t ret;
  243. void *fdt;
  244. fdt = map_sysmem(fdt_addr, 0);
  245. if (fdt_check_header(fdt)) {
  246. printf("ERROR: invalid device tree\n");
  247. return EFI_INVALID_PARAMETER;
  248. }
  249. /* Prepare fdt for payload */
  250. ret = copy_fdt(&fdt_addr, &fdt_size);
  251. if (ret)
  252. return ret;
  253. unmap_sysmem(fdt);
  254. fdt = map_sysmem(fdt_addr, 0);
  255. fdt_size = fdt_totalsize(fdt);
  256. if (image_setup_libfdt(&img, fdt, 0, NULL)) {
  257. printf("ERROR: failed to process device tree\n");
  258. return EFI_LOAD_ERROR;
  259. }
  260. efi_carve_out_dt_rsv(fdt);
  261. /* Link to it in the efi tables */
  262. ret = efi_install_configuration_table(&efi_guid_fdt, fdt);
  263. if (ret != EFI_SUCCESS)
  264. return EFI_OUT_OF_RESOURCES;
  265. /* And reserve the space in the memory map */
  266. fdt_start = fdt_addr;
  267. fdt_pages = fdt_size >> EFI_PAGE_SHIFT;
  268. ret = efi_add_memory_map(fdt_start, fdt_pages,
  269. EFI_BOOT_SERVICES_DATA, true);
  270. return ret;
  271. }
  272. /*
  273. * Load an EFI payload into a newly allocated piece of memory, register all
  274. * EFI objects it would want to access and jump to it.
  275. */
  276. static efi_status_t do_bootefi_exec(void *efi,
  277. struct efi_device_path *device_path,
  278. struct efi_device_path *image_path)
  279. {
  280. struct efi_loaded_image loaded_image_info = {};
  281. struct efi_object loaded_image_info_obj = {};
  282. efi_handle_t mem_handle = NULL;
  283. struct efi_device_path *memdp = NULL;
  284. efi_status_t ret;
  285. EFIAPI efi_status_t (*entry)(efi_handle_t image_handle,
  286. struct efi_system_table *st);
  287. /*
  288. * Special case for efi payload not loaded from disk, such as
  289. * 'bootefi hello' or for example payload loaded directly into
  290. * memory via jtag, etc:
  291. */
  292. if (!device_path && !image_path) {
  293. printf("WARNING: using memory device/image path, this may confuse some payloads!\n");
  294. /* actual addresses filled in after efi_load_pe() */
  295. memdp = efi_dp_from_mem(0, 0, 0);
  296. device_path = image_path = memdp;
  297. /*
  298. * Grub expects that the device path of the loaded image is
  299. * installed on a handle.
  300. */
  301. ret = efi_create_handle(&mem_handle);
  302. if (ret != EFI_SUCCESS)
  303. goto exit;
  304. ret = efi_add_protocol(mem_handle, &efi_guid_device_path,
  305. device_path);
  306. if (ret != EFI_SUCCESS)
  307. goto exit;
  308. } else {
  309. assert(device_path && image_path);
  310. }
  311. efi_setup_loaded_image(&loaded_image_info, &loaded_image_info_obj,
  312. device_path, image_path);
  313. /*
  314. * gd lives in a fixed register which may get clobbered while we execute
  315. * the payload. So save it here and restore it on every callback entry
  316. */
  317. efi_save_gd();
  318. /* Transfer environment variable bootargs as load options */
  319. set_load_options(&loaded_image_info, "bootargs");
  320. /* Load the EFI payload */
  321. entry = efi_load_pe(efi, &loaded_image_info);
  322. if (!entry) {
  323. ret = EFI_LOAD_ERROR;
  324. goto exit;
  325. }
  326. if (memdp) {
  327. struct efi_device_path_memory *mdp = (void *)memdp;
  328. mdp->memory_type = loaded_image_info.image_code_type;
  329. mdp->start_address = (uintptr_t)loaded_image_info.image_base;
  330. mdp->end_address = mdp->start_address +
  331. loaded_image_info.image_size;
  332. }
  333. /* we don't support much: */
  334. env_set("efi_8be4df61-93ca-11d2-aa0d-00e098032b8c_OsIndicationsSupported",
  335. "{ro,boot}(blob)0000000000000000");
  336. /* Call our payload! */
  337. debug("%s:%d Jumping to 0x%lx\n", __func__, __LINE__, (long)entry);
  338. if (setjmp(&loaded_image_info.exit_jmp)) {
  339. ret = loaded_image_info.exit_status;
  340. goto exit;
  341. }
  342. #ifdef CONFIG_ARM64
  343. /* On AArch64 we need to make sure we call our payload in < EL3 */
  344. if (current_el() == 3) {
  345. smp_kick_all_cpus();
  346. dcache_disable(); /* flush cache before switch to EL2 */
  347. /* Move into EL2 and keep running there */
  348. armv8_switch_to_el2((ulong)entry,
  349. (ulong)&loaded_image_info_obj.handle,
  350. (ulong)&systab, 0, (ulong)efi_run_in_el2,
  351. ES_TO_AARCH64);
  352. /* Should never reach here, efi exits with longjmp */
  353. while (1) { }
  354. }
  355. #endif
  356. #ifdef CONFIG_ARMV7_NONSEC
  357. if (armv7_boot_nonsec() && !is_nonsec) {
  358. dcache_disable(); /* flush cache before switch to HYP */
  359. armv7_init_nonsec();
  360. secure_ram_addr(_do_nonsec_entry)(
  361. efi_run_in_hyp,
  362. (uintptr_t)entry,
  363. (uintptr_t)loaded_image_info_obj.handle,
  364. (uintptr_t)&systab);
  365. /* Should never reach here, efi exits with longjmp */
  366. while (1) { }
  367. }
  368. #endif
  369. ret = efi_do_enter(loaded_image_info_obj.handle, &systab, entry);
  370. exit:
  371. /* image has returned, loaded-image obj goes *poof*: */
  372. list_del(&loaded_image_info_obj.link);
  373. if (mem_handle)
  374. efi_delete_handle(mem_handle);
  375. return ret;
  376. }
  377. static int do_bootefi_bootmgr_exec(void)
  378. {
  379. struct efi_device_path *device_path, *file_path;
  380. void *addr;
  381. efi_status_t r;
  382. /*
  383. * gd lives in a fixed register which may get clobbered while we execute
  384. * the payload. So save it here and restore it on every callback entry
  385. */
  386. efi_save_gd();
  387. addr = efi_bootmgr_load(&device_path, &file_path);
  388. if (!addr)
  389. return 1;
  390. printf("## Starting EFI application at %p ...\n", addr);
  391. r = do_bootefi_exec(addr, device_path, file_path);
  392. printf("## Application terminated, r = %lu\n",
  393. r & ~EFI_ERROR_MASK);
  394. if (r != EFI_SUCCESS)
  395. return 1;
  396. return 0;
  397. }
  398. /* Interpreter command to boot an arbitrary EFI image from memory */
  399. static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  400. {
  401. unsigned long addr;
  402. char *saddr;
  403. efi_status_t r;
  404. unsigned long fdt_addr;
  405. /* Allow unaligned memory access */
  406. allow_unaligned();
  407. /* Initialize EFI drivers */
  408. r = efi_init_obj_list();
  409. if (r != EFI_SUCCESS) {
  410. printf("Error: Cannot set up EFI drivers, r = %lu\n",
  411. r & ~EFI_ERROR_MASK);
  412. return CMD_RET_FAILURE;
  413. }
  414. if (argc < 2)
  415. return CMD_RET_USAGE;
  416. if (argc > 2) {
  417. fdt_addr = simple_strtoul(argv[2], NULL, 16);
  418. if (!fdt_addr && *argv[2] != '0')
  419. return CMD_RET_USAGE;
  420. /* Install device tree */
  421. r = efi_install_fdt(fdt_addr);
  422. if (r != EFI_SUCCESS) {
  423. printf("ERROR: failed to install device tree\n");
  424. return CMD_RET_FAILURE;
  425. }
  426. } else {
  427. /* Remove device tree. EFI_NOT_FOUND can be ignored here */
  428. efi_install_configuration_table(&efi_guid_fdt, NULL);
  429. printf("WARNING: booting without device tree\n");
  430. }
  431. #ifdef CONFIG_CMD_BOOTEFI_HELLO
  432. if (!strcmp(argv[1], "hello")) {
  433. ulong size = __efi_helloworld_end - __efi_helloworld_begin;
  434. saddr = env_get("loadaddr");
  435. if (saddr)
  436. addr = simple_strtoul(saddr, NULL, 16);
  437. else
  438. addr = CONFIG_SYS_LOAD_ADDR;
  439. memcpy(map_sysmem(addr, size), __efi_helloworld_begin, size);
  440. } else
  441. #endif
  442. #ifdef CONFIG_CMD_BOOTEFI_SELFTEST
  443. if (!strcmp(argv[1], "selftest")) {
  444. struct efi_loaded_image loaded_image_info = {};
  445. struct efi_object loaded_image_info_obj = {};
  446. /* Construct a dummy device path. */
  447. bootefi_device_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE,
  448. (uintptr_t)&efi_selftest,
  449. (uintptr_t)&efi_selftest);
  450. bootefi_image_path = efi_dp_from_file(NULL, 0, "\\selftest");
  451. efi_setup_loaded_image(&loaded_image_info,
  452. &loaded_image_info_obj,
  453. bootefi_device_path, bootefi_image_path);
  454. /*
  455. * gd lives in a fixed register which may get clobbered while we
  456. * execute the payload. So save it here and restore it on every
  457. * callback entry
  458. */
  459. efi_save_gd();
  460. /* Transfer environment variable efi_selftest as load options */
  461. set_load_options(&loaded_image_info, "efi_selftest");
  462. /* Execute the test */
  463. r = efi_selftest(loaded_image_info_obj.handle, &systab);
  464. efi_restore_gd();
  465. free(loaded_image_info.load_options);
  466. list_del(&loaded_image_info_obj.link);
  467. return r != EFI_SUCCESS;
  468. } else
  469. #endif
  470. if (!strcmp(argv[1], "bootmgr")) {
  471. return do_bootefi_bootmgr_exec();
  472. } else {
  473. saddr = argv[1];
  474. addr = simple_strtoul(saddr, NULL, 16);
  475. /* Check that a numeric value was passed */
  476. if (!addr && *saddr != '0')
  477. return CMD_RET_USAGE;
  478. }
  479. printf("## Starting EFI application at %08lx ...\n", addr);
  480. r = do_bootefi_exec(map_sysmem(addr, 0), bootefi_device_path,
  481. bootefi_image_path);
  482. printf("## Application terminated, r = %lu\n",
  483. r & ~EFI_ERROR_MASK);
  484. if (r != EFI_SUCCESS)
  485. return 1;
  486. else
  487. return 0;
  488. }
  489. #ifdef CONFIG_SYS_LONGHELP
  490. static char bootefi_help_text[] =
  491. "<image address> [fdt address]\n"
  492. " - boot EFI payload stored at address <image address>.\n"
  493. " If specified, the device tree located at <fdt address> gets\n"
  494. " exposed as EFI configuration table.\n"
  495. #ifdef CONFIG_CMD_BOOTEFI_HELLO
  496. "bootefi hello\n"
  497. " - boot a sample Hello World application stored within U-Boot\n"
  498. #endif
  499. #ifdef CONFIG_CMD_BOOTEFI_SELFTEST
  500. "bootefi selftest [fdt address]\n"
  501. " - boot an EFI selftest application stored within U-Boot\n"
  502. " Use environment variable efi_selftest to select a single test.\n"
  503. " Use 'setenv efi_selftest list' to enumerate all tests.\n"
  504. #endif
  505. "bootefi bootmgr [fdt addr]\n"
  506. " - load and boot EFI payload based on BootOrder/BootXXXX variables.\n"
  507. "\n"
  508. " If specified, the device tree located at <fdt address> gets\n"
  509. " exposed as EFI configuration table.\n";
  510. #endif
  511. U_BOOT_CMD(
  512. bootefi, 3, 0, do_bootefi,
  513. "Boots an EFI payload from memory",
  514. bootefi_help_text
  515. );
  516. void efi_set_bootdev(const char *dev, const char *devnr, const char *path)
  517. {
  518. char filename[32] = { 0 }; /* dp->str is u16[32] long */
  519. char *s;
  520. /* efi_set_bootdev is typically called repeatedly, recover memory */
  521. efi_free_pool(bootefi_device_path);
  522. efi_free_pool(bootefi_image_path);
  523. /* If blk_get_device_part_str fails, avoid duplicate free. */
  524. bootefi_device_path = NULL;
  525. bootefi_image_path = NULL;
  526. if (strcmp(dev, "Net")) {
  527. struct blk_desc *desc;
  528. disk_partition_t fs_partition;
  529. int part;
  530. part = blk_get_device_part_str(dev, devnr, &desc, &fs_partition,
  531. 1);
  532. if (part < 0)
  533. return;
  534. bootefi_device_path = efi_dp_from_part(desc, part);
  535. } else {
  536. #ifdef CONFIG_NET
  537. bootefi_device_path = efi_dp_from_eth();
  538. #endif
  539. }
  540. if (!path)
  541. return;
  542. if (strcmp(dev, "Net")) {
  543. /* Add leading / to fs paths, because they're absolute */
  544. snprintf(filename, sizeof(filename), "/%s", path);
  545. } else {
  546. snprintf(filename, sizeof(filename), "%s", path);
  547. }
  548. /* DOS style file path: */
  549. s = filename;
  550. while ((s = strchr(s, '/')))
  551. *s++ = '\\';
  552. bootefi_image_path = efi_dp_from_file(NULL, 0, filename);
  553. }