1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2008 Semihalf
5 * (C) Copyright 2000-2006
6 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
11 #include <bootstage.h>
17 #include <asm/cache.h>
18 #include <u-boot/crc.h>
21 #ifdef CONFIG_SHOW_BOOT_PROGRESS
22 #include <status_led.h>
32 #if IMAGE_ENABLE_FIT || IMAGE_ENABLE_OF_LIBFDT
33 #include <linux/libfdt.h>
34 #include <fdt_support.h>
39 #include <u-boot/md5.h>
40 #include <u-boot/sha1.h>
41 #include <linux/errno.h>
45 #include <linux/lzo.h>
46 #include <lzma/LzmaTypes.h>
47 #include <lzma/LzmaDec.h>
48 #include <lzma/LzmaTools.h>
51 extern int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc,
55 DECLARE_GLOBAL_DATA_PTR;
57 #if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
58 static const image_header_t *image_get_ramdisk(ulong rd_addr, uint8_t arch,
63 #include <u-boot/md5.h>
67 #ifndef __maybe_unused
68 # define __maybe_unused /* unimplemented */
70 #endif /* !USE_HOSTCC*/
72 #include <u-boot/crc.h>
75 #ifndef CONFIG_SYS_BARGSIZE
76 #define CONFIG_SYS_BARGSIZE 512
79 static const table_entry_t uimage_arch[] = {
80 { IH_ARCH_INVALID, "invalid", "Invalid ARCH", },
81 { IH_ARCH_ALPHA, "alpha", "Alpha", },
82 { IH_ARCH_ARM, "arm", "ARM", },
83 { IH_ARCH_I386, "x86", "Intel x86", },
84 { IH_ARCH_IA64, "ia64", "IA64", },
85 { IH_ARCH_M68K, "m68k", "M68K", },
86 { IH_ARCH_MICROBLAZE, "microblaze", "MicroBlaze", },
87 { IH_ARCH_MIPS, "mips", "MIPS", },
88 { IH_ARCH_MIPS64, "mips64", "MIPS 64 Bit", },
89 { IH_ARCH_NIOS2, "nios2", "NIOS II", },
90 { IH_ARCH_PPC, "powerpc", "PowerPC", },
91 { IH_ARCH_PPC, "ppc", "PowerPC", },
92 { IH_ARCH_S390, "s390", "IBM S390", },
93 { IH_ARCH_SH, "sh", "SuperH", },
94 { IH_ARCH_SPARC, "sparc", "SPARC", },
95 { IH_ARCH_SPARC64, "sparc64", "SPARC 64 Bit", },
96 { IH_ARCH_BLACKFIN, "blackfin", "Blackfin", },
97 { IH_ARCH_AVR32, "avr32", "AVR32", },
98 { IH_ARCH_NDS32, "nds32", "NDS32", },
99 { IH_ARCH_OPENRISC, "or1k", "OpenRISC 1000",},
100 { IH_ARCH_SANDBOX, "sandbox", "Sandbox", },
101 { IH_ARCH_ARM64, "arm64", "AArch64", },
102 { IH_ARCH_ARC, "arc", "ARC", },
103 { IH_ARCH_X86_64, "x86_64", "AMD x86_64", },
104 { IH_ARCH_XTENSA, "xtensa", "Xtensa", },
105 { IH_ARCH_RISCV, "riscv", "RISC-V", },
109 static const table_entry_t uimage_os[] = {
110 { IH_OS_INVALID, "invalid", "Invalid OS", },
111 { IH_OS_ARM_TRUSTED_FIRMWARE, "arm-trusted-firmware", "ARM Trusted Firmware" },
112 { IH_OS_LINUX, "linux", "Linux", },
113 #if defined(CONFIG_LYNXKDI) || defined(USE_HOSTCC)
114 { IH_OS_LYNXOS, "lynxos", "LynxOS", },
116 { IH_OS_NETBSD, "netbsd", "NetBSD", },
117 { IH_OS_OSE, "ose", "Enea OSE", },
118 { IH_OS_PLAN9, "plan9", "Plan 9", },
119 { IH_OS_RTEMS, "rtems", "RTEMS", },
120 { IH_OS_TEE, "tee", "Trusted Execution Environment" },
121 { IH_OS_U_BOOT, "u-boot", "U-Boot", },
122 { IH_OS_VXWORKS, "vxworks", "VxWorks", },
123 #if defined(CONFIG_CMD_ELF) || defined(USE_HOSTCC)
124 { IH_OS_QNX, "qnx", "QNX", },
126 #if defined(CONFIG_INTEGRITY) || defined(USE_HOSTCC)
127 { IH_OS_INTEGRITY,"integrity", "INTEGRITY", },
130 { IH_OS_4_4BSD, "4_4bsd", "4_4BSD", },
131 { IH_OS_DELL, "dell", "Dell", },
132 { IH_OS_ESIX, "esix", "Esix", },
133 { IH_OS_FREEBSD, "freebsd", "FreeBSD", },
134 { IH_OS_IRIX, "irix", "Irix", },
135 { IH_OS_NCR, "ncr", "NCR", },
136 { IH_OS_OPENBSD, "openbsd", "OpenBSD", },
137 { IH_OS_PSOS, "psos", "pSOS", },
138 { IH_OS_SCO, "sco", "SCO", },
139 { IH_OS_SOLARIS, "solaris", "Solaris", },
140 { IH_OS_SVR4, "svr4", "SVR4", },
142 #if defined(CONFIG_BOOTM_OPENRTOS) || defined(USE_HOSTCC)
143 { IH_OS_OPENRTOS, "openrtos", "OpenRTOS", },
145 { IH_OS_OPENSBI, "opensbi", "RISC-V OpenSBI", },
146 { IH_OS_EFI, "efi", "EFI Firmware" },
151 static const table_entry_t uimage_type[] = {
152 { IH_TYPE_AISIMAGE, "aisimage", "Davinci AIS image",},
153 { IH_TYPE_FILESYSTEM, "filesystem", "Filesystem Image", },
154 { IH_TYPE_FIRMWARE, "firmware", "Firmware", },
155 { IH_TYPE_FLATDT, "flat_dt", "Flat Device Tree", },
156 { IH_TYPE_GPIMAGE, "gpimage", "TI Keystone SPL Image",},
157 { IH_TYPE_KERNEL, "kernel", "Kernel Image", },
158 { IH_TYPE_KERNEL_NOLOAD, "kernel_noload", "Kernel Image (no loading done)", },
159 { IH_TYPE_KWBIMAGE, "kwbimage", "Kirkwood Boot Image",},
160 { IH_TYPE_IMXIMAGE, "imximage", "Freescale i.MX Boot Image",},
161 { IH_TYPE_IMX8IMAGE, "imx8image", "NXP i.MX8 Boot Image",},
162 { IH_TYPE_IMX8MIMAGE, "imx8mimage", "NXP i.MX8M Boot Image",},
163 { IH_TYPE_INVALID, "invalid", "Invalid Image", },
164 { IH_TYPE_MULTI, "multi", "Multi-File Image", },
165 { IH_TYPE_OMAPIMAGE, "omapimage", "TI OMAP SPL With GP CH",},
166 { IH_TYPE_PBLIMAGE, "pblimage", "Freescale PBL Boot Image",},
167 { IH_TYPE_RAMDISK, "ramdisk", "RAMDisk Image", },
168 { IH_TYPE_SCRIPT, "script", "Script", },
169 { IH_TYPE_SOCFPGAIMAGE, "socfpgaimage", "Altera SoCFPGA CV/AV preloader",},
170 { IH_TYPE_SOCFPGAIMAGE_V1, "socfpgaimage_v1", "Altera SoCFPGA A10 preloader",},
171 { IH_TYPE_STANDALONE, "standalone", "Standalone Program", },
172 { IH_TYPE_UBLIMAGE, "ublimage", "Davinci UBL image",},
173 { IH_TYPE_MXSIMAGE, "mxsimage", "Freescale MXS Boot Image",},
174 { IH_TYPE_ATMELIMAGE, "atmelimage", "ATMEL ROM-Boot Image",},
175 { IH_TYPE_X86_SETUP, "x86_setup", "x86 setup.bin", },
176 { IH_TYPE_LPC32XXIMAGE, "lpc32xximage", "LPC32XX Boot Image", },
177 { IH_TYPE_RKIMAGE, "rkimage", "Rockchip Boot Image" },
178 { IH_TYPE_RKSD, "rksd", "Rockchip SD Boot Image" },
179 { IH_TYPE_RKSPI, "rkspi", "Rockchip SPI Boot Image" },
180 { IH_TYPE_VYBRIDIMAGE, "vybridimage", "Vybrid Boot Image", },
181 { IH_TYPE_ZYNQIMAGE, "zynqimage", "Xilinx Zynq Boot Image" },
182 { IH_TYPE_ZYNQMPIMAGE, "zynqmpimage", "Xilinx ZynqMP Boot Image" },
183 { IH_TYPE_ZYNQMPBIF, "zynqmpbif", "Xilinx ZynqMP Boot Image (bif)" },
184 { IH_TYPE_FPGA, "fpga", "FPGA Image" },
185 { IH_TYPE_TEE, "tee", "Trusted Execution Environment Image",},
186 { IH_TYPE_FIRMWARE_IVT, "firmware_ivt", "Firmware with HABv4 IVT" },
187 { IH_TYPE_PMMC, "pmmc", "TI Power Management Micro-Controller Firmware",},
188 { IH_TYPE_STM32IMAGE, "stm32image", "STMicroelectronics STM32 Image" },
189 { IH_TYPE_MTKIMAGE, "mtk_image", "MediaTek BootROM loadable Image" },
190 { IH_TYPE_COPRO, "copro", "Coprocessor Image"},
194 static const table_entry_t uimage_comp[] = {
195 { IH_COMP_NONE, "none", "uncompressed", },
196 { IH_COMP_BZIP2, "bzip2", "bzip2 compressed", },
197 { IH_COMP_GZIP, "gzip", "gzip compressed", },
198 { IH_COMP_LZMA, "lzma", "lzma compressed", },
199 { IH_COMP_LZO, "lzo", "lzo compressed", },
200 { IH_COMP_LZ4, "lz4", "lz4 compressed", },
207 const table_entry_t *table;
210 static const struct comp_magic_map image_comp[] = {
211 { IH_COMP_BZIP2, "bzip2", {0x42, 0x5a},},
212 { IH_COMP_GZIP, "gzip", {0x1f, 0x8b},},
213 { IH_COMP_LZMA, "lzma", {0x5d, 0x00},},
214 { IH_COMP_LZO, "lzo", {0x89, 0x4c},},
215 { IH_COMP_NONE, "none", {}, },
218 static const struct table_info table_info[IH_COUNT] = {
219 { "architecture", IH_ARCH_COUNT, uimage_arch },
220 { "compression", IH_COMP_COUNT, uimage_comp },
221 { "operating system", IH_OS_COUNT, uimage_os },
222 { "image type", IH_TYPE_COUNT, uimage_type },
225 /*****************************************************************************/
226 /* Legacy format routines */
227 /*****************************************************************************/
228 int image_check_hcrc(const image_header_t *hdr)
231 ulong len = image_get_header_size();
232 image_header_t header;
234 /* Copy header so we can blank CRC field for re-calculation */
235 memmove(&header, (char *)hdr, image_get_header_size());
236 image_set_hcrc(&header, 0);
238 hcrc = crc32(0, (unsigned char *)&header, len);
240 return (hcrc == image_get_hcrc(hdr));
243 int image_check_dcrc(const image_header_t *hdr)
245 ulong data = image_get_data(hdr);
246 ulong len = image_get_data_size(hdr);
247 ulong dcrc = crc32_wd(0, (unsigned char *)data, len, CHUNKSZ_CRC32);
249 return (dcrc == image_get_dcrc(hdr));
253 * image_multi_count - get component (sub-image) count
254 * @hdr: pointer to the header of the multi component image
256 * image_multi_count() returns number of components in a multi
259 * Note: no checking of the image type is done, caller must pass
260 * a valid multi component image.
263 * number of components
265 ulong image_multi_count(const image_header_t *hdr)
270 /* get start of the image payload, which in case of multi
271 * component images that points to a table of component sizes */
272 size = (uint32_t *)image_get_data(hdr);
274 /* count non empty slots */
275 for (i = 0; size[i]; ++i)
282 * image_multi_getimg - get component data address and size
283 * @hdr: pointer to the header of the multi component image
284 * @idx: index of the requested component
285 * @data: pointer to a ulong variable, will hold component data address
286 * @len: pointer to a ulong variable, will hold component size
288 * image_multi_getimg() returns size and data address for the requested
289 * component in a multi component image.
291 * Note: no checking of the image type is done, caller must pass
292 * a valid multi component image.
295 * data address and size of the component, if idx is valid
296 * 0 in data and len, if idx is out of range
298 void image_multi_getimg(const image_header_t *hdr, ulong idx,
299 ulong *data, ulong *len)
303 ulong offset, count, img_data;
305 /* get number of component */
306 count = image_multi_count(hdr);
308 /* get start of the image payload, which in case of multi
309 * component images that points to a table of component sizes */
310 size = (uint32_t *)image_get_data(hdr);
312 /* get address of the proper component data start, which means
313 * skipping sizes table (add 1 for last, null entry) */
314 img_data = image_get_data(hdr) + (count + 1) * sizeof(uint32_t);
317 *len = uimage_to_cpu(size[idx]);
320 /* go over all indices preceding requested component idx */
321 for (i = 0; i < idx; i++) {
322 /* add up i-th component size, rounding up to 4 bytes */
323 offset += (uimage_to_cpu(size[i]) + 3) & ~3 ;
326 /* calculate idx-th component data address */
327 *data = img_data + offset;
334 static void image_print_type(const image_header_t *hdr)
336 const char __maybe_unused *os, *arch, *type, *comp;
338 os = genimg_get_os_name(image_get_os(hdr));
339 arch = genimg_get_arch_name(image_get_arch(hdr));
340 type = genimg_get_type_name(image_get_type(hdr));
341 comp = genimg_get_comp_name(image_get_comp(hdr));
343 printf("%s %s %s (%s)\n", arch, os, type, comp);
347 * image_print_contents - prints out the contents of the legacy format image
348 * @ptr: pointer to the legacy format image header
349 * @p: pointer to prefix string
351 * image_print_contents() formats a multi line legacy image contents description.
352 * The routine prints out all header fields followed by the size/offset data
353 * for MULTI/SCRIPT images.
356 * no returned results
358 void image_print_contents(const void *ptr)
360 const image_header_t *hdr = (const image_header_t *)ptr;
361 const char __maybe_unused *p;
363 p = IMAGE_INDENT_STRING;
364 printf("%sImage Name: %.*s\n", p, IH_NMLEN, image_get_name(hdr));
365 if (IMAGE_ENABLE_TIMESTAMP) {
366 printf("%sCreated: ", p);
367 genimg_print_time((time_t)image_get_time(hdr));
369 printf("%sImage Type: ", p);
370 image_print_type(hdr);
371 printf("%sData Size: ", p);
372 genimg_print_size(image_get_data_size(hdr));
373 printf("%sLoad Address: %08x\n", p, image_get_load(hdr));
374 printf("%sEntry Point: %08x\n", p, image_get_ep(hdr));
376 if (image_check_type(hdr, IH_TYPE_MULTI) ||
377 image_check_type(hdr, IH_TYPE_SCRIPT)) {
380 ulong count = image_multi_count(hdr);
382 printf("%sContents:\n", p);
383 for (i = 0; i < count; i++) {
384 image_multi_getimg(hdr, i, &data, &len);
386 printf("%s Image %d: ", p, i);
387 genimg_print_size(len);
389 if (image_check_type(hdr, IH_TYPE_SCRIPT) && i > 0) {
391 * the user may need to know offsets
392 * if planning to do something with
395 printf("%s Offset = 0x%08lx\n", p, data);
398 } else if (image_check_type(hdr, IH_TYPE_FIRMWARE_IVT)) {
399 printf("HAB Blocks: 0x%08x 0x0000 0x%08x\n",
400 image_get_load(hdr) - image_get_header_size(),
401 (int)(image_get_size(hdr) + image_get_header_size()
402 + sizeof(flash_header_v2_t) - 0x2060));
407 * print_decomp_msg() - Print a suitable decompression/loading message
409 * @type: OS type (IH_OS_...)
410 * @comp_type: Compression type being used (IH_COMP_...)
411 * @is_xip: true if the load address matches the image start
413 static void print_decomp_msg(int comp_type, int type, bool is_xip)
415 const char *name = genimg_get_type_name(type);
417 if (comp_type == IH_COMP_NONE)
418 printf(" %s %s\n", is_xip ? "XIP" : "Loading", name);
420 printf(" Uncompressing %s\n", name);
423 int image_decomp_type(const unsigned char *buf, ulong len)
425 const struct comp_magic_map *cmagic = image_comp;
430 for (; cmagic->comp_id > 0; cmagic++) {
431 if (!memcmp(buf, cmagic->magic, 2))
435 return cmagic->comp_id;
438 int image_decomp(int comp, ulong load, ulong image_start, int type,
439 void *load_buf, void *image_buf, ulong image_len,
440 uint unc_len, ulong *load_end)
445 print_decomp_msg(comp, type, load == image_start);
448 * Load the image to the right place, decompressing if needed. After
449 * this, image_len will be set to the number of uncompressed bytes
450 * loaded, ret will be non-zero on error.
454 if (load == image_start)
456 if (image_len <= unc_len)
457 memmove_wd(load_buf, image_buf, image_len, CHUNKSZ);
463 ret = gunzip(load_buf, unc_len, image_buf, &image_len);
466 #endif /* CONFIG_GZIP */
468 case IH_COMP_BZIP2: {
472 * If we've got less than 4 MB of malloc() space,
473 * use slower decompression algorithm which requires
474 * at most 2300 KB of memory.
476 ret = BZ2_bzBuffToBuffDecompress(load_buf, &size,
477 image_buf, image_len,
478 CONFIG_SYS_MALLOC_LEN < (4096 * 1024), 0);
482 #endif /* CONFIG_BZIP2 */
485 SizeT lzma_len = unc_len;
487 ret = lzmaBuffToBuffDecompress(load_buf, &lzma_len,
488 image_buf, image_len);
489 image_len = lzma_len;
492 #endif /* CONFIG_LZMA */
495 size_t size = unc_len;
497 ret = lzop_decompress(image_buf, image_len, load_buf, &size);
501 #endif /* CONFIG_LZO */
504 size_t size = unc_len;
506 ret = ulz4fn(image_buf, image_len, load_buf, &size);
510 #endif /* CONFIG_LZ4 */
512 printf("Unimplemented compression type %d\n", comp);
516 *load_end = load + image_len;
523 #if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
525 * image_get_ramdisk - get and verify ramdisk image
526 * @rd_addr: ramdisk image start address
527 * @arch: expected ramdisk architecture
528 * @verify: checksum verification flag
530 * image_get_ramdisk() returns a pointer to the verified ramdisk image
531 * header. Routine receives image start address and expected architecture
532 * flag. Verification done covers data and header integrity and os/type/arch
536 * pointer to a ramdisk image header, if image was found and valid
537 * otherwise, return NULL
539 static const image_header_t *image_get_ramdisk(ulong rd_addr, uint8_t arch,
542 const image_header_t *rd_hdr = (const image_header_t *)rd_addr;
544 if (!image_check_magic(rd_hdr)) {
545 puts("Bad Magic Number\n");
546 bootstage_error(BOOTSTAGE_ID_RD_MAGIC);
550 if (!image_check_hcrc(rd_hdr)) {
551 puts("Bad Header Checksum\n");
552 bootstage_error(BOOTSTAGE_ID_RD_HDR_CHECKSUM);
556 bootstage_mark(BOOTSTAGE_ID_RD_MAGIC);
557 image_print_contents(rd_hdr);
560 puts(" Verifying Checksum ... ");
561 if (!image_check_dcrc(rd_hdr)) {
562 puts("Bad Data CRC\n");
563 bootstage_error(BOOTSTAGE_ID_RD_CHECKSUM);
569 bootstage_mark(BOOTSTAGE_ID_RD_HDR_CHECKSUM);
571 if (!image_check_os(rd_hdr, IH_OS_LINUX) ||
572 !image_check_arch(rd_hdr, arch) ||
573 !image_check_type(rd_hdr, IH_TYPE_RAMDISK)) {
574 printf("No Linux %s Ramdisk Image\n",
575 genimg_get_arch_name(arch));
576 bootstage_error(BOOTSTAGE_ID_RAMDISK);
583 #endif /* !USE_HOSTCC */
585 /*****************************************************************************/
586 /* Shared dual-format routines */
587 /*****************************************************************************/
589 ulong image_load_addr = CONFIG_SYS_LOAD_ADDR; /* Default Load Address */
590 ulong image_save_addr; /* Default Save Address */
591 ulong image_save_size; /* Default Save Size (in bytes) */
593 static int on_loadaddr(const char *name, const char *value, enum env_op op,
598 case env_op_overwrite:
599 image_load_addr = simple_strtoul(value, NULL, 16);
607 U_BOOT_ENV_CALLBACK(loadaddr, on_loadaddr);
609 ulong env_get_bootm_low(void)
611 char *s = env_get("bootm_low");
613 ulong tmp = simple_strtoul(s, NULL, 16);
617 #if defined(CONFIG_SYS_SDRAM_BASE)
618 return CONFIG_SYS_SDRAM_BASE;
619 #elif defined(CONFIG_ARM) || defined(CONFIG_MICROBLAZE)
620 return gd->bd->bi_dram[0].start;
626 phys_size_t env_get_bootm_size(void)
628 phys_size_t tmp, size;
630 char *s = env_get("bootm_size");
632 tmp = (phys_size_t)simple_strtoull(s, NULL, 16);
636 #if (defined(CONFIG_ARM) || defined(CONFIG_MICROBLAZE)) && \
637 defined(CONFIG_NR_DRAM_BANKS)
638 start = gd->bd->bi_dram[0].start;
639 size = gd->bd->bi_dram[0].size;
641 start = gd->bd->bi_memstart;
642 size = gd->bd->bi_memsize;
645 s = env_get("bootm_low");
647 tmp = (phys_size_t)simple_strtoull(s, NULL, 16);
651 return size - (tmp - start);
654 phys_size_t env_get_bootm_mapsize(void)
657 char *s = env_get("bootm_mapsize");
659 tmp = (phys_size_t)simple_strtoull(s, NULL, 16);
663 #if defined(CONFIG_SYS_BOOTMAPSZ)
664 return CONFIG_SYS_BOOTMAPSZ;
666 return env_get_bootm_size();
670 void memmove_wd(void *to, void *from, size_t len, ulong chunksz)
675 #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
681 size_t tail = (len > chunksz) ? chunksz : len;
687 memmove(to, from, tail);
694 #else /* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
695 memmove(to, from, len);
696 #endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
698 #else /* USE_HOSTCC */
699 void memmove_wd(void *to, void *from, size_t len, ulong chunksz)
701 memmove(to, from, len);
703 #endif /* !USE_HOSTCC */
705 void genimg_print_size(uint32_t size)
708 printf("%d Bytes = ", size);
709 print_size(size, "\n");
711 printf("%d Bytes = %.2f KiB = %.2f MiB\n",
712 size, (double)size / 1.024e3,
713 (double)size / 1.048576e6);
717 #if IMAGE_ENABLE_TIMESTAMP
718 void genimg_print_time(time_t timestamp)
723 rtc_to_tm(timestamp, &tm);
724 printf("%4d-%02d-%02d %2d:%02d:%02d UTC\n",
725 tm.tm_year, tm.tm_mon, tm.tm_mday,
726 tm.tm_hour, tm.tm_min, tm.tm_sec);
728 printf("%s", ctime(×tamp));
733 const table_entry_t *get_table_entry(const table_entry_t *table, int id)
735 for (; table->id >= 0; ++table) {
742 static const char *unknown_msg(enum ih_category category)
744 static const char unknown_str[] = "Unknown ";
747 strcpy(msg, unknown_str);
748 strncat(msg, table_info[category].desc,
749 sizeof(msg) - sizeof(unknown_str));
755 * get_cat_table_entry_name - translate entry id to long name
756 * @category: category to look up (enum ih_category)
757 * @id: entry id to be translated
759 * This will scan the translation table trying to find the entry that matches
762 * @retur long entry name if translation succeeds; error string on failure
764 const char *genimg_get_cat_name(enum ih_category category, uint id)
766 const table_entry_t *entry;
768 entry = get_table_entry(table_info[category].table, id);
770 return unknown_msg(category);
771 #if defined(USE_HOSTCC) || !defined(CONFIG_NEEDS_MANUAL_RELOC)
774 return entry->lname + gd->reloc_off;
779 * get_cat_table_entry_short_name - translate entry id to short name
780 * @category: category to look up (enum ih_category)
781 * @id: entry id to be translated
783 * This will scan the translation table trying to find the entry that matches
786 * @retur short entry name if translation succeeds; error string on failure
788 const char *genimg_get_cat_short_name(enum ih_category category, uint id)
790 const table_entry_t *entry;
792 entry = get_table_entry(table_info[category].table, id);
794 return unknown_msg(category);
795 #if defined(USE_HOSTCC) || !defined(CONFIG_NEEDS_MANUAL_RELOC)
798 return entry->sname + gd->reloc_off;
802 int genimg_get_cat_count(enum ih_category category)
804 return table_info[category].count;
807 const char *genimg_get_cat_desc(enum ih_category category)
809 return table_info[category].desc;
813 * get_table_entry_name - translate entry id to long name
814 * @table: pointer to a translation table for entries of a specific type
815 * @msg: message to be returned when translation fails
816 * @id: entry id to be translated
818 * get_table_entry_name() will go over translation table trying to find
819 * entry that matches given id. If matching entry is found, its long
820 * name is returned to the caller.
823 * long entry name if translation succeeds
826 char *get_table_entry_name(const table_entry_t *table, char *msg, int id)
828 table = get_table_entry(table, id);
831 #if defined(USE_HOSTCC) || !defined(CONFIG_NEEDS_MANUAL_RELOC)
834 return table->lname + gd->reloc_off;
838 const char *genimg_get_os_name(uint8_t os)
840 return (get_table_entry_name(uimage_os, "Unknown OS", os));
843 const char *genimg_get_arch_name(uint8_t arch)
845 return (get_table_entry_name(uimage_arch, "Unknown Architecture",
849 const char *genimg_get_type_name(uint8_t type)
851 return (get_table_entry_name(uimage_type, "Unknown Image", type));
854 static const char *genimg_get_short_name(const table_entry_t *table, int val)
856 table = get_table_entry(table, val);
859 #if defined(USE_HOSTCC) || !defined(CONFIG_NEEDS_MANUAL_RELOC)
862 return table->sname + gd->reloc_off;
866 const char *genimg_get_type_short_name(uint8_t type)
868 return genimg_get_short_name(uimage_type, type);
871 const char *genimg_get_comp_name(uint8_t comp)
873 return (get_table_entry_name(uimage_comp, "Unknown Compression",
877 const char *genimg_get_comp_short_name(uint8_t comp)
879 return genimg_get_short_name(uimage_comp, comp);
882 const char *genimg_get_os_short_name(uint8_t os)
884 return genimg_get_short_name(uimage_os, os);
887 const char *genimg_get_arch_short_name(uint8_t arch)
889 return genimg_get_short_name(uimage_arch, arch);
893 * get_table_entry_id - translate short entry name to id
894 * @table: pointer to a translation table for entries of a specific type
895 * @table_name: to be used in case of error
896 * @name: entry short name to be translated
898 * get_table_entry_id() will go over translation table trying to find
899 * entry that matches given short name. If matching entry is found,
900 * its id returned to the caller.
903 * entry id if translation succeeds
906 int get_table_entry_id(const table_entry_t *table,
907 const char *table_name, const char *name)
909 const table_entry_t *t;
911 for (t = table; t->id >= 0; ++t) {
912 #ifdef CONFIG_NEEDS_MANUAL_RELOC
913 if (t->sname && strcasecmp(t->sname + gd->reloc_off, name) == 0)
915 if (t->sname && strcasecmp(t->sname, name) == 0)
919 debug("Invalid %s Type: %s\n", table_name, name);
924 int genimg_get_os_id(const char *name)
926 return (get_table_entry_id(uimage_os, "OS", name));
929 int genimg_get_arch_id(const char *name)
931 return (get_table_entry_id(uimage_arch, "CPU", name));
934 int genimg_get_type_id(const char *name)
936 return (get_table_entry_id(uimage_type, "Image", name));
939 int genimg_get_comp_id(const char *name)
941 return (get_table_entry_id(uimage_comp, "Compression", name));
946 * genimg_get_kernel_addr_fit - get the real kernel address and return 2
948 * @img_addr: a string might contain real image address
949 * @fit_uname_config: double pointer to a char, will hold pointer to a
950 * configuration unit name
951 * @fit_uname_kernel: double pointer to a char, will hold pointer to a subimage
954 * genimg_get_kernel_addr_fit get the real kernel start address from a string
955 * which is normally the first argv of bootm/bootz
958 * kernel start address
960 ulong genimg_get_kernel_addr_fit(char * const img_addr,
961 const char **fit_uname_config,
962 const char **fit_uname_kernel)
966 /* find out kernel image address */
968 kernel_addr = image_load_addr;
969 debug("* kernel: default image load address = 0x%08lx\n",
971 #if CONFIG_IS_ENABLED(FIT)
972 } else if (fit_parse_conf(img_addr, image_load_addr, &kernel_addr,
974 debug("* kernel: config '%s' from image at 0x%08lx\n",
975 *fit_uname_config, kernel_addr);
976 } else if (fit_parse_subimage(img_addr, image_load_addr, &kernel_addr,
978 debug("* kernel: subimage '%s' from image at 0x%08lx\n",
979 *fit_uname_kernel, kernel_addr);
982 kernel_addr = simple_strtoul(img_addr, NULL, 16);
983 debug("* kernel: cmdline image address = 0x%08lx\n",
991 * genimg_get_kernel_addr() is the simple version of
992 * genimg_get_kernel_addr_fit(). It ignores those return FIT strings
994 ulong genimg_get_kernel_addr(char * const img_addr)
996 const char *fit_uname_config = NULL;
997 const char *fit_uname_kernel = NULL;
999 return genimg_get_kernel_addr_fit(img_addr, &fit_uname_config,
1004 * genimg_get_format - get image format type
1005 * @img_addr: image start address
1007 * genimg_get_format() checks whether provided address points to a valid
1008 * legacy or FIT image.
1010 * New uImage format and FDT blob are based on a libfdt. FDT blob
1011 * may be passed directly or embedded in a FIT image. In both situations
1012 * genimg_get_format() must be able to dectect libfdt header.
1015 * image format type or IMAGE_FORMAT_INVALID if no image is present
1017 int genimg_get_format(const void *img_addr)
1019 #if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
1020 const image_header_t *hdr;
1022 hdr = (const image_header_t *)img_addr;
1023 if (image_check_magic(hdr))
1024 return IMAGE_FORMAT_LEGACY;
1026 #if IMAGE_ENABLE_FIT || IMAGE_ENABLE_OF_LIBFDT
1027 if (fdt_check_header(img_addr) == 0)
1028 return IMAGE_FORMAT_FIT;
1030 #ifdef CONFIG_ANDROID_BOOT_IMAGE
1031 if (android_image_check_header(img_addr) == 0)
1032 return IMAGE_FORMAT_ANDROID;
1035 return IMAGE_FORMAT_INVALID;
1039 * fit_has_config - check if there is a valid FIT configuration
1040 * @images: pointer to the bootm command headers structure
1042 * fit_has_config() checks if there is a FIT configuration in use
1043 * (if FTI support is present).
1046 * 0, no FIT support or no configuration found
1047 * 1, configuration found
1049 int genimg_has_config(bootm_headers_t *images)
1051 #if IMAGE_ENABLE_FIT
1052 if (images->fit_uname_cfg)
1059 * boot_get_ramdisk - main ramdisk handling routine
1060 * @argc: command argument count
1061 * @argv: command argument list
1062 * @images: pointer to the bootm images structure
1063 * @arch: expected ramdisk architecture
1064 * @rd_start: pointer to a ulong variable, will hold ramdisk start address
1065 * @rd_end: pointer to a ulong variable, will hold ramdisk end
1067 * boot_get_ramdisk() is responsible for finding a valid ramdisk image.
1068 * Curently supported are the following ramdisk sources:
1069 * - multicomponent kernel/ramdisk image,
1070 * - commandline provided address of decicated ramdisk image.
1073 * 0, if ramdisk image was found and valid, or skiped
1074 * rd_start and rd_end are set to ramdisk start/end addresses if
1075 * ramdisk image is found and valid
1077 * 1, if ramdisk image is found but corrupted, or invalid
1078 * rd_start and rd_end are set to 0 if no ramdisk exists
1080 int boot_get_ramdisk(int argc, char *const argv[], bootm_headers_t *images,
1081 uint8_t arch, ulong *rd_start, ulong *rd_end)
1083 ulong rd_addr, rd_load;
1084 ulong rd_data, rd_len;
1085 #if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
1086 const image_header_t *rd_hdr;
1089 #ifdef CONFIG_SUPPORT_RAW_INITRD
1092 #if IMAGE_ENABLE_FIT
1093 const char *fit_uname_config = images->fit_uname_cfg;
1094 const char *fit_uname_ramdisk = NULL;
1098 const char *select = NULL;
1103 #ifdef CONFIG_ANDROID_BOOT_IMAGE
1105 * Look for an Android boot image.
1107 buf = map_sysmem(images->os.start, 0);
1108 if (buf && genimg_get_format(buf) == IMAGE_FORMAT_ANDROID)
1109 select = (argc == 0) ? env_get("loadaddr") : argv[0];
1116 * Look for a '-' which indicates to ignore the
1119 if (select && strcmp(select, "-") == 0) {
1120 debug("## Skipping init Ramdisk\n");
1121 rd_len = rd_data = 0;
1122 } else if (select || genimg_has_config(images)) {
1123 #if IMAGE_ENABLE_FIT
1126 * If the init ramdisk comes from the FIT image and
1127 * the FIT image address is omitted in the command
1128 * line argument, try to use os FIT image address or
1129 * default load address.
1131 if (images->fit_uname_os)
1132 default_addr = (ulong)images->fit_hdr_os;
1134 default_addr = image_load_addr;
1136 if (fit_parse_conf(select, default_addr,
1137 &rd_addr, &fit_uname_config)) {
1138 debug("* ramdisk: config '%s' from image at "
1140 fit_uname_config, rd_addr);
1141 } else if (fit_parse_subimage(select, default_addr,
1142 &rd_addr, &fit_uname_ramdisk)) {
1143 debug("* ramdisk: subimage '%s' from image at "
1145 fit_uname_ramdisk, rd_addr);
1149 rd_addr = simple_strtoul(select, NULL, 16);
1150 debug("* ramdisk: cmdline image address = "
1154 #if IMAGE_ENABLE_FIT
1156 /* use FIT configuration provided in first bootm
1157 * command argument. If the property is not defined,
1160 rd_addr = map_to_sysmem(images->fit_hdr_os);
1161 rd_noffset = fit_get_node_from_config(images,
1162 FIT_RAMDISK_PROP, rd_addr);
1163 if (rd_noffset == -ENOENT)
1165 else if (rd_noffset < 0)
1171 * Check if there is an initrd image at the
1172 * address provided in the second bootm argument
1173 * check image type, for FIT images get FIT node.
1175 buf = map_sysmem(rd_addr, 0);
1176 switch (genimg_get_format(buf)) {
1177 #if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
1178 case IMAGE_FORMAT_LEGACY:
1179 printf("## Loading init Ramdisk from Legacy "
1180 "Image at %08lx ...\n", rd_addr);
1182 bootstage_mark(BOOTSTAGE_ID_CHECK_RAMDISK);
1183 rd_hdr = image_get_ramdisk(rd_addr, arch,
1189 rd_data = image_get_data(rd_hdr);
1190 rd_len = image_get_data_size(rd_hdr);
1191 rd_load = image_get_load(rd_hdr);
1194 #if IMAGE_ENABLE_FIT
1195 case IMAGE_FORMAT_FIT:
1196 rd_noffset = fit_image_load(images,
1197 rd_addr, &fit_uname_ramdisk,
1198 &fit_uname_config, arch,
1200 BOOTSTAGE_ID_FIT_RD_START,
1201 FIT_LOAD_OPTIONAL_NON_ZERO,
1206 images->fit_hdr_rd = map_sysmem(rd_addr, 0);
1207 images->fit_uname_rd = fit_uname_ramdisk;
1208 images->fit_noffset_rd = rd_noffset;
1211 #ifdef CONFIG_ANDROID_BOOT_IMAGE
1212 case IMAGE_FORMAT_ANDROID:
1213 android_image_get_ramdisk((void *)images->os.start,
1218 #ifdef CONFIG_SUPPORT_RAW_INITRD
1221 end = strchr(select, ':');
1223 rd_len = simple_strtoul(++end, NULL, 16);
1228 puts("Wrong Ramdisk Image Format\n");
1229 rd_data = rd_len = rd_load = 0;
1233 } else if (images->legacy_hdr_valid &&
1234 image_check_type(&images->legacy_hdr_os_copy,
1238 * Now check if we have a legacy mult-component image,
1239 * get second entry data start address and len.
1241 bootstage_mark(BOOTSTAGE_ID_RAMDISK);
1242 printf("## Loading init Ramdisk from multi component "
1243 "Legacy Image at %08lx ...\n",
1244 (ulong)images->legacy_hdr_os);
1246 image_multi_getimg(images->legacy_hdr_os, 1, &rd_data, &rd_len);
1251 bootstage_mark(BOOTSTAGE_ID_NO_RAMDISK);
1252 rd_len = rd_data = 0;
1256 debug("## No init Ramdisk\n");
1258 *rd_start = rd_data;
1259 *rd_end = rd_data + rd_len;
1261 debug(" ramdisk start = 0x%08lx, ramdisk end = 0x%08lx\n",
1262 *rd_start, *rd_end);
1267 #ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
1269 * boot_ramdisk_high - relocate init ramdisk
1270 * @lmb: pointer to lmb handle, will be used for memory mgmt
1271 * @rd_data: ramdisk data start address
1272 * @rd_len: ramdisk data length
1273 * @initrd_start: pointer to a ulong variable, will hold final init ramdisk
1274 * start address (after possible relocation)
1275 * @initrd_end: pointer to a ulong variable, will hold final init ramdisk
1276 * end address (after possible relocation)
1278 * boot_ramdisk_high() takes a relocation hint from "initrd_high" environment
1279 * variable and if requested ramdisk data is moved to a specified location.
1281 * Initrd_start and initrd_end are set to final (after relocation) ramdisk
1282 * start/end addresses if ramdisk image start and len were provided,
1283 * otherwise set initrd_start and initrd_end set to zeros.
1289 int boot_ramdisk_high(struct lmb *lmb, ulong rd_data, ulong rd_len,
1290 ulong *initrd_start, ulong *initrd_end)
1294 int initrd_copy_to_ram = 1;
1296 s = env_get("initrd_high");
1298 /* a value of "no" or a similar string will act like 0,
1299 * turning the "load high" feature off. This is intentional.
1301 initrd_high = simple_strtoul(s, NULL, 16);
1302 if (initrd_high == ~0)
1303 initrd_copy_to_ram = 0;
1305 initrd_high = env_get_bootm_mapsize() + env_get_bootm_low();
1309 debug("## initrd_high = 0x%08lx, copy_to_ram = %d\n",
1310 initrd_high, initrd_copy_to_ram);
1313 if (!initrd_copy_to_ram) { /* zero-copy ramdisk support */
1314 debug(" in-place initrd\n");
1315 *initrd_start = rd_data;
1316 *initrd_end = rd_data + rd_len;
1317 lmb_reserve(lmb, rd_data, rd_len);
1320 *initrd_start = (ulong)lmb_alloc_base(lmb,
1321 rd_len, 0x1000, initrd_high);
1323 *initrd_start = (ulong)lmb_alloc(lmb, rd_len,
1326 if (*initrd_start == 0) {
1327 puts("ramdisk - allocation error\n");
1330 bootstage_mark(BOOTSTAGE_ID_COPY_RAMDISK);
1332 *initrd_end = *initrd_start + rd_len;
1333 printf(" Loading Ramdisk to %08lx, end %08lx ... ",
1334 *initrd_start, *initrd_end);
1336 memmove_wd((void *)*initrd_start,
1337 (void *)rd_data, rd_len, CHUNKSZ);
1341 * Ensure the image is flushed to memory to handle
1342 * AMP boot scenarios in which we might not be
1345 flush_cache((unsigned long)*initrd_start,
1346 ALIGN(rd_len, ARCH_DMA_MINALIGN));
1354 debug(" ramdisk load start = 0x%08lx, ramdisk load end = 0x%08lx\n",
1355 *initrd_start, *initrd_end);
1362 #endif /* CONFIG_SYS_BOOT_RAMDISK_HIGH */
1364 int boot_get_setup(bootm_headers_t *images, uint8_t arch,
1365 ulong *setup_start, ulong *setup_len)
1367 #if IMAGE_ENABLE_FIT
1368 return boot_get_setup_fit(images, arch, setup_start, setup_len);
1374 #if IMAGE_ENABLE_FIT
1375 #if defined(CONFIG_FPGA)
1376 int boot_get_fpga(int argc, char *const argv[], bootm_headers_t *images,
1377 uint8_t arch, const ulong *ld_start, ulong * const ld_len)
1379 ulong tmp_img_addr, img_data, img_len;
1383 const char *uname, *name;
1385 int devnum = 0; /* TODO support multi fpga platforms */
1387 /* Check to see if the images struct has a FIT configuration */
1388 if (!genimg_has_config(images)) {
1389 debug("## FIT configuration was not specified\n");
1394 * Obtain the os FIT header from the images struct
1396 tmp_img_addr = map_to_sysmem(images->fit_hdr_os);
1397 buf = map_sysmem(tmp_img_addr, 0);
1399 * Check image type. For FIT images get FIT node
1400 * and attempt to locate a generic binary.
1402 switch (genimg_get_format(buf)) {
1403 case IMAGE_FORMAT_FIT:
1404 conf_noffset = fit_conf_get_node(buf, images->fit_uname_cfg);
1406 uname = fdt_stringlist_get(buf, conf_noffset, FIT_FPGA_PROP, 0,
1409 debug("## FPGA image is not specified\n");
1412 fit_img_result = fit_image_load(images,
1414 (const char **)&uname,
1415 &(images->fit_uname_cfg),
1418 BOOTSTAGE_ID_FPGA_INIT,
1419 FIT_LOAD_OPTIONAL_NON_ZERO,
1420 &img_data, &img_len);
1422 debug("FPGA image (%s) loaded to 0x%lx/size 0x%lx\n",
1423 uname, img_data, img_len);
1425 if (fit_img_result < 0) {
1426 /* Something went wrong! */
1427 return fit_img_result;
1430 if (!fpga_is_partial_data(devnum, img_len)) {
1432 err = fpga_loadbitstream(devnum, (char *)img_data,
1435 err = fpga_load(devnum, (const void *)img_data,
1439 err = fpga_loadbitstream(devnum, (char *)img_data,
1440 img_len, BIT_PARTIAL);
1442 err = fpga_load(devnum, (const void *)img_data,
1443 img_len, BIT_PARTIAL);
1449 printf(" Programming %s bitstream... OK\n", name);
1452 printf("The given image format is not supported (corrupt?)\n");
1460 static void fit_loadable_process(uint8_t img_type,
1465 const unsigned int count =
1466 ll_entry_count(struct fit_loadable_tbl, fit_loadable);
1467 struct fit_loadable_tbl *fit_loadable_handler =
1468 ll_entry_start(struct fit_loadable_tbl, fit_loadable);
1469 /* For each loadable handler */
1470 for (i = 0; i < count; i++, fit_loadable_handler++)
1471 /* matching this type */
1472 if (fit_loadable_handler->type == img_type)
1473 /* call that handler with this image data */
1474 fit_loadable_handler->handler(img_data, img_len);
1477 int boot_get_loadable(int argc, char *const argv[], bootm_headers_t *images,
1478 uint8_t arch, const ulong *ld_start, ulong * const ld_len)
1481 * These variables are used to hold the current image location
1486 * These two variables are requirements for fit_image_load, but
1487 * their values are not used
1489 ulong img_data, img_len;
1491 int loadables_index;
1497 /* Check to see if the images struct has a FIT configuration */
1498 if (!genimg_has_config(images)) {
1499 debug("## FIT configuration was not specified\n");
1504 * Obtain the os FIT header from the images struct
1506 tmp_img_addr = map_to_sysmem(images->fit_hdr_os);
1507 buf = map_sysmem(tmp_img_addr, 0);
1509 * Check image type. For FIT images get FIT node
1510 * and attempt to locate a generic binary.
1512 switch (genimg_get_format(buf)) {
1513 case IMAGE_FORMAT_FIT:
1514 conf_noffset = fit_conf_get_node(buf, images->fit_uname_cfg);
1516 for (loadables_index = 0;
1517 uname = fdt_stringlist_get(buf, conf_noffset,
1518 FIT_LOADABLE_PROP, loadables_index,
1522 fit_img_result = fit_image_load(images,
1525 &(images->fit_uname_cfg), arch,
1527 BOOTSTAGE_ID_FIT_LOADABLE_START,
1528 FIT_LOAD_OPTIONAL_NON_ZERO,
1529 &img_data, &img_len);
1530 if (fit_img_result < 0) {
1531 /* Something went wrong! */
1532 return fit_img_result;
1535 fit_img_result = fit_image_get_node(buf, uname);
1536 if (fit_img_result < 0) {
1537 /* Something went wrong! */
1538 return fit_img_result;
1540 fit_img_result = fit_image_get_type(buf,
1543 if (fit_img_result < 0) {
1544 /* Something went wrong! */
1545 return fit_img_result;
1548 fit_loadable_process(img_type, img_data, img_len);
1552 printf("The given image format is not supported (corrupt?)\n");
1560 #ifdef CONFIG_SYS_BOOT_GET_CMDLINE
1562 * boot_get_cmdline - allocate and initialize kernel cmdline
1563 * @lmb: pointer to lmb handle, will be used for memory mgmt
1564 * @cmd_start: pointer to a ulong variable, will hold cmdline start
1565 * @cmd_end: pointer to a ulong variable, will hold cmdline end
1567 * boot_get_cmdline() allocates space for kernel command line below
1568 * BOOTMAPSZ + env_get_bootm_low() address. If "bootargs" U-Boot environment
1569 * variable is present its contents is copied to allocated kernel
1576 int boot_get_cmdline(struct lmb *lmb, ulong *cmd_start, ulong *cmd_end)
1581 cmdline = (char *)(ulong)lmb_alloc_base(lmb, CONFIG_SYS_BARGSIZE, 0xf,
1582 env_get_bootm_mapsize() + env_get_bootm_low());
1584 if (cmdline == NULL)
1587 s = env_get("bootargs");
1593 *cmd_start = (ulong) & cmdline[0];
1594 *cmd_end = *cmd_start + strlen(cmdline);
1596 debug("## cmdline at 0x%08lx ... 0x%08lx\n", *cmd_start, *cmd_end);
1600 #endif /* CONFIG_SYS_BOOT_GET_CMDLINE */
1602 #ifdef CONFIG_SYS_BOOT_GET_KBD
1604 * boot_get_kbd - allocate and initialize kernel copy of board info
1605 * @lmb: pointer to lmb handle, will be used for memory mgmt
1606 * @kbd: double pointer to board info data
1608 * boot_get_kbd() allocates space for kernel copy of board info data below
1609 * BOOTMAPSZ + env_get_bootm_low() address and kernel board info is initialized
1610 * with the current u-boot board info data.
1616 int boot_get_kbd(struct lmb *lmb, bd_t **kbd)
1618 *kbd = (bd_t *)(ulong)lmb_alloc_base(lmb, sizeof(bd_t), 0xf,
1619 env_get_bootm_mapsize() + env_get_bootm_low());
1625 debug("## kernel board info at 0x%08lx\n", (ulong)*kbd);
1627 #if defined(DEBUG) && defined(CONFIG_CMD_BDI)
1628 do_bdinfo(NULL, 0, 0, NULL);
1633 #endif /* CONFIG_SYS_BOOT_GET_KBD */
1636 int image_setup_linux(bootm_headers_t *images)
1638 ulong of_size = images->ft_len;
1639 char **of_flat_tree = &images->ft_addr;
1640 struct lmb *lmb = &images->lmb;
1643 if (IMAGE_ENABLE_OF_LIBFDT)
1644 boot_fdt_add_mem_rsv_regions(lmb, *of_flat_tree);
1646 if (IMAGE_BOOT_GET_CMDLINE) {
1647 ret = boot_get_cmdline(lmb, &images->cmdline_start,
1648 &images->cmdline_end);
1650 puts("ERROR with allocation of cmdline\n");
1655 if (IMAGE_ENABLE_OF_LIBFDT) {
1656 ret = boot_relocate_fdt(lmb, of_flat_tree, &of_size);
1661 if (IMAGE_ENABLE_OF_LIBFDT && of_size) {
1662 ret = image_setup_libfdt(images, *of_flat_tree, of_size, lmb);
1669 #endif /* CONFIG_LMB */
1670 #endif /* !USE_HOSTCC */