wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 1 | /* |
Stefan Roese | 15940c9 | 2006-03-13 11:16:36 +0100 | [diff] [blame] | 2 | * (C) Copyright 2000-2006 |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 3 | * 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 Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 24 | #define DEBUG |
| 25 | |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 26 | /* |
| 27 | * Boot support |
| 28 | */ |
| 29 | #include <common.h> |
| 30 | #include <watchdog.h> |
| 31 | #include <command.h> |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 32 | #include <image.h> |
| 33 | #include <malloc.h> |
| 34 | #include <zlib.h> |
wdenk | c29fdfc | 2003-08-29 20:57:53 +0000 | [diff] [blame] | 35 | #include <bzlib.h> |
wdenk | 7f70e85 | 2003-05-20 14:25:27 +0000 | [diff] [blame] | 36 | #include <environment.h> |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 37 | #include <asm/byteorder.h> |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 38 | |
Gerald Van Baren | 213bf8c | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 39 | #if defined(CONFIG_OF_LIBFDT) |
| 40 | #include <fdt.h> |
| 41 | #include <libfdt.h> |
Gerald Van Baren | c28abb9 | 2007-04-14 22:51:24 -0400 | [diff] [blame] | 42 | #include <fdt_support.h> |
Gerald Van Baren | 213bf8c | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 43 | #endif |
Gerald Van Baren | aea03c4 | 2007-03-31 14:30:53 -0400 | [diff] [blame] | 44 | #if defined(CONFIG_OF_FLAT_TREE) |
Wolfgang Denk | f57f70a | 2005-10-13 01:45:54 +0200 | [diff] [blame] | 45 | #include <ft_build.h> |
| 46 | #endif |
| 47 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 48 | DECLARE_GLOBAL_DATA_PTR; |
| 49 | |
Gerald Van Baren | 38eb508 | 2007-05-12 09:45:46 -0400 | [diff] [blame] | 50 | /*cmd_boot.c*/ |
| 51 | extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 52 | |
Jon Loeliger | baa26db | 2007-07-08 17:51:39 -0500 | [diff] [blame] | 53 | #if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 54 | #include <rtc.h> |
| 55 | #endif |
| 56 | |
| 57 | #ifdef CFG_HUSH_PARSER |
| 58 | #include <hush.h> |
| 59 | #endif |
| 60 | |
wdenk | 2abbe07 | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 61 | #ifdef CONFIG_HAS_DATAFLASH |
| 62 | #include <dataflash.h> |
| 63 | #endif |
| 64 | |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 65 | /* |
| 66 | * Some systems (for example LWMON) have very short watchdog periods; |
| 67 | * we must make sure to split long operations like memmove() or |
| 68 | * crc32() into reasonable chunks. |
| 69 | */ |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 70 | #define CHUNKSZ (64 * 1024) |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 71 | |
wdenk | eedcd07 | 2004-09-08 22:03:11 +0000 | [diff] [blame] | 72 | int gunzip (void *, int, unsigned char *, unsigned long *); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 73 | |
| 74 | static void *zalloc(void *, unsigned, unsigned); |
| 75 | static void zfree(void *, void *, unsigned); |
| 76 | |
Jon Loeliger | baa26db | 2007-07-08 17:51:39 -0500 | [diff] [blame] | 77 | #if defined(CONFIG_CMD_IMI) |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 78 | static int image_info (unsigned long addr); |
| 79 | #endif |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 80 | |
Jon Loeliger | baa26db | 2007-07-08 17:51:39 -0500 | [diff] [blame] | 81 | #if defined(CONFIG_CMD_IMLS) |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 82 | #include <flash.h> |
Marian Balakowicz | e6f2e90 | 2005-10-11 19:09:42 +0200 | [diff] [blame] | 83 | extern flash_info_t flash_info[]; /* info for FLASH chips */ |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 84 | static int do_imls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); |
| 85 | #endif |
| 86 | |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 87 | static void print_type (image_header_t *hdr); |
| 88 | |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 89 | #ifdef __I386__ |
| 90 | image_header_t *fake_header(image_header_t *hdr, void *ptr, int size); |
| 91 | #endif |
| 92 | |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 93 | /* |
| 94 | * Continue booting an OS image; caller already has: |
| 95 | * - copied image header to global variable `header' |
| 96 | * - checked header magic number, checksums (both header & image), |
| 97 | * - verified image architecture (PPC) and type (KERNEL or MULTI), |
| 98 | * - loaded (first part of) image to header load address, |
| 99 | * - disabled interrupts. |
| 100 | */ |
| 101 | typedef void boot_os_Fcn (cmd_tbl_t *cmdtp, int flag, |
| 102 | int argc, char *argv[], |
| 103 | ulong addr, /* of image to boot */ |
| 104 | ulong *len_ptr, /* multi-file image length table */ |
| 105 | int verify); /* getenv("verify")[0] != 'n' */ |
| 106 | |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 107 | extern boot_os_Fcn do_bootm_linux; |
Marian Balakowicz | 5d3cc55 | 2008-01-08 18:11:43 +0100 | [diff] [blame^] | 108 | |
wdenk | f72da34 | 2003-10-10 10:05:42 +0000 | [diff] [blame] | 109 | #ifdef CONFIG_SILENT_CONSOLE |
| 110 | static void fixup_silent_linux (void); |
| 111 | #endif |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 112 | static boot_os_Fcn do_bootm_netbsd; |
wdenk | d791b1d | 2003-04-20 14:04:18 +0000 | [diff] [blame] | 113 | static boot_os_Fcn do_bootm_rtems; |
Jon Loeliger | baa26db | 2007-07-08 17:51:39 -0500 | [diff] [blame] | 114 | #if defined(CONFIG_CMD_ELF) |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 115 | static boot_os_Fcn do_bootm_vxworks; |
| 116 | static boot_os_Fcn do_bootm_qnxelf; |
| 117 | int do_bootvx ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[] ); |
| 118 | int do_bootelf (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[] ); |
Jon Loeliger | 9025317 | 2007-07-10 11:02:44 -0500 | [diff] [blame] | 119 | #endif |
wdenk | 7f70e85 | 2003-05-20 14:25:27 +0000 | [diff] [blame] | 120 | #if defined(CONFIG_ARTOS) && defined(CONFIG_PPC) |
| 121 | static boot_os_Fcn do_bootm_artos; |
| 122 | #endif |
wdenk | 1f4bb37 | 2003-07-27 00:21:01 +0000 | [diff] [blame] | 123 | #ifdef CONFIG_LYNXKDI |
| 124 | static boot_os_Fcn do_bootm_lynxkdi; |
| 125 | extern void lynxkdi_boot( image_header_t * ); |
| 126 | #endif |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 127 | |
Stefan Roese | 15940c9 | 2006-03-13 11:16:36 +0100 | [diff] [blame] | 128 | #ifndef CFG_BOOTM_LEN |
| 129 | #define CFG_BOOTM_LEN 0x800000 /* use 8MByte as default max gunzip size */ |
| 130 | #endif |
| 131 | |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 132 | image_header_t header; |
| 133 | |
| 134 | ulong load_addr = CFG_LOAD_ADDR; /* Default Load Address */ |
| 135 | |
| 136 | int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 137 | { |
| 138 | ulong iflag; |
| 139 | ulong addr; |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 140 | ulong data, len; |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 141 | ulong *len_ptr; |
Stefan Roese | 15940c9 | 2006-03-13 11:16:36 +0100 | [diff] [blame] | 142 | uint unc_len = CFG_BOOTM_LEN; |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 143 | int i, verify; |
| 144 | char *name, *s; |
wdenk | b13fb01 | 2003-10-30 21:49:38 +0000 | [diff] [blame] | 145 | int (*appl)(int, char *[]); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 146 | image_header_t *hdr = &header; |
| 147 | |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 148 | verify = getenv_verify (); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 149 | |
| 150 | if (argc < 2) { |
| 151 | addr = load_addr; |
| 152 | } else { |
| 153 | addr = simple_strtoul(argv[1], NULL, 16); |
| 154 | } |
| 155 | |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 156 | show_boot_progress (1); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 157 | printf ("## Booting image at %08lx ...\n", addr); |
| 158 | |
| 159 | /* Copy header so we can blank CRC field for re-calculation */ |
wdenk | 2abbe07 | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 160 | #ifdef CONFIG_HAS_DATAFLASH |
| 161 | if (addr_dataflash(addr)){ |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 162 | read_dataflash (addr, image_get_header_size (), (char *)&header); |
wdenk | 2abbe07 | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 163 | } else |
| 164 | #endif |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 165 | memmove (&header, (char *)addr, image_get_header_size ()); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 166 | |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 167 | if (!image_check_magic (hdr)) { |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 168 | #ifdef __I386__ /* correct image format not implemented yet - fake it */ |
| 169 | if (fake_header(hdr, (void*)addr, -1) != NULL) { |
| 170 | /* to compensate for the addition below */ |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 171 | addr -= image_get_header_size (); |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 172 | /* turnof verify, |
| 173 | * fake_header() does not fake the data crc |
| 174 | */ |
| 175 | verify = 0; |
| 176 | } else |
| 177 | #endif /* __I386__ */ |
| 178 | { |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 179 | puts ("Bad Magic Number\n"); |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 180 | show_boot_progress (-1); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 181 | return 1; |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 182 | } |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 183 | } |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 184 | show_boot_progress (2); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 185 | |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 186 | if (!image_check_hcrc (hdr)) { |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 187 | puts ("Bad Header Checksum\n"); |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 188 | show_boot_progress (-2); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 189 | return 1; |
| 190 | } |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 191 | show_boot_progress (3); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 192 | |
Wolfgang Denk | bccae90 | 2005-10-06 01:50:50 +0200 | [diff] [blame] | 193 | #ifdef CONFIG_HAS_DATAFLASH |
| 194 | if (addr_dataflash(addr)){ |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 195 | len = image_get_image_size (hdr); |
Wolfgang Denk | bccae90 | 2005-10-06 01:50:50 +0200 | [diff] [blame] | 196 | read_dataflash(addr, len, (char *)CFG_LOAD_ADDR); |
| 197 | addr = CFG_LOAD_ADDR; |
| 198 | } |
| 199 | #endif |
| 200 | |
| 201 | |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 202 | /* for multi-file images we need the data part, too */ |
wdenk | a57a496 | 2003-10-26 22:52:58 +0000 | [diff] [blame] | 203 | print_image_hdr ((image_header_t *)addr); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 204 | |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 205 | len = image_get_data_size (hdr); |
| 206 | data = addr + image_get_header_size (); |
| 207 | len_ptr = (ulong *)data; |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 208 | |
| 209 | if (verify) { |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 210 | puts (" Verifying Checksum ... "); |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 211 | if (!image_check_dcrc ((image_header_t *)addr)) { |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 212 | printf ("Bad Data CRC\n"); |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 213 | show_boot_progress (-3); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 214 | return 1; |
| 215 | } |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 216 | puts ("OK\n"); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 217 | } |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 218 | show_boot_progress (4); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 219 | |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 220 | if (!image_check_target_arch (hdr)) { |
| 221 | printf ("Unsupported Architecture 0x%x\n", image_get_arch (hdr)); |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 222 | show_boot_progress (-4); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 223 | return 1; |
| 224 | } |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 225 | show_boot_progress (5); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 226 | |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 227 | switch (image_get_type (hdr)) { |
wdenk | b13fb01 | 2003-10-30 21:49:38 +0000 | [diff] [blame] | 228 | case IH_TYPE_STANDALONE: |
| 229 | name = "Standalone Application"; |
| 230 | /* A second argument overwrites the load address */ |
| 231 | if (argc > 2) { |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 232 | image_set_load (hdr, simple_strtoul (argv[2], NULL, 16)); |
wdenk | b13fb01 | 2003-10-30 21:49:38 +0000 | [diff] [blame] | 233 | } |
| 234 | break; |
| 235 | case IH_TYPE_KERNEL: |
| 236 | name = "Kernel Image"; |
| 237 | break; |
wdenk | d4ca31c | 2004-01-02 14:00:00 +0000 | [diff] [blame] | 238 | case IH_TYPE_MULTI: |
wdenk | b13fb01 | 2003-10-30 21:49:38 +0000 | [diff] [blame] | 239 | name = "Multi-File Image"; |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 240 | len = image_to_cpu (len_ptr[0]); |
wdenk | b13fb01 | 2003-10-30 21:49:38 +0000 | [diff] [blame] | 241 | /* OS kernel is always the first image */ |
| 242 | data += 8; /* kernel_len + terminator */ |
| 243 | for (i=1; len_ptr[i]; ++i) |
| 244 | data += 4; |
| 245 | break; |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 246 | default: printf ("Wrong Image Type for %s command\n", cmdtp->name); |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 247 | show_boot_progress (-5); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 248 | return 1; |
| 249 | } |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 250 | show_boot_progress (6); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 251 | |
| 252 | /* |
| 253 | * We have reached the point of no return: we are going to |
| 254 | * overwrite all exception vector code, so we cannot easily |
| 255 | * recover from any failures any more... |
| 256 | */ |
| 257 | |
| 258 | iflag = disable_interrupts(); |
| 259 | |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 260 | #ifdef CONFIG_AMIGAONEG3SE |
| 261 | /* |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 262 | * We've possible left the caches enabled during |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 263 | * bios emulation, so turn them off again |
| 264 | */ |
| 265 | icache_disable(); |
| 266 | invalidate_l1_instruction_cache(); |
| 267 | flush_data_cache(); |
| 268 | dcache_disable(); |
| 269 | #endif |
| 270 | |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 271 | switch (image_get_comp (hdr)) { |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 272 | case IH_COMP_NONE: |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 273 | if (image_get_load (hdr) == addr) { |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 274 | printf (" XIP %s ... ", name); |
| 275 | } else { |
| 276 | #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG) |
| 277 | size_t l = len; |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 278 | void *to = (void *)image_get_load (hdr); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 279 | void *from = (void *)data; |
| 280 | |
| 281 | printf (" Loading %s ... ", name); |
| 282 | |
| 283 | while (l > 0) { |
| 284 | size_t tail = (l > CHUNKSZ) ? CHUNKSZ : l; |
| 285 | WATCHDOG_RESET(); |
| 286 | memmove (to, from, tail); |
| 287 | to += tail; |
| 288 | from += tail; |
| 289 | l -= tail; |
| 290 | } |
| 291 | #else /* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */ |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 292 | memmove ((void *)image_get_load (hdr), (uchar *)data, len); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 293 | #endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */ |
| 294 | } |
| 295 | break; |
| 296 | case IH_COMP_GZIP: |
| 297 | printf (" Uncompressing %s ... ", name); |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 298 | if (gunzip ((void *)image_get_load (hdr), unc_len, |
wdenk | eedcd07 | 2004-09-08 22:03:11 +0000 | [diff] [blame] | 299 | (uchar *)data, &len) != 0) { |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 300 | puts ("GUNZIP ERROR - must RESET board to recover\n"); |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 301 | show_boot_progress (-6); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 302 | do_reset (cmdtp, flag, argc, argv); |
| 303 | } |
| 304 | break; |
wdenk | c29fdfc | 2003-08-29 20:57:53 +0000 | [diff] [blame] | 305 | #ifdef CONFIG_BZIP2 |
| 306 | case IH_COMP_BZIP2: |
| 307 | printf (" Uncompressing %s ... ", name); |
wdenk | 5653fc3 | 2004-02-08 22:55:38 +0000 | [diff] [blame] | 308 | /* |
| 309 | * If we've got less than 4 MB of malloc() space, |
| 310 | * use slower decompression algorithm which requires |
| 311 | * at most 2300 KB of memory. |
| 312 | */ |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 313 | i = BZ2_bzBuffToBuffDecompress ((char*)image_get_load (hdr), |
wdenk | 5653fc3 | 2004-02-08 22:55:38 +0000 | [diff] [blame] | 314 | &unc_len, (char *)data, len, |
| 315 | CFG_MALLOC_LEN < (4096 * 1024), 0); |
wdenk | c29fdfc | 2003-08-29 20:57:53 +0000 | [diff] [blame] | 316 | if (i != BZ_OK) { |
| 317 | printf ("BUNZIP2 ERROR %d - must RESET board to recover\n", i); |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 318 | show_boot_progress (-6); |
wdenk | c29fdfc | 2003-08-29 20:57:53 +0000 | [diff] [blame] | 319 | do_reset (cmdtp, flag, argc, argv); |
| 320 | } |
| 321 | break; |
| 322 | #endif /* CONFIG_BZIP2 */ |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 323 | default: |
| 324 | if (iflag) |
| 325 | enable_interrupts(); |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 326 | printf ("Unimplemented compression type %d\n", image_get_comp (hdr)); |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 327 | show_boot_progress (-7); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 328 | return 1; |
| 329 | } |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 330 | puts ("OK\n"); |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 331 | show_boot_progress (7); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 332 | |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 333 | switch (image_get_type (hdr)) { |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 334 | case IH_TYPE_STANDALONE: |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 335 | if (iflag) |
| 336 | enable_interrupts(); |
| 337 | |
wdenk | 4a6fd34 | 2003-04-12 23:38:12 +0000 | [diff] [blame] | 338 | /* load (and uncompress), but don't start if "autostart" |
| 339 | * is set to "no" |
| 340 | */ |
wdenk | 4a55170 | 2003-10-08 23:26:14 +0000 | [diff] [blame] | 341 | if (((s = getenv("autostart")) != NULL) && (strcmp(s,"no") == 0)) { |
| 342 | char buf[32]; |
| 343 | sprintf(buf, "%lX", len); |
| 344 | setenv("filesize", buf); |
wdenk | 4a6fd34 | 2003-04-12 23:38:12 +0000 | [diff] [blame] | 345 | return 0; |
wdenk | 4a55170 | 2003-10-08 23:26:14 +0000 | [diff] [blame] | 346 | } |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 347 | appl = (int (*)(int, char *[]))image_get_ep (hdr); |
wdenk | b13fb01 | 2003-10-30 21:49:38 +0000 | [diff] [blame] | 348 | (*appl)(argc-1, &argv[1]); |
wdenk | 4a6fd34 | 2003-04-12 23:38:12 +0000 | [diff] [blame] | 349 | return 0; |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 350 | case IH_TYPE_KERNEL: |
| 351 | case IH_TYPE_MULTI: |
| 352 | /* handled below */ |
| 353 | break; |
| 354 | default: |
| 355 | if (iflag) |
| 356 | enable_interrupts(); |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 357 | printf ("Can't boot image type %d\n", image_get_type (hdr)); |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 358 | show_boot_progress (-8); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 359 | return 1; |
| 360 | } |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 361 | show_boot_progress (8); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 362 | |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 363 | switch (image_get_os (hdr)) { |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 364 | default: /* handled by (original) Linux case */ |
| 365 | case IH_OS_LINUX: |
wdenk | f72da34 | 2003-10-10 10:05:42 +0000 | [diff] [blame] | 366 | #ifdef CONFIG_SILENT_CONSOLE |
| 367 | fixup_silent_linux(); |
| 368 | #endif |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 369 | do_bootm_linux (cmdtp, flag, argc, argv, |
| 370 | addr, len_ptr, verify); |
| 371 | break; |
| 372 | case IH_OS_NETBSD: |
| 373 | do_bootm_netbsd (cmdtp, flag, argc, argv, |
| 374 | addr, len_ptr, verify); |
| 375 | break; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 376 | |
wdenk | 1f4bb37 | 2003-07-27 00:21:01 +0000 | [diff] [blame] | 377 | #ifdef CONFIG_LYNXKDI |
| 378 | case IH_OS_LYNXOS: |
| 379 | do_bootm_lynxkdi (cmdtp, flag, argc, argv, |
| 380 | addr, len_ptr, verify); |
| 381 | break; |
| 382 | #endif |
| 383 | |
wdenk | d791b1d | 2003-04-20 14:04:18 +0000 | [diff] [blame] | 384 | case IH_OS_RTEMS: |
| 385 | do_bootm_rtems (cmdtp, flag, argc, argv, |
| 386 | addr, len_ptr, verify); |
| 387 | break; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 388 | |
Jon Loeliger | baa26db | 2007-07-08 17:51:39 -0500 | [diff] [blame] | 389 | #if defined(CONFIG_CMD_ELF) |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 390 | case IH_OS_VXWORKS: |
| 391 | do_bootm_vxworks (cmdtp, flag, argc, argv, |
| 392 | addr, len_ptr, verify); |
| 393 | break; |
| 394 | case IH_OS_QNX: |
| 395 | do_bootm_qnxelf (cmdtp, flag, argc, argv, |
| 396 | addr, len_ptr, verify); |
| 397 | break; |
Jon Loeliger | 9025317 | 2007-07-10 11:02:44 -0500 | [diff] [blame] | 398 | #endif |
wdenk | 7f70e85 | 2003-05-20 14:25:27 +0000 | [diff] [blame] | 399 | #ifdef CONFIG_ARTOS |
| 400 | case IH_OS_ARTOS: |
| 401 | do_bootm_artos (cmdtp, flag, argc, argv, |
| 402 | addr, len_ptr, verify); |
| 403 | break; |
| 404 | #endif |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 405 | } |
| 406 | |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 407 | show_boot_progress (-9); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 408 | #ifdef DEBUG |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 409 | puts ("\n## Control returned to monitor - resetting...\n"); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 410 | do_reset (cmdtp, flag, argc, argv); |
| 411 | #endif |
| 412 | return 1; |
| 413 | } |
| 414 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 415 | U_BOOT_CMD( |
| 416 | bootm, CFG_MAXARGS, 1, do_bootm, |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 417 | "bootm - boot application image from memory\n", |
| 418 | "[addr [arg ...]]\n - boot application image stored in memory\n" |
wdenk | 9d5028c | 2004-11-21 00:06:33 +0000 | [diff] [blame] | 419 | "\tpassing arguments 'arg ...'; when booting a Linux kernel,\n" |
| 420 | "\t'arg' can be the address of an initrd image\n" |
Gerald Van Baren | 213bf8c | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 421 | #if defined(CONFIG_OF_FLAT_TREE) || defined(CONFIG_OF_LIBFDT) |
Matthew McClintock | 98a9c4d | 2006-06-28 10:41:37 -0500 | [diff] [blame] | 422 | "\tWhen booting a Linux kernel which requires a flat device-tree\n" |
Detlev Zundel | 5441f61 | 2007-10-19 16:47:26 +0200 | [diff] [blame] | 423 | "\ta third argument is required which is the address of the\n" |
Matthew McClintock | 98a9c4d | 2006-06-28 10:41:37 -0500 | [diff] [blame] | 424 | "\tdevice-tree blob. To boot that kernel without an initrd image,\n" |
| 425 | "\tuse a '-' for the second argument. If you do not pass a third\n" |
| 426 | "\ta bd_info struct will be passed instead\n" |
| 427 | #endif |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 428 | ); |
| 429 | |
wdenk | f72da34 | 2003-10-10 10:05:42 +0000 | [diff] [blame] | 430 | #ifdef CONFIG_SILENT_CONSOLE |
| 431 | static void |
| 432 | fixup_silent_linux () |
| 433 | { |
wdenk | f72da34 | 2003-10-10 10:05:42 +0000 | [diff] [blame] | 434 | char buf[256], *start, *end; |
| 435 | char *cmdline = getenv ("bootargs"); |
| 436 | |
| 437 | /* Only fix cmdline when requested */ |
| 438 | if (!(gd->flags & GD_FLG_SILENT)) |
| 439 | return; |
| 440 | |
| 441 | debug ("before silent fix-up: %s\n", cmdline); |
| 442 | if (cmdline) { |
| 443 | if ((start = strstr (cmdline, "console=")) != NULL) { |
| 444 | end = strchr (start, ' '); |
| 445 | strncpy (buf, cmdline, (start - cmdline + 8)); |
| 446 | if (end) |
| 447 | strcpy (buf + (start - cmdline + 8), end); |
| 448 | else |
| 449 | buf[start - cmdline + 8] = '\0'; |
| 450 | } else { |
| 451 | strcpy (buf, cmdline); |
| 452 | strcat (buf, " console="); |
| 453 | } |
| 454 | } else { |
| 455 | strcpy (buf, "console="); |
| 456 | } |
| 457 | |
| 458 | setenv ("bootargs", buf); |
| 459 | debug ("after silent fix-up: %s\n", buf); |
| 460 | } |
| 461 | #endif /* CONFIG_SILENT_CONSOLE */ |
| 462 | |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 463 | static void |
| 464 | do_bootm_netbsd (cmd_tbl_t *cmdtp, int flag, |
| 465 | int argc, char *argv[], |
| 466 | ulong addr, |
| 467 | ulong *len_ptr, |
| 468 | int verify) |
| 469 | { |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 470 | image_header_t *hdr = &header; |
| 471 | |
| 472 | void (*loader)(bd_t *, image_header_t *, char *, char *); |
| 473 | image_header_t *img_addr; |
| 474 | char *consdev; |
| 475 | char *cmdline; |
| 476 | |
| 477 | |
| 478 | /* |
| 479 | * Booting a (NetBSD) kernel image |
| 480 | * |
| 481 | * This process is pretty similar to a standalone application: |
| 482 | * The (first part of an multi-) image must be a stage-2 loader, |
| 483 | * which in turn is responsible for loading & invoking the actual |
| 484 | * kernel. The only differences are the parameters being passed: |
| 485 | * besides the board info strucure, the loader expects a command |
| 486 | * line, the name of the console device, and (optionally) the |
| 487 | * address of the original image header. |
| 488 | */ |
| 489 | |
| 490 | img_addr = 0; |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 491 | if ((image_check_type (hdr, IH_TYPE_MULTI)) && (len_ptr[1])) |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 492 | img_addr = (image_header_t *) addr; |
| 493 | |
| 494 | |
| 495 | consdev = ""; |
| 496 | #if defined (CONFIG_8xx_CONS_SMC1) |
| 497 | consdev = "smc1"; |
| 498 | #elif defined (CONFIG_8xx_CONS_SMC2) |
| 499 | consdev = "smc2"; |
| 500 | #elif defined (CONFIG_8xx_CONS_SCC2) |
| 501 | consdev = "scc2"; |
| 502 | #elif defined (CONFIG_8xx_CONS_SCC3) |
| 503 | consdev = "scc3"; |
| 504 | #endif |
| 505 | |
| 506 | if (argc > 2) { |
| 507 | ulong len; |
| 508 | int i; |
| 509 | |
| 510 | for (i=2, len=0 ; i<argc ; i+=1) |
| 511 | len += strlen (argv[i]) + 1; |
| 512 | cmdline = malloc (len); |
| 513 | |
| 514 | for (i=2, len=0 ; i<argc ; i+=1) { |
| 515 | if (i > 2) |
| 516 | cmdline[len++] = ' '; |
| 517 | strcpy (&cmdline[len], argv[i]); |
| 518 | len += strlen (argv[i]); |
| 519 | } |
| 520 | } else if ((cmdline = getenv("bootargs")) == NULL) { |
| 521 | cmdline = ""; |
| 522 | } |
| 523 | |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 524 | loader = (void (*)(bd_t *, image_header_t *, char *, char *))image_get_ep (hdr); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 525 | |
| 526 | printf ("## Transferring control to NetBSD stage-2 loader (at address %08lx) ...\n", |
| 527 | (ulong)loader); |
| 528 | |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 529 | show_boot_progress (15); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 530 | |
| 531 | /* |
| 532 | * NetBSD Stage-2 Loader Parameters: |
| 533 | * r3: ptr to board info data |
| 534 | * r4: image address |
| 535 | * r5: console device |
| 536 | * r6: boot args string |
| 537 | */ |
| 538 | (*loader) (gd->bd, img_addr, consdev, cmdline); |
| 539 | } |
| 540 | |
wdenk | 7f70e85 | 2003-05-20 14:25:27 +0000 | [diff] [blame] | 541 | #if defined(CONFIG_ARTOS) && defined(CONFIG_PPC) |
| 542 | |
| 543 | /* Function that returns a character from the environment */ |
| 544 | extern uchar (*env_get_char)(int); |
| 545 | |
| 546 | static void |
| 547 | do_bootm_artos (cmd_tbl_t *cmdtp, int flag, |
| 548 | int argc, char *argv[], |
| 549 | ulong addr, |
| 550 | ulong *len_ptr, |
| 551 | int verify) |
| 552 | { |
wdenk | 7f70e85 | 2003-05-20 14:25:27 +0000 | [diff] [blame] | 553 | ulong top; |
| 554 | char *s, *cmdline; |
| 555 | char **fwenv, **ss; |
| 556 | int i, j, nxt, len, envno, envsz; |
| 557 | bd_t *kbd; |
| 558 | void (*entry)(bd_t *bd, char *cmdline, char **fwenv, ulong top); |
| 559 | image_header_t *hdr = &header; |
| 560 | |
| 561 | /* |
| 562 | * Booting an ARTOS kernel image + application |
| 563 | */ |
| 564 | |
| 565 | /* this used to be the top of memory, but was wrong... */ |
| 566 | #ifdef CONFIG_PPC |
| 567 | /* get stack pointer */ |
| 568 | asm volatile ("mr %0,1" : "=r"(top) ); |
| 569 | #endif |
| 570 | debug ("## Current stack ends at 0x%08lX ", top); |
| 571 | |
| 572 | top -= 2048; /* just to be sure */ |
| 573 | if (top > CFG_BOOTMAPSZ) |
| 574 | top = CFG_BOOTMAPSZ; |
| 575 | top &= ~0xF; |
| 576 | |
| 577 | debug ("=> set upper limit to 0x%08lX\n", top); |
| 578 | |
| 579 | /* first check the artos specific boot args, then the linux args*/ |
| 580 | if ((s = getenv("abootargs")) == NULL && (s = getenv("bootargs")) == NULL) |
| 581 | s = ""; |
| 582 | |
| 583 | /* get length of cmdline, and place it */ |
| 584 | len = strlen(s); |
| 585 | top = (top - (len + 1)) & ~0xF; |
| 586 | cmdline = (char *)top; |
| 587 | debug ("## cmdline at 0x%08lX ", top); |
| 588 | strcpy(cmdline, s); |
| 589 | |
| 590 | /* copy bdinfo */ |
| 591 | top = (top - sizeof(bd_t)) & ~0xF; |
| 592 | debug ("## bd at 0x%08lX ", top); |
| 593 | kbd = (bd_t *)top; |
| 594 | memcpy(kbd, gd->bd, sizeof(bd_t)); |
| 595 | |
| 596 | /* first find number of env entries, and their size */ |
| 597 | envno = 0; |
| 598 | envsz = 0; |
| 599 | for (i = 0; env_get_char(i) != '\0'; i = nxt + 1) { |
| 600 | for (nxt = i; env_get_char(nxt) != '\0'; ++nxt) |
| 601 | ; |
| 602 | envno++; |
| 603 | envsz += (nxt - i) + 1; /* plus trailing zero */ |
| 604 | } |
| 605 | envno++; /* plus the terminating zero */ |
| 606 | debug ("## %u envvars total size %u ", envno, envsz); |
| 607 | |
| 608 | top = (top - sizeof(char **)*envno) & ~0xF; |
| 609 | fwenv = (char **)top; |
| 610 | debug ("## fwenv at 0x%08lX ", top); |
| 611 | |
| 612 | top = (top - envsz) & ~0xF; |
| 613 | s = (char *)top; |
| 614 | ss = fwenv; |
| 615 | |
| 616 | /* now copy them */ |
| 617 | for (i = 0; env_get_char(i) != '\0'; i = nxt + 1) { |
| 618 | for (nxt = i; env_get_char(nxt) != '\0'; ++nxt) |
| 619 | ; |
| 620 | *ss++ = s; |
| 621 | for (j = i; j < nxt; ++j) |
| 622 | *s++ = env_get_char(j); |
| 623 | *s++ = '\0'; |
| 624 | } |
| 625 | *ss++ = NULL; /* terminate */ |
| 626 | |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 627 | entry = (void (*)(bd_t *, char *, char **, ulong))image_get_ep (hdr); |
wdenk | 7f70e85 | 2003-05-20 14:25:27 +0000 | [diff] [blame] | 628 | (*entry)(kbd, cmdline, fwenv, top); |
| 629 | } |
| 630 | #endif |
| 631 | |
| 632 | |
Jon Loeliger | baa26db | 2007-07-08 17:51:39 -0500 | [diff] [blame] | 633 | #if defined(CONFIG_CMD_BOOTD) |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 634 | int do_bootd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 635 | { |
| 636 | int rcode = 0; |
| 637 | #ifndef CFG_HUSH_PARSER |
| 638 | if (run_command (getenv ("bootcmd"), flag) < 0) rcode = 1; |
| 639 | #else |
| 640 | if (parse_string_outer(getenv("bootcmd"), |
| 641 | FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP) != 0 ) rcode = 1; |
| 642 | #endif |
| 643 | return rcode; |
| 644 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 645 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 646 | U_BOOT_CMD( |
| 647 | boot, 1, 1, do_bootd, |
wdenk | 9d2b18a | 2003-06-28 23:11:04 +0000 | [diff] [blame] | 648 | "boot - boot default, i.e., run 'bootcmd'\n", |
| 649 | NULL |
| 650 | ); |
| 651 | |
| 652 | /* keep old command name "bootd" for backward compatibility */ |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 653 | U_BOOT_CMD( |
| 654 | bootd, 1, 1, do_bootd, |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 655 | "bootd - boot default, i.e., run 'bootcmd'\n", |
| 656 | NULL |
| 657 | ); |
| 658 | |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 659 | #endif |
| 660 | |
Jon Loeliger | baa26db | 2007-07-08 17:51:39 -0500 | [diff] [blame] | 661 | #if defined(CONFIG_CMD_IMI) |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 662 | int do_iminfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 663 | { |
| 664 | int arg; |
| 665 | ulong addr; |
| 666 | int rcode=0; |
| 667 | |
| 668 | if (argc < 2) { |
| 669 | return image_info (load_addr); |
| 670 | } |
| 671 | |
| 672 | for (arg=1; arg <argc; ++arg) { |
| 673 | addr = simple_strtoul(argv[arg], NULL, 16); |
| 674 | if (image_info (addr) != 0) rcode = 1; |
| 675 | } |
| 676 | return rcode; |
| 677 | } |
| 678 | |
| 679 | static int image_info (ulong addr) |
| 680 | { |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 681 | image_header_t *hdr = (image_header_t *)addr; |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 682 | |
| 683 | printf ("\n## Checking Image at %08lx ...\n", addr); |
| 684 | |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 685 | if (!image_check_magic (hdr)) { |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 686 | puts (" Bad Magic Number\n"); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 687 | return 1; |
| 688 | } |
| 689 | |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 690 | if (!image_check_hcrc (hdr)) { |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 691 | puts (" Bad Header Checksum\n"); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 692 | return 1; |
| 693 | } |
| 694 | |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 695 | print_image_hdr (hdr); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 696 | |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 697 | puts (" Verifying Checksum ... "); |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 698 | if (!image_check_dcrc (hdr)) { |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 699 | puts (" Bad Data CRC\n"); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 700 | return 1; |
| 701 | } |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 702 | puts ("OK\n"); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 703 | return 0; |
| 704 | } |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 705 | |
| 706 | U_BOOT_CMD( |
| 707 | iminfo, CFG_MAXARGS, 1, do_iminfo, |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 708 | "iminfo - print header information for application image\n", |
| 709 | "addr [addr ...]\n" |
| 710 | " - print header information for application image starting at\n" |
| 711 | " address 'addr' in memory; this includes verification of the\n" |
| 712 | " image contents (magic number, header and payload checksums)\n" |
| 713 | ); |
| 714 | |
Jon Loeliger | 9025317 | 2007-07-10 11:02:44 -0500 | [diff] [blame] | 715 | #endif |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 716 | |
Jon Loeliger | baa26db | 2007-07-08 17:51:39 -0500 | [diff] [blame] | 717 | #if defined(CONFIG_CMD_IMLS) |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 718 | /*----------------------------------------------------------------------- |
| 719 | * List all images found in flash. |
| 720 | */ |
| 721 | int do_imls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 722 | { |
| 723 | flash_info_t *info; |
| 724 | int i, j; |
| 725 | image_header_t *hdr; |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 726 | |
| 727 | for (i=0, info=&flash_info[0]; i<CFG_MAX_FLASH_BANKS; ++i, ++info) { |
| 728 | if (info->flash_id == FLASH_UNKNOWN) |
| 729 | goto next_bank; |
Marian Balakowicz | e6f2e90 | 2005-10-11 19:09:42 +0200 | [diff] [blame] | 730 | for (j=0; j<info->sector_count; ++j) { |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 731 | |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 732 | hdr = (image_header_t *)info->start[j]; |
| 733 | |
| 734 | if (!hdr || !image_check_magic (hdr)) |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 735 | goto next_sector; |
| 736 | |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 737 | if (!image_check_hcrc (hdr)) |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 738 | goto next_sector; |
| 739 | |
| 740 | printf ("Image at %08lX:\n", (ulong)hdr); |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 741 | print_image_hdr (hdr); |
wdenk | 5bb226e | 2003-11-17 21:14:37 +0000 | [diff] [blame] | 742 | |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 743 | puts (" Verifying Checksum ... "); |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 744 | if (!image_check_dcrc (hdr)) { |
| 745 | puts ("Bad Data CRC\n"); |
| 746 | } else { |
| 747 | puts ("OK\n"); |
wdenk | 5bb226e | 2003-11-17 21:14:37 +0000 | [diff] [blame] | 748 | } |
wdenk | bdccc4f | 2003-08-05 17:43:17 +0000 | [diff] [blame] | 749 | next_sector: ; |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 750 | } |
wdenk | bdccc4f | 2003-08-05 17:43:17 +0000 | [diff] [blame] | 751 | next_bank: ; |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 752 | } |
| 753 | |
| 754 | return (0); |
| 755 | } |
| 756 | |
| 757 | U_BOOT_CMD( |
| 758 | imls, 1, 1, do_imls, |
| 759 | "imls - list all images found in flash\n", |
| 760 | "\n" |
| 761 | " - Prints information about all images found at sector\n" |
| 762 | " boundaries in flash.\n" |
| 763 | ); |
Jon Loeliger | 9025317 | 2007-07-10 11:02:44 -0500 | [diff] [blame] | 764 | #endif |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 765 | |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 766 | void |
| 767 | print_image_hdr (image_header_t *hdr) |
| 768 | { |
Jon Loeliger | baa26db | 2007-07-08 17:51:39 -0500 | [diff] [blame] | 769 | #if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 770 | time_t timestamp = (time_t)image_get_time (hdr); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 771 | struct rtc_time tm; |
| 772 | #endif |
| 773 | |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 774 | printf (" Image Name: %.*s\n", IH_NMLEN, image_get_name (hdr)); |
Jon Loeliger | baa26db | 2007-07-08 17:51:39 -0500 | [diff] [blame] | 775 | #if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 776 | to_tm (timestamp, &tm); |
| 777 | printf (" Created: %4d-%02d-%02d %2d:%02d:%02d UTC\n", |
| 778 | tm.tm_year, tm.tm_mon, tm.tm_mday, |
| 779 | tm.tm_hour, tm.tm_min, tm.tm_sec); |
Jon Loeliger | 9025317 | 2007-07-10 11:02:44 -0500 | [diff] [blame] | 780 | #endif |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 781 | puts (" Image Type: "); print_type(hdr); |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 782 | printf ("\n Data Size: %d Bytes = ", image_get_data_size (hdr)); |
| 783 | print_size (image_get_data_size (hdr), "\n"); |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 784 | printf (" Load Address: %08x\n" |
| 785 | " Entry Point: %08x\n", |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 786 | image_get_load (hdr), image_get_ep (hdr)); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 787 | |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 788 | if (image_check_type (hdr, IH_TYPE_MULTI)) { |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 789 | int i; |
| 790 | ulong len; |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 791 | ulong *len_ptr = (ulong *)((ulong)hdr + image_get_header_size ()); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 792 | |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 793 | puts (" Contents:\n"); |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 794 | for (i=0; (len = image_to_cpu (*len_ptr)); ++i, ++len_ptr) { |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 795 | printf (" Image %d: %8ld Bytes = ", i, len); |
| 796 | print_size (len, "\n"); |
| 797 | } |
| 798 | } |
| 799 | } |
| 800 | |
| 801 | |
| 802 | static void |
| 803 | print_type (image_header_t *hdr) |
| 804 | { |
| 805 | char *os, *arch, *type, *comp; |
| 806 | |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 807 | switch (image_get_os (hdr)) { |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 808 | case IH_OS_INVALID: os = "Invalid OS"; break; |
| 809 | case IH_OS_NETBSD: os = "NetBSD"; break; |
| 810 | case IH_OS_LINUX: os = "Linux"; break; |
| 811 | case IH_OS_VXWORKS: os = "VxWorks"; break; |
| 812 | case IH_OS_QNX: os = "QNX"; break; |
| 813 | case IH_OS_U_BOOT: os = "U-Boot"; break; |
wdenk | d791b1d | 2003-04-20 14:04:18 +0000 | [diff] [blame] | 814 | case IH_OS_RTEMS: os = "RTEMS"; break; |
wdenk | 7f70e85 | 2003-05-20 14:25:27 +0000 | [diff] [blame] | 815 | #ifdef CONFIG_ARTOS |
| 816 | case IH_OS_ARTOS: os = "ARTOS"; break; |
| 817 | #endif |
wdenk | 1f4bb37 | 2003-07-27 00:21:01 +0000 | [diff] [blame] | 818 | #ifdef CONFIG_LYNXKDI |
| 819 | case IH_OS_LYNXOS: os = "LynxOS"; break; |
| 820 | #endif |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 821 | default: os = "Unknown OS"; break; |
| 822 | } |
| 823 | |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 824 | switch (image_get_arch (hdr)) { |
| 825 | case IH_ARCH_INVALID: arch = "Invalid CPU"; break; |
| 826 | case IH_ARCH_ALPHA: arch = "Alpha"; break; |
| 827 | case IH_ARCH_ARM: arch = "ARM"; break; |
| 828 | case IH_ARCH_AVR32: arch = "AVR32"; break; |
| 829 | case IH_ARCH_BLACKFIN: arch = "Blackfin"; break; |
| 830 | case IH_ARCH_I386: arch = "Intel x86"; break; |
| 831 | case IH_ARCH_IA64: arch = "IA64"; break; |
| 832 | case IH_ARCH_M68K: arch = "M68K"; break; |
| 833 | case IH_ARCH_MICROBLAZE:arch = "Microblaze"; break; |
| 834 | case IH_ARCH_MIPS64: arch = "MIPS 64 Bit"; break; |
| 835 | case IH_ARCH_MIPS: arch = "MIPS"; break; |
| 836 | case IH_ARCH_NIOS2: arch = "Nios-II"; break; |
| 837 | case IH_ARCH_NIOS: arch = "Nios"; break; |
| 838 | case IH_ARCH_PPC: arch = "PowerPC"; break; |
| 839 | case IH_ARCH_S390: arch = "IBM S390"; break; |
| 840 | case IH_ARCH_SH: arch = "SuperH"; break; |
| 841 | case IH_ARCH_SPARC64: arch = "SPARC 64 Bit"; break; |
| 842 | case IH_ARCH_SPARC: arch = "SPARC"; break; |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 843 | default: arch = "Unknown Architecture"; break; |
| 844 | } |
| 845 | |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 846 | switch (image_get_type (hdr)) { |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 847 | case IH_TYPE_INVALID: type = "Invalid Image"; break; |
| 848 | case IH_TYPE_STANDALONE:type = "Standalone Program"; break; |
| 849 | case IH_TYPE_KERNEL: type = "Kernel Image"; break; |
| 850 | case IH_TYPE_RAMDISK: type = "RAMDisk Image"; break; |
| 851 | case IH_TYPE_MULTI: type = "Multi-File Image"; break; |
| 852 | case IH_TYPE_FIRMWARE: type = "Firmware"; break; |
| 853 | case IH_TYPE_SCRIPT: type = "Script"; break; |
Matthew McClintock | 25c751e | 2006-08-16 10:54:09 -0500 | [diff] [blame] | 854 | case IH_TYPE_FLATDT: type = "Flat Device Tree"; break; |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 855 | default: type = "Unknown Image"; break; |
| 856 | } |
| 857 | |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 858 | switch (image_get_comp (hdr)) { |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 859 | case IH_COMP_NONE: comp = "uncompressed"; break; |
| 860 | case IH_COMP_GZIP: comp = "gzip compressed"; break; |
| 861 | case IH_COMP_BZIP2: comp = "bzip2 compressed"; break; |
| 862 | default: comp = "unknown compression"; break; |
| 863 | } |
| 864 | |
| 865 | printf ("%s %s %s (%s)", arch, os, type, comp); |
| 866 | } |
| 867 | |
| 868 | #define ZALLOC_ALIGNMENT 16 |
| 869 | |
| 870 | static void *zalloc(void *x, unsigned items, unsigned size) |
| 871 | { |
| 872 | void *p; |
| 873 | |
| 874 | size *= items; |
| 875 | size = (size + ZALLOC_ALIGNMENT - 1) & ~(ZALLOC_ALIGNMENT - 1); |
| 876 | |
| 877 | p = malloc (size); |
| 878 | |
| 879 | return (p); |
| 880 | } |
| 881 | |
| 882 | static void zfree(void *x, void *addr, unsigned nb) |
| 883 | { |
| 884 | free (addr); |
| 885 | } |
| 886 | |
| 887 | #define HEAD_CRC 2 |
| 888 | #define EXTRA_FIELD 4 |
| 889 | #define ORIG_NAME 8 |
| 890 | #define COMMENT 0x10 |
| 891 | #define RESERVED 0xe0 |
| 892 | |
| 893 | #define DEFLATED 8 |
| 894 | |
wdenk | eedcd07 | 2004-09-08 22:03:11 +0000 | [diff] [blame] | 895 | int gunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp) |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 896 | { |
| 897 | z_stream s; |
| 898 | int r, i, flags; |
| 899 | |
| 900 | /* skip header */ |
| 901 | i = 10; |
| 902 | flags = src[3]; |
| 903 | if (src[2] != DEFLATED || (flags & RESERVED) != 0) { |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 904 | puts ("Error: Bad gzipped data\n"); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 905 | return (-1); |
| 906 | } |
| 907 | if ((flags & EXTRA_FIELD) != 0) |
| 908 | i = 12 + src[10] + (src[11] << 8); |
| 909 | if ((flags & ORIG_NAME) != 0) |
| 910 | while (src[i++] != 0) |
| 911 | ; |
| 912 | if ((flags & COMMENT) != 0) |
| 913 | while (src[i++] != 0) |
| 914 | ; |
| 915 | if ((flags & HEAD_CRC) != 0) |
| 916 | i += 2; |
| 917 | if (i >= *lenp) { |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 918 | puts ("Error: gunzip out of data in header\n"); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 919 | return (-1); |
| 920 | } |
| 921 | |
| 922 | s.zalloc = zalloc; |
| 923 | s.zfree = zfree; |
| 924 | #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG) |
| 925 | s.outcb = (cb_func)WATCHDOG_RESET; |
| 926 | #else |
| 927 | s.outcb = Z_NULL; |
| 928 | #endif /* CONFIG_HW_WATCHDOG */ |
| 929 | |
| 930 | r = inflateInit2(&s, -MAX_WBITS); |
| 931 | if (r != Z_OK) { |
| 932 | printf ("Error: inflateInit2() returned %d\n", r); |
| 933 | return (-1); |
| 934 | } |
| 935 | s.next_in = src + i; |
| 936 | s.avail_in = *lenp - i; |
| 937 | s.next_out = dst; |
| 938 | s.avail_out = dstlen; |
| 939 | r = inflate(&s, Z_FINISH); |
| 940 | if (r != Z_OK && r != Z_STREAM_END) { |
| 941 | printf ("Error: inflate() returned %d\n", r); |
| 942 | return (-1); |
| 943 | } |
| 944 | *lenp = s.next_out - (unsigned char *) dst; |
| 945 | inflateEnd(&s); |
| 946 | |
| 947 | return (0); |
| 948 | } |
| 949 | |
wdenk | c29fdfc | 2003-08-29 20:57:53 +0000 | [diff] [blame] | 950 | #ifdef CONFIG_BZIP2 |
| 951 | void bz_internal_error(int errcode) |
| 952 | { |
| 953 | printf ("BZIP2 internal error %d\n", errcode); |
| 954 | } |
| 955 | #endif /* CONFIG_BZIP2 */ |
| 956 | |
wdenk | d791b1d | 2003-04-20 14:04:18 +0000 | [diff] [blame] | 957 | static void |
| 958 | do_bootm_rtems (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], |
| 959 | ulong addr, ulong *len_ptr, int verify) |
| 960 | { |
wdenk | d791b1d | 2003-04-20 14:04:18 +0000 | [diff] [blame] | 961 | image_header_t *hdr = &header; |
| 962 | void (*entry_point)(bd_t *); |
| 963 | |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 964 | entry_point = (void (*)(bd_t *))image_get_ep (hdr); |
wdenk | d791b1d | 2003-04-20 14:04:18 +0000 | [diff] [blame] | 965 | |
| 966 | printf ("## Transferring control to RTEMS (at address %08lx) ...\n", |
| 967 | (ulong)entry_point); |
| 968 | |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 969 | show_boot_progress (15); |
wdenk | d791b1d | 2003-04-20 14:04:18 +0000 | [diff] [blame] | 970 | |
| 971 | /* |
| 972 | * RTEMS Parameters: |
| 973 | * r3: ptr to board info data |
| 974 | */ |
| 975 | |
| 976 | (*entry_point ) ( gd->bd ); |
| 977 | } |
| 978 | |
Jon Loeliger | baa26db | 2007-07-08 17:51:39 -0500 | [diff] [blame] | 979 | #if defined(CONFIG_CMD_ELF) |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 980 | static void |
| 981 | do_bootm_vxworks (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], |
| 982 | ulong addr, ulong *len_ptr, int verify) |
| 983 | { |
| 984 | image_header_t *hdr = &header; |
| 985 | char str[80]; |
| 986 | |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 987 | sprintf(str, "%x", image_get_ep (hdr)); /* write entry-point into string */ |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 988 | setenv("loadaddr", str); |
| 989 | do_bootvx(cmdtp, 0, 0, NULL); |
| 990 | } |
| 991 | |
| 992 | static void |
| 993 | do_bootm_qnxelf (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], |
| 994 | ulong addr, ulong *len_ptr, int verify) |
| 995 | { |
| 996 | image_header_t *hdr = &header; |
| 997 | char *local_args[2]; |
| 998 | char str[16]; |
| 999 | |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 1000 | sprintf(str, "%x", image_get_ep (hdr)); /* write entry-point into string */ |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 1001 | local_args[0] = argv[0]; |
| 1002 | local_args[1] = str; /* and provide it via the arguments */ |
| 1003 | do_bootelf(cmdtp, 0, 2, local_args); |
| 1004 | } |
Jon Loeliger | 9025317 | 2007-07-10 11:02:44 -0500 | [diff] [blame] | 1005 | #endif |
wdenk | 1f4bb37 | 2003-07-27 00:21:01 +0000 | [diff] [blame] | 1006 | |
| 1007 | #ifdef CONFIG_LYNXKDI |
| 1008 | static void |
| 1009 | do_bootm_lynxkdi (cmd_tbl_t *cmdtp, int flag, |
| 1010 | int argc, char *argv[], |
| 1011 | ulong addr, |
| 1012 | ulong *len_ptr, |
| 1013 | int verify) |
| 1014 | { |
| 1015 | lynxkdi_boot( &header ); |
| 1016 | } |
| 1017 | |
| 1018 | #endif /* CONFIG_LYNXKDI */ |