2 * (C) Copyright 2000-2002
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,
34 #include <asm/byteorder.h>
35 #if (CONFIG_COMMANDS & CFG_CMD_DATE) || defined(CONFIG_TIMESTAMP)
39 #ifdef CFG_HUSH_PARSER
43 #ifdef CONFIG_SHOW_BOOT_PROGRESS
44 # include <status_led.h>
45 # define SHOW_BOOT_PROGRESS(arg) show_boot_progress(arg)
47 # define SHOW_BOOT_PROGRESS(arg)
50 #ifdef CFG_INIT_RAM_LOCK
51 #include <asm/cache.h>
55 * Some systems (for example LWMON) have very short watchdog periods;
56 * we must make sure to split long operations like memmove() or
57 * crc32() into reasonable chunks.
59 #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
60 # define CHUNKSZ (64 * 1024)
63 int gunzip (void *, int, unsigned char *, int *);
65 static void *zalloc(void *, unsigned, unsigned);
66 static void zfree(void *, void *, unsigned);
68 #if (CONFIG_COMMANDS & CFG_CMD_IMI)
69 static int image_info (unsigned long addr);
71 static void print_type (image_header_t *hdr);
74 * Continue booting an OS image; caller already has:
75 * - copied image header to global variable `header'
76 * - checked header magic number, checksums (both header & image),
77 * - verified image architecture (PPC) and type (KERNEL or MULTI),
78 * - loaded (first part of) image to header load address,
79 * - disabled interrupts.
81 typedef void boot_os_Fcn (cmd_tbl_t *cmdtp, int flag,
82 int argc, char *argv[],
83 ulong addr, /* of image to boot */
84 ulong *len_ptr, /* multi-file image length table */
85 int verify); /* getenv("verify")[0] != 'n' */
88 static boot_os_Fcn do_bootm_linux;
90 extern boot_os_Fcn do_bootm_linux;
92 static boot_os_Fcn do_bootm_netbsd;
93 #if (CONFIG_COMMANDS & CFG_CMD_ELF)
94 static boot_os_Fcn do_bootm_vxworks;
95 static boot_os_Fcn do_bootm_qnxelf;
96 int do_bootvx ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[] );
97 int do_bootelf (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[] );
98 #endif /* CFG_CMD_ELF */
100 image_header_t header;
102 ulong load_addr = CFG_LOAD_ADDR; /* Default Load Address */
104 int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
108 ulong data, len, checksum;
112 int (*appl)(cmd_tbl_t *, int, int, char *[]);
113 image_header_t *hdr = &header;
115 s = getenv ("verify");
116 verify = (s && (*s == 'n')) ? 0 : 1;
121 addr = simple_strtoul(argv[1], NULL, 16);
124 SHOW_BOOT_PROGRESS (1);
125 printf ("## Booting image at %08lx ...\n", addr);
127 /* Copy header so we can blank CRC field for re-calculation */
128 memmove (&header, (char *)addr, sizeof(image_header_t));
130 if (ntohl(hdr->ih_magic) != IH_MAGIC) {
131 printf ("Bad Magic Number\n");
132 SHOW_BOOT_PROGRESS (-1);
135 SHOW_BOOT_PROGRESS (2);
137 data = (ulong)&header;
138 len = sizeof(image_header_t);
140 checksum = ntohl(hdr->ih_hcrc);
143 if (crc32 (0, (char *)data, len) != checksum) {
144 printf ("Bad Header Checksum\n");
145 SHOW_BOOT_PROGRESS (-2);
148 SHOW_BOOT_PROGRESS (3);
150 /* for multi-file images we need the data part, too */
151 print_image_hdr ((image_header_t *)addr);
153 data = addr + sizeof(image_header_t);
154 len = ntohl(hdr->ih_size);
157 printf (" Verifying Checksum ... ");
158 if (crc32 (0, (char *)data, len) != ntohl(hdr->ih_dcrc)) {
159 printf ("Bad Data CRC\n");
160 SHOW_BOOT_PROGRESS (-3);
165 SHOW_BOOT_PROGRESS (4);
167 len_ptr = (ulong *)data;
169 if (hdr->ih_arch != IH_CPU_PPC && hdr->ih_arch != IH_CPU_ARM) {
170 printf ("Unsupported Architecture\n");
171 SHOW_BOOT_PROGRESS (-4);
174 SHOW_BOOT_PROGRESS (5);
176 switch (hdr->ih_type) {
177 case IH_TYPE_STANDALONE: name = "Standalone Application";
179 case IH_TYPE_KERNEL: name = "Kernel Image";
181 case IH_TYPE_MULTI: name = "Multi-File Image";
182 len = ntohl(len_ptr[0]);
183 /* OS kernel is always the first image */
184 data += 8; /* kernel_len + terminator */
185 for (i=1; len_ptr[i]; ++i)
188 default: printf ("Wrong Image Type for %s command\n", cmdtp->name);
189 SHOW_BOOT_PROGRESS (-5);
192 SHOW_BOOT_PROGRESS (6);
195 * We have reached the point of no return: we are going to
196 * overwrite all exception vector code, so we cannot easily
197 * recover from any failures any more...
200 iflag = disable_interrupts();
202 switch (hdr->ih_comp) {
204 if(hdr->ih_load == addr) {
205 printf (" XIP %s ... ", name);
207 #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
209 void *to = (void *)ntohl(hdr->ih_load);
210 void *from = (void *)data;
212 printf (" Loading %s ... ", name);
215 size_t tail = (l > CHUNKSZ) ? CHUNKSZ : l;
217 memmove (to, from, tail);
222 #else /* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
223 memmove ((void *) ntohl(hdr->ih_load), (uchar *)data, len);
224 #endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
228 printf (" Uncompressing %s ... ", name);
229 if (gunzip ((void *)ntohl(hdr->ih_load), 0x400000,
230 (uchar *)data, (int *)&len) != 0) {
231 printf ("GUNZIP ERROR - must RESET board to recover\n");
232 SHOW_BOOT_PROGRESS (-6);
233 do_reset (cmdtp, flag, argc, argv);
239 printf ("Unimplemented compression type %d\n", hdr->ih_comp);
240 SHOW_BOOT_PROGRESS (-7);
244 SHOW_BOOT_PROGRESS (7);
246 switch (hdr->ih_type) {
247 case IH_TYPE_STANDALONE:
248 appl = (int (*)(cmd_tbl_t *, int, int, char *[]))ntohl(hdr->ih_ep);
252 (*appl)(cmdtp, flag, argc-1, &argv[1]);
261 printf ("Can't boot image type %d\n", hdr->ih_type);
262 SHOW_BOOT_PROGRESS (-8);
265 SHOW_BOOT_PROGRESS (8);
267 switch (hdr->ih_os) {
268 default: /* handled by (original) Linux case */
270 do_bootm_linux (cmdtp, flag, argc, argv,
271 addr, len_ptr, verify);
274 do_bootm_netbsd (cmdtp, flag, argc, argv,
275 addr, len_ptr, verify);
277 #if (CONFIG_COMMANDS & CFG_CMD_ELF)
279 do_bootm_vxworks (cmdtp, flag, argc, argv,
280 addr, len_ptr, verify);
283 do_bootm_qnxelf (cmdtp, flag, argc, argv,
284 addr, len_ptr, verify);
286 #endif /* CFG_CMD_ELF */
289 SHOW_BOOT_PROGRESS (-9);
291 printf ("\n## Control returned to monitor - resetting...\n");
292 do_reset (cmdtp, flag, argc, argv);
299 do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
300 int argc, char *argv[],
305 DECLARE_GLOBAL_DATA_PTR;
309 ulong initrd_start, initrd_end;
310 ulong cmd_start, cmd_end;
316 void (*kernel)(bd_t *, ulong, ulong, ulong, ulong);
317 image_header_t *hdr = &header;
319 if ((s = getenv ("initrd_high")) != NULL) {
320 /* a value of "no" or a similar string will act like 0,
321 * turning the "load high" feature off. This is intentional.
323 initrd_high = simple_strtoul(s, NULL, 16);
324 } else { /* not set, no restrictions to load high */
329 * Booting a (Linux) kernel image
331 * Allocate space for command line and board info - the
332 * address should be as high as possible within the reach of
333 * the kernel (see CFG_BOOTMAPSZ settings), but in unused
334 * memory, which means far enough below the current stack
338 asm( "mr %0,1": "=r"(sp) : );
341 printf ("## Current stack ends at 0x%08lX ", sp);
343 sp -= 2048; /* just to be sure */
344 if (sp > CFG_BOOTMAPSZ)
349 printf ("=> set upper limit to 0x%08lX\n", sp);
351 cmdline = (char *)((sp - CFG_BARGSIZE) & ~0xF);
352 kbd = (bd_t *)(((ulong)cmdline - sizeof(bd_t)) & ~0xF);
354 if ((s = getenv("bootargs")) == NULL)
359 cmd_start = (ulong)&cmdline[0];
360 cmd_end = cmd_start + strlen(cmdline);
365 printf ("## cmdline at 0x%08lX ... 0x%08lX\n", cmd_start, cmd_end);
367 do_bdinfo (NULL, 0, 0, NULL);
370 if ((s = getenv ("clocks_in_mhz")) != NULL) {
371 /* convert all clock information to MHz */
372 kbd->bi_intfreq /= 1000000L;
373 kbd->bi_busfreq /= 1000000L;
374 #if defined(CONFIG_8260)
375 kbd->bi_cpmfreq /= 1000000L;
376 kbd->bi_brgfreq /= 1000000L;
377 kbd->bi_sccfreq /= 1000000L;
378 kbd->bi_vco /= 1000000L;
379 #endif /* CONFIG_8260 */
382 kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))hdr->ih_ep;
385 * Check if there is an initrd image
388 SHOW_BOOT_PROGRESS (9);
390 addr = simple_strtoul(argv[2], NULL, 16);
392 printf ("## Loading RAMDisk Image at %08lx ...\n", addr);
394 /* Copy header so we can blank CRC field for re-calculation */
395 memmove (&header, (char *)addr, sizeof(image_header_t));
397 if (hdr->ih_magic != IH_MAGIC) {
398 printf ("Bad Magic Number\n");
399 SHOW_BOOT_PROGRESS (-10);
400 do_reset (cmdtp, flag, argc, argv);
403 data = (ulong)&header;
404 len = sizeof(image_header_t);
406 checksum = hdr->ih_hcrc;
409 if (crc32 (0, (char *)data, len) != checksum) {
410 printf ("Bad Header Checksum\n");
411 SHOW_BOOT_PROGRESS (-11);
412 do_reset (cmdtp, flag, argc, argv);
415 SHOW_BOOT_PROGRESS (10);
417 print_image_hdr (hdr);
419 data = addr + sizeof(image_header_t);
424 #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
425 ulong cdata = data, edata = cdata + len;
426 #endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
428 printf (" Verifying Checksum ... ");
430 #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
432 while (cdata < edata) {
433 ulong chunk = edata - cdata;
437 csum = crc32 (csum, (char *)cdata, chunk);
442 #else /* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
443 csum = crc32 (0, (char *)data, len);
444 #endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
446 if (csum != hdr->ih_dcrc) {
447 printf ("Bad Data CRC\n");
448 SHOW_BOOT_PROGRESS (-12);
449 do_reset (cmdtp, flag, argc, argv);
454 SHOW_BOOT_PROGRESS (11);
456 if ((hdr->ih_os != IH_OS_LINUX) ||
457 (hdr->ih_arch != IH_CPU_PPC) ||
458 (hdr->ih_type != IH_TYPE_RAMDISK) ) {
459 printf ("No Linux PPC Ramdisk Image\n");
460 SHOW_BOOT_PROGRESS (-13);
461 do_reset (cmdtp, flag, argc, argv);
465 * Now check if we have a multifile image
467 } else if ((hdr->ih_type==IH_TYPE_MULTI) && (len_ptr[1])) {
468 u_long tail = ntohl(len_ptr[0]) % 4;
471 SHOW_BOOT_PROGRESS (13);
473 /* skip kernel length and terminator */
474 data = (ulong)(&len_ptr[2]);
475 /* skip any additional image length fields */
476 for (i=1; len_ptr[i]; ++i)
478 /* add kernel length, and align */
479 data += ntohl(len_ptr[0]);
484 len = ntohl(len_ptr[1]);
490 SHOW_BOOT_PROGRESS (14);
497 printf ("No initrd\n");
502 initrd_start = (ulong)kbd - len;
503 initrd_start &= ~(4096 - 1); /* align on page */
509 * the inital ramdisk does not need to be within
510 * CFG_BOOTMAPSZ as it is not accessed until after
511 * the mm system is initialised.
513 * do the stack bottom calculation again and see if
514 * the initrd will fit just below the monitor stack
515 * bottom without overwriting the area allocated
516 * above for command line args and board info.
518 asm( "mr %0,1": "=r"(nsp) : );
519 nsp -= 2048; /* just to be sure */
521 if (nsp > initrd_high) /* limit as specified */
524 nsp &= ~(4096 - 1); /* align on page */
529 SHOW_BOOT_PROGRESS (12);
531 printf ("## initrd at 0x%08lX ... 0x%08lX (len=%ld=0x%lX)\n",
532 data, data + len - 1, len, len);
534 initrd_end = initrd_start + len;
535 printf (" Loading Ramdisk to %08lx, end %08lx ... ",
536 initrd_start, initrd_end);
537 #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
540 void *to = (void *)initrd_start;
541 void *from = (void *)data;
544 size_t tail = (l > CHUNKSZ) ? CHUNKSZ : l;
546 memmove (to, from, tail);
552 #else /* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
553 memmove ((void *)initrd_start, (void *)data, len);
554 #endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
562 printf ("## Transferring control to Linux (at address %08lx) ...\n",
565 SHOW_BOOT_PROGRESS (15);
567 #ifdef CFG_INIT_RAM_LOCK
568 unlock_ram_in_cache();
571 * Linux Kernel Parameters:
572 * r3: ptr to board info data
573 * r4: initrd_start or 0 if no initrd
574 * r5: initrd_end - unused if r4 is 0
575 * r6: Start of command line string
576 * r7: End of command line string
578 (*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end);
580 #endif /* CONFIG_ARM */
583 do_bootm_netbsd (cmd_tbl_t *cmdtp, int flag,
584 int argc, char *argv[],
589 DECLARE_GLOBAL_DATA_PTR;
591 image_header_t *hdr = &header;
593 void (*loader)(bd_t *, image_header_t *, char *, char *);
594 image_header_t *img_addr;
600 * Booting a (NetBSD) kernel image
602 * This process is pretty similar to a standalone application:
603 * The (first part of an multi-) image must be a stage-2 loader,
604 * which in turn is responsible for loading & invoking the actual
605 * kernel. The only differences are the parameters being passed:
606 * besides the board info strucure, the loader expects a command
607 * line, the name of the console device, and (optionally) the
608 * address of the original image header.
612 if ((hdr->ih_type==IH_TYPE_MULTI) && (len_ptr[1]))
613 img_addr = (image_header_t *) addr;
617 #if defined (CONFIG_8xx_CONS_SMC1)
619 #elif defined (CONFIG_8xx_CONS_SMC2)
621 #elif defined (CONFIG_8xx_CONS_SCC2)
623 #elif defined (CONFIG_8xx_CONS_SCC3)
631 for (i=2, len=0 ; i<argc ; i+=1)
632 len += strlen (argv[i]) + 1;
633 cmdline = malloc (len);
635 for (i=2, len=0 ; i<argc ; i+=1) {
637 cmdline[len++] = ' ';
638 strcpy (&cmdline[len], argv[i]);
639 len += strlen (argv[i]);
641 } else if ((cmdline = getenv("bootargs")) == NULL) {
645 loader = (void (*)(bd_t *, image_header_t *, char *, char *)) hdr->ih_ep;
647 printf ("## Transferring control to NetBSD stage-2 loader (at address %08lx) ...\n",
650 SHOW_BOOT_PROGRESS (15);
653 * NetBSD Stage-2 Loader Parameters:
654 * r3: ptr to board info data
657 * r6: boot args string
659 (*loader) (gd->bd, img_addr, consdev, cmdline);
662 #if (CONFIG_COMMANDS & CFG_CMD_BOOTD)
663 int do_bootd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
666 #ifndef CFG_HUSH_PARSER
667 if (run_command (getenv ("bootcmd"), flag) < 0) rcode = 1;
669 if (parse_string_outer(getenv("bootcmd"),
670 FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP) != 0 ) rcode = 1;
676 #if (CONFIG_COMMANDS & CFG_CMD_IMI)
677 int do_iminfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
684 return image_info (load_addr);
687 for (arg=1; arg <argc; ++arg) {
688 addr = simple_strtoul(argv[arg], NULL, 16);
689 if (image_info (addr) != 0) rcode = 1;
694 static int image_info (ulong addr)
696 ulong data, len, checksum;
697 image_header_t *hdr = &header;
699 printf ("\n## Checking Image at %08lx ...\n", addr);
701 /* Copy header so we can blank CRC field for re-calculation */
702 memmove (&header, (char *)addr, sizeof(image_header_t));
704 if (ntohl(hdr->ih_magic) != IH_MAGIC) {
705 printf (" Bad Magic Number\n");
709 data = (ulong)&header;
710 len = sizeof(image_header_t);
712 checksum = ntohl(hdr->ih_hcrc);
715 if (crc32 (0, (char *)data, len) != checksum) {
716 printf (" Bad Header Checksum\n");
720 /* for multi-file images we need the data part, too */
721 print_image_hdr ((image_header_t *)addr);
723 data = addr + sizeof(image_header_t);
724 len = ntohl(hdr->ih_size);
726 printf (" Verifying Checksum ... ");
727 if (crc32 (0, (char *)data, len) != ntohl(hdr->ih_dcrc)) {
728 printf (" Bad Data CRC\n");
734 #endif /* CFG_CMD_IMI */
737 print_image_hdr (image_header_t *hdr)
739 #if (CONFIG_COMMANDS & CFG_CMD_DATE) || defined(CONFIG_TIMESTAMP)
740 time_t timestamp = (time_t)ntohl(hdr->ih_time);
744 printf (" Image Name: %.*s\n", IH_NMLEN, hdr->ih_name);
745 #if (CONFIG_COMMANDS & CFG_CMD_DATE) || defined(CONFIG_TIMESTAMP)
746 to_tm (timestamp, &tm);
747 printf (" Created: %4d-%02d-%02d %2d:%02d:%02d UTC\n",
748 tm.tm_year, tm.tm_mon, tm.tm_mday,
749 tm.tm_hour, tm.tm_min, tm.tm_sec);
750 #endif /* CFG_CMD_DATE, CONFIG_TIMESTAMP */
751 printf (" Image Type: "); print_type(hdr); printf ("\n");
752 printf (" Data Size: %d Bytes = ", ntohl(hdr->ih_size));
753 print_size (ntohl(hdr->ih_size), "\n");
754 printf (" Load Address: %08x\n", ntohl(hdr->ih_load));
755 printf (" Entry Point: %08x\n", ntohl(hdr->ih_ep));
757 if (hdr->ih_type == IH_TYPE_MULTI) {
760 ulong *len_ptr = (ulong *)((ulong)hdr + sizeof(image_header_t));
762 printf (" Contents:\n");
763 for (i=0; (len = ntohl(*len_ptr)); ++i, ++len_ptr) {
764 printf (" Image %d: %8ld Bytes = ", i, len);
765 print_size (len, "\n");
772 print_type (image_header_t *hdr)
774 char *os, *arch, *type, *comp;
776 switch (hdr->ih_os) {
777 case IH_OS_INVALID: os = "Invalid OS"; break;
778 case IH_OS_NETBSD: os = "NetBSD"; break;
779 case IH_OS_LINUX: os = "Linux"; break;
780 case IH_OS_VXWORKS: os = "VxWorks"; break;
781 case IH_OS_QNX: os = "QNX"; break;
782 case IH_OS_U_BOOT: os = "U-Boot"; break;
783 default: os = "Unknown OS"; break;
786 switch (hdr->ih_arch) {
787 case IH_CPU_INVALID: arch = "Invalid CPU"; break;
788 case IH_CPU_ALPHA: arch = "Alpha"; break;
789 case IH_CPU_ARM: arch = "ARM"; break;
790 case IH_CPU_I386: arch = "Intel x86"; break;
791 case IH_CPU_IA64: arch = "IA64"; break;
792 case IH_CPU_MIPS: arch = "MIPS"; break;
793 case IH_CPU_MIPS64: arch = "MIPS 64 Bit"; break;
794 case IH_CPU_PPC: arch = "PowerPC"; break;
795 case IH_CPU_S390: arch = "IBM S390"; break;
796 case IH_CPU_SH: arch = "SuperH"; break;
797 case IH_CPU_SPARC: arch = "SPARC"; break;
798 case IH_CPU_SPARC64: arch = "SPARC 64 Bit"; break;
799 default: arch = "Unknown Architecture"; break;
802 switch (hdr->ih_type) {
803 case IH_TYPE_INVALID: type = "Invalid Image"; break;
804 case IH_TYPE_STANDALONE:type = "Standalone Program"; break;
805 case IH_TYPE_KERNEL: type = "Kernel Image"; break;
806 case IH_TYPE_RAMDISK: type = "RAMDisk Image"; break;
807 case IH_TYPE_MULTI: type = "Multi-File Image"; break;
808 case IH_TYPE_FIRMWARE: type = "Firmware"; break;
809 case IH_TYPE_SCRIPT: type = "Script"; break;
810 default: type = "Unknown Image"; break;
813 switch (hdr->ih_comp) {
814 case IH_COMP_NONE: comp = "uncompressed"; break;
815 case IH_COMP_GZIP: comp = "gzip compressed"; break;
816 case IH_COMP_BZIP2: comp = "bzip2 compressed"; break;
817 default: comp = "unknown compression"; break;
820 printf ("%s %s %s (%s)", arch, os, type, comp);
823 #define ZALLOC_ALIGNMENT 16
825 static void *zalloc(void *x, unsigned items, unsigned size)
830 size = (size + ZALLOC_ALIGNMENT - 1) & ~(ZALLOC_ALIGNMENT - 1);
837 static void zfree(void *x, void *addr, unsigned nb)
843 #define EXTRA_FIELD 4
846 #define RESERVED 0xe0
850 int gunzip(void *dst, int dstlen, unsigned char *src, int *lenp)
858 if (src[2] != DEFLATED || (flags & RESERVED) != 0) {
859 printf ("Error: Bad gzipped data\n");
862 if ((flags & EXTRA_FIELD) != 0)
863 i = 12 + src[10] + (src[11] << 8);
864 if ((flags & ORIG_NAME) != 0)
865 while (src[i++] != 0)
867 if ((flags & COMMENT) != 0)
868 while (src[i++] != 0)
870 if ((flags & HEAD_CRC) != 0)
873 printf ("Error: gunzip out of data in header\n");
879 #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
880 s.outcb = (cb_func)WATCHDOG_RESET;
883 #endif /* CONFIG_HW_WATCHDOG */
885 r = inflateInit2(&s, -MAX_WBITS);
887 printf ("Error: inflateInit2() returned %d\n", r);
891 s.avail_in = *lenp - i;
893 s.avail_out = dstlen;
894 r = inflate(&s, Z_FINISH);
895 if (r != Z_OK && r != Z_STREAM_END) {
896 printf ("Error: inflate() returned %d\n", r);
899 *lenp = s.next_out - (unsigned char *) dst;
905 #if (CONFIG_COMMANDS & CFG_CMD_ELF)
907 do_bootm_vxworks (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
908 ulong addr, ulong *len_ptr, int verify)
910 image_header_t *hdr = &header;
913 sprintf(str, "%x", hdr->ih_ep); /* write entry-point into string */
914 setenv("loadaddr", str);
915 do_bootvx(cmdtp, 0, 0, NULL);
919 do_bootm_qnxelf (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
920 ulong addr, ulong *len_ptr, int verify)
922 image_header_t *hdr = &header;
926 sprintf(str, "%x", hdr->ih_ep); /* write entry-point into string */
927 local_args[0] = argv[0];
928 local_args[1] = str; /* and provide it via the arguments */
929 do_bootelf(cmdtp, 0, 2, local_args);
931 #endif /* CFG_CMD_ELF */