2 * (C) Copyright 2000-2009
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * SPDX-License-Identifier: GPL-2.0+
10 #include <bootstage.h>
12 #include <fdt_support.h>
16 #include <linux/lzo.h>
17 #include <lzma/LzmaTypes.h>
18 #include <lzma/LzmaDec.h>
19 #include <lzma/LzmaTools.h>
20 #if defined(CONFIG_CMD_USB)
31 #ifndef CONFIG_SYS_BOOTM_LEN
32 /* use 8MByte as default max gunzip size */
33 #define CONFIG_SYS_BOOTM_LEN 0x800000
36 #define IH_INITRD_ARCH IH_ARCH_DEFAULT
40 DECLARE_GLOBAL_DATA_PTR
;
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
);
47 static void boot_start_lmb(bootm_headers_t
*images
)
52 lmb_init(&images
->lmb
);
54 mem_start
= getenv_bootm_low();
55 mem_size
= getenv_bootm_size();
57 lmb_add(&images
->lmb
, (phys_addr_t
)mem_start
, mem_size
);
59 arch_lmb_reserve(&images
->lmb
);
60 board_lmb_reserve(&images
->lmb
);
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
= getenv_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;
87 /* get kernel image header, start address and length */
88 os_hdr
= boot_get_kernel(cmdtp
, flag
, argc
, argv
,
89 &images
, &images
.os
.image_start
, &images
.os
.image_len
);
90 if (images
.os
.image_len
== 0) {
91 puts("ERROR: can't get kernel image!\n");
95 /* get image parameters */
96 switch (genimg_get_format(os_hdr
)) {
97 #if defined(CONFIG_IMAGE_FORMAT_LEGACY)
98 case IMAGE_FORMAT_LEGACY
:
99 images
.os
.type
= image_get_type(os_hdr
);
100 images
.os
.comp
= image_get_comp(os_hdr
);
101 images
.os
.os
= image_get_os(os_hdr
);
103 images
.os
.end
= image_get_image_end(os_hdr
);
104 images
.os
.load
= image_get_load(os_hdr
);
107 #if defined(CONFIG_FIT)
108 case IMAGE_FORMAT_FIT
:
109 if (fit_image_get_type(images
.fit_hdr_os
,
110 images
.fit_noffset_os
,
112 puts("Can't get image type!\n");
113 bootstage_error(BOOTSTAGE_ID_FIT_TYPE
);
117 if (fit_image_get_comp(images
.fit_hdr_os
,
118 images
.fit_noffset_os
,
120 puts("Can't get image compression!\n");
121 bootstage_error(BOOTSTAGE_ID_FIT_COMPRESSION
);
125 if (fit_image_get_os(images
.fit_hdr_os
, images
.fit_noffset_os
,
127 puts("Can't get image OS!\n");
128 bootstage_error(BOOTSTAGE_ID_FIT_OS
);
132 images
.os
.end
= fit_get_end(images
.fit_hdr_os
);
134 if (fit_image_get_load(images
.fit_hdr_os
, images
.fit_noffset_os
,
136 puts("Can't get image load address!\n");
137 bootstage_error(BOOTSTAGE_ID_FIT_LOADADDR
);
142 #ifdef CONFIG_ANDROID_BOOT_IMAGE
143 case IMAGE_FORMAT_ANDROID
:
144 images
.os
.type
= IH_TYPE_KERNEL
;
145 images
.os
.comp
= IH_COMP_NONE
;
146 images
.os
.os
= IH_OS_LINUX
;
147 images
.ep
= images
.os
.load
;
150 images
.os
.end
= android_image_get_end(os_hdr
);
151 images
.os
.load
= android_image_get_kload(os_hdr
);
155 puts("ERROR: unknown image format type!\n");
159 /* find kernel entry point */
160 if (images
.legacy_hdr_valid
) {
161 images
.ep
= image_get_ep(&images
.legacy_hdr_os_copy
);
162 #if defined(CONFIG_FIT)
163 } else if (images
.fit_uname_os
) {
166 ret
= fit_image_get_entry(images
.fit_hdr_os
,
167 images
.fit_noffset_os
, &images
.ep
);
169 puts("Can't get entry point property!\n");
173 } else if (!ep_found
) {
174 puts("Could not find kernel entry point!\n");
178 if (images
.os
.type
== IH_TYPE_KERNEL_NOLOAD
) {
179 images
.os
.load
= images
.os
.image_start
;
180 images
.ep
+= images
.os
.load
;
183 images
.os
.start
= (ulong
)os_hdr
;
188 static int bootm_find_ramdisk(int flag
, int argc
, char * const argv
[])
193 ret
= boot_get_ramdisk(argc
, argv
, &images
, IH_INITRD_ARCH
,
194 &images
.rd_start
, &images
.rd_end
);
196 puts("Ramdisk image is corrupt or invalid\n");
203 #if defined(CONFIG_OF_LIBFDT)
204 static int bootm_find_fdt(int flag
, int argc
, char * const argv
[])
208 /* find flattened device tree */
209 ret
= boot_get_fdt(flag
, argc
, argv
, IH_ARCH_DEFAULT
, &images
,
210 &images
.ft_addr
, &images
.ft_len
);
212 puts("Could not find a valid device tree\n");
216 set_working_fdt_addr(images
.ft_addr
);
222 int bootm_find_ramdisk_fdt(int flag
, int argc
, char * const argv
[])
224 if (bootm_find_ramdisk(flag
, argc
, argv
))
227 #if defined(CONFIG_OF_LIBFDT)
228 if (bootm_find_fdt(flag
, argc
, argv
))
235 static int bootm_find_other(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
238 if (((images
.os
.type
== IH_TYPE_KERNEL
) ||
239 (images
.os
.type
== IH_TYPE_KERNEL_NOLOAD
) ||
240 (images
.os
.type
== IH_TYPE_MULTI
)) &&
241 (images
.os
.os
== IH_OS_LINUX
||
242 images
.os
.os
== IH_OS_VXWORKS
))
243 return bootm_find_ramdisk_fdt(flag
, argc
, argv
);
249 * decomp_image() - decompress the operating system
251 * @comp: Compression algorithm that is used (IH_COMP_...)
252 * @load: Destination load address in U-Boot memory
253 * @image_start Image start address (where we are decompressing from)
254 * @type: OS type (IH_OS_...)
255 * @load_bug: Place to decompress to
256 * @image_buf: Address to decompress from
257 * @return 0 if OK, -ve on error (BOOTM_ERR_...)
259 static int decomp_image(int comp
, ulong load
, ulong image_start
, int type
,
260 void *load_buf
, void *image_buf
, ulong image_len
,
263 const char *type_name
= genimg_get_type_name(type
);
264 __attribute__((unused
)) uint unc_len
= CONFIG_SYS_BOOTM_LEN
;
269 if (load
== image_start
) {
270 printf(" XIP %s ... ", type_name
);
272 printf(" Loading %s ... ", type_name
);
273 memmove_wd(load_buf
, image_buf
, image_len
, CHUNKSZ
);
275 *load_end
= load
+ image_len
;
279 printf(" Uncompressing %s ... ", type_name
);
280 if (gunzip(load_buf
, unc_len
, image_buf
, &image_len
) != 0) {
281 puts("GUNZIP: uncompress, out-of-mem or overwrite error - must RESET board to recover\n");
282 return BOOTM_ERR_RESET
;
285 *load_end
= load
+ image_len
;
287 #endif /* CONFIG_GZIP */
290 printf(" Uncompressing %s ... ", type_name
);
292 * If we've got less than 4 MB of malloc() space,
293 * use slower decompression algorithm which requires
294 * at most 2300 KB of memory.
296 int i
= BZ2_bzBuffToBuffDecompress(load_buf
, &unc_len
,
297 image_buf
, image_len
,
298 CONFIG_SYS_MALLOC_LEN
< (4096 * 1024), 0);
300 printf("BUNZIP2: uncompress or overwrite error %d - must RESET board to recover\n",
302 return BOOTM_ERR_RESET
;
305 *load_end
= load
+ unc_len
;
307 #endif /* CONFIG_BZIP2 */
310 SizeT lzma_len
= unc_len
;
313 printf(" Uncompressing %s ... ", type_name
);
315 ret
= lzmaBuffToBuffDecompress(load_buf
, &lzma_len
,
316 image_buf
, image_len
);
319 printf("LZMA: uncompress or overwrite error %d - must RESET board to recover\n",
321 bootstage_error(BOOTSTAGE_ID_DECOMP_IMAGE
);
322 return BOOTM_ERR_RESET
;
324 *load_end
= load
+ unc_len
;
327 #endif /* CONFIG_LZMA */
330 size_t size
= unc_len
;
333 printf(" Uncompressing %s ... ", type_name
);
335 ret
= lzop_decompress(image_buf
, image_len
, load_buf
, &size
);
336 if (ret
!= LZO_E_OK
) {
337 printf("LZO: uncompress or overwrite error %d - must RESET board to recover\n",
339 return BOOTM_ERR_RESET
;
342 *load_end
= load
+ size
;
345 #endif /* CONFIG_LZO */
347 printf("Unimplemented compression type %d\n", comp
);
348 return BOOTM_ERR_UNIMPLEMENTED
;
356 static int bootm_load_os(bootm_headers_t
*images
, unsigned long *load_end
,
359 image_info_t os
= images
->os
;
360 ulong load
= os
.load
;
361 ulong blob_start
= os
.start
;
362 ulong blob_end
= os
.end
;
363 ulong image_start
= os
.image_start
;
364 ulong image_len
= os
.image_len
;
366 void *load_buf
, *image_buf
;
369 load_buf
= map_sysmem(load
, 0);
370 image_buf
= map_sysmem(os
.image_start
, image_len
);
371 err
= decomp_image(os
.comp
, load
, os
.image_start
, os
.type
, load_buf
,
372 image_buf
, image_len
, load_end
);
374 bootstage_error(BOOTSTAGE_ID_DECOMP_IMAGE
);
377 flush_cache(load
, (*load_end
- load
) * sizeof(ulong
));
379 debug(" kernel loaded at 0x%08lx, end = 0x%08lx\n", load
, *load_end
);
380 bootstage_mark(BOOTSTAGE_ID_KERNEL_LOADED
);
382 no_overlap
= (os
.comp
== IH_COMP_NONE
&& load
== image_start
);
384 if (!no_overlap
&& (load
< blob_end
) && (*load_end
> blob_start
)) {
385 debug("images.os.start = 0x%lX, images.os.end = 0x%lx\n",
386 blob_start
, blob_end
);
387 debug("images.os.load = 0x%lx, load_end = 0x%lx\n", load
,
390 /* Check what type of image this is. */
391 if (images
->legacy_hdr_valid
) {
392 if (image_get_type(&images
->legacy_hdr_os_copy
)
394 puts("WARNING: legacy format multi component image overwritten\n");
395 return BOOTM_ERR_OVERLAP
;
397 puts("ERROR: new format image overwritten - must RESET the board to recover\n");
398 bootstage_error(BOOTSTAGE_ID_OVERWRITTEN
);
399 return BOOTM_ERR_RESET
;
407 * bootm_disable_interrupts() - Disable interrupts in preparation for load/boot
409 * @return interrupt flag (0 if interrupts were disabled, non-zero if they were
412 ulong
bootm_disable_interrupts(void)
417 * We have reached the point of no return: we are going to
418 * overwrite all exception vector code, so we cannot easily
419 * recover from any failures any more...
421 iflag
= disable_interrupts();
422 #ifdef CONFIG_NETCONSOLE
423 /* Stop the ethernet stack if NetConsole could have left it up */
425 eth_unregister(eth_get_dev());
428 #if defined(CONFIG_CMD_USB)
430 * turn off USB to prevent the host controller from writing to the
431 * SDRAM while Linux is booting. This could happen (at least for OHCI
432 * controller), because the HCCA (Host Controller Communication Area)
433 * lies within the SDRAM and the host controller writes continously to
434 * this area (as busmaster!). The HccaFrameNumber is for example
435 * updated every 1 ms within the HCCA structure in SDRAM! For more
436 * details see the OpenHCI specification.
443 #if defined(CONFIG_SILENT_CONSOLE) && !defined(CONFIG_SILENT_U_BOOT_ONLY)
445 #define CONSOLE_ARG "console="
446 #define CONSOLE_ARG_LEN (sizeof(CONSOLE_ARG) - 1)
448 static void fixup_silent_linux(void)
452 char *cmdline
= getenv("bootargs");
456 * Only fix cmdline when requested. The environment variable can be:
458 * no - we never fixup
459 * yes - we always fixup
460 * unset - we rely on the console silent flag
462 want_silent
= getenv_yesno("silent_linux");
463 if (want_silent
== 0)
465 else if (want_silent
== -1 && !(gd
->flags
& GD_FLG_SILENT
))
468 debug("before silent fix-up: %s\n", cmdline
);
469 if (cmdline
&& (cmdline
[0] != '\0')) {
470 char *start
= strstr(cmdline
, CONSOLE_ARG
);
472 /* Allocate space for maximum possible new command line */
473 buf
= malloc(strlen(cmdline
) + 1 + CONSOLE_ARG_LEN
+ 1);
475 debug("%s: out of memory\n", __func__
);
480 char *end
= strchr(start
, ' ');
481 int num_start_bytes
= start
- cmdline
+ CONSOLE_ARG_LEN
;
483 strncpy(buf
, cmdline
, num_start_bytes
);
485 strcpy(buf
+ num_start_bytes
, end
);
487 buf
[num_start_bytes
] = '\0';
489 sprintf(buf
, "%s %s", cmdline
, CONSOLE_ARG
);
494 env_val
= CONSOLE_ARG
;
497 setenv("bootargs", env_val
);
498 debug("after silent fix-up: %s\n", env_val
);
501 #endif /* CONFIG_SILENT_CONSOLE */
504 * Execute selected states of the bootm command.
506 * Note the arguments to this state must be the first argument, Any 'bootm'
507 * or sub-command arguments must have already been taken.
509 * Note that if states contains more than one flag it MUST contain
510 * BOOTM_STATE_START, since this handles and consumes the command line args.
512 * Also note that aside from boot_os_fn functions and bootm_load_os no other
513 * functions we store the return value of in 'ret' may use a negative return
514 * value, without special handling.
516 * @param cmdtp Pointer to bootm command table entry
517 * @param flag Command flags (CMD_FLAG_...)
518 * @param argc Number of subcommand arguments (0 = no arguments)
519 * @param argv Arguments
520 * @param states Mask containing states to run (BOOTM_STATE_...)
521 * @param images Image header information
522 * @param boot_progress 1 to show boot progress, 0 to not do this
523 * @return 0 if ok, something else on error. Some errors will cause this
524 * function to perform a reboot! If states contains BOOTM_STATE_OS_GO
525 * then the intent is to boot an OS, so this function will not return
526 * unless the image type is standalone.
528 int do_bootm_states(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[],
529 int states
, bootm_headers_t
*images
, int boot_progress
)
533 int ret
= 0, need_boot_fn
;
535 images
->state
|= states
;
538 * Work through the states and see how far we get. We stop on
541 if (states
& BOOTM_STATE_START
)
542 ret
= bootm_start(cmdtp
, flag
, argc
, argv
);
544 if (!ret
&& (states
& BOOTM_STATE_FINDOS
))
545 ret
= bootm_find_os(cmdtp
, flag
, argc
, argv
);
547 if (!ret
&& (states
& BOOTM_STATE_FINDOTHER
)) {
548 ret
= bootm_find_other(cmdtp
, flag
, argc
, argv
);
549 argc
= 0; /* consume the args */
553 if (!ret
&& (states
& BOOTM_STATE_LOADOS
)) {
556 iflag
= bootm_disable_interrupts();
557 ret
= bootm_load_os(images
, &load_end
, 0);
559 lmb_reserve(&images
->lmb
, images
->os
.load
,
560 (load_end
- images
->os
.load
));
561 else if (ret
&& ret
!= BOOTM_ERR_OVERLAP
)
563 else if (ret
== BOOTM_ERR_OVERLAP
)
565 #if defined(CONFIG_SILENT_CONSOLE) && !defined(CONFIG_SILENT_U_BOOT_ONLY)
566 if (images
->os
.os
== IH_OS_LINUX
)
567 fixup_silent_linux();
571 /* Relocate the ramdisk */
572 #ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
573 if (!ret
&& (states
& BOOTM_STATE_RAMDISK
)) {
574 ulong rd_len
= images
->rd_end
- images
->rd_start
;
576 ret
= boot_ramdisk_high(&images
->lmb
, images
->rd_start
,
577 rd_len
, &images
->initrd_start
, &images
->initrd_end
);
579 setenv_hex("initrd_start", images
->initrd_start
);
580 setenv_hex("initrd_end", images
->initrd_end
);
584 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_LMB)
585 if (!ret
&& (states
& BOOTM_STATE_FDT
)) {
586 boot_fdt_add_mem_rsv_regions(&images
->lmb
, images
->ft_addr
);
587 ret
= boot_relocate_fdt(&images
->lmb
, &images
->ft_addr
,
592 /* From now on, we need the OS boot function */
595 boot_fn
= bootm_os_get_boot_func(images
->os
.os
);
596 need_boot_fn
= states
& (BOOTM_STATE_OS_CMDLINE
|
597 BOOTM_STATE_OS_BD_T
| BOOTM_STATE_OS_PREP
|
598 BOOTM_STATE_OS_FAKE_GO
| BOOTM_STATE_OS_GO
);
599 if (boot_fn
== NULL
&& need_boot_fn
) {
602 printf("ERROR: booting os '%s' (%d) is not supported\n",
603 genimg_get_os_name(images
->os
.os
), images
->os
.os
);
604 bootstage_error(BOOTSTAGE_ID_CHECK_BOOT_OS
);
608 /* Call various other states that are not generally used */
609 if (!ret
&& (states
& BOOTM_STATE_OS_CMDLINE
))
610 ret
= boot_fn(BOOTM_STATE_OS_CMDLINE
, argc
, argv
, images
);
611 if (!ret
&& (states
& BOOTM_STATE_OS_BD_T
))
612 ret
= boot_fn(BOOTM_STATE_OS_BD_T
, argc
, argv
, images
);
613 if (!ret
&& (states
& BOOTM_STATE_OS_PREP
))
614 ret
= boot_fn(BOOTM_STATE_OS_PREP
, argc
, argv
, images
);
617 /* Pretend to run the OS, then run a user command */
618 if (!ret
&& (states
& BOOTM_STATE_OS_FAKE_GO
)) {
619 char *cmd_list
= getenv("fakegocmd");
621 ret
= boot_selected_os(argc
, argv
, BOOTM_STATE_OS_FAKE_GO
,
623 if (!ret
&& cmd_list
)
624 ret
= run_command_list(cmd_list
, -1, flag
);
628 /* Check for unsupported subcommand. */
630 puts("subcommand not supported\n");
634 /* Now run the OS! We hope this doesn't return */
635 if (!ret
&& (states
& BOOTM_STATE_OS_GO
))
636 ret
= boot_selected_os(argc
, argv
, BOOTM_STATE_OS_GO
,
639 /* Deal with any fallout */
644 if (ret
== BOOTM_ERR_UNIMPLEMENTED
)
645 bootstage_error(BOOTSTAGE_ID_DECOMP_UNIMPL
);
646 else if (ret
== BOOTM_ERR_RESET
)
647 do_reset(cmdtp
, flag
, argc
, argv
);
652 #if defined(CONFIG_IMAGE_FORMAT_LEGACY)
654 * image_get_kernel - verify legacy format kernel image
655 * @img_addr: in RAM address of the legacy format image to be verified
656 * @verify: data CRC verification flag
658 * image_get_kernel() verifies legacy image integrity and returns pointer to
659 * legacy image header if image verification was completed successfully.
662 * pointer to a legacy image header if valid image was found
663 * otherwise return NULL
665 static image_header_t
*image_get_kernel(ulong img_addr
, int verify
)
667 image_header_t
*hdr
= (image_header_t
*)img_addr
;
669 if (!image_check_magic(hdr
)) {
670 puts("Bad Magic Number\n");
671 bootstage_error(BOOTSTAGE_ID_CHECK_MAGIC
);
674 bootstage_mark(BOOTSTAGE_ID_CHECK_HEADER
);
676 if (!image_check_hcrc(hdr
)) {
677 puts("Bad Header Checksum\n");
678 bootstage_error(BOOTSTAGE_ID_CHECK_HEADER
);
682 bootstage_mark(BOOTSTAGE_ID_CHECK_CHECKSUM
);
683 image_print_contents(hdr
);
686 puts(" Verifying Checksum ... ");
687 if (!image_check_dcrc(hdr
)) {
688 printf("Bad Data CRC\n");
689 bootstage_error(BOOTSTAGE_ID_CHECK_CHECKSUM
);
694 bootstage_mark(BOOTSTAGE_ID_CHECK_ARCH
);
696 if (!image_check_target_arch(hdr
)) {
697 printf("Unsupported Architecture 0x%x\n", image_get_arch(hdr
));
698 bootstage_error(BOOTSTAGE_ID_CHECK_ARCH
);
706 * boot_get_kernel - find kernel image
707 * @os_data: pointer to a ulong variable, will hold os data start address
708 * @os_len: pointer to a ulong variable, will hold os data length
710 * boot_get_kernel() tries to find a kernel image, verifies its integrity
711 * and locates kernel data.
714 * pointer to image header if valid image was found, plus kernel start
715 * address and length, otherwise NULL
717 static const void *boot_get_kernel(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
718 char * const argv
[], bootm_headers_t
*images
,
719 ulong
*os_data
, ulong
*os_len
)
721 #if defined(CONFIG_IMAGE_FORMAT_LEGACY)
726 #if defined(CONFIG_FIT)
727 const char *fit_uname_config
= NULL
;
728 const char *fit_uname_kernel
= NULL
;
732 /* find out kernel image address */
734 img_addr
= load_addr
;
735 debug("* kernel: default image load address = 0x%08lx\n",
737 #if defined(CONFIG_FIT)
738 } else if (fit_parse_conf(argv
[0], load_addr
, &img_addr
,
739 &fit_uname_config
)) {
740 debug("* kernel: config '%s' from image at 0x%08lx\n",
741 fit_uname_config
, img_addr
);
742 } else if (fit_parse_subimage(argv
[0], load_addr
, &img_addr
,
743 &fit_uname_kernel
)) {
744 debug("* kernel: subimage '%s' from image at 0x%08lx\n",
745 fit_uname_kernel
, img_addr
);
748 img_addr
= simple_strtoul(argv
[0], NULL
, 16);
749 debug("* kernel: cmdline image address = 0x%08lx\n",
753 bootstage_mark(BOOTSTAGE_ID_CHECK_MAGIC
);
755 /* copy from dataflash if needed */
756 img_addr
= genimg_get_image(img_addr
);
758 /* check image type, for FIT images get FIT kernel node */
759 *os_data
= *os_len
= 0;
760 buf
= map_sysmem(img_addr
, 0);
761 switch (genimg_get_format(buf
)) {
762 #if defined(CONFIG_IMAGE_FORMAT_LEGACY)
763 case IMAGE_FORMAT_LEGACY
:
764 printf("## Booting kernel from Legacy Image at %08lx ...\n",
766 hdr
= image_get_kernel(img_addr
, images
->verify
);
769 bootstage_mark(BOOTSTAGE_ID_CHECK_IMAGETYPE
);
771 /* get os_data and os_len */
772 switch (image_get_type(hdr
)) {
774 case IH_TYPE_KERNEL_NOLOAD
:
775 *os_data
= image_get_data(hdr
);
776 *os_len
= image_get_data_size(hdr
);
779 image_multi_getimg(hdr
, 0, os_data
, os_len
);
781 case IH_TYPE_STANDALONE
:
782 *os_data
= image_get_data(hdr
);
783 *os_len
= image_get_data_size(hdr
);
786 printf("Wrong Image Type for %s command\n",
788 bootstage_error(BOOTSTAGE_ID_CHECK_IMAGETYPE
);
793 * copy image header to allow for image overwrites during
794 * kernel decompression.
796 memmove(&images
->legacy_hdr_os_copy
, hdr
,
797 sizeof(image_header_t
));
799 /* save pointer to image header */
800 images
->legacy_hdr_os
= hdr
;
802 images
->legacy_hdr_valid
= 1;
803 bootstage_mark(BOOTSTAGE_ID_DECOMP_IMAGE
);
806 #if defined(CONFIG_FIT)
807 case IMAGE_FORMAT_FIT
:
808 os_noffset
= fit_image_load(images
, img_addr
,
809 &fit_uname_kernel
, &fit_uname_config
,
810 IH_ARCH_DEFAULT
, IH_TYPE_KERNEL
,
811 BOOTSTAGE_ID_FIT_KERNEL_START
,
812 FIT_LOAD_IGNORED
, os_data
, os_len
);
816 images
->fit_hdr_os
= map_sysmem(img_addr
, 0);
817 images
->fit_uname_os
= fit_uname_kernel
;
818 images
->fit_uname_cfg
= fit_uname_config
;
819 images
->fit_noffset_os
= os_noffset
;
822 #ifdef CONFIG_ANDROID_BOOT_IMAGE
823 case IMAGE_FORMAT_ANDROID
:
824 printf("## Booting Android Image at 0x%08lx ...\n", img_addr
);
825 if (android_image_get_kernel(buf
, images
->verify
,
831 printf("Wrong Image Format for %s command\n", cmdtp
->name
);
832 bootstage_error(BOOTSTAGE_ID_FIT_KERNEL_INFO
);
836 debug(" kernel data at 0x%08lx, len = 0x%08lx (%ld)\n",
837 *os_data
, *os_len
, *os_len
);
842 #endif /* ndef USE_HOSTCC */