Commit 1c39809b92c217877e160ee91a82743c9d4f3ed1

Authored by Alexander Graf
Committed by Tom Rini
1 parent 0c4b3880c1

efi_loader: Pass fdt address directly to bootefi cmd

The bootefi cmd today fetches its device tree pointer from either the
location appointed by "fdt addr" with a fallback to the U-Boot control
fdt.

This integration is unusual for U-Boot and diverges from the way we
usually handle parameters to boot commands. So let's pass the fdt
directly into the bootefi command instead and move the control fdt
logic into the distro boot script.

Signed-off-by: Alexander Graf <agraf@suse.de>
Acked-by: Stephen Warren <swarren@wwwdotorg.org>
Reviewed-by: Andreas Färber <afaerber@suse.de>

Showing 2 changed files with 22 additions and 23 deletions Side-by-side Diff

... ... @@ -142,12 +142,11 @@
142 142 * Load an EFI payload into a newly allocated piece of memory, register all
143 143 * EFI objects it would want to access and jump to it.
144 144 */
145   -static unsigned long do_bootefi_exec(void *efi)
  145 +static unsigned long do_bootefi_exec(void *efi, void *fdt)
146 146 {
147 147 ulong (*entry)(void *image_handle, struct efi_system_table *st);
148 148 ulong fdt_pages, fdt_size, fdt_start, fdt_end;
149 149 bootm_headers_t img = { 0 };
150   - void *fdt = working_fdt;
151 150  
152 151 /*
153 152 * gd lives in a fixed register which may get clobbered while we execute
... ... @@ -155,13 +154,7 @@
155 154 */
156 155 efi_save_gd();
157 156  
158   - /* Update system table to point to our currently loaded FDT */
159   -
160   - /* Fall back to included fdt if none was manually loaded */
161   - if (!fdt && gd->fdt_blob)
162   - fdt = (void *)gd->fdt_blob;
163   -
164   - if (fdt) {
  157 + if (fdt && !fdt_check_header(fdt)) {
165 158 /* Prepare fdt for payload */
166 159 fdt = copy_fdt(fdt);
167 160  
... ... @@ -185,7 +178,7 @@
185 178 efi_add_memory_map(fdt_start, fdt_pages,
186 179 EFI_BOOT_SERVICES_DATA, true);
187 180 } else {
188   - printf("WARNING: No device tree loaded, expect boot to fail\n");
  181 + printf("WARNING: Invalid device tree, expect boot to fail\n");
189 182 systab.nr_tables = 0;
190 183 }
191 184  
... ... @@ -216,8 +209,8 @@
216 209 /* Interpreter command to boot an arbitrary EFI image from memory */
217 210 static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
218 211 {
219   - char *saddr;
220   - unsigned long addr;
  212 + char *saddr, *sfdt;
  213 + unsigned long addr, fdt_addr = 0;
221 214 int r = 0;
222 215  
223 216 if (argc < 2)
224 217  
... ... @@ -226,8 +219,13 @@
226 219  
227 220 addr = simple_strtoul(saddr, NULL, 16);
228 221  
  222 + if (argc > 2) {
  223 + sfdt = argv[2];
  224 + fdt_addr = simple_strtoul(sfdt, NULL, 16);
  225 + }
  226 +
229 227 printf("## Starting EFI application at 0x%08lx ...\n", addr);
230   - r = do_bootefi_exec((void *)addr);
  228 + r = do_bootefi_exec((void *)addr, (void*)fdt_addr);
231 229 printf("## Application terminated, r = %d\n", r);
232 230  
233 231 if (r != 0)
234 232  
... ... @@ -238,16 +236,14 @@
238 236  
239 237 #ifdef CONFIG_SYS_LONGHELP
240 238 static char bootefi_help_text[] =
241   - "<image address>\n"
242   - " - boot EFI payload stored at address <image address>\n"
243   - "\n"
244   - "Since most EFI payloads want to have a device tree provided, please\n"
245   - "make sure you load a device tree using the fdt addr command before\n"
246   - "executing bootefi.\n";
  239 + "<image address> [fdt address]\n"
  240 + " - boot EFI payload stored at address <image address>.\n"
  241 + " If specified, the device tree located at <fdt address> gets\n"
  242 + " exposed as EFI configuration table.\n";
247 243 #endif
248 244  
249 245 U_BOOT_CMD(
250   - bootefi, 2, 0, do_bootefi,
  246 + bootefi, 3, 0, do_bootefi,
251 247 "Boots an EFI payload from memory\n",
252 248 bootefi_help_text
253 249 );
include/config_distro_bootcmd.h
... ... @@ -103,12 +103,15 @@
103 103 "boot_efi_binary=" \
104 104 "load ${devtype} ${devnum}:${distro_bootpart} " \
105 105 "${kernel_addr_r} efi/boot/"BOOTEFI_NAME"; " \
106   - "bootefi ${kernel_addr_r}\0" \
  106 + "if fdt addr ${fdt_addr_r}; then " \
  107 + "bootefi ${kernel_addr_r} ${fdt_addr_r};" \
  108 + "else" \
  109 + "bootefi ${kernel_addr_r} ${fdtcontroladdr};" \
  110 + "fi\0" \
107 111 \
108 112 "load_efi_dtb=" \
109 113 "load ${devtype} ${devnum}:${distro_bootpart} " \
110   - "${fdt_addr_r} ${prefix}${fdtfile}; " \
111   - "fdt addr ${fdt_addr_r}\0" \
  114 + "${fdt_addr_r} ${prefix}${fdtfile}\0" \
112 115 \
113 116 "efi_dtb_prefixes=/ /dtb/ /dtb/current/\0" \
114 117 "scan_dev_for_efi=" \