1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2000-2009
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
13 #include <fdt_support.h>
18 #if defined(CONFIG_CMD_USB)
29 #ifndef CONFIG_SYS_BOOTM_LEN
30 /* use 8MByte as default max gunzip size */
31 #define CONFIG_SYS_BOOTM_LEN 0x800000
34 #define IH_INITRD_ARCH IH_ARCH_DEFAULT
38 DECLARE_GLOBAL_DATA_PTR;
40 bootm_headers_t images; /* pointers to os/initrd/fdt images */
42 static const void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
43 char * const argv[], bootm_headers_t *images,
44 ulong *os_data, ulong *os_len);
46 __weak void board_quiesce_devices(void)
51 static void boot_start_lmb(bootm_headers_t *images)
56 mem_start = env_get_bootm_low();
57 mem_size = env_get_bootm_size();
59 lmb_init_and_reserve_range(&images->lmb, (phys_addr_t)mem_start,
63 #define lmb_reserve(lmb, base, size)
64 static inline void boot_start_lmb(bootm_headers_t *images) { }
67 static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc,
70 memset((void *)&images, 0, sizeof(images));
71 images.verify = env_get_yesno("verify");
73 boot_start_lmb(&images);
75 bootstage_mark_name(BOOTSTAGE_ID_BOOTM_START, "bootm_start");
76 images.state = BOOTM_STATE_START;
81 static int bootm_find_os(cmd_tbl_t *cmdtp, int flag, int argc,
85 bool ep_found = false;
88 /* get kernel image header, start address and length */
89 os_hdr = boot_get_kernel(cmdtp, flag, argc, argv,
90 &images, &images.os.image_start, &images.os.image_len);
91 if (images.os.image_len == 0) {
92 puts("ERROR: can't get kernel image!\n");
96 /* get image parameters */
97 switch (genimg_get_format(os_hdr)) {
98 #if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
99 case IMAGE_FORMAT_LEGACY:
100 images.os.type = image_get_type(os_hdr);
101 images.os.comp = image_get_comp(os_hdr);
102 images.os.os = image_get_os(os_hdr);
104 images.os.end = image_get_image_end(os_hdr);
105 images.os.load = image_get_load(os_hdr);
106 images.os.arch = image_get_arch(os_hdr);
110 case IMAGE_FORMAT_FIT:
111 if (fit_image_get_type(images.fit_hdr_os,
112 images.fit_noffset_os,
114 puts("Can't get image type!\n");
115 bootstage_error(BOOTSTAGE_ID_FIT_TYPE);
119 if (fit_image_get_comp(images.fit_hdr_os,
120 images.fit_noffset_os,
122 puts("Can't get image compression!\n");
123 bootstage_error(BOOTSTAGE_ID_FIT_COMPRESSION);
127 if (fit_image_get_os(images.fit_hdr_os, images.fit_noffset_os,
129 puts("Can't get image OS!\n");
130 bootstage_error(BOOTSTAGE_ID_FIT_OS);
134 if (fit_image_get_arch(images.fit_hdr_os,
135 images.fit_noffset_os,
137 puts("Can't get image ARCH!\n");
141 images.os.end = fit_get_end(images.fit_hdr_os);
143 if (fit_image_get_load(images.fit_hdr_os, images.fit_noffset_os,
145 puts("Can't get image load address!\n");
146 bootstage_error(BOOTSTAGE_ID_FIT_LOADADDR);
151 #ifdef CONFIG_ANDROID_BOOT_IMAGE
152 case IMAGE_FORMAT_ANDROID:
153 images.os.type = IH_TYPE_KERNEL;
154 images.os.comp = android_image_get_kcomp(os_hdr);
155 images.os.os = IH_OS_LINUX;
157 images.os.end = android_image_get_end(os_hdr);
158 images.os.load = android_image_get_kload(os_hdr);
159 images.ep = images.os.load;
164 puts("ERROR: unknown image format type!\n");
168 /* If we have a valid setup.bin, we will use that for entry (x86) */
169 if (images.os.arch == IH_ARCH_I386 ||
170 images.os.arch == IH_ARCH_X86_64) {
173 ret = boot_get_setup(&images, IH_ARCH_I386, &images.ep, &len);
174 if (ret < 0 && ret != -ENOENT) {
175 puts("Could not find a valid setup.bin for x86\n");
178 /* Kernel entry point is the setup.bin */
179 } else if (images.legacy_hdr_valid) {
180 images.ep = image_get_ep(&images.legacy_hdr_os_copy);
182 } else if (images.fit_uname_os) {
185 ret = fit_image_get_entry(images.fit_hdr_os,
186 images.fit_noffset_os, &images.ep);
188 puts("Can't get entry point property!\n");
192 } else if (!ep_found) {
193 puts("Could not find kernel entry point!\n");
197 if (images.os.type == IH_TYPE_KERNEL_NOLOAD) {
198 if (CONFIG_IS_ENABLED(CMD_BOOTI) &&
199 images.os.arch == IH_ARCH_ARM64) {
203 ret = booti_setup(images.os.image_start, &image_addr,
208 images.os.type = IH_TYPE_KERNEL;
209 images.os.load = image_addr;
210 images.ep = image_addr;
212 images.os.load = images.os.image_start;
213 images.ep += images.os.image_start;
217 images.os.start = map_to_sysmem(os_hdr);
223 * bootm_find_images - wrapper to find and locate various images
224 * @flag: Ignored Argument
225 * @argc: command argument count
226 * @argv: command argument list
228 * boot_find_images() will attempt to load an available ramdisk,
229 * flattened device tree, as well as specifically marked
230 * "loadable" images (loadables are FIT only)
232 * Note: bootm_find_images will skip an image if it is not found
235 * 0, if all existing images were loaded correctly
236 * 1, if an image is found but corrupted, or invalid
238 int bootm_find_images(int flag, int argc, char * const argv[])
243 ret = boot_get_ramdisk(argc, argv, &images, IH_INITRD_ARCH,
244 &images.rd_start, &images.rd_end);
246 puts("Ramdisk image is corrupt or invalid\n");
250 #if IMAGE_ENABLE_OF_LIBFDT
251 /* find flattened device tree */
252 ret = boot_get_fdt(flag, argc, argv, IH_ARCH_DEFAULT, &images,
253 &images.ft_addr, &images.ft_len);
255 puts("Could not find a valid device tree\n");
258 if (CONFIG_IS_ENABLED(CMD_FDT))
259 set_working_fdt_addr(map_to_sysmem(images.ft_addr));
263 #if defined(CONFIG_FPGA)
264 /* find bitstreams */
265 ret = boot_get_fpga(argc, argv, &images, IH_ARCH_DEFAULT,
268 printf("FPGA image is corrupted or invalid\n");
273 /* find all of the loadables */
274 ret = boot_get_loadable(argc, argv, &images, IH_ARCH_DEFAULT,
277 printf("Loadable(s) is corrupt or invalid\n");
285 static int bootm_find_other(cmd_tbl_t *cmdtp, int flag, int argc,
288 if (((images.os.type == IH_TYPE_KERNEL) ||
289 (images.os.type == IH_TYPE_KERNEL_NOLOAD) ||
290 (images.os.type == IH_TYPE_MULTI)) &&
291 (images.os.os == IH_OS_LINUX ||
292 images.os.os == IH_OS_VXWORKS))
293 return bootm_find_images(flag, argc, argv);
297 #endif /* USE_HOSTC */
299 #if !defined(USE_HOSTCC) || defined(CONFIG_FIT_SIGNATURE)
301 * handle_decomp_error() - display a decompression error
303 * This function tries to produce a useful message. In the case where the
304 * uncompressed size is the same as the available space, we can assume that
305 * the image is too large for the buffer.
307 * @comp_type: Compression type being used (IH_COMP_...)
308 * @uncomp_size: Number of bytes uncompressed
309 * @ret: errno error code received from compression library
310 * @return Appropriate BOOTM_ERR_ error code
312 static int handle_decomp_error(int comp_type, size_t uncomp_size, int ret)
314 const char *name = genimg_get_comp_name(comp_type);
316 /* ENOSYS means unimplemented compression type, don't reset. */
318 return BOOTM_ERR_UNIMPLEMENTED;
320 if (uncomp_size >= CONFIG_SYS_BOOTM_LEN)
321 printf("Image too large: increase CONFIG_SYS_BOOTM_LEN\n");
323 printf("%s: uncompress error %d\n", name, ret);
326 * The decompression routines are now safe, so will not write beyond
327 * their bounds. Probably it is not necessary to reset, but maintain
328 * the current behaviour for now.
330 printf("Must RESET board to recover\n");
332 bootstage_error(BOOTSTAGE_ID_DECOMP_IMAGE);
335 return BOOTM_ERR_RESET;
340 static int bootm_load_os(bootm_headers_t *images, int boot_progress)
342 image_info_t os = images->os;
343 ulong load = os.load;
345 ulong blob_start = os.start;
346 ulong blob_end = os.end;
347 ulong image_start = os.image_start;
348 ulong image_len = os.image_len;
349 ulong flush_start = ALIGN_DOWN(load, ARCH_DMA_MINALIGN);
351 void *load_buf, *image_buf;
354 load_buf = map_sysmem(load, 0);
355 image_buf = map_sysmem(os.image_start, image_len);
356 err = image_decomp(os.comp, load, os.image_start, os.type,
357 load_buf, image_buf, image_len,
358 CONFIG_SYS_BOOTM_LEN, &load_end);
360 err = handle_decomp_error(os.comp, load_end - load, err);
361 bootstage_error(BOOTSTAGE_ID_DECOMP_IMAGE);
365 flush_cache(flush_start, ALIGN(load_end, ARCH_DMA_MINALIGN) - flush_start);
367 debug(" kernel loaded at 0x%08lx, end = 0x%08lx\n", load, load_end);
368 bootstage_mark(BOOTSTAGE_ID_KERNEL_LOADED);
370 no_overlap = (os.comp == IH_COMP_NONE && load == image_start);
372 if (!no_overlap && load < blob_end && load_end > blob_start) {
373 debug("images.os.start = 0x%lX, images.os.end = 0x%lx\n",
374 blob_start, blob_end);
375 debug("images.os.load = 0x%lx, load_end = 0x%lx\n", load,
378 /* Check what type of image this is. */
379 if (images->legacy_hdr_valid) {
380 if (image_get_type(&images->legacy_hdr_os_copy)
382 puts("WARNING: legacy format multi component image overwritten\n");
383 return BOOTM_ERR_OVERLAP;
385 puts("ERROR: new format image overwritten - must RESET the board to recover\n");
386 bootstage_error(BOOTSTAGE_ID_OVERWRITTEN);
387 return BOOTM_ERR_RESET;
391 lmb_reserve(&images->lmb, images->os.load, (load_end -
397 * bootm_disable_interrupts() - Disable interrupts in preparation for load/boot
399 * @return interrupt flag (0 if interrupts were disabled, non-zero if they were
402 ulong bootm_disable_interrupts(void)
407 * We have reached the point of no return: we are going to
408 * overwrite all exception vector code, so we cannot easily
409 * recover from any failures any more...
411 iflag = disable_interrupts();
412 #ifdef CONFIG_NETCONSOLE
413 /* Stop the ethernet stack if NetConsole could have left it up */
415 # ifndef CONFIG_DM_ETH
416 eth_unregister(eth_get_dev());
420 #if defined(CONFIG_CMD_USB)
422 * turn off USB to prevent the host controller from writing to the
423 * SDRAM while Linux is booting. This could happen (at least for OHCI
424 * controller), because the HCCA (Host Controller Communication Area)
425 * lies within the SDRAM and the host controller writes continously to
426 * this area (as busmaster!). The HccaFrameNumber is for example
427 * updated every 1 ms within the HCCA structure in SDRAM! For more
428 * details see the OpenHCI specification.
435 #if defined(CONFIG_SILENT_CONSOLE) && !defined(CONFIG_SILENT_U_BOOT_ONLY)
437 #define CONSOLE_ARG "console="
438 #define CONSOLE_ARG_LEN (sizeof(CONSOLE_ARG) - 1)
440 static void fixup_silent_linux(void)
444 char *cmdline = env_get("bootargs");
448 * Only fix cmdline when requested. The environment variable can be:
450 * no - we never fixup
451 * yes - we always fixup
452 * unset - we rely on the console silent flag
454 want_silent = env_get_yesno("silent_linux");
455 if (want_silent == 0)
457 else if (want_silent == -1 && !(gd->flags & GD_FLG_SILENT))
460 debug("before silent fix-up: %s\n", cmdline);
461 if (cmdline && (cmdline[0] != '\0')) {
462 char *start = strstr(cmdline, CONSOLE_ARG);
464 /* Allocate space for maximum possible new command line */
465 buf = malloc(strlen(cmdline) + 1 + CONSOLE_ARG_LEN + 1);
467 debug("%s: out of memory\n", __func__);
472 char *end = strchr(start, ' ');
473 int num_start_bytes = start - cmdline + CONSOLE_ARG_LEN;
475 strncpy(buf, cmdline, num_start_bytes);
477 strcpy(buf + num_start_bytes, end);
479 buf[num_start_bytes] = '\0';
481 sprintf(buf, "%s %s", cmdline, CONSOLE_ARG);
486 env_val = CONSOLE_ARG;
489 env_set("bootargs", env_val);
490 debug("after silent fix-up: %s\n", env_val);
493 #endif /* CONFIG_SILENT_CONSOLE */
496 * Execute selected states of the bootm command.
498 * Note the arguments to this state must be the first argument, Any 'bootm'
499 * or sub-command arguments must have already been taken.
501 * Note that if states contains more than one flag it MUST contain
502 * BOOTM_STATE_START, since this handles and consumes the command line args.
504 * Also note that aside from boot_os_fn functions and bootm_load_os no other
505 * functions we store the return value of in 'ret' may use a negative return
506 * value, without special handling.
508 * @param cmdtp Pointer to bootm command table entry
509 * @param flag Command flags (CMD_FLAG_...)
510 * @param argc Number of subcommand arguments (0 = no arguments)
511 * @param argv Arguments
512 * @param states Mask containing states to run (BOOTM_STATE_...)
513 * @param images Image header information
514 * @param boot_progress 1 to show boot progress, 0 to not do this
515 * @return 0 if ok, something else on error. Some errors will cause this
516 * function to perform a reboot! If states contains BOOTM_STATE_OS_GO
517 * then the intent is to boot an OS, so this function will not return
518 * unless the image type is standalone.
520 int do_bootm_states(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
521 int states, bootm_headers_t *images, int boot_progress)
525 int ret = 0, need_boot_fn;
527 images->state |= states;
530 * Work through the states and see how far we get. We stop on
533 if (states & BOOTM_STATE_START)
534 ret = bootm_start(cmdtp, flag, argc, argv);
536 if (!ret && (states & BOOTM_STATE_FINDOS))
537 ret = bootm_find_os(cmdtp, flag, argc, argv);
539 if (!ret && (states & BOOTM_STATE_FINDOTHER))
540 ret = bootm_find_other(cmdtp, flag, argc, argv);
543 if (!ret && (states & BOOTM_STATE_LOADOS)) {
544 iflag = bootm_disable_interrupts();
545 ret = bootm_load_os(images, 0);
546 if (ret && ret != BOOTM_ERR_OVERLAP)
548 else if (ret == BOOTM_ERR_OVERLAP)
552 /* Relocate the ramdisk */
553 #ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
554 if (!ret && (states & BOOTM_STATE_RAMDISK)) {
555 ulong rd_len = images->rd_end - images->rd_start;
557 ret = boot_ramdisk_high(&images->lmb, images->rd_start,
558 rd_len, &images->initrd_start, &images->initrd_end);
560 env_set_hex("initrd_start", images->initrd_start);
561 env_set_hex("initrd_end", images->initrd_end);
565 #if IMAGE_ENABLE_OF_LIBFDT && defined(CONFIG_LMB)
566 if (!ret && (states & BOOTM_STATE_FDT)) {
567 boot_fdt_add_mem_rsv_regions(&images->lmb, images->ft_addr);
568 ret = boot_relocate_fdt(&images->lmb, &images->ft_addr,
573 /* From now on, we need the OS boot function */
576 boot_fn = bootm_os_get_boot_func(images->os.os);
577 need_boot_fn = states & (BOOTM_STATE_OS_CMDLINE |
578 BOOTM_STATE_OS_BD_T | BOOTM_STATE_OS_PREP |
579 BOOTM_STATE_OS_FAKE_GO | BOOTM_STATE_OS_GO);
580 if (boot_fn == NULL && need_boot_fn) {
583 printf("ERROR: booting os '%s' (%d) is not supported\n",
584 genimg_get_os_name(images->os.os), images->os.os);
585 bootstage_error(BOOTSTAGE_ID_CHECK_BOOT_OS);
590 /* Call various other states that are not generally used */
591 if (!ret && (states & BOOTM_STATE_OS_CMDLINE))
592 ret = boot_fn(BOOTM_STATE_OS_CMDLINE, argc, argv, images);
593 if (!ret && (states & BOOTM_STATE_OS_BD_T))
594 ret = boot_fn(BOOTM_STATE_OS_BD_T, argc, argv, images);
595 if (!ret && (states & BOOTM_STATE_OS_PREP)) {
596 #if defined(CONFIG_SILENT_CONSOLE) && !defined(CONFIG_SILENT_U_BOOT_ONLY)
597 if (images->os.os == IH_OS_LINUX)
598 fixup_silent_linux();
600 ret = boot_fn(BOOTM_STATE_OS_PREP, argc, argv, images);
604 /* Pretend to run the OS, then run a user command */
605 if (!ret && (states & BOOTM_STATE_OS_FAKE_GO)) {
606 char *cmd_list = env_get("fakegocmd");
608 ret = boot_selected_os(argc, argv, BOOTM_STATE_OS_FAKE_GO,
610 if (!ret && cmd_list)
611 ret = run_command_list(cmd_list, -1, flag);
615 /* Check for unsupported subcommand. */
617 puts("subcommand not supported\n");
621 /* Now run the OS! We hope this doesn't return */
622 if (!ret && (states & BOOTM_STATE_OS_GO))
623 ret = boot_selected_os(argc, argv, BOOTM_STATE_OS_GO,
626 /* Deal with any fallout */
631 if (ret == BOOTM_ERR_UNIMPLEMENTED)
632 bootstage_error(BOOTSTAGE_ID_DECOMP_UNIMPL);
633 else if (ret == BOOTM_ERR_RESET)
634 do_reset(cmdtp, flag, argc, argv);
639 #if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
641 * image_get_kernel - verify legacy format kernel image
642 * @img_addr: in RAM address of the legacy format image to be verified
643 * @verify: data CRC verification flag
645 * image_get_kernel() verifies legacy image integrity and returns pointer to
646 * legacy image header if image verification was completed successfully.
649 * pointer to a legacy image header if valid image was found
650 * otherwise return NULL
652 static image_header_t *image_get_kernel(ulong img_addr, int verify)
654 image_header_t *hdr = (image_header_t *)img_addr;
656 if (!image_check_magic(hdr)) {
657 puts("Bad Magic Number\n");
658 bootstage_error(BOOTSTAGE_ID_CHECK_MAGIC);
661 bootstage_mark(BOOTSTAGE_ID_CHECK_HEADER);
663 if (!image_check_hcrc(hdr)) {
664 puts("Bad Header Checksum\n");
665 bootstage_error(BOOTSTAGE_ID_CHECK_HEADER);
669 bootstage_mark(BOOTSTAGE_ID_CHECK_CHECKSUM);
670 image_print_contents(hdr);
673 puts(" Verifying Checksum ... ");
674 if (!image_check_dcrc(hdr)) {
675 printf("Bad Data CRC\n");
676 bootstage_error(BOOTSTAGE_ID_CHECK_CHECKSUM);
681 bootstage_mark(BOOTSTAGE_ID_CHECK_ARCH);
683 if (!image_check_target_arch(hdr)) {
684 printf("Unsupported Architecture 0x%x\n", image_get_arch(hdr));
685 bootstage_error(BOOTSTAGE_ID_CHECK_ARCH);
693 * boot_get_kernel - find kernel image
694 * @os_data: pointer to a ulong variable, will hold os data start address
695 * @os_len: pointer to a ulong variable, will hold os data length
697 * boot_get_kernel() tries to find a kernel image, verifies its integrity
698 * and locates kernel data.
701 * pointer to image header if valid image was found, plus kernel start
702 * address and length, otherwise NULL
704 static const void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
705 char * const argv[], bootm_headers_t *images,
706 ulong *os_data, ulong *os_len)
708 #if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
713 const char *fit_uname_config = NULL;
714 const char *fit_uname_kernel = NULL;
719 img_addr = genimg_get_kernel_addr_fit(argc < 1 ? NULL : argv[0],
723 bootstage_mark(BOOTSTAGE_ID_CHECK_MAGIC);
725 /* check image type, for FIT images get FIT kernel node */
726 *os_data = *os_len = 0;
727 buf = map_sysmem(img_addr, 0);
728 switch (genimg_get_format(buf)) {
729 #if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
730 case IMAGE_FORMAT_LEGACY:
731 printf("## Booting kernel from Legacy Image at %08lx ...\n",
733 hdr = image_get_kernel(img_addr, images->verify);
736 bootstage_mark(BOOTSTAGE_ID_CHECK_IMAGETYPE);
738 /* get os_data and os_len */
739 switch (image_get_type(hdr)) {
741 case IH_TYPE_KERNEL_NOLOAD:
742 *os_data = image_get_data(hdr);
743 *os_len = image_get_data_size(hdr);
746 image_multi_getimg(hdr, 0, os_data, os_len);
748 case IH_TYPE_STANDALONE:
749 *os_data = image_get_data(hdr);
750 *os_len = image_get_data_size(hdr);
753 printf("Wrong Image Type for %s command\n",
755 bootstage_error(BOOTSTAGE_ID_CHECK_IMAGETYPE);
760 * copy image header to allow for image overwrites during
761 * kernel decompression.
763 memmove(&images->legacy_hdr_os_copy, hdr,
764 sizeof(image_header_t));
766 /* save pointer to image header */
767 images->legacy_hdr_os = hdr;
769 images->legacy_hdr_valid = 1;
770 bootstage_mark(BOOTSTAGE_ID_DECOMP_IMAGE);
774 case IMAGE_FORMAT_FIT:
775 os_noffset = fit_image_load(images, img_addr,
776 &fit_uname_kernel, &fit_uname_config,
777 IH_ARCH_DEFAULT, IH_TYPE_KERNEL,
778 BOOTSTAGE_ID_FIT_KERNEL_START,
779 FIT_LOAD_IGNORED, os_data, os_len);
783 images->fit_hdr_os = map_sysmem(img_addr, 0);
784 images->fit_uname_os = fit_uname_kernel;
785 images->fit_uname_cfg = fit_uname_config;
786 images->fit_noffset_os = os_noffset;
789 #ifdef CONFIG_ANDROID_BOOT_IMAGE
790 case IMAGE_FORMAT_ANDROID:
791 printf("## Booting Android Image at 0x%08lx ...\n", img_addr);
792 if (android_image_get_kernel(buf, images->verify,
798 printf("Wrong Image Format for %s command\n", cmdtp->name);
799 bootstage_error(BOOTSTAGE_ID_FIT_KERNEL_INFO);
803 debug(" kernel data at 0x%08lx, len = 0x%08lx (%ld)\n",
804 *os_data, *os_len, *os_len);
810 * switch_to_non_secure_mode() - switch to non-secure mode
812 * This routine is overridden by architectures requiring this feature.
814 void __weak switch_to_non_secure_mode(void)
818 #else /* USE_HOSTCC */
820 #if defined(CONFIG_FIT_SIGNATURE)
821 static int bootm_host_load_image(const void *fit, int req_image_type)
823 const char *fit_uname_config = NULL;
825 bootm_headers_t images;
833 memset(&images, '\0', sizeof(images));
835 noffset = fit_image_load(&images, (ulong)fit,
836 NULL, &fit_uname_config,
837 IH_ARCH_DEFAULT, req_image_type, -1,
838 FIT_LOAD_IGNORED, &data, &len);
841 if (fit_image_get_type(fit, noffset, &image_type)) {
842 puts("Can't get image type!\n");
846 if (fit_image_get_comp(fit, noffset, &imape_comp)) {
847 puts("Can't get image compression!\n");
851 /* Allow the image to expand by a factor of 4, should be safe */
852 load_buf = malloc((1 << 20) + len * 4);
853 ret = image_decomp(imape_comp, 0, data, image_type, load_buf,
854 (void *)data, len, CONFIG_SYS_BOOTM_LEN,
859 ret = handle_decomp_error(imape_comp, load_end - 0, ret);
860 if (ret != BOOTM_ERR_UNIMPLEMENTED)
867 int bootm_host_load_images(const void *fit, int cfg_noffset)
869 static uint8_t image_types[] = {
877 for (i = 0; i < ARRAY_SIZE(image_types); i++) {
880 ret = bootm_host_load_image(fit, image_types[i]);
881 if (!err && ret && ret != -ENOENT)
885 /* Return the first error we found */
890 #endif /* ndef USE_HOSTCC */