blob: fbe81d3039aa41e61e46ce7764eb776e81b94083 [file] [log] [blame]
wdenk47d1a6e2002-11-03 00:01:44 +00001/*
Stefan Roese15940c92006-03-13 11:16:36 +01002 * (C) Copyright 2000-2006
wdenk47d1a6e2002-11-03 00:01:44 +00003 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
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.
12 *
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.
17 *
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,
21 * MA 02111-1307 USA
22 */
23
Marian Balakowiczb97a2a02008-01-08 18:14:09 +010024#define DEBUG
25
wdenk47d1a6e2002-11-03 00:01:44 +000026/*
27 * Boot support
28 */
29#include <common.h>
30#include <watchdog.h>
31#include <command.h>
wdenk47d1a6e2002-11-03 00:01:44 +000032#include <image.h>
33#include <malloc.h>
34#include <zlib.h>
wdenkc29fdfc2003-08-29 20:57:53 +000035#include <bzlib.h>
wdenk7f70e852003-05-20 14:25:27 +000036#include <environment.h>
wdenk47d1a6e2002-11-03 00:01:44 +000037#include <asm/byteorder.h>
wdenk8bde7f72003-06-27 21:31:46 +000038
Gerald Van Baren213bf8c2007-03-31 12:23:51 -040039#if defined(CONFIG_OF_LIBFDT)
40#include <fdt.h>
41#include <libfdt.h>
Gerald Van Barenc28abb92007-04-14 22:51:24 -040042#include <fdt_support.h>
Marian Balakowiczd45d5a12008-01-08 18:11:43 +010043#elif defined(CONFIG_OF_FLAT_TREE)
Wolfgang Denkf57f70a2005-10-13 01:45:54 +020044#include <ft_build.h>
45#endif
46
Wolfgang Denkd87080b2006-03-31 18:32:53 +020047DECLARE_GLOBAL_DATA_PTR;
48
Gerald Van Baren38eb5082007-05-12 09:45:46 -040049/*cmd_boot.c*/
50extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
wdenk8bde7f72003-06-27 21:31:46 +000051
Jon Loeligerbaa26db2007-07-08 17:51:39 -050052#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE)
wdenk47d1a6e2002-11-03 00:01:44 +000053#include <rtc.h>
54#endif
55
56#ifdef CFG_HUSH_PARSER
57#include <hush.h>
58#endif
59
wdenk2abbe072003-06-16 23:50:08 +000060#ifdef CONFIG_HAS_DATAFLASH
61#include <dataflash.h>
62#endif
63
wdenkeedcd072004-09-08 22:03:11 +000064int gunzip (void *, int, unsigned char *, unsigned long *);
wdenk47d1a6e2002-11-03 00:01:44 +000065
Marian Balakowicz321359f2008-01-08 18:11:43 +010066#ifdef CONFIG_BZIP2
67extern void bz_internal_error(int);
68#endif
wdenk47d1a6e2002-11-03 00:01:44 +000069
Jon Loeligerbaa26db2007-07-08 17:51:39 -050070#if defined(CONFIG_CMD_IMI)
wdenk47d1a6e2002-11-03 00:01:44 +000071static int image_info (unsigned long addr);
72#endif
wdenk27b207f2003-07-24 23:38:38 +000073
Jon Loeligerbaa26db2007-07-08 17:51:39 -050074#if defined(CONFIG_CMD_IMLS)
wdenk27b207f2003-07-24 23:38:38 +000075#include <flash.h>
Marian Balakowicze6f2e902005-10-11 19:09:42 +020076extern flash_info_t flash_info[]; /* info for FLASH chips */
wdenk27b207f2003-07-24 23:38:38 +000077static int do_imls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
78#endif
79
wdenk47d1a6e2002-11-03 00:01:44 +000080static void print_type (image_header_t *hdr);
81
wdenk2262cfe2002-11-18 00:14:45 +000082#ifdef __I386__
83image_header_t *fake_header(image_header_t *hdr, void *ptr, int size);
84#endif
85
wdenk47d1a6e2002-11-03 00:01:44 +000086/*
87 * Continue booting an OS image; caller already has:
88 * - copied image header to global variable `header'
89 * - checked header magic number, checksums (both header & image),
90 * - verified image architecture (PPC) and type (KERNEL or MULTI),
91 * - loaded (first part of) image to header load address,
92 * - disabled interrupts.
93 */
94typedef void boot_os_Fcn (cmd_tbl_t *cmdtp, int flag,
95 int argc, char *argv[],
96 ulong addr, /* of image to boot */
97 ulong *len_ptr, /* multi-file image length table */
98 int verify); /* getenv("verify")[0] != 'n' */
99
wdenk47d1a6e2002-11-03 00:01:44 +0000100extern boot_os_Fcn do_bootm_linux;
Marian Balakowicz5d3cc552008-01-08 18:11:43 +0100101
wdenkf72da342003-10-10 10:05:42 +0000102#ifdef CONFIG_SILENT_CONSOLE
103static void fixup_silent_linux (void);
104#endif
wdenk47d1a6e2002-11-03 00:01:44 +0000105static boot_os_Fcn do_bootm_netbsd;
wdenkd791b1d2003-04-20 14:04:18 +0000106static boot_os_Fcn do_bootm_rtems;
Jon Loeligerbaa26db2007-07-08 17:51:39 -0500107#if defined(CONFIG_CMD_ELF)
wdenk47d1a6e2002-11-03 00:01:44 +0000108static boot_os_Fcn do_bootm_vxworks;
109static boot_os_Fcn do_bootm_qnxelf;
110int do_bootvx ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[] );
111int do_bootelf (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[] );
Jon Loeliger90253172007-07-10 11:02:44 -0500112#endif
wdenk7f70e852003-05-20 14:25:27 +0000113#if defined(CONFIG_ARTOS) && defined(CONFIG_PPC)
114static boot_os_Fcn do_bootm_artos;
115#endif
wdenk1f4bb372003-07-27 00:21:01 +0000116#ifdef CONFIG_LYNXKDI
117static boot_os_Fcn do_bootm_lynxkdi;
118extern void lynxkdi_boot( image_header_t * );
119#endif
wdenk47d1a6e2002-11-03 00:01:44 +0000120
Stefan Roese15940c92006-03-13 11:16:36 +0100121#ifndef CFG_BOOTM_LEN
122#define CFG_BOOTM_LEN 0x800000 /* use 8MByte as default max gunzip size */
123#endif
124
wdenk47d1a6e2002-11-03 00:01:44 +0000125image_header_t header;
126
127ulong load_addr = CFG_LOAD_ADDR; /* Default Load Address */
128
129int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
130{
131 ulong iflag;
132 ulong addr;
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100133 ulong data, len;
wdenk47d1a6e2002-11-03 00:01:44 +0000134 ulong *len_ptr;
Stefan Roese15940c92006-03-13 11:16:36 +0100135 uint unc_len = CFG_BOOTM_LEN;
wdenk47d1a6e2002-11-03 00:01:44 +0000136 int i, verify;
137 char *name, *s;
wdenkb13fb012003-10-30 21:49:38 +0000138 int (*appl)(int, char *[]);
wdenk47d1a6e2002-11-03 00:01:44 +0000139 image_header_t *hdr = &header;
140
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100141 verify = getenv_verify ();
wdenk47d1a6e2002-11-03 00:01:44 +0000142
143 if (argc < 2) {
144 addr = load_addr;
145 } else {
146 addr = simple_strtoul(argv[1], NULL, 16);
147 }
148
Heiko Schocherfad63402007-07-13 09:54:17 +0200149 show_boot_progress (1);
wdenk47d1a6e2002-11-03 00:01:44 +0000150 printf ("## Booting image at %08lx ...\n", addr);
151
152 /* Copy header so we can blank CRC field for re-calculation */
wdenk2abbe072003-06-16 23:50:08 +0000153#ifdef CONFIG_HAS_DATAFLASH
154 if (addr_dataflash(addr)){
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100155 read_dataflash (addr, image_get_header_size (), (char *)&header);
wdenk2abbe072003-06-16 23:50:08 +0000156 } else
157#endif
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100158 memmove (&header, (char *)addr, image_get_header_size ());
wdenk47d1a6e2002-11-03 00:01:44 +0000159
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100160 if (!image_check_magic (hdr)) {
wdenk2262cfe2002-11-18 00:14:45 +0000161#ifdef __I386__ /* correct image format not implemented yet - fake it */
162 if (fake_header(hdr, (void*)addr, -1) != NULL) {
163 /* to compensate for the addition below */
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100164 addr -= image_get_header_size ();
wdenk2262cfe2002-11-18 00:14:45 +0000165 /* turnof verify,
166 * fake_header() does not fake the data crc
167 */
168 verify = 0;
169 } else
170#endif /* __I386__ */
171 {
wdenk4b9206e2004-03-23 22:14:11 +0000172 puts ("Bad Magic Number\n");
Heiko Schocherfad63402007-07-13 09:54:17 +0200173 show_boot_progress (-1);
wdenk47d1a6e2002-11-03 00:01:44 +0000174 return 1;
wdenk2262cfe2002-11-18 00:14:45 +0000175 }
wdenk47d1a6e2002-11-03 00:01:44 +0000176 }
Heiko Schocherfad63402007-07-13 09:54:17 +0200177 show_boot_progress (2);
wdenk47d1a6e2002-11-03 00:01:44 +0000178
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100179 if (!image_check_hcrc (hdr)) {
wdenk4b9206e2004-03-23 22:14:11 +0000180 puts ("Bad Header Checksum\n");
Heiko Schocherfad63402007-07-13 09:54:17 +0200181 show_boot_progress (-2);
wdenk47d1a6e2002-11-03 00:01:44 +0000182 return 1;
183 }
Heiko Schocherfad63402007-07-13 09:54:17 +0200184 show_boot_progress (3);
wdenk47d1a6e2002-11-03 00:01:44 +0000185
Wolfgang Denkbccae902005-10-06 01:50:50 +0200186#ifdef CONFIG_HAS_DATAFLASH
187 if (addr_dataflash(addr)){
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100188 len = image_get_image_size (hdr);
Wolfgang Denkbccae902005-10-06 01:50:50 +0200189 read_dataflash(addr, len, (char *)CFG_LOAD_ADDR);
190 addr = CFG_LOAD_ADDR;
191 }
192#endif
193
194
wdenk47d1a6e2002-11-03 00:01:44 +0000195 /* for multi-file images we need the data part, too */
wdenka57a4962003-10-26 22:52:58 +0000196 print_image_hdr ((image_header_t *)addr);
wdenk47d1a6e2002-11-03 00:01:44 +0000197
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100198 len = image_get_data_size (hdr);
199 data = addr + image_get_header_size ();
200 len_ptr = (ulong *)data;
wdenk47d1a6e2002-11-03 00:01:44 +0000201
202 if (verify) {
wdenk4b9206e2004-03-23 22:14:11 +0000203 puts (" Verifying Checksum ... ");
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100204 if (!image_check_dcrc ((image_header_t *)addr)) {
wdenk47d1a6e2002-11-03 00:01:44 +0000205 printf ("Bad Data CRC\n");
Heiko Schocherfad63402007-07-13 09:54:17 +0200206 show_boot_progress (-3);
wdenk47d1a6e2002-11-03 00:01:44 +0000207 return 1;
208 }
wdenk4b9206e2004-03-23 22:14:11 +0000209 puts ("OK\n");
wdenk47d1a6e2002-11-03 00:01:44 +0000210 }
Heiko Schocherfad63402007-07-13 09:54:17 +0200211 show_boot_progress (4);
wdenk47d1a6e2002-11-03 00:01:44 +0000212
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100213 if (!image_check_target_arch (hdr)) {
214 printf ("Unsupported Architecture 0x%x\n", image_get_arch (hdr));
Heiko Schocherfad63402007-07-13 09:54:17 +0200215 show_boot_progress (-4);
wdenk47d1a6e2002-11-03 00:01:44 +0000216 return 1;
217 }
Heiko Schocherfad63402007-07-13 09:54:17 +0200218 show_boot_progress (5);
wdenk47d1a6e2002-11-03 00:01:44 +0000219
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100220 switch (image_get_type (hdr)) {
wdenkb13fb012003-10-30 21:49:38 +0000221 case IH_TYPE_STANDALONE:
222 name = "Standalone Application";
223 /* A second argument overwrites the load address */
224 if (argc > 2) {
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100225 image_set_load (hdr, simple_strtoul (argv[2], NULL, 16));
wdenkb13fb012003-10-30 21:49:38 +0000226 }
227 break;
228 case IH_TYPE_KERNEL:
229 name = "Kernel Image";
230 break;
wdenkd4ca31c2004-01-02 14:00:00 +0000231 case IH_TYPE_MULTI:
wdenkb13fb012003-10-30 21:49:38 +0000232 name = "Multi-File Image";
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100233 len = image_to_cpu (len_ptr[0]);
wdenkb13fb012003-10-30 21:49:38 +0000234 /* OS kernel is always the first image */
235 data += 8; /* kernel_len + terminator */
236 for (i=1; len_ptr[i]; ++i)
237 data += 4;
238 break;
wdenk47d1a6e2002-11-03 00:01:44 +0000239 default: printf ("Wrong Image Type for %s command\n", cmdtp->name);
Heiko Schocherfad63402007-07-13 09:54:17 +0200240 show_boot_progress (-5);
wdenk47d1a6e2002-11-03 00:01:44 +0000241 return 1;
242 }
Heiko Schocherfad63402007-07-13 09:54:17 +0200243 show_boot_progress (6);
wdenk47d1a6e2002-11-03 00:01:44 +0000244
245 /*
246 * We have reached the point of no return: we are going to
247 * overwrite all exception vector code, so we cannot easily
248 * recover from any failures any more...
249 */
250
251 iflag = disable_interrupts();
252
wdenkc7de8292002-11-19 11:04:11 +0000253#ifdef CONFIG_AMIGAONEG3SE
254 /*
wdenk8bde7f72003-06-27 21:31:46 +0000255 * We've possible left the caches enabled during
wdenkc7de8292002-11-19 11:04:11 +0000256 * bios emulation, so turn them off again
257 */
258 icache_disable();
259 invalidate_l1_instruction_cache();
260 flush_data_cache();
261 dcache_disable();
262#endif
263
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100264 switch (image_get_comp (hdr)) {
wdenk47d1a6e2002-11-03 00:01:44 +0000265 case IH_COMP_NONE:
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100266 if (image_get_load (hdr) == addr) {
wdenk47d1a6e2002-11-03 00:01:44 +0000267 printf (" XIP %s ... ", name);
268 } else {
269#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
270 size_t l = len;
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100271 void *to = (void *)image_get_load (hdr);
wdenk47d1a6e2002-11-03 00:01:44 +0000272 void *from = (void *)data;
273
274 printf (" Loading %s ... ", name);
275
276 while (l > 0) {
277 size_t tail = (l > CHUNKSZ) ? CHUNKSZ : l;
278 WATCHDOG_RESET();
279 memmove (to, from, tail);
280 to += tail;
281 from += tail;
282 l -= tail;
283 }
284#else /* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100285 memmove ((void *)image_get_load (hdr), (uchar *)data, len);
wdenk47d1a6e2002-11-03 00:01:44 +0000286#endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
287 }
288 break;
289 case IH_COMP_GZIP:
290 printf (" Uncompressing %s ... ", name);
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100291 if (gunzip ((void *)image_get_load (hdr), unc_len,
wdenkeedcd072004-09-08 22:03:11 +0000292 (uchar *)data, &len) != 0) {
wdenk4b9206e2004-03-23 22:14:11 +0000293 puts ("GUNZIP ERROR - must RESET board to recover\n");
Heiko Schocherfad63402007-07-13 09:54:17 +0200294 show_boot_progress (-6);
wdenk47d1a6e2002-11-03 00:01:44 +0000295 do_reset (cmdtp, flag, argc, argv);
296 }
297 break;
wdenkc29fdfc2003-08-29 20:57:53 +0000298#ifdef CONFIG_BZIP2
299 case IH_COMP_BZIP2:
300 printf (" Uncompressing %s ... ", name);
wdenk5653fc32004-02-08 22:55:38 +0000301 /*
302 * If we've got less than 4 MB of malloc() space,
303 * use slower decompression algorithm which requires
304 * at most 2300 KB of memory.
305 */
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100306 i = BZ2_bzBuffToBuffDecompress ((char*)image_get_load (hdr),
wdenk5653fc32004-02-08 22:55:38 +0000307 &unc_len, (char *)data, len,
308 CFG_MALLOC_LEN < (4096 * 1024), 0);
wdenkc29fdfc2003-08-29 20:57:53 +0000309 if (i != BZ_OK) {
310 printf ("BUNZIP2 ERROR %d - must RESET board to recover\n", i);
Heiko Schocherfad63402007-07-13 09:54:17 +0200311 show_boot_progress (-6);
wdenkc29fdfc2003-08-29 20:57:53 +0000312 do_reset (cmdtp, flag, argc, argv);
313 }
314 break;
315#endif /* CONFIG_BZIP2 */
wdenk47d1a6e2002-11-03 00:01:44 +0000316 default:
317 if (iflag)
318 enable_interrupts();
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100319 printf ("Unimplemented compression type %d\n", image_get_comp (hdr));
Heiko Schocherfad63402007-07-13 09:54:17 +0200320 show_boot_progress (-7);
wdenk47d1a6e2002-11-03 00:01:44 +0000321 return 1;
322 }
wdenk4b9206e2004-03-23 22:14:11 +0000323 puts ("OK\n");
Heiko Schocherfad63402007-07-13 09:54:17 +0200324 show_boot_progress (7);
wdenk47d1a6e2002-11-03 00:01:44 +0000325
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100326 switch (image_get_type (hdr)) {
wdenk47d1a6e2002-11-03 00:01:44 +0000327 case IH_TYPE_STANDALONE:
wdenk47d1a6e2002-11-03 00:01:44 +0000328 if (iflag)
329 enable_interrupts();
330
wdenk4a6fd342003-04-12 23:38:12 +0000331 /* load (and uncompress), but don't start if "autostart"
332 * is set to "no"
333 */
wdenk4a551702003-10-08 23:26:14 +0000334 if (((s = getenv("autostart")) != NULL) && (strcmp(s,"no") == 0)) {
335 char buf[32];
336 sprintf(buf, "%lX", len);
337 setenv("filesize", buf);
wdenk4a6fd342003-04-12 23:38:12 +0000338 return 0;
wdenk4a551702003-10-08 23:26:14 +0000339 }
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100340 appl = (int (*)(int, char *[]))image_get_ep (hdr);
wdenkb13fb012003-10-30 21:49:38 +0000341 (*appl)(argc-1, &argv[1]);
wdenk4a6fd342003-04-12 23:38:12 +0000342 return 0;
wdenk47d1a6e2002-11-03 00:01:44 +0000343 case IH_TYPE_KERNEL:
344 case IH_TYPE_MULTI:
345 /* handled below */
346 break;
347 default:
348 if (iflag)
349 enable_interrupts();
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100350 printf ("Can't boot image type %d\n", image_get_type (hdr));
Heiko Schocherfad63402007-07-13 09:54:17 +0200351 show_boot_progress (-8);
wdenk47d1a6e2002-11-03 00:01:44 +0000352 return 1;
353 }
Heiko Schocherfad63402007-07-13 09:54:17 +0200354 show_boot_progress (8);
wdenk47d1a6e2002-11-03 00:01:44 +0000355
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100356 switch (image_get_os (hdr)) {
wdenk47d1a6e2002-11-03 00:01:44 +0000357 default: /* handled by (original) Linux case */
358 case IH_OS_LINUX:
wdenkf72da342003-10-10 10:05:42 +0000359#ifdef CONFIG_SILENT_CONSOLE
360 fixup_silent_linux();
361#endif
wdenk47d1a6e2002-11-03 00:01:44 +0000362 do_bootm_linux (cmdtp, flag, argc, argv,
363 addr, len_ptr, verify);
364 break;
365 case IH_OS_NETBSD:
366 do_bootm_netbsd (cmdtp, flag, argc, argv,
367 addr, len_ptr, verify);
368 break;
wdenk8bde7f72003-06-27 21:31:46 +0000369
wdenk1f4bb372003-07-27 00:21:01 +0000370#ifdef CONFIG_LYNXKDI
371 case IH_OS_LYNXOS:
372 do_bootm_lynxkdi (cmdtp, flag, argc, argv,
373 addr, len_ptr, verify);
374 break;
375#endif
376
wdenkd791b1d2003-04-20 14:04:18 +0000377 case IH_OS_RTEMS:
378 do_bootm_rtems (cmdtp, flag, argc, argv,
379 addr, len_ptr, verify);
380 break;
wdenk8bde7f72003-06-27 21:31:46 +0000381
Jon Loeligerbaa26db2007-07-08 17:51:39 -0500382#if defined(CONFIG_CMD_ELF)
wdenk47d1a6e2002-11-03 00:01:44 +0000383 case IH_OS_VXWORKS:
384 do_bootm_vxworks (cmdtp, flag, argc, argv,
385 addr, len_ptr, verify);
386 break;
387 case IH_OS_QNX:
388 do_bootm_qnxelf (cmdtp, flag, argc, argv,
389 addr, len_ptr, verify);
390 break;
Jon Loeliger90253172007-07-10 11:02:44 -0500391#endif
wdenk7f70e852003-05-20 14:25:27 +0000392#ifdef CONFIG_ARTOS
393 case IH_OS_ARTOS:
394 do_bootm_artos (cmdtp, flag, argc, argv,
395 addr, len_ptr, verify);
396 break;
397#endif
wdenk47d1a6e2002-11-03 00:01:44 +0000398 }
399
Heiko Schocherfad63402007-07-13 09:54:17 +0200400 show_boot_progress (-9);
wdenk47d1a6e2002-11-03 00:01:44 +0000401#ifdef DEBUG
wdenk4b9206e2004-03-23 22:14:11 +0000402 puts ("\n## Control returned to monitor - resetting...\n");
wdenk47d1a6e2002-11-03 00:01:44 +0000403 do_reset (cmdtp, flag, argc, argv);
404#endif
405 return 1;
406}
407
wdenk0d498392003-07-01 21:06:45 +0000408U_BOOT_CMD(
409 bootm, CFG_MAXARGS, 1, do_bootm,
wdenk8bde7f72003-06-27 21:31:46 +0000410 "bootm - boot application image from memory\n",
411 "[addr [arg ...]]\n - boot application image stored in memory\n"
wdenk9d5028c2004-11-21 00:06:33 +0000412 "\tpassing arguments 'arg ...'; when booting a Linux kernel,\n"
413 "\t'arg' can be the address of an initrd image\n"
Gerald Van Baren213bf8c2007-03-31 12:23:51 -0400414#if defined(CONFIG_OF_FLAT_TREE) || defined(CONFIG_OF_LIBFDT)
Matthew McClintock98a9c4d2006-06-28 10:41:37 -0500415 "\tWhen booting a Linux kernel which requires a flat device-tree\n"
Detlev Zundel5441f612007-10-19 16:47:26 +0200416 "\ta third argument is required which is the address of the\n"
Matthew McClintock98a9c4d2006-06-28 10:41:37 -0500417 "\tdevice-tree blob. To boot that kernel without an initrd image,\n"
418 "\tuse a '-' for the second argument. If you do not pass a third\n"
419 "\ta bd_info struct will be passed instead\n"
420#endif
wdenk8bde7f72003-06-27 21:31:46 +0000421);
422
wdenkf72da342003-10-10 10:05:42 +0000423#ifdef CONFIG_SILENT_CONSOLE
424static void
425fixup_silent_linux ()
426{
wdenkf72da342003-10-10 10:05:42 +0000427 char buf[256], *start, *end;
428 char *cmdline = getenv ("bootargs");
429
430 /* Only fix cmdline when requested */
431 if (!(gd->flags & GD_FLG_SILENT))
432 return;
433
434 debug ("before silent fix-up: %s\n", cmdline);
435 if (cmdline) {
436 if ((start = strstr (cmdline, "console=")) != NULL) {
437 end = strchr (start, ' ');
438 strncpy (buf, cmdline, (start - cmdline + 8));
439 if (end)
440 strcpy (buf + (start - cmdline + 8), end);
441 else
442 buf[start - cmdline + 8] = '\0';
443 } else {
444 strcpy (buf, cmdline);
445 strcat (buf, " console=");
446 }
447 } else {
448 strcpy (buf, "console=");
449 }
450
451 setenv ("bootargs", buf);
452 debug ("after silent fix-up: %s\n", buf);
453}
454#endif /* CONFIG_SILENT_CONSOLE */
455
wdenk47d1a6e2002-11-03 00:01:44 +0000456static void
457do_bootm_netbsd (cmd_tbl_t *cmdtp, int flag,
458 int argc, char *argv[],
459 ulong addr,
460 ulong *len_ptr,
461 int verify)
462{
wdenk47d1a6e2002-11-03 00:01:44 +0000463 image_header_t *hdr = &header;
464
465 void (*loader)(bd_t *, image_header_t *, char *, char *);
466 image_header_t *img_addr;
467 char *consdev;
468 char *cmdline;
469
470
471 /*
472 * Booting a (NetBSD) kernel image
473 *
474 * This process is pretty similar to a standalone application:
475 * The (first part of an multi-) image must be a stage-2 loader,
476 * which in turn is responsible for loading & invoking the actual
477 * kernel. The only differences are the parameters being passed:
478 * besides the board info strucure, the loader expects a command
479 * line, the name of the console device, and (optionally) the
480 * address of the original image header.
481 */
482
483 img_addr = 0;
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100484 if ((image_check_type (hdr, IH_TYPE_MULTI)) && (len_ptr[1]))
wdenk47d1a6e2002-11-03 00:01:44 +0000485 img_addr = (image_header_t *) addr;
486
487
488 consdev = "";
489#if defined (CONFIG_8xx_CONS_SMC1)
490 consdev = "smc1";
491#elif defined (CONFIG_8xx_CONS_SMC2)
492 consdev = "smc2";
493#elif defined (CONFIG_8xx_CONS_SCC2)
494 consdev = "scc2";
495#elif defined (CONFIG_8xx_CONS_SCC3)
496 consdev = "scc3";
497#endif
498
499 if (argc > 2) {
500 ulong len;
501 int i;
502
503 for (i=2, len=0 ; i<argc ; i+=1)
504 len += strlen (argv[i]) + 1;
505 cmdline = malloc (len);
506
507 for (i=2, len=0 ; i<argc ; i+=1) {
508 if (i > 2)
509 cmdline[len++] = ' ';
510 strcpy (&cmdline[len], argv[i]);
511 len += strlen (argv[i]);
512 }
513 } else if ((cmdline = getenv("bootargs")) == NULL) {
514 cmdline = "";
515 }
516
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100517 loader = (void (*)(bd_t *, image_header_t *, char *, char *))image_get_ep (hdr);
wdenk47d1a6e2002-11-03 00:01:44 +0000518
519 printf ("## Transferring control to NetBSD stage-2 loader (at address %08lx) ...\n",
520 (ulong)loader);
521
Heiko Schocherfad63402007-07-13 09:54:17 +0200522 show_boot_progress (15);
wdenk47d1a6e2002-11-03 00:01:44 +0000523
524 /*
525 * NetBSD Stage-2 Loader Parameters:
526 * r3: ptr to board info data
527 * r4: image address
528 * r5: console device
529 * r6: boot args string
530 */
531 (*loader) (gd->bd, img_addr, consdev, cmdline);
532}
533
wdenk7f70e852003-05-20 14:25:27 +0000534#if defined(CONFIG_ARTOS) && defined(CONFIG_PPC)
535
536/* Function that returns a character from the environment */
537extern uchar (*env_get_char)(int);
538
539static void
540do_bootm_artos (cmd_tbl_t *cmdtp, int flag,
541 int argc, char *argv[],
542 ulong addr,
543 ulong *len_ptr,
544 int verify)
545{
wdenk7f70e852003-05-20 14:25:27 +0000546 ulong top;
547 char *s, *cmdline;
548 char **fwenv, **ss;
549 int i, j, nxt, len, envno, envsz;
550 bd_t *kbd;
551 void (*entry)(bd_t *bd, char *cmdline, char **fwenv, ulong top);
552 image_header_t *hdr = &header;
553
554 /*
555 * Booting an ARTOS kernel image + application
556 */
557
558 /* this used to be the top of memory, but was wrong... */
559#ifdef CONFIG_PPC
560 /* get stack pointer */
561 asm volatile ("mr %0,1" : "=r"(top) );
562#endif
563 debug ("## Current stack ends at 0x%08lX ", top);
564
565 top -= 2048; /* just to be sure */
566 if (top > CFG_BOOTMAPSZ)
567 top = CFG_BOOTMAPSZ;
568 top &= ~0xF;
569
570 debug ("=> set upper limit to 0x%08lX\n", top);
571
572 /* first check the artos specific boot args, then the linux args*/
573 if ((s = getenv("abootargs")) == NULL && (s = getenv("bootargs")) == NULL)
574 s = "";
575
576 /* get length of cmdline, and place it */
577 len = strlen(s);
578 top = (top - (len + 1)) & ~0xF;
579 cmdline = (char *)top;
580 debug ("## cmdline at 0x%08lX ", top);
581 strcpy(cmdline, s);
582
583 /* copy bdinfo */
584 top = (top - sizeof(bd_t)) & ~0xF;
585 debug ("## bd at 0x%08lX ", top);
586 kbd = (bd_t *)top;
587 memcpy(kbd, gd->bd, sizeof(bd_t));
588
589 /* first find number of env entries, and their size */
590 envno = 0;
591 envsz = 0;
592 for (i = 0; env_get_char(i) != '\0'; i = nxt + 1) {
593 for (nxt = i; env_get_char(nxt) != '\0'; ++nxt)
594 ;
595 envno++;
596 envsz += (nxt - i) + 1; /* plus trailing zero */
597 }
598 envno++; /* plus the terminating zero */
599 debug ("## %u envvars total size %u ", envno, envsz);
600
601 top = (top - sizeof(char **)*envno) & ~0xF;
602 fwenv = (char **)top;
603 debug ("## fwenv at 0x%08lX ", top);
604
605 top = (top - envsz) & ~0xF;
606 s = (char *)top;
607 ss = fwenv;
608
609 /* now copy them */
610 for (i = 0; env_get_char(i) != '\0'; i = nxt + 1) {
611 for (nxt = i; env_get_char(nxt) != '\0'; ++nxt)
612 ;
613 *ss++ = s;
614 for (j = i; j < nxt; ++j)
615 *s++ = env_get_char(j);
616 *s++ = '\0';
617 }
618 *ss++ = NULL; /* terminate */
619
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100620 entry = (void (*)(bd_t *, char *, char **, ulong))image_get_ep (hdr);
wdenk7f70e852003-05-20 14:25:27 +0000621 (*entry)(kbd, cmdline, fwenv, top);
622}
623#endif
624
625
Jon Loeligerbaa26db2007-07-08 17:51:39 -0500626#if defined(CONFIG_CMD_BOOTD)
wdenk47d1a6e2002-11-03 00:01:44 +0000627int do_bootd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
628{
629 int rcode = 0;
630#ifndef CFG_HUSH_PARSER
631 if (run_command (getenv ("bootcmd"), flag) < 0) rcode = 1;
632#else
633 if (parse_string_outer(getenv("bootcmd"),
634 FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP) != 0 ) rcode = 1;
635#endif
636 return rcode;
637}
wdenk8bde7f72003-06-27 21:31:46 +0000638
wdenk0d498392003-07-01 21:06:45 +0000639U_BOOT_CMD(
640 boot, 1, 1, do_bootd,
wdenk9d2b18a2003-06-28 23:11:04 +0000641 "boot - boot default, i.e., run 'bootcmd'\n",
642 NULL
643);
644
645/* keep old command name "bootd" for backward compatibility */
wdenk0d498392003-07-01 21:06:45 +0000646U_BOOT_CMD(
647 bootd, 1, 1, do_bootd,
wdenk8bde7f72003-06-27 21:31:46 +0000648 "bootd - boot default, i.e., run 'bootcmd'\n",
649 NULL
650);
651
wdenk47d1a6e2002-11-03 00:01:44 +0000652#endif
653
Jon Loeligerbaa26db2007-07-08 17:51:39 -0500654#if defined(CONFIG_CMD_IMI)
wdenk47d1a6e2002-11-03 00:01:44 +0000655int do_iminfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
656{
657 int arg;
658 ulong addr;
659 int rcode=0;
660
661 if (argc < 2) {
662 return image_info (load_addr);
663 }
664
665 for (arg=1; arg <argc; ++arg) {
666 addr = simple_strtoul(argv[arg], NULL, 16);
667 if (image_info (addr) != 0) rcode = 1;
668 }
669 return rcode;
670}
671
672static int image_info (ulong addr)
673{
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100674 image_header_t *hdr = (image_header_t *)addr;
wdenk47d1a6e2002-11-03 00:01:44 +0000675
676 printf ("\n## Checking Image at %08lx ...\n", addr);
677
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100678 if (!image_check_magic (hdr)) {
wdenk4b9206e2004-03-23 22:14:11 +0000679 puts (" Bad Magic Number\n");
wdenk47d1a6e2002-11-03 00:01:44 +0000680 return 1;
681 }
682
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100683 if (!image_check_hcrc (hdr)) {
wdenk4b9206e2004-03-23 22:14:11 +0000684 puts (" Bad Header Checksum\n");
wdenk47d1a6e2002-11-03 00:01:44 +0000685 return 1;
686 }
687
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100688 print_image_hdr (hdr);
wdenk47d1a6e2002-11-03 00:01:44 +0000689
wdenk4b9206e2004-03-23 22:14:11 +0000690 puts (" Verifying Checksum ... ");
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100691 if (!image_check_dcrc (hdr)) {
wdenk4b9206e2004-03-23 22:14:11 +0000692 puts (" Bad Data CRC\n");
wdenk47d1a6e2002-11-03 00:01:44 +0000693 return 1;
694 }
wdenk4b9206e2004-03-23 22:14:11 +0000695 puts ("OK\n");
wdenk47d1a6e2002-11-03 00:01:44 +0000696 return 0;
697}
wdenk0d498392003-07-01 21:06:45 +0000698
699U_BOOT_CMD(
700 iminfo, CFG_MAXARGS, 1, do_iminfo,
wdenk8bde7f72003-06-27 21:31:46 +0000701 "iminfo - print header information for application image\n",
702 "addr [addr ...]\n"
703 " - print header information for application image starting at\n"
704 " address 'addr' in memory; this includes verification of the\n"
705 " image contents (magic number, header and payload checksums)\n"
706);
707
Jon Loeliger90253172007-07-10 11:02:44 -0500708#endif
wdenk47d1a6e2002-11-03 00:01:44 +0000709
Jon Loeligerbaa26db2007-07-08 17:51:39 -0500710#if defined(CONFIG_CMD_IMLS)
wdenk27b207f2003-07-24 23:38:38 +0000711/*-----------------------------------------------------------------------
712 * List all images found in flash.
713 */
714int do_imls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
715{
716 flash_info_t *info;
717 int i, j;
718 image_header_t *hdr;
wdenk27b207f2003-07-24 23:38:38 +0000719
720 for (i=0, info=&flash_info[0]; i<CFG_MAX_FLASH_BANKS; ++i, ++info) {
721 if (info->flash_id == FLASH_UNKNOWN)
722 goto next_bank;
Marian Balakowicze6f2e902005-10-11 19:09:42 +0200723 for (j=0; j<info->sector_count; ++j) {
wdenk27b207f2003-07-24 23:38:38 +0000724
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100725 hdr = (image_header_t *)info->start[j];
726
727 if (!hdr || !image_check_magic (hdr))
wdenk27b207f2003-07-24 23:38:38 +0000728 goto next_sector;
729
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100730 if (!image_check_hcrc (hdr))
wdenk27b207f2003-07-24 23:38:38 +0000731 goto next_sector;
732
733 printf ("Image at %08lX:\n", (ulong)hdr);
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100734 print_image_hdr (hdr);
wdenk5bb226e2003-11-17 21:14:37 +0000735
wdenk4b9206e2004-03-23 22:14:11 +0000736 puts (" Verifying Checksum ... ");
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100737 if (!image_check_dcrc (hdr)) {
738 puts ("Bad Data CRC\n");
739 } else {
740 puts ("OK\n");
wdenk5bb226e2003-11-17 21:14:37 +0000741 }
wdenkbdccc4f2003-08-05 17:43:17 +0000742next_sector: ;
wdenk27b207f2003-07-24 23:38:38 +0000743 }
wdenkbdccc4f2003-08-05 17:43:17 +0000744next_bank: ;
wdenk27b207f2003-07-24 23:38:38 +0000745 }
746
747 return (0);
748}
749
750U_BOOT_CMD(
751 imls, 1, 1, do_imls,
752 "imls - list all images found in flash\n",
753 "\n"
754 " - Prints information about all images found at sector\n"
755 " boundaries in flash.\n"
756);
Jon Loeliger90253172007-07-10 11:02:44 -0500757#endif
wdenk27b207f2003-07-24 23:38:38 +0000758
wdenk47d1a6e2002-11-03 00:01:44 +0000759void
760print_image_hdr (image_header_t *hdr)
761{
Jon Loeligerbaa26db2007-07-08 17:51:39 -0500762#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE)
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100763 time_t timestamp = (time_t)image_get_time (hdr);
wdenk47d1a6e2002-11-03 00:01:44 +0000764 struct rtc_time tm;
765#endif
766
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100767 printf (" Image Name: %.*s\n", IH_NMLEN, image_get_name (hdr));
Jon Loeligerbaa26db2007-07-08 17:51:39 -0500768#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE)
wdenk47d1a6e2002-11-03 00:01:44 +0000769 to_tm (timestamp, &tm);
770 printf (" Created: %4d-%02d-%02d %2d:%02d:%02d UTC\n",
771 tm.tm_year, tm.tm_mon, tm.tm_mday,
772 tm.tm_hour, tm.tm_min, tm.tm_sec);
Jon Loeliger90253172007-07-10 11:02:44 -0500773#endif
wdenk4b9206e2004-03-23 22:14:11 +0000774 puts (" Image Type: "); print_type(hdr);
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100775 printf ("\n Data Size: %d Bytes = ", image_get_data_size (hdr));
776 print_size (image_get_data_size (hdr), "\n");
wdenk4b9206e2004-03-23 22:14:11 +0000777 printf (" Load Address: %08x\n"
778 " Entry Point: %08x\n",
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100779 image_get_load (hdr), image_get_ep (hdr));
wdenk47d1a6e2002-11-03 00:01:44 +0000780
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100781 if (image_check_type (hdr, IH_TYPE_MULTI)) {
wdenk47d1a6e2002-11-03 00:01:44 +0000782 int i;
783 ulong len;
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100784 ulong *len_ptr = (ulong *)((ulong)hdr + image_get_header_size ());
wdenk47d1a6e2002-11-03 00:01:44 +0000785
wdenk4b9206e2004-03-23 22:14:11 +0000786 puts (" Contents:\n");
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100787 for (i=0; (len = image_to_cpu (*len_ptr)); ++i, ++len_ptr) {
wdenk47d1a6e2002-11-03 00:01:44 +0000788 printf (" Image %d: %8ld Bytes = ", i, len);
789 print_size (len, "\n");
790 }
791 }
792}
793
794
795static void
796print_type (image_header_t *hdr)
797{
798 char *os, *arch, *type, *comp;
799
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100800 switch (image_get_os (hdr)) {
wdenk47d1a6e2002-11-03 00:01:44 +0000801 case IH_OS_INVALID: os = "Invalid OS"; break;
802 case IH_OS_NETBSD: os = "NetBSD"; break;
803 case IH_OS_LINUX: os = "Linux"; break;
804 case IH_OS_VXWORKS: os = "VxWorks"; break;
805 case IH_OS_QNX: os = "QNX"; break;
806 case IH_OS_U_BOOT: os = "U-Boot"; break;
wdenkd791b1d2003-04-20 14:04:18 +0000807 case IH_OS_RTEMS: os = "RTEMS"; break;
wdenk7f70e852003-05-20 14:25:27 +0000808#ifdef CONFIG_ARTOS
809 case IH_OS_ARTOS: os = "ARTOS"; break;
810#endif
wdenk1f4bb372003-07-27 00:21:01 +0000811#ifdef CONFIG_LYNXKDI
812 case IH_OS_LYNXOS: os = "LynxOS"; break;
813#endif
wdenk47d1a6e2002-11-03 00:01:44 +0000814 default: os = "Unknown OS"; break;
815 }
816
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100817 switch (image_get_arch (hdr)) {
818 case IH_ARCH_INVALID: arch = "Invalid CPU"; break;
819 case IH_ARCH_ALPHA: arch = "Alpha"; break;
820 case IH_ARCH_ARM: arch = "ARM"; break;
821 case IH_ARCH_AVR32: arch = "AVR32"; break;
822 case IH_ARCH_BLACKFIN: arch = "Blackfin"; break;
823 case IH_ARCH_I386: arch = "Intel x86"; break;
824 case IH_ARCH_IA64: arch = "IA64"; break;
825 case IH_ARCH_M68K: arch = "M68K"; break;
826 case IH_ARCH_MICROBLAZE:arch = "Microblaze"; break;
827 case IH_ARCH_MIPS64: arch = "MIPS 64 Bit"; break;
828 case IH_ARCH_MIPS: arch = "MIPS"; break;
829 case IH_ARCH_NIOS2: arch = "Nios-II"; break;
830 case IH_ARCH_NIOS: arch = "Nios"; break;
831 case IH_ARCH_PPC: arch = "PowerPC"; break;
832 case IH_ARCH_S390: arch = "IBM S390"; break;
833 case IH_ARCH_SH: arch = "SuperH"; break;
834 case IH_ARCH_SPARC64: arch = "SPARC 64 Bit"; break;
835 case IH_ARCH_SPARC: arch = "SPARC"; break;
wdenk47d1a6e2002-11-03 00:01:44 +0000836 default: arch = "Unknown Architecture"; break;
837 }
838
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100839 switch (image_get_type (hdr)) {
wdenk47d1a6e2002-11-03 00:01:44 +0000840 case IH_TYPE_INVALID: type = "Invalid Image"; break;
841 case IH_TYPE_STANDALONE:type = "Standalone Program"; break;
842 case IH_TYPE_KERNEL: type = "Kernel Image"; break;
843 case IH_TYPE_RAMDISK: type = "RAMDisk Image"; break;
844 case IH_TYPE_MULTI: type = "Multi-File Image"; break;
845 case IH_TYPE_FIRMWARE: type = "Firmware"; break;
846 case IH_TYPE_SCRIPT: type = "Script"; break;
Matthew McClintock25c751e2006-08-16 10:54:09 -0500847 case IH_TYPE_FLATDT: type = "Flat Device Tree"; break;
wdenk47d1a6e2002-11-03 00:01:44 +0000848 default: type = "Unknown Image"; break;
849 }
850
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100851 switch (image_get_comp (hdr)) {
wdenk47d1a6e2002-11-03 00:01:44 +0000852 case IH_COMP_NONE: comp = "uncompressed"; break;
853 case IH_COMP_GZIP: comp = "gzip compressed"; break;
854 case IH_COMP_BZIP2: comp = "bzip2 compressed"; break;
855 default: comp = "unknown compression"; break;
856 }
857
858 printf ("%s %s %s (%s)", arch, os, type, comp);
859}
860
wdenkd791b1d2003-04-20 14:04:18 +0000861static void
862do_bootm_rtems (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
863 ulong addr, ulong *len_ptr, int verify)
864{
wdenkd791b1d2003-04-20 14:04:18 +0000865 image_header_t *hdr = &header;
866 void (*entry_point)(bd_t *);
867
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100868 entry_point = (void (*)(bd_t *))image_get_ep (hdr);
wdenkd791b1d2003-04-20 14:04:18 +0000869
870 printf ("## Transferring control to RTEMS (at address %08lx) ...\n",
871 (ulong)entry_point);
872
Heiko Schocherfad63402007-07-13 09:54:17 +0200873 show_boot_progress (15);
wdenkd791b1d2003-04-20 14:04:18 +0000874
875 /*
876 * RTEMS Parameters:
877 * r3: ptr to board info data
878 */
879
880 (*entry_point ) ( gd->bd );
881}
882
Jon Loeligerbaa26db2007-07-08 17:51:39 -0500883#if defined(CONFIG_CMD_ELF)
wdenk47d1a6e2002-11-03 00:01:44 +0000884static void
885do_bootm_vxworks (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
886 ulong addr, ulong *len_ptr, int verify)
887{
888 image_header_t *hdr = &header;
889 char str[80];
890
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100891 sprintf(str, "%x", image_get_ep (hdr)); /* write entry-point into string */
wdenk47d1a6e2002-11-03 00:01:44 +0000892 setenv("loadaddr", str);
893 do_bootvx(cmdtp, 0, 0, NULL);
894}
895
896static void
897do_bootm_qnxelf (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
898 ulong addr, ulong *len_ptr, int verify)
899{
900 image_header_t *hdr = &header;
901 char *local_args[2];
902 char str[16];
903
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100904 sprintf(str, "%x", image_get_ep (hdr)); /* write entry-point into string */
wdenk47d1a6e2002-11-03 00:01:44 +0000905 local_args[0] = argv[0];
906 local_args[1] = str; /* and provide it via the arguments */
907 do_bootelf(cmdtp, 0, 2, local_args);
908}
Jon Loeliger90253172007-07-10 11:02:44 -0500909#endif
wdenk1f4bb372003-07-27 00:21:01 +0000910
911#ifdef CONFIG_LYNXKDI
912static void
913do_bootm_lynxkdi (cmd_tbl_t *cmdtp, int flag,
914 int argc, char *argv[],
915 ulong addr,
916 ulong *len_ptr,
917 int verify)
918{
919 lynxkdi_boot( &header );
920}
921
922#endif /* CONFIG_LYNXKDI */