]>
Commit | Line | Data |
---|---|---|
41506ff5 SG |
1 | // SPDX-License-Identifier: GPL-2.0+ |
2 | /* | |
3 | * Image code used by boards (and not host tools) | |
4 | * | |
5 | * (C) Copyright 2008 Semihalf | |
6 | * | |
7 | * (C) Copyright 2000-2006 | |
8 | * Wolfgang Denk, DENX Software Engineering, [email protected]. | |
9 | */ | |
10 | ||
03de305e | 11 | #include <config.h> |
41506ff5 SG |
12 | #include <bootstage.h> |
13 | #include <cpu_func.h> | |
4e4bf944 | 14 | #include <display_options.h> |
41506ff5 SG |
15 | #include <env.h> |
16 | #include <fpga.h> | |
17 | #include <image.h> | |
4b32531b | 18 | #include <init.h> |
9c2e9128 | 19 | #include <log.h> |
41506ff5 | 20 | #include <mapmem.h> |
5d3248a6 | 21 | #include <rtc.h> |
41506ff5 SG |
22 | #include <watchdog.h> |
23 | #include <asm/cache.h> | |
24 | #include <asm/global_data.h> | |
25 | ||
41506ff5 SG |
26 | DECLARE_GLOBAL_DATA_PTR; |
27 | ||
41506ff5 SG |
28 | /** |
29 | * image_get_ramdisk - get and verify ramdisk image | |
30 | * @rd_addr: ramdisk image start address | |
31 | * @arch: expected ramdisk architecture | |
32 | * @verify: checksum verification flag | |
33 | * | |
34 | * image_get_ramdisk() returns a pointer to the verified ramdisk image | |
35 | * header. Routine receives image start address and expected architecture | |
36 | * flag. Verification done covers data and header integrity and os/type/arch | |
37 | * fields checking. | |
38 | * | |
39 | * returns: | |
40 | * pointer to a ramdisk image header, if image was found and valid | |
41 | * otherwise, return NULL | |
42 | */ | |
f3543e69 SG |
43 | static const struct legacy_img_hdr *image_get_ramdisk(ulong rd_addr, u8 arch, |
44 | int verify) | |
41506ff5 | 45 | { |
f3543e69 | 46 | const struct legacy_img_hdr *rd_hdr = (const struct legacy_img_hdr *)rd_addr; |
41506ff5 SG |
47 | |
48 | if (!image_check_magic(rd_hdr)) { | |
49 | puts("Bad Magic Number\n"); | |
50 | bootstage_error(BOOTSTAGE_ID_RD_MAGIC); | |
51 | return NULL; | |
52 | } | |
53 | ||
54 | if (!image_check_hcrc(rd_hdr)) { | |
55 | puts("Bad Header Checksum\n"); | |
56 | bootstage_error(BOOTSTAGE_ID_RD_HDR_CHECKSUM); | |
57 | return NULL; | |
58 | } | |
59 | ||
60 | bootstage_mark(BOOTSTAGE_ID_RD_MAGIC); | |
61 | image_print_contents(rd_hdr); | |
62 | ||
63 | if (verify) { | |
64 | puts(" Verifying Checksum ... "); | |
65 | if (!image_check_dcrc(rd_hdr)) { | |
66 | puts("Bad Data CRC\n"); | |
67 | bootstage_error(BOOTSTAGE_ID_RD_CHECKSUM); | |
68 | return NULL; | |
69 | } | |
70 | puts("OK\n"); | |
71 | } | |
72 | ||
73 | bootstage_mark(BOOTSTAGE_ID_RD_HDR_CHECKSUM); | |
74 | ||
75 | if (!image_check_os(rd_hdr, IH_OS_LINUX) || | |
76 | !image_check_arch(rd_hdr, arch) || | |
77 | !image_check_type(rd_hdr, IH_TYPE_RAMDISK)) { | |
78 | printf("No Linux %s Ramdisk Image\n", | |
3d2a47f1 | 79 | genimg_get_arch_name(arch)); |
41506ff5 SG |
80 | bootstage_error(BOOTSTAGE_ID_RAMDISK); |
81 | return NULL; | |
82 | } | |
83 | ||
84 | return rd_hdr; | |
85 | } | |
41506ff5 SG |
86 | |
87 | /*****************************************************************************/ | |
88 | /* Shared dual-format routines */ | |
89 | /*****************************************************************************/ | |
90 | ulong image_load_addr = CONFIG_SYS_LOAD_ADDR; /* Default Load Address */ | |
91 | ulong image_save_addr; /* Default Save Address */ | |
92 | ulong image_save_size; /* Default Save Size (in bytes) */ | |
93 | ||
94 | static int on_loadaddr(const char *name, const char *value, enum env_op op, | |
3d2a47f1 | 95 | int flags) |
41506ff5 SG |
96 | { |
97 | switch (op) { | |
98 | case env_op_create: | |
99 | case env_op_overwrite: | |
100 | image_load_addr = hextoul(value, NULL); | |
101 | break; | |
102 | default: | |
103 | break; | |
104 | } | |
105 | ||
106 | return 0; | |
107 | } | |
108 | U_BOOT_ENV_CALLBACK(loadaddr, on_loadaddr); | |
109 | ||
a4df06e4 | 110 | phys_addr_t env_get_bootm_low(void) |
41506ff5 SG |
111 | { |
112 | char *s = env_get("bootm_low"); | |
3d2a47f1 | 113 | |
a4df06e4 MV |
114 | if (s) |
115 | return simple_strtoull(s, NULL, 16); | |
41506ff5 | 116 | |
aa6e94de TR |
117 | #if defined(CFG_SYS_SDRAM_BASE) |
118 | return CFG_SYS_SDRAM_BASE; | |
41506ff5 SG |
119 | #elif defined(CONFIG_ARM) || defined(CONFIG_MICROBLAZE) || defined(CONFIG_RISCV) |
120 | return gd->bd->bi_dram[0].start; | |
121 | #else | |
122 | return 0; | |
123 | #endif | |
124 | } | |
125 | ||
126 | phys_size_t env_get_bootm_size(void) | |
127 | { | |
5fb569b3 MV |
128 | phys_addr_t start, low; |
129 | phys_size_t size; | |
41506ff5 | 130 | char *s = env_get("bootm_size"); |
3d2a47f1 | 131 | |
98e68ec1 MV |
132 | if (s) |
133 | return simple_strtoull(s, NULL, 16); | |
41506ff5 SG |
134 | |
135 | start = gd->ram_base; | |
136 | size = gd->ram_size; | |
137 | ||
138 | if (start + size > gd->ram_top) | |
139 | size = gd->ram_top - start; | |
140 | ||
141 | s = env_get("bootm_low"); | |
142 | if (s) | |
5fb569b3 | 143 | low = simple_strtoull(s, NULL, 16); |
41506ff5 | 144 | else |
5fb569b3 | 145 | low = start; |
41506ff5 | 146 | |
5fb569b3 | 147 | return size - (low - start); |
41506ff5 SG |
148 | } |
149 | ||
150 | phys_size_t env_get_bootm_mapsize(void) | |
151 | { | |
41506ff5 | 152 | char *s = env_get("bootm_mapsize"); |
3d2a47f1 | 153 | |
ca8d4dfd MV |
154 | if (s) |
155 | return simple_strtoull(s, NULL, 16); | |
41506ff5 | 156 | |
65cc0e2a TR |
157 | #if defined(CFG_SYS_BOOTMAPSZ) |
158 | return CFG_SYS_BOOTMAPSZ; | |
41506ff5 SG |
159 | #else |
160 | return env_get_bootm_size(); | |
161 | #endif | |
162 | } | |
163 | ||
164 | void memmove_wd(void *to, void *from, size_t len, ulong chunksz) | |
165 | { | |
166 | if (to == from) | |
167 | return; | |
168 | ||
9c2e9128 | 169 | if (IS_ENABLED(CONFIG_HW_WATCHDOG) || IS_ENABLED(CONFIG_WATCHDOG)) { |
41506ff5 | 170 | if (to > from) { |
9c2e9128 SG |
171 | from += len; |
172 | to += len; | |
41506ff5 | 173 | } |
9c2e9128 SG |
174 | while (len > 0) { |
175 | size_t tail = (len > chunksz) ? chunksz : len; | |
176 | ||
29caf930 | 177 | schedule(); |
9c2e9128 SG |
178 | if (to > from) { |
179 | to -= tail; | |
180 | from -= tail; | |
181 | } | |
182 | memmove(to, from, tail); | |
183 | if (to < from) { | |
184 | to += tail; | |
185 | from += tail; | |
186 | } | |
187 | len -= tail; | |
41506ff5 | 188 | } |
9c2e9128 SG |
189 | } else { |
190 | memmove(to, from, len); | |
41506ff5 | 191 | } |
41506ff5 SG |
192 | } |
193 | ||
530cc479 | 194 | ulong genimg_get_kernel_addr_fit(const char *const img_addr, |
3d2a47f1 SG |
195 | const char **fit_uname_config, |
196 | const char **fit_uname_kernel) | |
41506ff5 SG |
197 | { |
198 | ulong kernel_addr; | |
199 | ||
200 | /* find out kernel image address */ | |
201 | if (!img_addr) { | |
202 | kernel_addr = image_load_addr; | |
203 | debug("* kernel: default image load address = 0x%08lx\n", | |
204 | image_load_addr); | |
1df654a6 SG |
205 | } else if (CONFIG_IS_ENABLED(FIT) && |
206 | fit_parse_conf(img_addr, image_load_addr, &kernel_addr, | |
41506ff5 SG |
207 | fit_uname_config)) { |
208 | debug("* kernel: config '%s' from image at 0x%08lx\n", | |
209 | *fit_uname_config, kernel_addr); | |
1df654a6 SG |
210 | } else if (CONFIG_IS_ENABLED(FIT) && |
211 | fit_parse_subimage(img_addr, image_load_addr, &kernel_addr, | |
212 | fit_uname_kernel)) { | |
41506ff5 SG |
213 | debug("* kernel: subimage '%s' from image at 0x%08lx\n", |
214 | *fit_uname_kernel, kernel_addr); | |
41506ff5 SG |
215 | } else { |
216 | kernel_addr = hextoul(img_addr, NULL); | |
217 | debug("* kernel: cmdline image address = 0x%08lx\n", | |
218 | kernel_addr); | |
219 | } | |
220 | ||
221 | return kernel_addr; | |
222 | } | |
223 | ||
224 | /** | |
225 | * genimg_get_kernel_addr() is the simple version of | |
226 | * genimg_get_kernel_addr_fit(). It ignores those return FIT strings | |
227 | */ | |
228 | ulong genimg_get_kernel_addr(char * const img_addr) | |
229 | { | |
230 | const char *fit_uname_config = NULL; | |
231 | const char *fit_uname_kernel = NULL; | |
232 | ||
233 | return genimg_get_kernel_addr_fit(img_addr, &fit_uname_config, | |
234 | &fit_uname_kernel); | |
235 | } | |
236 | ||
237 | /** | |
238 | * genimg_get_format - get image format type | |
239 | * @img_addr: image start address | |
240 | * | |
241 | * genimg_get_format() checks whether provided address points to a valid | |
242 | * legacy or FIT image. | |
243 | * | |
244 | * New uImage format and FDT blob are based on a libfdt. FDT blob | |
245 | * may be passed directly or embedded in a FIT image. In both situations | |
246 | * genimg_get_format() must be able to dectect libfdt header. | |
247 | * | |
248 | * returns: | |
249 | * image format type or IMAGE_FORMAT_INVALID if no image is present | |
250 | */ | |
251 | int genimg_get_format(const void *img_addr) | |
252 | { | |
1df654a6 | 253 | if (CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)) { |
f3543e69 | 254 | const struct legacy_img_hdr *hdr; |
41506ff5 | 255 | |
f3543e69 | 256 | hdr = (const struct legacy_img_hdr *)img_addr; |
1df654a6 SG |
257 | if (image_check_magic(hdr)) |
258 | return IMAGE_FORMAT_LEGACY; | |
259 | } | |
260 | if (CONFIG_IS_ENABLED(FIT) || CONFIG_IS_ENABLED(OF_LIBFDT)) { | |
261 | if (!fdt_check_header(img_addr)) | |
262 | return IMAGE_FORMAT_FIT; | |
263 | } | |
264 | if (IS_ENABLED(CONFIG_ANDROID_BOOT_IMAGE) && | |
734cb47d | 265 | is_android_boot_image_header(img_addr)) |
41506ff5 | 266 | return IMAGE_FORMAT_ANDROID; |
41506ff5 SG |
267 | |
268 | return IMAGE_FORMAT_INVALID; | |
269 | } | |
270 | ||
271 | /** | |
272 | * fit_has_config - check if there is a valid FIT configuration | |
273 | * @images: pointer to the bootm command headers structure | |
274 | * | |
275 | * fit_has_config() checks if there is a FIT configuration in use | |
276 | * (if FTI support is present). | |
277 | * | |
278 | * returns: | |
279 | * 0, no FIT support or no configuration found | |
280 | * 1, configuration found | |
281 | */ | |
d9d7c20b | 282 | int genimg_has_config(struct bootm_headers *images) |
41506ff5 | 283 | { |
1df654a6 | 284 | if (CONFIG_IS_ENABLED(FIT) && images->fit_uname_cfg) |
41506ff5 | 285 | return 1; |
1df654a6 | 286 | |
41506ff5 SG |
287 | return 0; |
288 | } | |
289 | ||
290 | /** | |
e4c92879 SG |
291 | * select_ramdisk() - Select and locate the ramdisk to use |
292 | * | |
41506ff5 | 293 | * @images: pointer to the bootm images structure |
4f2d9412 | 294 | * @select: name of ramdisk to select, or hex address, NULL for any |
41506ff5 | 295 | * @arch: expected ramdisk architecture |
e4c92879 SG |
296 | * @rd_datap: pointer to a ulong variable, will hold ramdisk pointer |
297 | * @rd_lenp: pointer to a ulong variable, will hold ramdisk length | |
185f812c | 298 | * Return: 0 if OK, -ENOPKG if no ramdisk (but an error should not be reported), |
e4c92879 | 299 | * other -ve value on other error |
41506ff5 | 300 | */ |
d9d7c20b | 301 | static int select_ramdisk(struct bootm_headers *images, const char *select, u8 arch, |
e4c92879 | 302 | ulong *rd_datap, ulong *rd_lenp) |
41506ff5 | 303 | { |
f7659f69 SG |
304 | const char *fit_uname_config; |
305 | const char *fit_uname_ramdisk; | |
ca78883f | 306 | bool done_select = !select; |
4f2d9412 | 307 | bool done = false; |
f7659f69 | 308 | int rd_noffset; |
51a765b3 | 309 | ulong rd_addr = 0; |
e4c92879 | 310 | char *buf; |
78f88790 | 311 | |
ca78883f | 312 | if (CONFIG_IS_ENABLED(FIT)) { |
f7659f69 SG |
313 | fit_uname_config = images->fit_uname_cfg; |
314 | fit_uname_ramdisk = NULL; | |
78f88790 | 315 | |
621158d1 TR |
316 | if (select) { |
317 | ulong default_addr; | |
41506ff5 SG |
318 | /* |
319 | * If the init ramdisk comes from the FIT image and | |
320 | * the FIT image address is omitted in the command | |
321 | * line argument, try to use os FIT image address or | |
322 | * default load address. | |
323 | */ | |
324 | if (images->fit_uname_os) | |
325 | default_addr = (ulong)images->fit_hdr_os; | |
326 | else | |
327 | default_addr = image_load_addr; | |
328 | ||
20f5d83f SG |
329 | if (fit_parse_conf(select, default_addr, &rd_addr, |
330 | &fit_uname_config)) { | |
3d2a47f1 SG |
331 | debug("* ramdisk: config '%s' from image at 0x%08lx\n", |
332 | fit_uname_config, rd_addr); | |
ca78883f | 333 | done_select = true; |
41506ff5 | 334 | } else if (fit_parse_subimage(select, default_addr, |
3d2a47f1 SG |
335 | &rd_addr, |
336 | &fit_uname_ramdisk)) { | |
337 | debug("* ramdisk: subimage '%s' from image at 0x%08lx\n", | |
338 | fit_uname_ramdisk, rd_addr); | |
ca78883f SG |
339 | done_select = true; |
340 | } | |
341 | } | |
342 | } | |
343 | if (!done_select) { | |
20f5d83f SG |
344 | rd_addr = hextoul(select, NULL); |
345 | debug("* ramdisk: cmdline image address = 0x%08lx\n", rd_addr); | |
ca78883f | 346 | } |
20f5d83f SG |
347 | if (CONFIG_IS_ENABLED(FIT) && !select) { |
348 | /* use FIT configuration provided in first bootm | |
349 | * command argument. If the property is not defined, | |
350 | * quit silently (with -ENOPKG) | |
621158d1 | 351 | */ |
20f5d83f SG |
352 | rd_addr = map_to_sysmem(images->fit_hdr_os); |
353 | rd_noffset = fit_get_node_from_config(images, FIT_RAMDISK_PROP, | |
354 | rd_addr); | |
355 | if (rd_noffset == -ENOENT) | |
356 | return -ENOPKG; | |
357 | else if (rd_noffset < 0) | |
358 | return rd_noffset; | |
359 | } | |
621158d1 | 360 | |
20f5d83f SG |
361 | /* |
362 | * Check if there is an initrd image at the | |
363 | * address provided in the second bootm argument | |
364 | * check image type, for FIT images get FIT node. | |
365 | */ | |
366 | buf = map_sysmem(rd_addr, 0); | |
367 | switch (genimg_get_format(buf)) { | |
368 | case IMAGE_FORMAT_LEGACY: | |
369 | if (CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)) { | |
f3543e69 | 370 | const struct legacy_img_hdr *rd_hdr; |
20f5d83f SG |
371 | |
372 | printf("## Loading init Ramdisk from Legacy Image at %08lx ...\n", | |
373 | rd_addr); | |
374 | ||
375 | bootstage_mark(BOOTSTAGE_ID_CHECK_RAMDISK); | |
376 | rd_hdr = image_get_ramdisk(rd_addr, arch, | |
377 | images->verify); | |
378 | ||
379 | if (!rd_hdr) | |
380 | return -ENOENT; | |
381 | ||
382 | *rd_datap = image_get_data(rd_hdr); | |
383 | *rd_lenp = image_get_data_size(rd_hdr); | |
384 | done = true; | |
385 | } | |
386 | break; | |
387 | case IMAGE_FORMAT_FIT: | |
388 | if (CONFIG_IS_ENABLED(FIT)) { | |
389 | rd_noffset = fit_image_load(images, rd_addr, | |
390 | &fit_uname_ramdisk, | |
391 | &fit_uname_config, | |
392 | arch, IH_TYPE_RAMDISK, | |
393 | BOOTSTAGE_ID_FIT_RD_START, | |
394 | FIT_LOAD_OPTIONAL_NON_ZERO, | |
395 | rd_datap, rd_lenp); | |
396 | if (rd_noffset < 0) | |
397 | return rd_noffset; | |
41506ff5 | 398 | |
20f5d83f SG |
399 | images->fit_hdr_rd = map_sysmem(rd_addr, 0); |
400 | images->fit_uname_rd = fit_uname_ramdisk; | |
401 | images->fit_noffset_rd = rd_noffset; | |
402 | done = true; | |
403 | } | |
404 | break; | |
405 | case IMAGE_FORMAT_ANDROID: | |
406 | if (IS_ENABLED(CONFIG_ANDROID_BOOT_IMAGE)) { | |
20f5d83f | 407 | int ret; |
636da203 | 408 | if (IS_ENABLED(CONFIG_CMD_ABOOTIMG)) { |
17b1656d RS |
409 | ulong boot_img = get_abootimg_addr(); |
410 | ulong init_boot_img = get_ainit_bootimg_addr(); | |
636da203 | 411 | void *vendor_boot_img = map_sysmem(get_avendor_bootimg_addr(), 0); |
17b1656d | 412 | void *ramdisk_img; |
636da203 | 413 | |
17b1656d RS |
414 | if (init_boot_img == -1) |
415 | ramdisk_img = map_sysmem(boot_img, 0); | |
416 | else | |
417 | ramdisk_img = map_sysmem(init_boot_img, 0); | |
418 | ||
419 | ret = android_image_get_ramdisk(ramdisk_img, vendor_boot_img, | |
636da203 SO |
420 | rd_datap, rd_lenp); |
421 | unmap_sysmem(vendor_boot_img); | |
17b1656d | 422 | unmap_sysmem(ramdisk_img); |
636da203 SO |
423 | } else { |
424 | void *ptr = map_sysmem(images->os.start, 0); | |
425 | ||
426 | ret = android_image_get_ramdisk(ptr, NULL, rd_datap, rd_lenp); | |
427 | unmap_sysmem(ptr); | |
428 | } | |
429 | ||
6509c3fe MW |
430 | if (ret == -ENOENT) |
431 | return -ENOPKG; | |
432 | else if (ret) | |
20f5d83f SG |
433 | return ret; |
434 | done = true; | |
4f2d9412 | 435 | } |
20f5d83f SG |
436 | break; |
437 | } | |
4f2d9412 SG |
438 | |
439 | if (!done) { | |
440 | if (IS_ENABLED(CONFIG_SUPPORT_RAW_INITRD)) { | |
441 | char *end = NULL; | |
442 | ||
443 | if (select) | |
444 | end = strchr(select, ':'); | |
445 | if (end) { | |
446 | *rd_lenp = hextoul(++end, NULL); | |
447 | *rd_datap = rd_addr; | |
448 | done = true; | |
41506ff5 | 449 | } |
4f2d9412 SG |
450 | } |
451 | ||
452 | if (!done) { | |
1df654a6 | 453 | puts("Wrong Ramdisk Image Format\n"); |
e4c92879 | 454 | return -EINVAL; |
41506ff5 | 455 | } |
4f2d9412 | 456 | } |
e4c92879 SG |
457 | |
458 | return 0; | |
459 | } | |
460 | ||
8eda15bc SG |
461 | int boot_get_ramdisk(char const *select, struct bootm_headers *images, |
462 | uint arch, ulong *rd_start, ulong *rd_end) | |
e4c92879 SG |
463 | { |
464 | ulong rd_data, rd_len; | |
e4c92879 SG |
465 | |
466 | *rd_start = 0; | |
467 | *rd_end = 0; | |
468 | ||
e4c92879 SG |
469 | /* |
470 | * Look for a '-' which indicates to ignore the | |
471 | * ramdisk argument | |
472 | */ | |
473 | if (select && strcmp(select, "-") == 0) { | |
474 | debug("## Skipping init Ramdisk\n"); | |
475 | rd_len = 0; | |
476 | rd_data = 0; | |
477 | } else if (select || genimg_has_config(images)) { | |
478 | int ret; | |
479 | ||
480 | ret = select_ramdisk(images, select, arch, &rd_data, &rd_len); | |
481 | if (ret == -ENOPKG) | |
482 | return 0; | |
483 | else if (ret) | |
484 | return ret; | |
41506ff5 SG |
485 | } else if (images->legacy_hdr_valid && |
486 | image_check_type(&images->legacy_hdr_os_copy, | |
3d2a47f1 | 487 | IH_TYPE_MULTI)) { |
41506ff5 SG |
488 | /* |
489 | * Now check if we have a legacy mult-component image, | |
490 | * get second entry data start address and len. | |
491 | */ | |
492 | bootstage_mark(BOOTSTAGE_ID_RAMDISK); | |
3d2a47f1 SG |
493 | printf("## Loading init Ramdisk from multi component Legacy Image at %08lx ...\n", |
494 | (ulong)images->legacy_hdr_os); | |
41506ff5 SG |
495 | |
496 | image_multi_getimg(images->legacy_hdr_os, 1, &rd_data, &rd_len); | |
497 | } else { | |
498 | /* | |
499 | * no initrd image | |
500 | */ | |
501 | bootstage_mark(BOOTSTAGE_ID_NO_RAMDISK); | |
3d2a47f1 SG |
502 | rd_len = 0; |
503 | rd_data = 0; | |
41506ff5 SG |
504 | } |
505 | ||
506 | if (!rd_data) { | |
507 | debug("## No init Ramdisk\n"); | |
508 | } else { | |
509 | *rd_start = rd_data; | |
510 | *rd_end = rd_data + rd_len; | |
511 | } | |
512 | debug(" ramdisk start = 0x%08lx, ramdisk end = 0x%08lx\n", | |
3d2a47f1 | 513 | *rd_start, *rd_end); |
41506ff5 SG |
514 | |
515 | return 0; | |
516 | } | |
517 | ||
41506ff5 SG |
518 | /** |
519 | * boot_ramdisk_high - relocate init ramdisk | |
41506ff5 SG |
520 | * @rd_data: ramdisk data start address |
521 | * @rd_len: ramdisk data length | |
522 | * @initrd_start: pointer to a ulong variable, will hold final init ramdisk | |
523 | * start address (after possible relocation) | |
524 | * @initrd_end: pointer to a ulong variable, will hold final init ramdisk | |
525 | * end address (after possible relocation) | |
526 | * | |
527 | * boot_ramdisk_high() takes a relocation hint from "initrd_high" environment | |
528 | * variable and if requested ramdisk data is moved to a specified location. | |
529 | * | |
530 | * Initrd_start and initrd_end are set to final (after relocation) ramdisk | |
531 | * start/end addresses if ramdisk image start and len were provided, | |
532 | * otherwise set initrd_start and initrd_end set to zeros. | |
533 | * | |
534 | * returns: | |
535 | * 0 - success | |
536 | * -1 - failure | |
537 | */ | |
ed17a33f SG |
538 | int boot_ramdisk_high(ulong rd_data, ulong rd_len, ulong *initrd_start, |
539 | ulong *initrd_end) | |
41506ff5 SG |
540 | { |
541 | char *s; | |
a4df06e4 | 542 | phys_addr_t initrd_high; |
41506ff5 SG |
543 | int initrd_copy_to_ram = 1; |
544 | ||
545 | s = env_get("initrd_high"); | |
546 | if (s) { | |
547 | /* a value of "no" or a similar string will act like 0, | |
548 | * turning the "load high" feature off. This is intentional. | |
549 | */ | |
550 | initrd_high = hextoul(s, NULL); | |
551 | if (initrd_high == ~0) | |
552 | initrd_copy_to_ram = 0; | |
553 | } else { | |
554 | initrd_high = env_get_bootm_mapsize() + env_get_bootm_low(); | |
555 | } | |
556 | ||
a4df06e4 MV |
557 | debug("## initrd_high = 0x%llx, copy_to_ram = %d\n", |
558 | (u64)initrd_high, initrd_copy_to_ram); | |
41506ff5 SG |
559 | |
560 | if (rd_data) { | |
561 | if (!initrd_copy_to_ram) { /* zero-copy ramdisk support */ | |
562 | debug(" in-place initrd\n"); | |
563 | *initrd_start = rd_data; | |
564 | *initrd_end = rd_data + rd_len; | |
ed17a33f | 565 | lmb_reserve(rd_data, rd_len); |
41506ff5 SG |
566 | } else { |
567 | if (initrd_high) | |
ed17a33f SG |
568 | *initrd_start = (ulong)lmb_alloc_base(rd_len, |
569 | 0x1000, | |
570 | initrd_high); | |
41506ff5 | 571 | else |
ed17a33f | 572 | *initrd_start = (ulong)lmb_alloc(rd_len, |
41506ff5 SG |
573 | 0x1000); |
574 | ||
575 | if (*initrd_start == 0) { | |
576 | puts("ramdisk - allocation error\n"); | |
577 | goto error; | |
578 | } | |
579 | bootstage_mark(BOOTSTAGE_ID_COPY_RAMDISK); | |
580 | ||
581 | *initrd_end = *initrd_start + rd_len; | |
582 | printf(" Loading Ramdisk to %08lx, end %08lx ... ", | |
3d2a47f1 | 583 | *initrd_start, *initrd_end); |
41506ff5 SG |
584 | |
585 | memmove_wd((void *)*initrd_start, | |
3d2a47f1 | 586 | (void *)rd_data, rd_len, CHUNKSZ); |
41506ff5 | 587 | |
41506ff5 SG |
588 | /* |
589 | * Ensure the image is flushed to memory to handle | |
590 | * AMP boot scenarios in which we might not be | |
591 | * HW cache coherent | |
592 | */ | |
1df654a6 SG |
593 | if (IS_ENABLED(CONFIG_MP)) { |
594 | flush_cache((unsigned long)*initrd_start, | |
595 | ALIGN(rd_len, ARCH_DMA_MINALIGN)); | |
596 | } | |
41506ff5 SG |
597 | puts("OK\n"); |
598 | } | |
599 | } else { | |
600 | *initrd_start = 0; | |
601 | *initrd_end = 0; | |
602 | } | |
603 | debug(" ramdisk load start = 0x%08lx, ramdisk load end = 0x%08lx\n", | |
3d2a47f1 | 604 | *initrd_start, *initrd_end); |
41506ff5 SG |
605 | |
606 | return 0; | |
607 | ||
608 | error: | |
609 | return -1; | |
610 | } | |
41506ff5 | 611 | |
d9d7c20b | 612 | int boot_get_setup(struct bootm_headers *images, u8 arch, |
41506ff5 SG |
613 | ulong *setup_start, ulong *setup_len) |
614 | { | |
1df654a6 SG |
615 | if (!CONFIG_IS_ENABLED(FIT)) |
616 | return -ENOENT; | |
617 | ||
41506ff5 | 618 | return boot_get_setup_fit(images, arch, setup_start, setup_len); |
41506ff5 SG |
619 | } |
620 | ||
745367b2 | 621 | int boot_get_fpga(struct bootm_headers *images) |
41506ff5 SG |
622 | { |
623 | ulong tmp_img_addr, img_data, img_len; | |
624 | void *buf; | |
625 | int conf_noffset; | |
626 | int fit_img_result; | |
627 | const char *uname, *name; | |
628 | int err; | |
629 | int devnum = 0; /* TODO support multi fpga platforms */ | |
630 | ||
1df654a6 SG |
631 | if (!IS_ENABLED(CONFIG_FPGA)) |
632 | return -ENOSYS; | |
633 | ||
41506ff5 SG |
634 | /* Check to see if the images struct has a FIT configuration */ |
635 | if (!genimg_has_config(images)) { | |
636 | debug("## FIT configuration was not specified\n"); | |
637 | return 0; | |
638 | } | |
639 | ||
640 | /* | |
641 | * Obtain the os FIT header from the images struct | |
642 | */ | |
643 | tmp_img_addr = map_to_sysmem(images->fit_hdr_os); | |
644 | buf = map_sysmem(tmp_img_addr, 0); | |
645 | /* | |
646 | * Check image type. For FIT images get FIT node | |
647 | * and attempt to locate a generic binary. | |
648 | */ | |
649 | switch (genimg_get_format(buf)) { | |
650 | case IMAGE_FORMAT_FIT: | |
651 | conf_noffset = fit_conf_get_node(buf, images->fit_uname_cfg); | |
652 | ||
653 | uname = fdt_stringlist_get(buf, conf_noffset, FIT_FPGA_PROP, 0, | |
654 | NULL); | |
655 | if (!uname) { | |
656 | debug("## FPGA image is not specified\n"); | |
657 | return 0; | |
658 | } | |
659 | fit_img_result = fit_image_load(images, | |
660 | tmp_img_addr, | |
661 | (const char **)&uname, | |
3d2a47f1 | 662 | &images->fit_uname_cfg, |
745367b2 | 663 | IH_ARCH_DEFAULT, |
41506ff5 SG |
664 | IH_TYPE_FPGA, |
665 | BOOTSTAGE_ID_FPGA_INIT, | |
666 | FIT_LOAD_OPTIONAL_NON_ZERO, | |
667 | &img_data, &img_len); | |
668 | ||
669 | debug("FPGA image (%s) loaded to 0x%lx/size 0x%lx\n", | |
670 | uname, img_data, img_len); | |
671 | ||
672 | if (fit_img_result < 0) { | |
673 | /* Something went wrong! */ | |
674 | return fit_img_result; | |
675 | } | |
676 | ||
677 | if (!fpga_is_partial_data(devnum, img_len)) { | |
678 | name = "full"; | |
679 | err = fpga_loadbitstream(devnum, (char *)img_data, | |
680 | img_len, BIT_FULL); | |
681 | if (err) | |
682 | err = fpga_load(devnum, (const void *)img_data, | |
282eed50 | 683 | img_len, BIT_FULL, 0); |
41506ff5 SG |
684 | } else { |
685 | name = "partial"; | |
686 | err = fpga_loadbitstream(devnum, (char *)img_data, | |
687 | img_len, BIT_PARTIAL); | |
688 | if (err) | |
689 | err = fpga_load(devnum, (const void *)img_data, | |
282eed50 | 690 | img_len, BIT_PARTIAL, 0); |
41506ff5 SG |
691 | } |
692 | ||
693 | if (err) | |
694 | return err; | |
695 | ||
696 | printf(" Programming %s bitstream... OK\n", name); | |
697 | break; | |
698 | default: | |
699 | printf("The given image format is not supported (corrupt?)\n"); | |
700 | return 1; | |
701 | } | |
702 | ||
703 | return 0; | |
704 | } | |
41506ff5 | 705 | |
3d2a47f1 | 706 | static void fit_loadable_process(u8 img_type, |
41506ff5 SG |
707 | ulong img_data, |
708 | ulong img_len) | |
709 | { | |
710 | int i; | |
711 | const unsigned int count = | |
712 | ll_entry_count(struct fit_loadable_tbl, fit_loadable); | |
713 | struct fit_loadable_tbl *fit_loadable_handler = | |
714 | ll_entry_start(struct fit_loadable_tbl, fit_loadable); | |
715 | /* For each loadable handler */ | |
716 | for (i = 0; i < count; i++, fit_loadable_handler++) | |
717 | /* matching this type */ | |
718 | if (fit_loadable_handler->type == img_type) | |
719 | /* call that handler with this image data */ | |
720 | fit_loadable_handler->handler(img_data, img_len); | |
721 | } | |
722 | ||
96456285 | 723 | int boot_get_loadable(struct bootm_headers *images) |
41506ff5 SG |
724 | { |
725 | /* | |
726 | * These variables are used to hold the current image location | |
727 | * in system memory. | |
728 | */ | |
729 | ulong tmp_img_addr; | |
730 | /* | |
731 | * These two variables are requirements for fit_image_load, but | |
732 | * their values are not used | |
733 | */ | |
734 | ulong img_data, img_len; | |
735 | void *buf; | |
736 | int loadables_index; | |
737 | int conf_noffset; | |
738 | int fit_img_result; | |
739 | const char *uname; | |
3d2a47f1 | 740 | u8 img_type; |
41506ff5 SG |
741 | |
742 | /* Check to see if the images struct has a FIT configuration */ | |
743 | if (!genimg_has_config(images)) { | |
744 | debug("## FIT configuration was not specified\n"); | |
745 | return 0; | |
746 | } | |
747 | ||
748 | /* | |
749 | * Obtain the os FIT header from the images struct | |
750 | */ | |
751 | tmp_img_addr = map_to_sysmem(images->fit_hdr_os); | |
752 | buf = map_sysmem(tmp_img_addr, 0); | |
753 | /* | |
754 | * Check image type. For FIT images get FIT node | |
755 | * and attempt to locate a generic binary. | |
756 | */ | |
757 | switch (genimg_get_format(buf)) { | |
758 | case IMAGE_FORMAT_FIT: | |
759 | conf_noffset = fit_conf_get_node(buf, images->fit_uname_cfg); | |
760 | ||
761 | for (loadables_index = 0; | |
762 | uname = fdt_stringlist_get(buf, conf_noffset, | |
3d2a47f1 SG |
763 | FIT_LOADABLE_PROP, |
764 | loadables_index, NULL), uname; | |
765 | loadables_index++) { | |
766 | fit_img_result = fit_image_load(images, tmp_img_addr, | |
767 | &uname, | |
768 | &images->fit_uname_cfg, | |
96456285 SG |
769 | IH_ARCH_DEFAULT, |
770 | IH_TYPE_LOADABLE, | |
3d2a47f1 SG |
771 | BOOTSTAGE_ID_FIT_LOADABLE_START, |
772 | FIT_LOAD_OPTIONAL_NON_ZERO, | |
773 | &img_data, &img_len); | |
41506ff5 SG |
774 | if (fit_img_result < 0) { |
775 | /* Something went wrong! */ | |
776 | return fit_img_result; | |
777 | } | |
778 | ||
779 | fit_img_result = fit_image_get_node(buf, uname); | |
780 | if (fit_img_result < 0) { | |
781 | /* Something went wrong! */ | |
782 | return fit_img_result; | |
783 | } | |
784 | fit_img_result = fit_image_get_type(buf, | |
785 | fit_img_result, | |
786 | &img_type); | |
787 | if (fit_img_result < 0) { | |
788 | /* Something went wrong! */ | |
789 | return fit_img_result; | |
790 | } | |
791 | ||
792 | fit_loadable_process(img_type, img_data, img_len); | |
793 | } | |
794 | break; | |
795 | default: | |
796 | printf("The given image format is not supported (corrupt?)\n"); | |
797 | return 1; | |
798 | } | |
799 | ||
800 | return 0; | |
801 | } | |
41506ff5 | 802 | |
41506ff5 SG |
803 | /** |
804 | * boot_get_cmdline - allocate and initialize kernel cmdline | |
41506ff5 SG |
805 | * @cmd_start: pointer to a ulong variable, will hold cmdline start |
806 | * @cmd_end: pointer to a ulong variable, will hold cmdline end | |
807 | * | |
9c2e9128 | 808 | * This allocates space for kernel command line below |
41506ff5 SG |
809 | * BOOTMAPSZ + env_get_bootm_low() address. If "bootargs" U-Boot environment |
810 | * variable is present its contents is copied to allocated kernel | |
811 | * command line. | |
812 | * | |
813 | * returns: | |
814 | * 0 - success | |
815 | * -1 - failure | |
816 | */ | |
ed17a33f | 817 | int boot_get_cmdline(ulong *cmd_start, ulong *cmd_end) |
41506ff5 | 818 | { |
9c2e9128 | 819 | int barg; |
41506ff5 SG |
820 | char *cmdline; |
821 | char *s; | |
822 | ||
9c2e9128 SG |
823 | /* |
824 | * Help the compiler detect that this function is only called when | |
825 | * CONFIG_SYS_BOOT_GET_CMDLINE is enabled | |
826 | */ | |
827 | if (!IS_ENABLED(CONFIG_SYS_BOOT_GET_CMDLINE)) | |
828 | return 0; | |
829 | ||
830 | barg = IF_ENABLED_INT(CONFIG_SYS_BOOT_GET_CMDLINE, CONFIG_SYS_BARGSIZE); | |
ed17a33f | 831 | cmdline = (char *)(ulong)lmb_alloc_base(barg, 0xf, |
41506ff5 | 832 | env_get_bootm_mapsize() + env_get_bootm_low()); |
3d2a47f1 | 833 | if (!cmdline) |
41506ff5 SG |
834 | return -1; |
835 | ||
836 | s = env_get("bootargs"); | |
837 | if (!s) | |
838 | s = ""; | |
839 | ||
840 | strcpy(cmdline, s); | |
841 | ||
3d2a47f1 | 842 | *cmd_start = (ulong)cmdline; |
41506ff5 SG |
843 | *cmd_end = *cmd_start + strlen(cmdline); |
844 | ||
845 | debug("## cmdline at 0x%08lx ... 0x%08lx\n", *cmd_start, *cmd_end); | |
846 | ||
847 | return 0; | |
848 | } | |
41506ff5 | 849 | |
41506ff5 SG |
850 | /** |
851 | * boot_get_kbd - allocate and initialize kernel copy of board info | |
41506ff5 SG |
852 | * @kbd: double pointer to board info data |
853 | * | |
854 | * boot_get_kbd() allocates space for kernel copy of board info data below | |
855 | * BOOTMAPSZ + env_get_bootm_low() address and kernel board info is initialized | |
856 | * with the current u-boot board info data. | |
857 | * | |
858 | * returns: | |
859 | * 0 - success | |
860 | * -1 - failure | |
861 | */ | |
ed17a33f | 862 | int boot_get_kbd(struct bd_info **kbd) |
41506ff5 | 863 | { |
ed17a33f | 864 | *kbd = (struct bd_info *)(ulong)lmb_alloc_base(sizeof(struct bd_info), |
41506ff5 | 865 | 0xf, |
3d2a47f1 SG |
866 | env_get_bootm_mapsize() + |
867 | env_get_bootm_low()); | |
868 | if (!*kbd) | |
41506ff5 SG |
869 | return -1; |
870 | ||
3d2a47f1 | 871 | **kbd = *gd->bd; |
41506ff5 SG |
872 | |
873 | debug("## kernel board info at 0x%08lx\n", (ulong)*kbd); | |
874 | ||
9c2e9128 | 875 | if (_DEBUG && IS_ENABLED(CONFIG_CMD_BDI)) |
4ed37abc | 876 | do_bdinfo(NULL, 0, 0, NULL); |
41506ff5 SG |
877 | |
878 | return 0; | |
879 | } | |
41506ff5 | 880 | |
d9d7c20b | 881 | int image_setup_linux(struct bootm_headers *images) |
41506ff5 SG |
882 | { |
883 | ulong of_size = images->ft_len; | |
884 | char **of_flat_tree = &images->ft_addr; | |
41506ff5 SG |
885 | int ret; |
886 | ||
9c2e9128 | 887 | /* This function cannot be called without lmb support */ |
6942bdb4 | 888 | if (!CONFIG_IS_ENABLED(LMB)) |
9c2e9128 | 889 | return -EFAULT; |
0c303f9a | 890 | if (CONFIG_IS_ENABLED(OF_LIBFDT)) |
ed17a33f | 891 | boot_fdt_add_mem_rsv_regions(*of_flat_tree); |
41506ff5 | 892 | |
806d1ff3 | 893 | if (IS_ENABLED(CONFIG_SYS_BOOT_GET_CMDLINE)) { |
ed17a33f | 894 | ret = boot_get_cmdline(&images->cmdline_start, |
3d2a47f1 | 895 | &images->cmdline_end); |
41506ff5 SG |
896 | if (ret) { |
897 | puts("ERROR with allocation of cmdline\n"); | |
898 | return ret; | |
899 | } | |
900 | } | |
901 | ||
0c303f9a | 902 | if (CONFIG_IS_ENABLED(OF_LIBFDT)) { |
ed17a33f | 903 | ret = boot_relocate_fdt(of_flat_tree, &of_size); |
41506ff5 SG |
904 | if (ret) |
905 | return ret; | |
906 | } | |
907 | ||
0c303f9a | 908 | if (CONFIG_IS_ENABLED(OF_LIBFDT) && of_size) { |
ed17a33f | 909 | ret = image_setup_libfdt(images, *of_flat_tree, true); |
41506ff5 SG |
910 | if (ret) |
911 | return ret; | |
912 | } | |
913 | ||
914 | return 0; | |
915 | } | |
5d3248a6 SG |
916 | |
917 | void genimg_print_size(uint32_t size) | |
918 | { | |
919 | printf("%d Bytes = ", size); | |
920 | print_size(size, "\n"); | |
921 | } | |
922 | ||
923 | void genimg_print_time(time_t timestamp) | |
924 | { | |
925 | struct rtc_time tm; | |
926 | ||
927 | rtc_to_tm(timestamp, &tm); | |
928 | printf("%4d-%02d-%02d %2d:%02d:%02d UTC\n", | |
929 | tm.tm_year, tm.tm_mon, tm.tm_mday, | |
930 | tm.tm_hour, tm.tm_min, tm.tm_sec); | |
931 | } | |
30f3333d SG |
932 | |
933 | /** | |
934 | * get_default_image() - Return default property from /images | |
935 | * | |
936 | * Return: Pointer to value of default property (or NULL) | |
937 | */ | |
938 | static const char *get_default_image(const void *fit) | |
939 | { | |
940 | int images_noffset; | |
941 | ||
942 | images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH); | |
943 | if (images_noffset < 0) | |
944 | return NULL; | |
945 | ||
946 | return fdt_getprop(fit, images_noffset, FIT_DEFAULT_PROP, NULL); | |
947 | } | |
948 | ||
949 | int image_locate_script(void *buf, int size, const char *fit_uname, | |
950 | const char *confname, char **datap, uint *lenp) | |
951 | { | |
952 | const struct legacy_img_hdr *hdr; | |
953 | const void *fit_data; | |
954 | const void *fit_hdr; | |
955 | size_t fit_len; | |
956 | int noffset; | |
957 | int verify; | |
958 | ulong len; | |
959 | u32 *data; | |
960 | ||
961 | verify = env_get_yesno("verify"); | |
962 | ||
963 | switch (genimg_get_format(buf)) { | |
964 | case IMAGE_FORMAT_LEGACY: | |
771cb4d5 MV |
965 | if (!IS_ENABLED(CONFIG_LEGACY_IMAGE_FORMAT)) { |
966 | goto exit_image_format; | |
967 | } else { | |
30f3333d SG |
968 | hdr = buf; |
969 | ||
970 | if (!image_check_magic(hdr)) { | |
971 | puts("Bad magic number\n"); | |
972 | return 1; | |
973 | } | |
974 | ||
975 | if (!image_check_hcrc(hdr)) { | |
976 | puts("Bad header crc\n"); | |
977 | return 1; | |
978 | } | |
979 | ||
980 | if (verify) { | |
981 | if (!image_check_dcrc(hdr)) { | |
982 | puts("Bad data crc\n"); | |
983 | return 1; | |
984 | } | |
985 | } | |
986 | ||
987 | if (!image_check_type(hdr, IH_TYPE_SCRIPT)) { | |
988 | puts("Bad image type\n"); | |
989 | return 1; | |
990 | } | |
991 | ||
992 | /* get length of script */ | |
993 | data = (u32 *)image_get_data(hdr); | |
994 | ||
995 | len = uimage_to_cpu(*data); | |
996 | if (!len) { | |
997 | puts("Empty Script\n"); | |
998 | return 1; | |
999 | } | |
1000 | ||
1001 | /* | |
1002 | * scripts are just multi-image files with one | |
1003 | * component, so seek past the zero-terminated sequence | |
1004 | * of image lengths to get to the actual image data | |
1005 | */ | |
1006 | while (*data++); | |
1007 | } | |
1008 | break; | |
1009 | case IMAGE_FORMAT_FIT: | |
771cb4d5 MV |
1010 | if (!IS_ENABLED(CONFIG_FIT)) { |
1011 | goto exit_image_format; | |
1012 | } else { | |
30f3333d SG |
1013 | fit_hdr = buf; |
1014 | if (fit_check_format(fit_hdr, IMAGE_SIZE_INVAL)) { | |
1015 | puts("Bad FIT image format\n"); | |
1016 | return 1; | |
1017 | } | |
1018 | ||
1019 | if (!fit_uname) { | |
1020 | /* If confname is empty, use the default */ | |
1021 | if (confname && *confname) | |
1022 | noffset = fit_conf_get_node(fit_hdr, confname); | |
1023 | else | |
1024 | noffset = fit_conf_get_node(fit_hdr, NULL); | |
1025 | if (noffset < 0) { | |
1026 | if (!confname) | |
1027 | goto fallback; | |
1028 | printf("Could not find config %s\n", confname); | |
1029 | return 1; | |
1030 | } | |
1031 | ||
1032 | if (verify && fit_config_verify(fit_hdr, noffset)) | |
1033 | return 1; | |
1034 | ||
1035 | noffset = fit_conf_get_prop_node(fit_hdr, | |
1036 | noffset, | |
1037 | FIT_SCRIPT_PROP, | |
1038 | IH_PHASE_NONE); | |
1039 | if (noffset < 0) { | |
1040 | if (!confname) | |
1041 | goto fallback; | |
1042 | printf("Could not find script in %s\n", confname); | |
1043 | return 1; | |
1044 | } | |
1045 | } else { | |
1046 | fallback: | |
1047 | if (!fit_uname || !*fit_uname) | |
1048 | fit_uname = get_default_image(fit_hdr); | |
1049 | if (!fit_uname) { | |
1050 | puts("No FIT subimage unit name\n"); | |
1051 | return 1; | |
1052 | } | |
1053 | ||
1054 | /* get script component image node offset */ | |
1055 | noffset = fit_image_get_node(fit_hdr, fit_uname); | |
1056 | if (noffset < 0) { | |
1057 | printf("Can't find '%s' FIT subimage\n", | |
1058 | fit_uname); | |
1059 | return 1; | |
1060 | } | |
1061 | } | |
1062 | ||
1063 | if (!fit_image_check_type(fit_hdr, noffset, | |
1064 | IH_TYPE_SCRIPT)) { | |
1065 | puts("Not a image image\n"); | |
1066 | return 1; | |
1067 | } | |
1068 | ||
1069 | /* verify integrity */ | |
1070 | if (verify && !fit_image_verify(fit_hdr, noffset)) { | |
1071 | puts("Bad Data Hash\n"); | |
1072 | return 1; | |
1073 | } | |
1074 | ||
1075 | /* get script subimage data address and length */ | |
e45bba56 TW |
1076 | if (fit_image_get_data_and_size(fit_hdr, noffset, |
1077 | &fit_data, &fit_len)) { | |
30f3333d SG |
1078 | puts("Could not find script subimage data\n"); |
1079 | return 1; | |
1080 | } | |
1081 | ||
1082 | data = (u32 *)fit_data; | |
1083 | len = (ulong)fit_len; | |
1084 | } | |
1085 | break; | |
1086 | default: | |
771cb4d5 | 1087 | goto exit_image_format; |
30f3333d SG |
1088 | } |
1089 | ||
1090 | *datap = (char *)data; | |
1091 | *lenp = len; | |
1092 | ||
1093 | return 0; | |
771cb4d5 MV |
1094 | |
1095 | exit_image_format: | |
1096 | puts("Wrong image format for \"source\" command\n"); | |
1097 | return -EPERM; | |
30f3333d | 1098 | } |