"Das U-Boot" Source Tree
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

efi_loader: Support loading a ramdisk with bootefi

It is sometimes useful to be able to boot via EFI using a Linux initrd.
Add support for this.

Fix a 'specifiy' typo while here.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

authored by

Simon Glass and committed by
Heinrich Schuchardt
47e9b739 8e5d34a3

+55 -15
+25 -8
cmd/bootefi.c
··· 136 136 { 137 137 efi_status_t ret; 138 138 char *p; 139 - void *fdt, *image_buf; 140 - unsigned long addr, size; 139 + void *fdt, *initrd = NULL, *image_buf; 140 + unsigned long addr, size, rd_len = 0, fdt_addr = 0; 141 141 void *image_addr; 142 142 size_t image_size; 143 + int fdt_arg = 2; 143 144 144 145 if (argc < 2) 145 146 return CMD_RET_USAGE; 146 147 147 148 if (argc > 2) { 148 - uintptr_t fdt_addr; 149 + ulong rd_addr = 0; 150 + char *end = strchr(argv[2], ':'); 151 + 152 + if (end) { 153 + rd_addr = hextoul(argv[2], NULL); 154 + if (!rd_addr) 155 + return CMD_RET_USAGE; 156 + 157 + rd_len = hextoul(++end, NULL); 158 + initrd = map_sysmem(rd_addr, rd_len); 159 + ++fdt_arg; 160 + } 161 + } 149 162 150 - fdt_addr = hextoul(argv[2], NULL); 163 + if (argc > fdt_arg + 1) 164 + return CMD_RET_USAGE; 165 + if (argc == fdt_arg + 1) 166 + fdt_addr = hextoul(argv[fdt_arg], NULL); 167 + 168 + if (fdt_addr) 151 169 fdt = map_sysmem(fdt_addr, 0); 152 - } else { 170 + else 153 171 fdt = EFI_FDT_USE_INTERNAL; 154 - } 155 172 156 173 if (IS_ENABLED(CONFIG_CMD_BOOTEFI_BOOTMGR) && 157 174 !strcmp(argv[1], "bootmgr")) { ··· 215 232 } 216 233 } 217 234 218 - ret = efi_binary_run(image_buf, size, fdt, NULL, 0); 235 + ret = efi_binary_run(image_buf, size, fdt, initrd, rd_len); 219 236 220 237 if (ret != EFI_SUCCESS) 221 238 return CMD_RET_FAILURE; ··· 224 241 } 225 242 226 243 U_BOOT_LONGHELP(bootefi, 227 - "<image address>[:<image size>] [<fdt address>]\n" 244 + "<image address>[:<size>] [<initrd address>:<size>] [<fdt address>]\n" 228 245 " - boot EFI payload\n" 229 246 #ifdef CONFIG_CMD_BOOTEFI_HELLO 230 247 "bootefi hello\n"
+30 -7
doc/usage/cmd/bootefi.rst
··· 12 12 13 13 :: 14 14 15 - bootefi <image_addr>[:<image_size>] [<fdt_addr>] 15 + bootefi <image_addr>[:<image_size>] [<initrd_addr>:<initrd_size>] [<fdt_address>] 16 16 bootefi bootmgr [<fdt_addr>] 17 17 bootefi hello [<fdt_addr>] 18 18 bootefi selftest [<fdt_addr>] ··· 44 44 load mmc 0:1 $kernel_addr_r /EFI/grub/grubaa64.efi 45 45 bootefi $kernel_addr_r $fdt_addr_r 46 46 47 + or 48 + 49 + :: 50 + 51 + setenv bootargs root=/dev/vda1 52 + load mmc 0:1 $fdt_addr_r dtb 53 + load mmc 0:1 $kernel_addr_r vmlinux 54 + load mmc 0:1 $initrd_addr_r intird 55 + bootefi $kernel_addr_r $initrd_addr_r:$filesize $fdt_addr_r 56 + 47 57 The last UEFI binary loaded defines the image file path in the loaded image 48 58 protocol. 49 59 ··· 51 61 UTF-16 and passed as load options in the loaded image protocol to the UEFI 52 62 binary. 53 63 64 + .. note:: 65 + 66 + The bootefi command accepts one to three arguments. 67 + If the second argument contains a colon ':', it is assumed to specify the 68 + initial RAM disk. 69 + 54 70 image_addr 55 71 Address of the UEFI binary. 56 72 57 - fdt_addr 58 - Address of the device-tree or '-'. If no address is specifiy, the 59 - environment variable $fdt_addr is used as first fallback, the address of 60 - U-Boot's internal device-tree $fdtcontroladdr as second fallback. 61 - When using ACPI no device-tree shall be specified. 62 - 63 73 image_size 64 74 Size of the UEFI binary file. This argument is only needed if *image_addr* 65 75 does not match the address of the last loaded UEFI binary. In this case 66 76 a memory device path will be used as image file path in the loaded image 67 77 protocol. 78 + 79 + initrd_addr 80 + Address of the Linux initial RAM disk or '-'. If no address is specified, 81 + no RAM disk is used when booting. 82 + 83 + initrd_size 84 + Size of the Linux initial RAM disk. 85 + 86 + fdt_addr 87 + Address of the device-tree or '-'. If no address is specified, the 88 + environment variable $fdt_addr is used as first fallback, the address of 89 + U-Boot's internal device-tree $fdtcontroladdr as second fallback. 90 + When using ACPI no device-tree shall be specified. 68 91 69 92 Note 70 93 UEFI binaries that are contained in FIT images are launched via the