2 * (C) Copyright 2000-2006
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
36 #include <environment.h>
38 #include <asm/byteorder.h>
40 #ifdef CFG_HUSH_PARSER
44 DECLARE_GLOBAL_DATA_PTR
;
46 extern int gunzip (void *dst
, int dstlen
, unsigned char *src
, unsigned long *lenp
);
48 #define CFG_BOOTM_LEN 0x800000 /* use 8MByte as default max gunzip size */
52 extern void bz_internal_error(int);
55 #if defined(CONFIG_CMD_IMI)
56 static int image_info (unsigned long addr
);
59 #if defined(CONFIG_CMD_IMLS)
61 extern flash_info_t flash_info
[]; /* info for FLASH chips */
62 static int do_imls (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[]);
65 #ifdef CONFIG_SILENT_CONSOLE
66 static void fixup_silent_linux (void);
69 static image_header_t
*image_get_kernel (ulong img_addr
, int verify
);
70 #if defined(CONFIG_FIT)
71 static int fit_check_kernel (const void *fit
, int os_noffset
, int verify
);
74 static void *boot_get_kernel (cmd_tbl_t
*cmdtp
, int flag
,int argc
, char *argv
[],
75 bootm_headers_t
*images
, ulong
*os_data
, ulong
*os_len
);
76 extern int do_reset (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[]);
79 * Continue booting an OS image; caller already has:
80 * - copied image header to global variable `header'
81 * - checked header magic number, checksums (both header & image),
82 * - verified image architecture (PPC) and type (KERNEL or MULTI),
83 * - loaded (first part of) image to header load address,
84 * - disabled interrupts.
86 typedef void boot_os_fn (cmd_tbl_t
*cmdtp
, int flag
,
87 int argc
, char *argv
[],
88 bootm_headers_t
*images
); /* pointers to os/initrd/fdt */
90 extern boot_os_fn do_bootm_linux
;
91 static boot_os_fn do_bootm_netbsd
;
92 #if defined(CONFIG_LYNXKDI)
93 static boot_os_fn do_bootm_lynxkdi
;
94 extern void lynxkdi_boot (image_header_t
*);
96 static boot_os_fn do_bootm_rtems
;
97 #if defined(CONFIG_CMD_ELF)
98 static boot_os_fn do_bootm_vxworks
;
99 static boot_os_fn do_bootm_qnxelf
;
100 int do_bootvx (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[]);
101 int do_bootelf (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[]);
103 #if defined(CONFIG_ARTOS) && defined(CONFIG_PPC)
104 extern uchar (*env_get_char
)(int); /* Returns a character from the environment */
105 static boot_os_fn do_bootm_artos
;
108 ulong load_addr
= CFG_LOAD_ADDR
; /* Default Load Address */
109 static bootm_headers_t images
; /* pointers to os/initrd/fdt images */
111 void __board_lmb_reserve(struct lmb
*lmb
)
113 /* please define platform specific board_lmb_reserve() */
115 void board_lmb_reserve(struct lmb
*lmb
) __attribute__((weak
, alias("__board_lmb_reserve")));
118 /*******************************************************************/
119 /* bootm - boot application image from image in memory */
120 /*******************************************************************/
121 int do_bootm (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[])
124 const char *type_name
;
125 uint unc_len
= CFG_BOOTM_LEN
;
126 uint8_t comp
, type
, os
;
129 ulong os_data
, os_len
;
130 ulong image_start
, image_end
;
131 ulong load_start
, load_end
;
132 ulong mem_start
, mem_size
;
133 #if defined(CONFIG_FIT)
139 memset ((void *)&images
, 0, sizeof (images
));
140 images
.verify
= getenv_verify();
141 images
.autostart
= getenv_autostart();
146 mem_start
= getenv_bootm_low();
147 mem_size
= getenv_bootm_size();
149 lmb_add(&lmb
, mem_start
, mem_size
);
151 board_lmb_reserve(&lmb
);
153 /* get kernel image header, start address and length */
154 os_hdr
= boot_get_kernel (cmdtp
, flag
, argc
, argv
,
155 &images
, &os_data
, &os_len
);
157 puts ("ERROR: can't get kernel image!\n");
161 show_boot_progress (6);
163 /* get image parameters */
164 switch (genimg_get_format (os_hdr
)) {
165 case IMAGE_FORMAT_LEGACY
:
166 type
= image_get_type (os_hdr
);
167 comp
= image_get_comp (os_hdr
);
168 os
= image_get_os (os_hdr
);
170 image_end
= image_get_image_end (os_hdr
);
171 load_start
= image_get_load (os_hdr
);
173 #if defined(CONFIG_FIT)
174 case IMAGE_FORMAT_FIT
:
175 os_noffset
= fit_image_get_node (images
.fit_hdr_os
,
176 images
.fit_uname_os
);
177 if (os_noffset
< 0) {
178 printf ("Can't get image node for '%s'!\n",
179 images
.fit_uname_os
);
183 if (fit_image_get_type (images
.fit_hdr_os
, os_noffset
, &type
)) {
184 puts ("Can't get image type!\n");
188 if (fit_image_get_comp (images
.fit_hdr_os
, os_noffset
, &comp
)) {
189 puts ("Can't get image compression!\n");
193 if (fit_image_get_os (images
.fit_hdr_os
, os_noffset
, &os
)) {
194 puts ("Can't get image OS!\n");
198 image_end
= fit_get_end (images
.fit_hdr_os
);
200 if (fit_image_get_load (images
.fit_hdr_os
, os_noffset
,
202 puts ("Can't get image load address!\n");
208 puts ("ERROR: unknown image format type!\n");
212 image_start
= (ulong
)os_hdr
;
214 type_name
= genimg_get_type_name (type
);
217 * We have reached the point of no return: we are going to
218 * overwrite all exception vector code, so we cannot easily
219 * recover from any failures any more...
221 iflag
= disable_interrupts();
223 #ifdef CONFIG_AMIGAONEG3SE
225 * We've possible left the caches enabled during
226 * bios emulation, so turn them off again
229 invalidate_l1_instruction_cache();
236 if (load_start
== (ulong
)os_hdr
) {
237 printf (" XIP %s ... ", type_name
);
239 printf (" Loading %s ... ", type_name
);
241 memmove_wd ((void *)load_start
,
242 (void *)os_data
, os_len
, CHUNKSZ
);
244 load_end
= load_start
+ os_len
;
249 printf (" Uncompressing %s ... ", type_name
);
250 if (gunzip ((void *)load_start
, unc_len
,
251 (uchar
*)os_data
, &os_len
) != 0) {
252 puts ("GUNZIP ERROR - must RESET board to recover\n");
253 show_boot_progress (-6);
254 do_reset (cmdtp
, flag
, argc
, argv
);
257 load_end
= load_start
+ os_len
;
261 printf (" Uncompressing %s ... ", type_name
);
263 * If we've got less than 4 MB of malloc() space,
264 * use slower decompression algorithm which requires
265 * at most 2300 KB of memory.
267 int i
= BZ2_bzBuffToBuffDecompress ((char*)load_start
,
268 &unc_len
, (char *)os_data
, os_len
,
269 CFG_MALLOC_LEN
< (4096 * 1024), 0);
271 printf ("BUNZIP2 ERROR %d - must RESET board to recover\n", i
);
272 show_boot_progress (-6);
273 do_reset (cmdtp
, flag
, argc
, argv
);
276 load_end
= load_start
+ unc_len
;
278 #endif /* CONFIG_BZIP2 */
282 printf ("Unimplemented compression type %d\n", comp
);
283 show_boot_progress (-7);
287 debug (" kernel loaded at 0x%08lx, end = 0x%08lx\n", load_start
, load_end
);
288 show_boot_progress (7);
290 if ((load_start
< image_end
) && (load_end
> image_start
)) {
291 debug ("image_start = 0x%lX, image_end = 0x%lx\n", image_start
, image_end
);
292 debug ("load_start = 0x%lx, load_end = 0x%lx\n", load_start
, load_end
);
294 puts ("ERROR: image overwritten - must RESET the board to recover.\n");
295 do_reset (cmdtp
, flag
, argc
, argv
);
298 show_boot_progress (8);
300 lmb_reserve(&lmb
, load_start
, (load_end
- load_start
));
303 default: /* handled by (original) Linux case */
305 #ifdef CONFIG_SILENT_CONSOLE
306 fixup_silent_linux();
308 do_bootm_linux (cmdtp
, flag
, argc
, argv
, &images
);
312 do_bootm_netbsd (cmdtp
, flag
, argc
, argv
, &images
);
315 #ifdef CONFIG_LYNXKDI
317 do_bootm_lynxkdi (cmdtp
, flag
, argc
, argv
, &images
);
322 do_bootm_rtems (cmdtp
, flag
, argc
, argv
, &images
);
325 #if defined(CONFIG_CMD_ELF)
327 do_bootm_vxworks (cmdtp
, flag
, argc
, argv
, &images
);
331 do_bootm_qnxelf (cmdtp
, flag
, argc
, argv
, &images
);
337 do_bootm_artos (cmdtp
, flag
, argc
, argv
, &images
);
342 show_boot_progress (-9);
344 puts ("\n## Control returned to monitor - resetting...\n");
345 if (images
.autostart
)
346 do_reset (cmdtp
, flag
, argc
, argv
);
348 if (!images
.autostart
&& iflag
)
355 * image_get_kernel - verify legacy format kernel image
356 * @img_addr: in RAM address of the legacy format image to be verified
357 * @verify: data CRC verification flag
359 * image_get_kernel() verifies legacy image integrity and returns pointer to
360 * legacy image header if image verification was completed successfully.
363 * pointer to a legacy image header if valid image was found
364 * otherwise return NULL
366 static image_header_t
*image_get_kernel (ulong img_addr
, int verify
)
368 image_header_t
*hdr
= (image_header_t
*)img_addr
;
370 if (!image_check_magic(hdr
)) {
371 puts ("Bad Magic Number\n");
372 show_boot_progress (-1);
375 show_boot_progress (2);
377 if (!image_check_hcrc (hdr
)) {
378 puts ("Bad Header Checksum\n");
379 show_boot_progress (-2);
383 show_boot_progress (3);
384 image_print_contents (hdr
);
387 puts (" Verifying Checksum ... ");
388 if (!image_check_dcrc (hdr
)) {
389 printf ("Bad Data CRC\n");
390 show_boot_progress (-3);
395 show_boot_progress (4);
397 if (!image_check_target_arch (hdr
)) {
398 printf ("Unsupported Architecture 0x%x\n", image_get_arch (hdr
));
399 show_boot_progress (-4);
406 * fit_check_kernel - verify FIT format kernel subimage
407 * @fit_hdr: pointer to the FIT image header
408 * os_noffset: kernel subimage node offset within FIT image
409 * @verify: data CRC verification flag
411 * fit_check_kernel() verifies integrity of the kernel subimage and from
412 * specified FIT image.
418 #if defined (CONFIG_FIT)
419 static int fit_check_kernel (const void *fit
, int os_noffset
, int verify
)
421 fit_image_print (fit
, os_noffset
, " ");
424 puts (" Verifying Hash Integrity ... ");
425 if (!fit_image_check_hashes (fit
, os_noffset
)) {
426 puts ("Bad Data Hash\n");
432 if (!fit_image_check_target_arch (fit
, os_noffset
)) {
433 puts ("Unsupported Architecture\n");
437 if (!fit_image_check_type (fit
, os_noffset
, IH_TYPE_KERNEL
)) {
438 puts ("Not a kernel image\n");
444 #endif /* CONFIG_FIT */
447 * boot_get_kernel - find kernel image
448 * @os_data: pointer to a ulong variable, will hold os data start address
449 * @os_len: pointer to a ulong variable, will hold os data length
451 * boot_get_kernel() tries to find a kernel image, verifies its integrity
452 * and locates kernel data.
455 * pointer to image header if valid image was found, plus kernel start
456 * address and length, otherwise NULL
458 static void *boot_get_kernel (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[],
459 bootm_headers_t
*images
, ulong
*os_data
, ulong
*os_len
)
463 #if defined(CONFIG_FIT)
465 const char *fit_uname_config
= NULL
;
466 const char *fit_uname_kernel
= NULL
;
473 /* find out kernel image address */
475 img_addr
= load_addr
;
476 debug ("* kernel: default image load address = 0x%08lx\n",
478 #if defined(CONFIG_FIT)
479 } else if (fit_parse_conf (argv
[1], load_addr
, &img_addr
,
480 &fit_uname_config
)) {
481 debug ("* kernel: config '%s' from image at 0x%08lx\n",
482 fit_uname_config
, img_addr
);
483 } else if (fit_parse_subimage (argv
[1], load_addr
, &img_addr
,
484 &fit_uname_kernel
)) {
485 debug ("* kernel: subimage '%s' from image at 0x%08lx\n",
486 fit_uname_kernel
, img_addr
);
489 img_addr
= simple_strtoul(argv
[1], NULL
, 16);
490 debug ("* kernel: cmdline image address = 0x%08lx\n", img_addr
);
493 show_boot_progress (1);
495 /* copy from dataflash if needed */
496 img_addr
= genimg_get_image (img_addr
);
498 /* check image type, for FIT images get FIT kernel node */
499 *os_data
= *os_len
= 0;
500 switch (genimg_get_format ((void *)img_addr
)) {
501 case IMAGE_FORMAT_LEGACY
:
502 printf ("## Booting kernel from Legacy Image at %08lx ...\n",
504 hdr
= image_get_kernel (img_addr
, images
->verify
);
507 show_boot_progress (5);
509 /* get os_data and os_len */
510 switch (image_get_type (hdr
)) {
512 *os_data
= image_get_data (hdr
);
513 *os_len
= image_get_data_size (hdr
);
516 image_multi_getimg (hdr
, 0, os_data
, os_len
);
519 printf ("Wrong Image Type for %s command\n", cmdtp
->name
);
520 show_boot_progress (-5);
523 images
->legacy_hdr_os
= hdr
;
524 images
->legacy_hdr_valid
= 1;
527 #if defined(CONFIG_FIT)
528 case IMAGE_FORMAT_FIT
:
529 fit_hdr
= (void *)img_addr
;
530 printf ("## Booting kernel from FIT Image at %08lx ...\n",
533 if (!fit_check_format (fit_hdr
)) {
534 puts ("Bad FIT kernel image format!\n");
538 if (!fit_uname_kernel
) {
540 * no kernel image node unit name, try to get config
541 * node first. If config unit node name is NULL
542 * fit_conf_get_node() will try to find default config node
544 conf_noffset
= fit_conf_get_node (fit_hdr
, fit_uname_config
);
545 if (conf_noffset
< 0)
548 os_noffset
= fit_conf_get_kernel_node (fit_hdr
, conf_noffset
);
549 fit_uname_kernel
= fit_get_name (fit_hdr
, os_noffset
, NULL
);
551 /* get kernel component image node offset */
552 os_noffset
= fit_image_get_node (fit_hdr
, fit_uname_kernel
);
557 printf (" Trying '%s' kernel subimage\n", fit_uname_kernel
);
559 if (!fit_check_kernel (fit_hdr
, os_noffset
, images
->verify
))
562 /* get kernel image data address and length */
563 if (fit_image_get_data (fit_hdr
, os_noffset
, &data
, &len
)) {
564 puts ("Could not find kernel subimage data!\n");
569 *os_data
= (ulong
)data
;
570 images
->fit_hdr_os
= fit_hdr
;
571 images
->fit_uname_os
= fit_uname_kernel
;
575 printf ("Wrong Image Format for %s command\n", cmdtp
->name
);
579 debug (" kernel data at 0x%08lx, len = 0x%08lx (%d)\n",
580 *os_data
, *os_len
, *os_len
);
582 return (void *)img_addr
;
586 bootm
, CFG_MAXARGS
, 1, do_bootm
,
587 "bootm - boot application image from memory\n",
588 "[addr [arg ...]]\n - boot application image stored in memory\n"
589 "\tpassing arguments 'arg ...'; when booting a Linux kernel,\n"
590 "\t'arg' can be the address of an initrd image\n"
591 #if defined(CONFIG_OF_LIBFDT)
592 "\tWhen booting a Linux kernel which requires a flat device-tree\n"
593 "\ta third argument is required which is the address of the\n"
594 "\tdevice-tree blob. To boot that kernel without an initrd image,\n"
595 "\tuse a '-' for the second argument. If you do not pass a third\n"
596 "\ta bd_info struct will be passed instead\n"
598 #if defined(CONFIG_FIT)
599 "\t\nFor the new multi component uImage format (FIT) addresses\n"
600 "\tmust be extened to include component or configuration unit name:\n"
601 "\taddr:<subimg_uname> - direct component image specification\n"
602 "\taddr#<conf_uname> - configuration specification\n"
603 "\tUse iminfo command to get the list of existing component\n"
604 "\timages and configurations.\n"
608 /*******************************************************************/
609 /* bootd - boot default image */
610 /*******************************************************************/
611 #if defined(CONFIG_CMD_BOOTD)
612 int do_bootd (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[])
616 #ifndef CFG_HUSH_PARSER
617 if (run_command (getenv ("bootcmd"), flag
) < 0)
620 if (parse_string_outer (getenv ("bootcmd"),
621 FLAG_PARSE_SEMICOLON
| FLAG_EXIT_FROM_LOOP
) != 0)
628 boot
, 1, 1, do_bootd
,
629 "boot - boot default, i.e., run 'bootcmd'\n",
633 /* keep old command name "bootd" for backward compatibility */
635 bootd
, 1, 1, do_bootd
,
636 "bootd - boot default, i.e., run 'bootcmd'\n",
643 /*******************************************************************/
644 /* iminfo - print header info for a requested image */
645 /*******************************************************************/
646 #if defined(CONFIG_CMD_IMI)
647 int do_iminfo (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[])
654 return image_info (load_addr
);
657 for (arg
= 1; arg
< argc
; ++arg
) {
658 addr
= simple_strtoul (argv
[arg
], NULL
, 16);
659 if (image_info (addr
) != 0)
665 static int image_info (ulong addr
)
667 void *hdr
= (void *)addr
;
669 printf ("\n## Checking Image at %08lx ...\n", addr
);
671 switch (genimg_get_format (hdr
)) {
672 case IMAGE_FORMAT_LEGACY
:
673 puts (" Legacy image found\n");
674 if (!image_check_magic (hdr
)) {
675 puts (" Bad Magic Number\n");
679 if (!image_check_hcrc (hdr
)) {
680 puts (" Bad Header Checksum\n");
684 image_print_contents (hdr
);
686 puts (" Verifying Checksum ... ");
687 if (!image_check_dcrc (hdr
)) {
688 puts (" Bad Data CRC\n");
693 #if defined(CONFIG_FIT)
694 case IMAGE_FORMAT_FIT
:
695 puts (" FIT image found\n");
697 if (!fit_check_format (hdr
)) {
698 puts ("Bad FIT image format!\n");
702 fit_print_contents (hdr
);
706 puts ("Unknown image format!\n");
714 iminfo
, CFG_MAXARGS
, 1, do_iminfo
,
715 "iminfo - print header information for application image\n",
717 " - print header information for application image starting at\n"
718 " address 'addr' in memory; this includes verification of the\n"
719 " image contents (magic number, header and payload checksums)\n"
724 /*******************************************************************/
725 /* imls - list all images found in flash */
726 /*******************************************************************/
727 #if defined(CONFIG_CMD_IMLS)
728 int do_imls (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[])
734 for (i
= 0, info
= &flash_info
[0];
735 i
< CFG_MAX_FLASH_BANKS
; ++i
, ++info
) {
737 if (info
->flash_id
== FLASH_UNKNOWN
)
739 for (j
= 0; j
< info
->sector_count
; ++j
) {
741 hdr
= (void *)info
->start
[j
];
745 switch (genimg_get_format (hdr
)) {
746 case IMAGE_FORMAT_LEGACY
:
747 if (!image_check_hcrc (hdr
))
750 printf ("Legacy Image at %08lX:\n", (ulong
)hdr
);
751 image_print_contents (hdr
);
753 puts (" Verifying Checksum ... ");
754 if (!image_check_dcrc (hdr
)) {
755 puts ("Bad Data CRC\n");
760 #if defined(CONFIG_FIT)
761 case IMAGE_FORMAT_FIT
:
762 if (!fit_check_format (hdr
))
765 printf ("FIT Image at %08lX:\n", (ulong
)hdr
);
766 fit_print_contents (hdr
);
783 "imls - list all images found in flash\n",
785 " - Prints information about all images found at sector\n"
786 " boundaries in flash.\n"
790 /*******************************************************************/
791 /* helper routines */
792 /*******************************************************************/
793 #ifdef CONFIG_SILENT_CONSOLE
794 static void fixup_silent_linux ()
796 char buf
[256], *start
, *end
;
797 char *cmdline
= getenv ("bootargs");
799 /* Only fix cmdline when requested */
800 if (!(gd
->flags
& GD_FLG_SILENT
))
803 debug ("before silent fix-up: %s\n", cmdline
);
805 if ((start
= strstr (cmdline
, "console=")) != NULL
) {
806 end
= strchr (start
, ' ');
807 strncpy (buf
, cmdline
, (start
- cmdline
+ 8));
809 strcpy (buf
+ (start
- cmdline
+ 8), end
);
811 buf
[start
- cmdline
+ 8] = '\0';
813 strcpy (buf
, cmdline
);
814 strcat (buf
, " console=");
817 strcpy (buf
, "console=");
820 setenv ("bootargs", buf
);
821 debug ("after silent fix-up: %s\n", buf
);
823 #endif /* CONFIG_SILENT_CONSOLE */
826 /*******************************************************************/
827 /* OS booting routines */
828 /*******************************************************************/
830 static void do_bootm_netbsd (cmd_tbl_t
*cmdtp
, int flag
,
831 int argc
, char *argv
[],
832 bootm_headers_t
*images
)
834 void (*loader
)(bd_t
*, image_header_t
*, char *, char *);
835 image_header_t
*os_hdr
, *hdr
;
836 ulong kernel_data
, kernel_len
;
840 #if defined(CONFIG_FIT)
841 if (!images
->legacy_hdr_valid
) {
842 fit_unsupported_reset ("NetBSD");
843 do_reset (cmdtp
, flag
, argc
, argv
);
846 hdr
= images
->legacy_hdr_os
;
849 * Booting a (NetBSD) kernel image
851 * This process is pretty similar to a standalone application:
852 * The (first part of an multi-) image must be a stage-2 loader,
853 * which in turn is responsible for loading & invoking the actual
854 * kernel. The only differences are the parameters being passed:
855 * besides the board info strucure, the loader expects a command
856 * line, the name of the console device, and (optionally) the
857 * address of the original image header.
860 if (image_check_type (hdr
, IH_TYPE_MULTI
)) {
861 image_multi_getimg (hdr
, 1, &kernel_data
, &kernel_len
);
867 #if defined (CONFIG_8xx_CONS_SMC1)
869 #elif defined (CONFIG_8xx_CONS_SMC2)
871 #elif defined (CONFIG_8xx_CONS_SCC2)
873 #elif defined (CONFIG_8xx_CONS_SCC3)
881 for (i
= 2, len
= 0; i
< argc
; i
+= 1)
882 len
+= strlen (argv
[i
]) + 1;
883 cmdline
= malloc (len
);
885 for (i
= 2, len
= 0; i
< argc
; i
+= 1) {
887 cmdline
[len
++] = ' ';
888 strcpy (&cmdline
[len
], argv
[i
]);
889 len
+= strlen (argv
[i
]);
891 } else if ((cmdline
= getenv ("bootargs")) == NULL
) {
895 loader
= (void (*)(bd_t
*, image_header_t
*, char *, char *))image_get_ep (hdr
);
897 printf ("## Transferring control to NetBSD stage-2 loader (at address %08lx) ...\n",
900 show_boot_progress (15);
903 * NetBSD Stage-2 Loader Parameters:
904 * r3: ptr to board info data
907 * r6: boot args string
909 (*loader
) (gd
->bd
, os_hdr
, consdev
, cmdline
);
912 #ifdef CONFIG_LYNXKDI
913 static void do_bootm_lynxkdi (cmd_tbl_t
*cmdtp
, int flag
,
914 int argc
, char *argv
[],
915 bootm_headers_t
*images
)
917 image_header_t
*hdr
= images
->legacy_hdr_os
;
919 #if defined(CONFIG_FIT)
920 if (!images
->legacy_hdr_valid
) {
921 fit_unsupported_reset ("Lynx");
922 do_reset (cmdtp
, flag
, argc
, argv
);
926 lynxkdi_boot ((image_header_t
*)hdr
);
928 #endif /* CONFIG_LYNXKDI */
930 static void do_bootm_rtems (cmd_tbl_t
*cmdtp
, int flag
,
931 int argc
, char *argv
[],
932 bootm_headers_t
*images
)
934 image_header_t
*hdr
= images
->legacy_hdr_os
;
935 void (*entry_point
)(bd_t
*);
937 #if defined(CONFIG_FIT)
938 if (!images
->legacy_hdr_valid
) {
939 fit_unsupported_reset ("RTEMS");
940 do_reset (cmdtp
, flag
, argc
, argv
);
944 entry_point
= (void (*)(bd_t
*))image_get_ep (hdr
);
946 printf ("## Transferring control to RTEMS (at address %08lx) ...\n",
949 show_boot_progress (15);
953 * r3: ptr to board info data
955 (*entry_point
)(gd
->bd
);
958 #if defined(CONFIG_CMD_ELF)
959 static void do_bootm_vxworks (cmd_tbl_t
*cmdtp
, int flag
,
960 int argc
, char *argv
[],
961 bootm_headers_t
*images
)
964 image_header_t
*hdr
= images
->legacy_hdr_os
;
966 #if defined(CONFIG_FIT)
968 fit_unsupported_reset ("VxWorks");
969 do_reset (cmdtp
, flag
, argc
, argv
);
973 sprintf(str
, "%x", image_get_ep (hdr
)); /* write entry-point into string */
974 setenv("loadaddr", str
);
975 do_bootvx(cmdtp
, 0, 0, NULL
);
978 static void do_bootm_qnxelf(cmd_tbl_t
*cmdtp
, int flag
,
979 int argc
, char *argv
[],
980 bootm_headers_t
*images
)
984 image_header_t
*hdr
= images
->legacy_hdr_os
;
986 #if defined(CONFIG_FIT)
987 if (!images
->legacy_hdr_valid
) {
988 fit_unsupported_reset ("QNX");
989 do_reset (cmdtp
, flag
, argc
, argv
);
993 sprintf(str
, "%x", image_get_ep (hdr
)); /* write entry-point into string */
994 local_args
[0] = argv
[0];
995 local_args
[1] = str
; /* and provide it via the arguments */
996 do_bootelf(cmdtp
, 0, 2, local_args
);
1000 #if defined(CONFIG_ARTOS) && defined(CONFIG_PPC)
1001 static void do_bootm_artos (cmd_tbl_t
*cmdtp
, int flag
,
1002 int argc
, char *argv
[],
1003 bootm_headers_t
*images
)
1008 int i
, j
, nxt
, len
, envno
, envsz
;
1010 void (*entry
)(bd_t
*bd
, char *cmdline
, char **fwenv
, ulong top
);
1011 image_header_t
*hdr
= images
->legacy_hdr_os
;
1013 #if defined(CONFIG_FIT)
1014 if (!images
->legacy_hdr_valid
) {
1015 fit_unsupported_reset ("ARTOS");
1016 do_reset (cmdtp
, flag
, argc
, argv
);
1021 * Booting an ARTOS kernel image + application
1024 /* this used to be the top of memory, but was wrong... */
1026 /* get stack pointer */
1027 asm volatile ("mr %0,1" : "=r"(top
) );
1029 debug ("## Current stack ends at 0x%08lX ", top
);
1031 top
-= 2048; /* just to be sure */
1032 if (top
> CFG_BOOTMAPSZ
)
1033 top
= CFG_BOOTMAPSZ
;
1036 debug ("=> set upper limit to 0x%08lX\n", top
);
1038 /* first check the artos specific boot args, then the linux args*/
1039 if ((s
= getenv( "abootargs")) == NULL
&& (s
= getenv ("bootargs")) == NULL
)
1042 /* get length of cmdline, and place it */
1044 top
= (top
- (len
+ 1)) & ~0xF;
1045 cmdline
= (char *)top
;
1046 debug ("## cmdline at 0x%08lX ", top
);
1047 strcpy (cmdline
, s
);
1050 top
= (top
- sizeof (bd_t
)) & ~0xF;
1051 debug ("## bd at 0x%08lX ", top
);
1053 memcpy (kbd
, gd
->bd
, sizeof (bd_t
));
1055 /* first find number of env entries, and their size */
1058 for (i
= 0; env_get_char (i
) != '\0'; i
= nxt
+ 1) {
1059 for (nxt
= i
; env_get_char (nxt
) != '\0'; ++nxt
)
1062 envsz
+= (nxt
- i
) + 1; /* plus trailing zero */
1064 envno
++; /* plus the terminating zero */
1065 debug ("## %u envvars total size %u ", envno
, envsz
);
1067 top
= (top
- sizeof (char **) * envno
) & ~0xF;
1068 fwenv
= (char **)top
;
1069 debug ("## fwenv at 0x%08lX ", top
);
1071 top
= (top
- envsz
) & ~0xF;
1076 for (i
= 0; env_get_char (i
) != '\0'; i
= nxt
+ 1) {
1077 for (nxt
= i
; env_get_char (nxt
) != '\0'; ++nxt
)
1080 for (j
= i
; j
< nxt
; ++j
)
1081 *s
++ = env_get_char (j
);
1084 *ss
++ = NULL
; /* terminate */
1086 entry
= (void (*)(bd_t
*, char *, char **, ulong
))image_get_ep (hdr
);
1087 (*entry
) (kbd
, cmdline
, fwenv
, top
);