1b9939336SAlexander Graf /* 2b9939336SAlexander Graf * EFI application loader 3b9939336SAlexander Graf * 4b9939336SAlexander Graf * Copyright (c) 2016 Alexander Graf 5b9939336SAlexander Graf * 6b9939336SAlexander Graf * SPDX-License-Identifier: GPL-2.0+ 7b9939336SAlexander Graf */ 8b9939336SAlexander Graf 9b9939336SAlexander Graf #include <common.h> 10b9939336SAlexander Graf #include <command.h> 119d922450SSimon Glass #include <dm.h> 12b9939336SAlexander Graf #include <efi_loader.h> 13b9939336SAlexander Graf #include <errno.h> 14b9939336SAlexander Graf #include <libfdt.h> 15b9939336SAlexander Graf #include <libfdt_env.h> 16ad0c1a3dSAlexander Graf #include <memalign.h> 170d9d501fSAlexander Graf #include <asm/global_data.h> 18e275458cSSimon Glass #include <asm-generic/sections.h> 19e275458cSSimon Glass #include <linux/linkage.h> 200d9d501fSAlexander Graf 210d9d501fSAlexander Graf DECLARE_GLOBAL_DATA_PTR; 22b9939336SAlexander Graf 23b9939336SAlexander Graf /* 24b9939336SAlexander Graf * When booting using the "bootefi" command, we don't know which 25b9939336SAlexander Graf * physical device the file came from. So we create a pseudo-device 26b9939336SAlexander Graf * called "bootefi" with the device path /bootefi. 27b9939336SAlexander Graf * 28b9939336SAlexander Graf * In addition to the originating device we also declare the file path 29b9939336SAlexander Graf * of "bootefi" based loads to be /bootefi. 30b9939336SAlexander Graf */ 310f4060ebSAlexander Graf static struct efi_device_path_file_path bootefi_image_path[] = { 32b9939336SAlexander Graf { 33b9939336SAlexander Graf .dp.type = DEVICE_PATH_TYPE_MEDIA_DEVICE, 34b9939336SAlexander Graf .dp.sub_type = DEVICE_PATH_SUB_TYPE_FILE_PATH, 350f4060ebSAlexander Graf .dp.length = sizeof(bootefi_image_path[0]), 36b9939336SAlexander Graf .str = { 'b','o','o','t','e','f','i' }, 37b9939336SAlexander Graf }, { 38b9939336SAlexander Graf .dp.type = DEVICE_PATH_TYPE_END, 39b9939336SAlexander Graf .dp.sub_type = DEVICE_PATH_SUB_TYPE_END, 400f4060ebSAlexander Graf .dp.length = sizeof(bootefi_image_path[0]), 41b9939336SAlexander Graf } 42b9939336SAlexander Graf }; 43b9939336SAlexander Graf 44c07ad7c0SAlexander Graf static struct efi_device_path_file_path bootefi_device_path[] = { 45c07ad7c0SAlexander Graf { 46c07ad7c0SAlexander Graf .dp.type = DEVICE_PATH_TYPE_MEDIA_DEVICE, 47c07ad7c0SAlexander Graf .dp.sub_type = DEVICE_PATH_SUB_TYPE_FILE_PATH, 48c07ad7c0SAlexander Graf .dp.length = sizeof(bootefi_image_path[0]), 49c07ad7c0SAlexander Graf .str = { 'b','o','o','t','e','f','i' }, 50c07ad7c0SAlexander Graf }, { 51c07ad7c0SAlexander Graf .dp.type = DEVICE_PATH_TYPE_END, 52c07ad7c0SAlexander Graf .dp.sub_type = DEVICE_PATH_SUB_TYPE_END, 53c07ad7c0SAlexander Graf .dp.length = sizeof(bootefi_image_path[0]), 54c07ad7c0SAlexander Graf } 55c07ad7c0SAlexander Graf }; 56c07ad7c0SAlexander Graf 57b9939336SAlexander Graf /* The EFI loaded_image interface for the image executed via "bootefi" */ 58b9939336SAlexander Graf static struct efi_loaded_image loaded_image_info = { 59c07ad7c0SAlexander Graf .device_handle = bootefi_device_path, 600f4060ebSAlexander Graf .file_path = bootefi_image_path, 61b9939336SAlexander Graf }; 62b9939336SAlexander Graf 63b9939336SAlexander Graf /* The EFI object struct for the image executed via "bootefi" */ 64b9939336SAlexander Graf static struct efi_object loaded_image_info_obj = { 65b9939336SAlexander Graf .handle = &loaded_image_info, 66b9939336SAlexander Graf .protocols = { 67b9939336SAlexander Graf { 68b9939336SAlexander Graf /* 69b9939336SAlexander Graf * When asking for the loaded_image interface, just 70b9939336SAlexander Graf * return handle which points to loaded_image_info 71b9939336SAlexander Graf */ 72b9939336SAlexander Graf .guid = &efi_guid_loaded_image, 73b5349f74Sxypron.glpk@gmx.de .protocol_interface = &loaded_image_info, 74b9939336SAlexander Graf }, 75b9939336SAlexander Graf { 76b9939336SAlexander Graf /* 77b9939336SAlexander Graf * When asking for the device path interface, return 78c07ad7c0SAlexander Graf * bootefi_device_path 79b9939336SAlexander Graf */ 80b9939336SAlexander Graf .guid = &efi_guid_device_path, 81b5349f74Sxypron.glpk@gmx.de .protocol_interface = bootefi_device_path, 82b9939336SAlexander Graf }, 8388adae5eSxypron.glpk@gmx.de { 8488adae5eSxypron.glpk@gmx.de .guid = &efi_guid_console_control, 8588adae5eSxypron.glpk@gmx.de .protocol_interface = (void *) &efi_console_control 8688adae5eSxypron.glpk@gmx.de }, 87cc5b7081Sxypron.glpk@gmx.de { 88cc5b7081Sxypron.glpk@gmx.de .guid = &efi_guid_device_path_to_text_protocol, 89cc5b7081Sxypron.glpk@gmx.de .protocol_interface = (void *) &efi_device_path_to_text 90cc5b7081Sxypron.glpk@gmx.de }, 91b9939336SAlexander Graf }, 92b9939336SAlexander Graf }; 93b9939336SAlexander Graf 94b9939336SAlexander Graf /* The EFI object struct for the device the "bootefi" image was loaded from */ 95b9939336SAlexander Graf static struct efi_object bootefi_device_obj = { 96c07ad7c0SAlexander Graf .handle = bootefi_device_path, 97b9939336SAlexander Graf .protocols = { 98b9939336SAlexander Graf { 99b9939336SAlexander Graf /* When asking for the device path interface, return 100c07ad7c0SAlexander Graf * bootefi_device_path */ 101b9939336SAlexander Graf .guid = &efi_guid_device_path, 102b5349f74Sxypron.glpk@gmx.de .protocol_interface = bootefi_device_path 103b9939336SAlexander Graf } 104b9939336SAlexander Graf }, 105b9939336SAlexander Graf }; 106b9939336SAlexander Graf 1070d9d501fSAlexander Graf static void *copy_fdt(void *fdt) 1080d9d501fSAlexander Graf { 1090d9d501fSAlexander Graf u64 fdt_size = fdt_totalsize(fdt); 110ad0c1a3dSAlexander Graf unsigned long fdt_ram_start = -1L, fdt_pages; 111ad0c1a3dSAlexander Graf u64 new_fdt_addr; 1120d9d501fSAlexander Graf void *new_fdt; 113ad0c1a3dSAlexander Graf int i; 1140d9d501fSAlexander Graf 115ad0c1a3dSAlexander Graf for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { 116ad0c1a3dSAlexander Graf u64 ram_start = gd->bd->bi_dram[i].start; 117ad0c1a3dSAlexander Graf u64 ram_size = gd->bd->bi_dram[i].size; 1180d9d501fSAlexander Graf 119ad0c1a3dSAlexander Graf if (!ram_size) 120ad0c1a3dSAlexander Graf continue; 121ad0c1a3dSAlexander Graf 122ad0c1a3dSAlexander Graf if (ram_start < fdt_ram_start) 123ad0c1a3dSAlexander Graf fdt_ram_start = ram_start; 124ad0c1a3dSAlexander Graf } 125ad0c1a3dSAlexander Graf 126ad0c1a3dSAlexander Graf /* Give us at least 4kb breathing room */ 127ad0c1a3dSAlexander Graf fdt_size = ALIGN(fdt_size + 4096, 4096); 128ad0c1a3dSAlexander Graf fdt_pages = fdt_size >> EFI_PAGE_SHIFT; 129ad0c1a3dSAlexander Graf 130ad0c1a3dSAlexander Graf /* Safe fdt location is at 128MB */ 131ad0c1a3dSAlexander Graf new_fdt_addr = fdt_ram_start + (128 * 1024 * 1024) + fdt_size; 132ad0c1a3dSAlexander Graf if (efi_allocate_pages(1, EFI_BOOT_SERVICES_DATA, fdt_pages, 133ad0c1a3dSAlexander Graf &new_fdt_addr) != EFI_SUCCESS) { 134ad0c1a3dSAlexander Graf /* If we can't put it there, put it somewhere */ 135ad0c1a3dSAlexander Graf new_fdt_addr = (ulong)memalign(4096, fdt_size); 13685a6e9b3SAlexander Graf if (efi_allocate_pages(1, EFI_BOOT_SERVICES_DATA, fdt_pages, 13785a6e9b3SAlexander Graf &new_fdt_addr) != EFI_SUCCESS) { 13885a6e9b3SAlexander Graf printf("ERROR: Failed to reserve space for FDT\n"); 13985a6e9b3SAlexander Graf return NULL; 140ad0c1a3dSAlexander Graf } 14185a6e9b3SAlexander Graf } 14285a6e9b3SAlexander Graf 143ad0c1a3dSAlexander Graf new_fdt = (void*)(ulong)new_fdt_addr; 1440d9d501fSAlexander Graf memcpy(new_fdt, fdt, fdt_totalsize(fdt)); 1450d9d501fSAlexander Graf fdt_set_totalsize(new_fdt, fdt_size); 1460d9d501fSAlexander Graf 1470d9d501fSAlexander Graf return new_fdt; 1480d9d501fSAlexander Graf } 1490d9d501fSAlexander Graf 150b06d8ac3Sxypron.glpk@gmx.de static ulong efi_do_enter(void *image_handle, 151b06d8ac3Sxypron.glpk@gmx.de struct efi_system_table *st, 152b06d8ac3Sxypron.glpk@gmx.de asmlinkage ulong (*entry)(void *image_handle, 153b06d8ac3Sxypron.glpk@gmx.de struct efi_system_table *st)) 154b06d8ac3Sxypron.glpk@gmx.de { 155b06d8ac3Sxypron.glpk@gmx.de efi_status_t ret = EFI_LOAD_ERROR; 156b06d8ac3Sxypron.glpk@gmx.de 157b06d8ac3Sxypron.glpk@gmx.de if (entry) 158b06d8ac3Sxypron.glpk@gmx.de ret = entry(image_handle, st); 159b06d8ac3Sxypron.glpk@gmx.de st->boottime->exit(image_handle, ret, 0, NULL); 160b06d8ac3Sxypron.glpk@gmx.de return ret; 161b06d8ac3Sxypron.glpk@gmx.de } 162b06d8ac3Sxypron.glpk@gmx.de 163ec6617c3SAlison Wang #ifdef CONFIG_ARM64 164b06d8ac3Sxypron.glpk@gmx.de static unsigned long efi_run_in_el2(asmlinkage ulong (*entry)( 165b06d8ac3Sxypron.glpk@gmx.de void *image_handle, struct efi_system_table *st), 166b06d8ac3Sxypron.glpk@gmx.de void *image_handle, struct efi_system_table *st) 167ec6617c3SAlison Wang { 168ec6617c3SAlison Wang /* Enable caches again */ 169ec6617c3SAlison Wang dcache_enable(); 170ec6617c3SAlison Wang 171b06d8ac3Sxypron.glpk@gmx.de return efi_do_enter(image_handle, st, entry); 172ec6617c3SAlison Wang } 173ec6617c3SAlison Wang #endif 174ec6617c3SAlison Wang 175b9939336SAlexander Graf /* 176b9939336SAlexander Graf * Load an EFI payload into a newly allocated piece of memory, register all 177b9939336SAlexander Graf * EFI objects it would want to access and jump to it. 178b9939336SAlexander Graf */ 1791c39809bSAlexander Graf static unsigned long do_bootefi_exec(void *efi, void *fdt) 180b9939336SAlexander Graf { 181e275458cSSimon Glass ulong (*entry)(void *image_handle, struct efi_system_table *st) 182e275458cSSimon Glass asmlinkage; 183b9939336SAlexander Graf ulong fdt_pages, fdt_size, fdt_start, fdt_end; 184dea2174dSAlexander Graf bootm_headers_t img = { 0 }; 185b9939336SAlexander Graf 186b9939336SAlexander Graf /* 187b9939336SAlexander Graf * gd lives in a fixed register which may get clobbered while we execute 188b9939336SAlexander Graf * the payload. So save it here and restore it on every callback entry 189b9939336SAlexander Graf */ 190b9939336SAlexander Graf efi_save_gd(); 191b9939336SAlexander Graf 1921c39809bSAlexander Graf if (fdt && !fdt_check_header(fdt)) { 193dea2174dSAlexander Graf /* Prepare fdt for payload */ 1940d9d501fSAlexander Graf fdt = copy_fdt(fdt); 1950d9d501fSAlexander Graf 1960d9d501fSAlexander Graf if (image_setup_libfdt(&img, fdt, 0, NULL)) { 197dea2174dSAlexander Graf printf("ERROR: Failed to process device tree\n"); 198dea2174dSAlexander Graf return -EINVAL; 199dea2174dSAlexander Graf } 200dea2174dSAlexander Graf 201dea2174dSAlexander Graf /* Link to it in the efi tables */ 202b9939336SAlexander Graf systab.tables[0].guid = EFI_FDT_GUID; 2030d9d501fSAlexander Graf systab.tables[0].table = fdt; 204b9939336SAlexander Graf systab.nr_tables = 1; 205b9939336SAlexander Graf 206b9939336SAlexander Graf /* And reserve the space in the memory map */ 2070d9d501fSAlexander Graf fdt_start = ((ulong)fdt) & ~EFI_PAGE_MASK; 2080d9d501fSAlexander Graf fdt_end = ((ulong)fdt) + fdt_totalsize(fdt); 209b9939336SAlexander Graf fdt_size = (fdt_end - fdt_start) + EFI_PAGE_MASK; 210b9939336SAlexander Graf fdt_pages = fdt_size >> EFI_PAGE_SHIFT; 211b9939336SAlexander Graf /* Give a bootloader the chance to modify the device tree */ 212b9939336SAlexander Graf fdt_pages += 2; 213b9939336SAlexander Graf efi_add_memory_map(fdt_start, fdt_pages, 214b9939336SAlexander Graf EFI_BOOT_SERVICES_DATA, true); 215b9939336SAlexander Graf } else { 2161c39809bSAlexander Graf printf("WARNING: Invalid device tree, expect boot to fail\n"); 217b9939336SAlexander Graf systab.nr_tables = 0; 218b9939336SAlexander Graf } 219b9939336SAlexander Graf 220b9939336SAlexander Graf /* Load the EFI payload */ 221b9939336SAlexander Graf entry = efi_load_pe(efi, &loaded_image_info); 222b9939336SAlexander Graf if (!entry) 223b9939336SAlexander Graf return -ENOENT; 224b9939336SAlexander Graf 225b9939336SAlexander Graf /* Initialize and populate EFI object list */ 226b9939336SAlexander Graf INIT_LIST_HEAD(&efi_obj_list); 227b9939336SAlexander Graf list_add_tail(&loaded_image_info_obj.link, &efi_obj_list); 228b9939336SAlexander Graf list_add_tail(&bootefi_device_obj.link, &efi_obj_list); 229b9939336SAlexander Graf #ifdef CONFIG_PARTITIONS 230b9939336SAlexander Graf efi_disk_register(); 231b9939336SAlexander Graf #endif 232be8d3241SAlexander Graf #ifdef CONFIG_LCD 233be8d3241SAlexander Graf efi_gop_register(); 234be8d3241SAlexander Graf #endif 2350efe1bcfSAlexander Graf #ifdef CONFIG_NET 2360efe1bcfSAlexander Graf void *nethandle = loaded_image_info.device_handle; 2370efe1bcfSAlexander Graf efi_net_register(&nethandle); 2380efe1bcfSAlexander Graf 2390efe1bcfSAlexander Graf if (!memcmp(bootefi_device_path[0].str, "N\0e\0t", 6)) 2400efe1bcfSAlexander Graf loaded_image_info.device_handle = nethandle; 2413fb97e26SAlexander Graf else 2423fb97e26SAlexander Graf loaded_image_info.device_handle = bootefi_device_path; 2430efe1bcfSAlexander Graf #endif 244e663b350SAlexander Graf #ifdef CONFIG_GENERATE_SMBIOS_TABLE 245e663b350SAlexander Graf efi_smbios_register(); 246e663b350SAlexander Graf #endif 247b9939336SAlexander Graf 24880a4800eSAlexander Graf /* Initialize EFI runtime services */ 24980a4800eSAlexander Graf efi_reset_system_init(); 25080a4800eSAlexander Graf efi_get_time_init(); 25180a4800eSAlexander Graf 252b9939336SAlexander Graf /* Call our payload! */ 253edcef3baSAlexander Graf debug("%s:%d Jumping to 0x%lx\n", __func__, __LINE__, (long)entry); 254a86aeaf2SAlexander Graf 255a86aeaf2SAlexander Graf if (setjmp(&loaded_image_info.exit_jmp)) { 256*1da1bac4Sxypron.glpk@gmx.de return loaded_image_info.exit_status; 257a86aeaf2SAlexander Graf } 258a86aeaf2SAlexander Graf 25969bd459dSAlexander Graf #ifdef CONFIG_ARM64 26069bd459dSAlexander Graf /* On AArch64 we need to make sure we call our payload in < EL3 */ 26169bd459dSAlexander Graf if (current_el() == 3) { 26269bd459dSAlexander Graf smp_kick_all_cpus(); 26369bd459dSAlexander Graf dcache_disable(); /* flush cache before switch to EL2 */ 264ec6617c3SAlison Wang 265ec6617c3SAlison Wang /* Move into EL2 and keep running there */ 266ec6617c3SAlison Wang armv8_switch_to_el2((ulong)entry, (ulong)&loaded_image_info, 2677c5e1febSAlison Wang (ulong)&systab, 0, (ulong)efi_run_in_el2, 268ec6617c3SAlison Wang ES_TO_AARCH64); 269ec6617c3SAlison Wang 270ec6617c3SAlison Wang /* Should never reach here, efi exits with longjmp */ 271ec6617c3SAlison Wang while (1) { } 27269bd459dSAlexander Graf } 27369bd459dSAlexander Graf #endif 27469bd459dSAlexander Graf 275b06d8ac3Sxypron.glpk@gmx.de return efi_do_enter(&loaded_image_info, &systab, entry); 276b9939336SAlexander Graf } 277b9939336SAlexander Graf 278b9939336SAlexander Graf 279b9939336SAlexander Graf /* Interpreter command to boot an arbitrary EFI image from memory */ 280b9939336SAlexander Graf static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) 281b9939336SAlexander Graf { 2821c39809bSAlexander Graf char *saddr, *sfdt; 2831c39809bSAlexander Graf unsigned long addr, fdt_addr = 0; 284*1da1bac4Sxypron.glpk@gmx.de unsigned long r; 285b9939336SAlexander Graf 286b9939336SAlexander Graf if (argc < 2) 2873c1dcef6SBin Meng return CMD_RET_USAGE; 288c7ae3dfdSSimon Glass #ifdef CONFIG_CMD_BOOTEFI_HELLO 289c7ae3dfdSSimon Glass if (!strcmp(argv[1], "hello")) { 290c7ae3dfdSSimon Glass ulong size = __efi_hello_world_end - __efi_hello_world_begin; 291c7ae3dfdSSimon Glass 292c7ae3dfdSSimon Glass addr = CONFIG_SYS_LOAD_ADDR; 293c7ae3dfdSSimon Glass memcpy((char *)addr, __efi_hello_world_begin, size); 294c7ae3dfdSSimon Glass } else 295c7ae3dfdSSimon Glass #endif 296c7ae3dfdSSimon Glass { 297b9939336SAlexander Graf saddr = argv[1]; 298b9939336SAlexander Graf 299b9939336SAlexander Graf addr = simple_strtoul(saddr, NULL, 16); 300b9939336SAlexander Graf 3011c39809bSAlexander Graf if (argc > 2) { 3021c39809bSAlexander Graf sfdt = argv[2]; 3031c39809bSAlexander Graf fdt_addr = simple_strtoul(sfdt, NULL, 16); 3041c39809bSAlexander Graf } 305c7ae3dfdSSimon Glass } 3061c39809bSAlexander Graf 3075ee31bafSSimon Glass printf("## Starting EFI application at %08lx ...\n", addr); 3081c39809bSAlexander Graf r = do_bootefi_exec((void *)addr, (void*)fdt_addr); 309*1da1bac4Sxypron.glpk@gmx.de printf("## Application terminated, r = %lu\n", 310*1da1bac4Sxypron.glpk@gmx.de r & ~EFI_ERROR_MASK); 311b9939336SAlexander Graf 312*1da1bac4Sxypron.glpk@gmx.de if (r != EFI_SUCCESS) 313*1da1bac4Sxypron.glpk@gmx.de return 1; 314*1da1bac4Sxypron.glpk@gmx.de else 315*1da1bac4Sxypron.glpk@gmx.de return 0; 316b9939336SAlexander Graf } 317b9939336SAlexander Graf 318b9939336SAlexander Graf #ifdef CONFIG_SYS_LONGHELP 319b9939336SAlexander Graf static char bootefi_help_text[] = 3201c39809bSAlexander Graf "<image address> [fdt address]\n" 3211c39809bSAlexander Graf " - boot EFI payload stored at address <image address>.\n" 3221c39809bSAlexander Graf " If specified, the device tree located at <fdt address> gets\n" 323c7ae3dfdSSimon Glass " exposed as EFI configuration table.\n" 324c7ae3dfdSSimon Glass #ifdef CONFIG_CMD_BOOTEFI_HELLO 325c7ae3dfdSSimon Glass "hello\n" 326c7ae3dfdSSimon Glass " - boot a sample Hello World application stored within U-Boot" 327c7ae3dfdSSimon Glass #endif 328c7ae3dfdSSimon Glass ; 329b9939336SAlexander Graf #endif 330b9939336SAlexander Graf 331b9939336SAlexander Graf U_BOOT_CMD( 3321c39809bSAlexander Graf bootefi, 3, 0, do_bootefi, 33392dfd922SSergey Kubushyn "Boots an EFI payload from memory", 334b9939336SAlexander Graf bootefi_help_text 335b9939336SAlexander Graf ); 3360f4060ebSAlexander Graf 337c07ad7c0SAlexander Graf void efi_set_bootdev(const char *dev, const char *devnr, const char *path) 3380f4060ebSAlexander Graf { 3398c3df0bfSAlexander Graf __maybe_unused struct blk_desc *desc; 340ecbe1a07SAlexander Graf char devname[32] = { 0 }; /* dp->str is u16[32] long */ 3410f4060ebSAlexander Graf char *colon; 3420f4060ebSAlexander Graf 3431acc0087SPatrick Delaunay #if defined(CONFIG_BLK) || CONFIG_IS_ENABLED(ISO_PARTITION) 344f9d334bdSAlexander Graf desc = blk_get_dev(dev, simple_strtol(devnr, NULL, 10)); 345f9d334bdSAlexander Graf #endif 346f9d334bdSAlexander Graf 347f9d334bdSAlexander Graf #ifdef CONFIG_BLK 348f9d334bdSAlexander Graf if (desc) { 349f9d334bdSAlexander Graf snprintf(devname, sizeof(devname), "%s", desc->bdev->name); 350f9d334bdSAlexander Graf } else 351f9d334bdSAlexander Graf #endif 352f9d334bdSAlexander Graf 353f9d334bdSAlexander Graf { 3540f4060ebSAlexander Graf /* Assemble the condensed device name we use in efi_disk.c */ 3550f4060ebSAlexander Graf snprintf(devname, sizeof(devname), "%s%s", dev, devnr); 356f9d334bdSAlexander Graf } 357f9d334bdSAlexander Graf 3580f4060ebSAlexander Graf colon = strchr(devname, ':'); 3598c3df0bfSAlexander Graf 3601acc0087SPatrick Delaunay #if CONFIG_IS_ENABLED(ISO_PARTITION) 3618c3df0bfSAlexander Graf /* For ISOs we create partition block devices */ 3628c3df0bfSAlexander Graf if (desc && (desc->type != DEV_TYPE_UNKNOWN) && 3638c3df0bfSAlexander Graf (desc->part_type == PART_TYPE_ISO)) { 3648c3df0bfSAlexander Graf if (!colon) 365f9d334bdSAlexander Graf snprintf(devname, sizeof(devname), "%s:1", devname); 366f9d334bdSAlexander Graf 3678c3df0bfSAlexander Graf colon = NULL; 3688c3df0bfSAlexander Graf } 3698c3df0bfSAlexander Graf #endif 3708c3df0bfSAlexander Graf 3710f4060ebSAlexander Graf if (colon) 3720f4060ebSAlexander Graf *colon = '\0'; 3730f4060ebSAlexander Graf 374c07ad7c0SAlexander Graf /* Patch bootefi_device_path to the target device */ 375c07ad7c0SAlexander Graf memset(bootefi_device_path[0].str, 0, sizeof(bootefi_device_path[0].str)); 376c07ad7c0SAlexander Graf ascii2unicode(bootefi_device_path[0].str, devname); 377c07ad7c0SAlexander Graf 378c07ad7c0SAlexander Graf /* Patch bootefi_image_path to the target file path */ 3790f4060ebSAlexander Graf memset(bootefi_image_path[0].str, 0, sizeof(bootefi_image_path[0].str)); 38049271666SAlexander Graf if (strcmp(dev, "Net")) { 38149271666SAlexander Graf /* Add leading / to fs paths, because they're absolute */ 38249271666SAlexander Graf snprintf(devname, sizeof(devname), "/%s", path); 38349271666SAlexander Graf } else { 384c07ad7c0SAlexander Graf snprintf(devname, sizeof(devname), "%s", path); 38549271666SAlexander Graf } 3860f4060ebSAlexander Graf ascii2unicode(bootefi_image_path[0].str, devname); 3870f4060ebSAlexander Graf } 388