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 | |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 25 | /* |
| 26 | * Boot support |
| 27 | */ |
| 28 | #include <common.h> |
| 29 | #include <watchdog.h> |
| 30 | #include <command.h> |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 31 | #include <image.h> |
| 32 | #include <malloc.h> |
| 33 | #include <zlib.h> |
wdenk | c29fdfc | 2003-08-29 20:57:53 +0000 | [diff] [blame] | 34 | #include <bzlib.h> |
wdenk | 7f70e85 | 2003-05-20 14:25:27 +0000 | [diff] [blame] | 35 | #include <environment.h> |
Kumar Gala | 4ed6552 | 2008-02-27 21:51:47 -0600 | [diff] [blame] | 36 | #include <lmb.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 | |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 39 | #ifdef CFG_HUSH_PARSER |
| 40 | #include <hush.h> |
| 41 | #endif |
| 42 | |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 43 | DECLARE_GLOBAL_DATA_PTR; |
| 44 | |
| 45 | extern int gunzip (void *dst, int dstlen, unsigned char *src, unsigned long *lenp); |
| 46 | #ifndef CFG_BOOTM_LEN |
| 47 | #define CFG_BOOTM_LEN 0x800000 /* use 8MByte as default max gunzip size */ |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 48 | #endif |
| 49 | |
Marian Balakowicz | 321359f | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 50 | #ifdef CONFIG_BZIP2 |
| 51 | extern void bz_internal_error(int); |
wdenk | 228f29a | 2002-12-08 09:53:23 +0000 | [diff] [blame] | 52 | #endif |
| 53 | |
Jon Loeliger | baa26db | 2007-07-08 17:51:39 -0500 | [diff] [blame] | 54 | #if defined(CONFIG_CMD_IMI) |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 55 | static int image_info (unsigned long addr); |
| 56 | #endif |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 57 | |
Jon Loeliger | baa26db | 2007-07-08 17:51:39 -0500 | [diff] [blame] | 58 | #if defined(CONFIG_CMD_IMLS) |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 59 | #include <flash.h> |
Marian Balakowicz | e6f2e90 | 2005-10-11 19:09:42 +0200 | [diff] [blame] | 60 | extern flash_info_t flash_info[]; /* info for FLASH chips */ |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 61 | static int do_imls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); |
| 62 | #endif |
| 63 | |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 64 | #ifdef CONFIG_SILENT_CONSOLE |
| 65 | static void fixup_silent_linux (void); |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 66 | #endif |
| 67 | |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 68 | static image_header_t *image_get_kernel (ulong img_addr, int verify); |
| 69 | #if defined(CONFIG_FIT) |
| 70 | static int fit_check_kernel (const void *fit, int os_noffset, int verify); |
| 71 | #endif |
| 72 | |
Marian Balakowicz | 9a4daad | 2008-02-29 14:58:34 +0100 | [diff] [blame] | 73 | static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag,int argc, char *argv[], |
Marian Balakowicz | 8a5ea3e | 2008-02-27 11:01:04 +0100 | [diff] [blame] | 74 | bootm_headers_t *images, ulong *os_data, ulong *os_len); |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 75 | extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 76 | |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 77 | /* |
| 78 | * Continue booting an OS image; caller already has: |
| 79 | * - copied image header to global variable `header' |
| 80 | * - checked header magic number, checksums (both header & image), |
| 81 | * - verified image architecture (PPC) and type (KERNEL or MULTI), |
| 82 | * - loaded (first part of) image to header load address, |
| 83 | * - disabled interrupts. |
| 84 | */ |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 85 | typedef void boot_os_fn (cmd_tbl_t *cmdtp, int flag, |
Marian Balakowicz | f13e7b2 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 86 | int argc, char *argv[], |
Marian Balakowicz | 8a5ea3e | 2008-02-27 11:01:04 +0100 | [diff] [blame] | 87 | bootm_headers_t *images); /* pointers to os/initrd/fdt */ |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 88 | |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 89 | extern boot_os_fn do_bootm_linux; |
| 90 | static boot_os_fn do_bootm_netbsd; |
Marian Balakowicz | f13e7b2 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 91 | #if defined(CONFIG_LYNXKDI) |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 92 | static boot_os_fn do_bootm_lynxkdi; |
| 93 | extern void lynxkdi_boot (image_header_t *); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 94 | #endif |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 95 | static boot_os_fn do_bootm_rtems; |
Jon Loeliger | baa26db | 2007-07-08 17:51:39 -0500 | [diff] [blame] | 96 | #if defined(CONFIG_CMD_ELF) |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 97 | static boot_os_fn do_bootm_vxworks; |
| 98 | static boot_os_fn do_bootm_qnxelf; |
| 99 | int do_bootvx (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); |
| 100 | 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] | 101 | #endif |
wdenk | 7f70e85 | 2003-05-20 14:25:27 +0000 | [diff] [blame] | 102 | #if defined(CONFIG_ARTOS) && defined(CONFIG_PPC) |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 103 | extern uchar (*env_get_char)(int); /* Returns a character from the environment */ |
| 104 | static boot_os_fn do_bootm_artos; |
wdenk | 1f4bb37 | 2003-07-27 00:21:01 +0000 | [diff] [blame] | 105 | #endif |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 106 | |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 107 | ulong load_addr = CFG_LOAD_ADDR; /* Default Load Address */ |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 108 | static bootm_headers_t images; /* pointers to os/initrd/fdt images */ |
Stefan Roese | 15940c9 | 2006-03-13 11:16:36 +0100 | [diff] [blame] | 109 | |
Kumar Gala | e822d7f | 2008-02-27 21:51:49 -0600 | [diff] [blame] | 110 | void __board_lmb_reserve(struct lmb *lmb) |
| 111 | { |
| 112 | /* please define platform specific board_lmb_reserve() */ |
| 113 | } |
| 114 | void board_lmb_reserve(struct lmb *lmb) __attribute__((weak, alias("__board_lmb_reserve"))); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 115 | |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 116 | |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 117 | /*******************************************************************/ |
| 118 | /* bootm - boot application image from image in memory */ |
| 119 | /*******************************************************************/ |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 120 | int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 121 | { |
Marian Balakowicz | f13e7b2 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 122 | ulong iflag; |
Marian Balakowicz | 42b73e8 | 2008-01-31 13:20:07 +0100 | [diff] [blame] | 123 | const char *type_name; |
Marian Balakowicz | f13e7b2 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 124 | uint unc_len = CFG_BOOTM_LEN; |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 125 | uint8_t comp, type, os; |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 126 | |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 127 | void *os_hdr; |
Marian Balakowicz | f13e7b2 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 128 | ulong os_data, os_len; |
Marian Balakowicz | 7582438 | 2008-01-31 13:20:06 +0100 | [diff] [blame] | 129 | ulong image_start, image_end; |
| 130 | ulong load_start, load_end; |
Kumar Gala | d3f2fa0 | 2008-02-27 21:51:50 -0600 | [diff] [blame] | 131 | ulong mem_start, mem_size; |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 132 | |
Kumar Gala | 4ed6552 | 2008-02-27 21:51:47 -0600 | [diff] [blame] | 133 | struct lmb lmb; |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 134 | |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 135 | memset ((void *)&images, 0, sizeof (images)); |
Marian Balakowicz | 8a5ea3e | 2008-02-27 11:01:04 +0100 | [diff] [blame] | 136 | images.verify = getenv_verify(); |
Kumar Gala | f5614e7 | 2008-02-27 21:51:48 -0600 | [diff] [blame] | 137 | images.autostart = getenv_autostart(); |
Kumar Gala | 4ed6552 | 2008-02-27 21:51:47 -0600 | [diff] [blame] | 138 | images.lmb = &lmb; |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 139 | |
Kumar Gala | 4ed6552 | 2008-02-27 21:51:47 -0600 | [diff] [blame] | 140 | lmb_init(&lmb); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 141 | |
Kumar Gala | d3f2fa0 | 2008-02-27 21:51:50 -0600 | [diff] [blame] | 142 | mem_start = getenv_bootm_low(); |
| 143 | mem_size = getenv_bootm_size(); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 144 | |
Kumar Gala | d3f2fa0 | 2008-02-27 21:51:50 -0600 | [diff] [blame] | 145 | lmb_add(&lmb, mem_start, mem_size); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 146 | |
Kumar Gala | e822d7f | 2008-02-27 21:51:49 -0600 | [diff] [blame] | 147 | board_lmb_reserve(&lmb); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 148 | |
Marian Balakowicz | 5cf746c | 2008-01-31 13:59:09 +0100 | [diff] [blame] | 149 | /* get kernel image header, start address and length */ |
Marian Balakowicz | 9a4daad | 2008-02-29 14:58:34 +0100 | [diff] [blame] | 150 | os_hdr = boot_get_kernel (cmdtp, flag, argc, argv, |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 151 | &images, &os_data, &os_len); |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 152 | if (os_len == 0) { |
| 153 | puts ("ERROR: can't get kernel image!\n"); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 154 | return 1; |
| 155 | } |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 156 | |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 157 | /* get image parameters */ |
Marian Balakowicz | 9a4daad | 2008-02-29 14:58:34 +0100 | [diff] [blame] | 158 | switch (genimg_get_format (os_hdr)) { |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 159 | case IMAGE_FORMAT_LEGACY: |
| 160 | type = image_get_type (os_hdr); |
| 161 | comp = image_get_comp (os_hdr); |
| 162 | os = image_get_os (os_hdr); |
Wolfgang Denk | bccae90 | 2005-10-06 01:50:50 +0200 | [diff] [blame] | 163 | |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 164 | image_end = image_get_image_end (os_hdr); |
| 165 | load_start = image_get_load (os_hdr); |
| 166 | break; |
| 167 | #if defined(CONFIG_FIT) |
| 168 | case IMAGE_FORMAT_FIT: |
Marian Balakowicz | 3dfe110 | 2008-03-12 10:32:59 +0100 | [diff] [blame] | 169 | if (fit_image_get_type (images.fit_hdr_os, |
| 170 | images.fit_noffset_os, &type)) { |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 171 | puts ("Can't get image type!\n"); |
Marian Balakowicz | 1372cce | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 172 | show_boot_progress (-109); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 173 | return 1; |
| 174 | } |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 175 | |
Marian Balakowicz | 3dfe110 | 2008-03-12 10:32:59 +0100 | [diff] [blame] | 176 | if (fit_image_get_comp (images.fit_hdr_os, |
| 177 | images.fit_noffset_os, &comp)) { |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 178 | puts ("Can't get image compression!\n"); |
Marian Balakowicz | 1372cce | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 179 | show_boot_progress (-110); |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 180 | return 1; |
| 181 | } |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 182 | |
Marian Balakowicz | 3dfe110 | 2008-03-12 10:32:59 +0100 | [diff] [blame] | 183 | if (fit_image_get_os (images.fit_hdr_os, |
| 184 | images.fit_noffset_os, &os)) { |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 185 | puts ("Can't get image OS!\n"); |
Marian Balakowicz | 1372cce | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 186 | show_boot_progress (-111); |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 187 | return 1; |
| 188 | } |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 189 | |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 190 | image_end = fit_get_end (images.fit_hdr_os); |
| 191 | |
Marian Balakowicz | 3dfe110 | 2008-03-12 10:32:59 +0100 | [diff] [blame] | 192 | if (fit_image_get_load (images.fit_hdr_os, images.fit_noffset_os, |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 193 | &load_start)) { |
| 194 | puts ("Can't get image load address!\n"); |
Marian Balakowicz | 1372cce | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 195 | show_boot_progress (-112); |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 196 | return 1; |
wdenk | b13fb01 | 2003-10-30 21:49:38 +0000 | [diff] [blame] | 197 | } |
| 198 | break; |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 199 | #endif |
| 200 | default: |
| 201 | puts ("ERROR: unknown image format type!\n"); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 202 | return 1; |
| 203 | } |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 204 | |
| 205 | image_start = (ulong)os_hdr; |
| 206 | load_end = 0; |
Marian Balakowicz | 9a4daad | 2008-02-29 14:58:34 +0100 | [diff] [blame] | 207 | type_name = genimg_get_type_name (type); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 208 | |
| 209 | /* |
| 210 | * We have reached the point of no return: we are going to |
| 211 | * overwrite all exception vector code, so we cannot easily |
| 212 | * recover from any failures any more... |
| 213 | */ |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 214 | iflag = disable_interrupts(); |
| 215 | |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 216 | #ifdef CONFIG_AMIGAONEG3SE |
| 217 | /* |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 218 | * We've possible left the caches enabled during |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 219 | * bios emulation, so turn them off again |
| 220 | */ |
| 221 | icache_disable(); |
| 222 | invalidate_l1_instruction_cache(); |
| 223 | flush_data_cache(); |
| 224 | dcache_disable(); |
| 225 | #endif |
| 226 | |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 227 | switch (comp) { |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 228 | case IH_COMP_NONE: |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 229 | if (load_start == (ulong)os_hdr) { |
Marian Balakowicz | 42b73e8 | 2008-01-31 13:20:07 +0100 | [diff] [blame] | 230 | printf (" XIP %s ... ", type_name); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 231 | } else { |
Marian Balakowicz | 42b73e8 | 2008-01-31 13:20:07 +0100 | [diff] [blame] | 232 | printf (" Loading %s ... ", type_name); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 233 | |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 234 | memmove_wd ((void *)load_start, |
Marian Balakowicz | f13e7b2 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 235 | (void *)os_data, os_len, CHUNKSZ); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 236 | |
Marian Balakowicz | 7582438 | 2008-01-31 13:20:06 +0100 | [diff] [blame] | 237 | load_end = load_start + os_len; |
Marian Balakowicz | af13cdb | 2008-01-08 18:11:45 +0100 | [diff] [blame] | 238 | puts("OK\n"); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 239 | } |
| 240 | break; |
| 241 | case IH_COMP_GZIP: |
Marian Balakowicz | 42b73e8 | 2008-01-31 13:20:07 +0100 | [diff] [blame] | 242 | printf (" Uncompressing %s ... ", type_name); |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 243 | if (gunzip ((void *)load_start, unc_len, |
Marian Balakowicz | f13e7b2 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 244 | (uchar *)os_data, &os_len) != 0) { |
Marian Balakowicz | 2682ce8 | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 245 | puts ("GUNZIP: uncompress or overwrite error " |
| 246 | "- must RESET board to recover\n"); |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 247 | show_boot_progress (-6); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 248 | do_reset (cmdtp, flag, argc, argv); |
| 249 | } |
Marian Balakowicz | 7582438 | 2008-01-31 13:20:06 +0100 | [diff] [blame] | 250 | |
| 251 | load_end = load_start + os_len; |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 252 | break; |
wdenk | c29fdfc | 2003-08-29 20:57:53 +0000 | [diff] [blame] | 253 | #ifdef CONFIG_BZIP2 |
| 254 | case IH_COMP_BZIP2: |
Marian Balakowicz | 42b73e8 | 2008-01-31 13:20:07 +0100 | [diff] [blame] | 255 | printf (" Uncompressing %s ... ", type_name); |
wdenk | 5653fc3 | 2004-02-08 22:55:38 +0000 | [diff] [blame] | 256 | /* |
| 257 | * If we've got less than 4 MB of malloc() space, |
| 258 | * use slower decompression algorithm which requires |
| 259 | * at most 2300 KB of memory. |
| 260 | */ |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 261 | int i = BZ2_bzBuffToBuffDecompress ((char*)load_start, |
Marian Balakowicz | f13e7b2 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 262 | &unc_len, (char *)os_data, os_len, |
| 263 | CFG_MALLOC_LEN < (4096 * 1024), 0); |
wdenk | c29fdfc | 2003-08-29 20:57:53 +0000 | [diff] [blame] | 264 | if (i != BZ_OK) { |
Marian Balakowicz | 2682ce8 | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 265 | printf ("BUNZIP2: uncompress or overwrite error %d " |
| 266 | "- must RESET board to recover\n", i); |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 267 | show_boot_progress (-6); |
wdenk | c29fdfc | 2003-08-29 20:57:53 +0000 | [diff] [blame] | 268 | do_reset (cmdtp, flag, argc, argv); |
| 269 | } |
Marian Balakowicz | 7582438 | 2008-01-31 13:20:06 +0100 | [diff] [blame] | 270 | |
| 271 | load_end = load_start + unc_len; |
wdenk | c29fdfc | 2003-08-29 20:57:53 +0000 | [diff] [blame] | 272 | break; |
| 273 | #endif /* CONFIG_BZIP2 */ |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 274 | default: |
| 275 | if (iflag) |
| 276 | enable_interrupts(); |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 277 | printf ("Unimplemented compression type %d\n", comp); |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 278 | show_boot_progress (-7); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 279 | return 1; |
| 280 | } |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 281 | puts ("OK\n"); |
Marian Balakowicz | 5cf746c | 2008-01-31 13:59:09 +0100 | [diff] [blame] | 282 | debug (" kernel loaded at 0x%08lx, end = 0x%08lx\n", load_start, load_end); |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 283 | show_boot_progress (7); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 284 | |
Marian Balakowicz | 7582438 | 2008-01-31 13:20:06 +0100 | [diff] [blame] | 285 | if ((load_start < image_end) && (load_end > image_start)) { |
| 286 | debug ("image_start = 0x%lX, image_end = 0x%lx\n", image_start, image_end); |
| 287 | debug ("load_start = 0x%lx, load_end = 0x%lx\n", load_start, load_end); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 288 | |
Marian Balakowicz | cb1c489 | 2008-04-11 11:07:49 +0200 | [diff] [blame^] | 289 | if (images.legacy_hdr_valid) { |
| 290 | if (image_get_type (&images.legacy_hdr_os_copy) == IH_TYPE_MULTI) |
| 291 | puts ("WARNING: legacy format multi component " |
| 292 | "image overwritten\n"); |
| 293 | } else { |
| 294 | puts ("ERROR: new format image overwritten - " |
| 295 | "must RESET the board to recover\n"); |
| 296 | show_boot_progress (-113); |
| 297 | do_reset (cmdtp, flag, argc, argv); |
| 298 | } |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 299 | } |
Marian Balakowicz | 7582438 | 2008-01-31 13:20:06 +0100 | [diff] [blame] | 300 | |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 301 | show_boot_progress (8); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 302 | |
Kumar Gala | 4ed6552 | 2008-02-27 21:51:47 -0600 | [diff] [blame] | 303 | lmb_reserve(&lmb, load_start, (load_end - load_start)); |
| 304 | |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 305 | switch (os) { |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 306 | default: /* handled by (original) Linux case */ |
| 307 | case IH_OS_LINUX: |
wdenk | f72da34 | 2003-10-10 10:05:42 +0000 | [diff] [blame] | 308 | #ifdef CONFIG_SILENT_CONSOLE |
| 309 | fixup_silent_linux(); |
| 310 | #endif |
Marian Balakowicz | 8a5ea3e | 2008-02-27 11:01:04 +0100 | [diff] [blame] | 311 | do_bootm_linux (cmdtp, flag, argc, argv, &images); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 312 | break; |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 313 | |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 314 | case IH_OS_NETBSD: |
Marian Balakowicz | 8a5ea3e | 2008-02-27 11:01:04 +0100 | [diff] [blame] | 315 | do_bootm_netbsd (cmdtp, flag, argc, argv, &images); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 316 | break; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 317 | |
wdenk | 1f4bb37 | 2003-07-27 00:21:01 +0000 | [diff] [blame] | 318 | #ifdef CONFIG_LYNXKDI |
| 319 | case IH_OS_LYNXOS: |
Marian Balakowicz | 8a5ea3e | 2008-02-27 11:01:04 +0100 | [diff] [blame] | 320 | do_bootm_lynxkdi (cmdtp, flag, argc, argv, &images); |
wdenk | 1f4bb37 | 2003-07-27 00:21:01 +0000 | [diff] [blame] | 321 | break; |
| 322 | #endif |
| 323 | |
wdenk | d791b1d | 2003-04-20 14:04:18 +0000 | [diff] [blame] | 324 | case IH_OS_RTEMS: |
Marian Balakowicz | 8a5ea3e | 2008-02-27 11:01:04 +0100 | [diff] [blame] | 325 | do_bootm_rtems (cmdtp, flag, argc, argv, &images); |
wdenk | d791b1d | 2003-04-20 14:04:18 +0000 | [diff] [blame] | 326 | break; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 327 | |
Jon Loeliger | baa26db | 2007-07-08 17:51:39 -0500 | [diff] [blame] | 328 | #if defined(CONFIG_CMD_ELF) |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 329 | case IH_OS_VXWORKS: |
Marian Balakowicz | 8a5ea3e | 2008-02-27 11:01:04 +0100 | [diff] [blame] | 330 | do_bootm_vxworks (cmdtp, flag, argc, argv, &images); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 331 | break; |
Marian Balakowicz | f13e7b2 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 332 | |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 333 | case IH_OS_QNX: |
Marian Balakowicz | 8a5ea3e | 2008-02-27 11:01:04 +0100 | [diff] [blame] | 334 | do_bootm_qnxelf (cmdtp, flag, argc, argv, &images); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 335 | break; |
Jon Loeliger | 9025317 | 2007-07-10 11:02:44 -0500 | [diff] [blame] | 336 | #endif |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 337 | |
wdenk | 7f70e85 | 2003-05-20 14:25:27 +0000 | [diff] [blame] | 338 | #ifdef CONFIG_ARTOS |
| 339 | case IH_OS_ARTOS: |
Marian Balakowicz | 8a5ea3e | 2008-02-27 11:01:04 +0100 | [diff] [blame] | 340 | do_bootm_artos (cmdtp, flag, argc, argv, &images); |
wdenk | 7f70e85 | 2003-05-20 14:25:27 +0000 | [diff] [blame] | 341 | break; |
| 342 | #endif |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 343 | } |
| 344 | |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 345 | show_boot_progress (-9); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 346 | #ifdef DEBUG |
wdenk | 4b9206e | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 347 | puts ("\n## Control returned to monitor - resetting...\n"); |
Marian Balakowicz | a44a269 | 2008-03-12 10:14:57 +0100 | [diff] [blame] | 348 | if (images.autostart) |
| 349 | do_reset (cmdtp, flag, argc, argv); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 350 | #endif |
Marian Balakowicz | a44a269 | 2008-03-12 10:14:57 +0100 | [diff] [blame] | 351 | if (!images.autostart && iflag) |
| 352 | enable_interrupts(); |
| 353 | |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 354 | return 1; |
| 355 | } |
| 356 | |
Marian Balakowicz | 5cf746c | 2008-01-31 13:59:09 +0100 | [diff] [blame] | 357 | /** |
Marian Balakowicz | 9a4daad | 2008-02-29 14:58:34 +0100 | [diff] [blame] | 358 | * image_get_kernel - verify legacy format kernel image |
| 359 | * @img_addr: in RAM address of the legacy format image to be verified |
| 360 | * @verify: data CRC verification flag |
Marian Balakowicz | 5cf746c | 2008-01-31 13:59:09 +0100 | [diff] [blame] | 361 | * |
Marian Balakowicz | 9a4daad | 2008-02-29 14:58:34 +0100 | [diff] [blame] | 362 | * image_get_kernel() verifies legacy image integrity and returns pointer to |
| 363 | * legacy image header if image verification was completed successfully. |
Marian Balakowicz | 5cf746c | 2008-01-31 13:59:09 +0100 | [diff] [blame] | 364 | * |
| 365 | * returns: |
Marian Balakowicz | 9a4daad | 2008-02-29 14:58:34 +0100 | [diff] [blame] | 366 | * pointer to a legacy image header if valid image was found |
| 367 | * otherwise return NULL |
Marian Balakowicz | 5cf746c | 2008-01-31 13:59:09 +0100 | [diff] [blame] | 368 | */ |
Marian Balakowicz | 1efd436 | 2008-02-27 11:02:07 +0100 | [diff] [blame] | 369 | static image_header_t *image_get_kernel (ulong img_addr, int verify) |
| 370 | { |
| 371 | image_header_t *hdr = (image_header_t *)img_addr; |
| 372 | |
| 373 | if (!image_check_magic(hdr)) { |
| 374 | puts ("Bad Magic Number\n"); |
| 375 | show_boot_progress (-1); |
| 376 | return NULL; |
| 377 | } |
| 378 | show_boot_progress (2); |
| 379 | |
| 380 | if (!image_check_hcrc (hdr)) { |
| 381 | puts ("Bad Header Checksum\n"); |
| 382 | show_boot_progress (-2); |
| 383 | return NULL; |
| 384 | } |
| 385 | |
| 386 | show_boot_progress (3); |
| 387 | image_print_contents (hdr); |
| 388 | |
| 389 | if (verify) { |
| 390 | puts (" Verifying Checksum ... "); |
| 391 | if (!image_check_dcrc (hdr)) { |
| 392 | printf ("Bad Data CRC\n"); |
| 393 | show_boot_progress (-3); |
| 394 | return NULL; |
| 395 | } |
| 396 | puts ("OK\n"); |
| 397 | } |
| 398 | show_boot_progress (4); |
| 399 | |
| 400 | if (!image_check_target_arch (hdr)) { |
| 401 | printf ("Unsupported Architecture 0x%x\n", image_get_arch (hdr)); |
| 402 | show_boot_progress (-4); |
| 403 | return NULL; |
| 404 | } |
| 405 | return hdr; |
| 406 | } |
| 407 | |
| 408 | /** |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 409 | * fit_check_kernel - verify FIT format kernel subimage |
| 410 | * @fit_hdr: pointer to the FIT image header |
| 411 | * os_noffset: kernel subimage node offset within FIT image |
| 412 | * @verify: data CRC verification flag |
| 413 | * |
| 414 | * fit_check_kernel() verifies integrity of the kernel subimage and from |
| 415 | * specified FIT image. |
| 416 | * |
| 417 | * returns: |
| 418 | * 1, on success |
| 419 | * 0, on failure |
| 420 | */ |
| 421 | #if defined (CONFIG_FIT) |
| 422 | static int fit_check_kernel (const void *fit, int os_noffset, int verify) |
| 423 | { |
| 424 | fit_image_print (fit, os_noffset, " "); |
| 425 | |
| 426 | if (verify) { |
| 427 | puts (" Verifying Hash Integrity ... "); |
| 428 | if (!fit_image_check_hashes (fit, os_noffset)) { |
| 429 | puts ("Bad Data Hash\n"); |
Marian Balakowicz | 1372cce | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 430 | show_boot_progress (-104); |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 431 | return 0; |
| 432 | } |
| 433 | puts ("OK\n"); |
| 434 | } |
Marian Balakowicz | 1372cce | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 435 | show_boot_progress (105); |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 436 | |
Bartlomiej Sieka | 27f33e9 | 2008-03-26 09:38:06 +0100 | [diff] [blame] | 437 | #ifdef CONFIG_LOGBUFFER |
| 438 | #ifndef CONFIG_ALT_LB_ADDR |
| 439 | kbd=gd->bd; |
| 440 | /* Prevent initrd from overwriting logbuffer */ |
| 441 | if (initrd_high < (kbd->bi_memsize-LOGBUFF_LEN-LOGBUFF_OVERHEAD)) |
| 442 | initrd_high = kbd->bi_memsize-LOGBUFF_LEN-LOGBUFF_OVERHEAD; |
| 443 | debug ("## Logbuffer at 0x%08lX ", kbd->bi_memsize-LOGBUFF_LEN); |
| 444 | #else |
| 445 | debug ("## Logbuffer at 0x%08lX ", CONFIG_ALT_LB_ADDR); |
| 446 | #endif |
| 447 | #endif |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 448 | if (!fit_image_check_target_arch (fit, os_noffset)) { |
| 449 | puts ("Unsupported Architecture\n"); |
Marian Balakowicz | 1372cce | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 450 | show_boot_progress (-105); |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 451 | return 0; |
| 452 | } |
| 453 | |
Marian Balakowicz | 1372cce | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 454 | show_boot_progress (106); |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 455 | if (!fit_image_check_type (fit, os_noffset, IH_TYPE_KERNEL)) { |
| 456 | puts ("Not a kernel image\n"); |
Marian Balakowicz | 1372cce | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 457 | show_boot_progress (-106); |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 458 | return 0; |
| 459 | } |
| 460 | |
Marian Balakowicz | 1372cce | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 461 | show_boot_progress (107); |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 462 | return 1; |
| 463 | } |
| 464 | #endif /* CONFIG_FIT */ |
| 465 | |
| 466 | /** |
Marian Balakowicz | 9a4daad | 2008-02-29 14:58:34 +0100 | [diff] [blame] | 467 | * boot_get_kernel - find kernel image |
Marian Balakowicz | 1efd436 | 2008-02-27 11:02:07 +0100 | [diff] [blame] | 468 | * @os_data: pointer to a ulong variable, will hold os data start address |
| 469 | * @os_len: pointer to a ulong variable, will hold os data length |
| 470 | * |
Marian Balakowicz | 9a4daad | 2008-02-29 14:58:34 +0100 | [diff] [blame] | 471 | * boot_get_kernel() tries to find a kernel image, verifies its integrity |
Marian Balakowicz | 1efd436 | 2008-02-27 11:02:07 +0100 | [diff] [blame] | 472 | * and locates kernel data. |
| 473 | * |
| 474 | * returns: |
| 475 | * pointer to image header if valid image was found, plus kernel start |
| 476 | * address and length, otherwise NULL |
| 477 | */ |
Marian Balakowicz | 9a4daad | 2008-02-29 14:58:34 +0100 | [diff] [blame] | 478 | static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], |
Marian Balakowicz | 8a5ea3e | 2008-02-27 11:01:04 +0100 | [diff] [blame] | 479 | bootm_headers_t *images, ulong *os_data, ulong *os_len) |
Marian Balakowicz | 5cf746c | 2008-01-31 13:59:09 +0100 | [diff] [blame] | 480 | { |
| 481 | image_header_t *hdr; |
| 482 | ulong img_addr; |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 483 | #if defined(CONFIG_FIT) |
| 484 | void *fit_hdr; |
| 485 | const char *fit_uname_config = NULL; |
| 486 | const char *fit_uname_kernel = NULL; |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 487 | const void *data; |
| 488 | size_t len; |
Marian Balakowicz | f773bea | 2008-03-12 10:35:46 +0100 | [diff] [blame] | 489 | int cfg_noffset; |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 490 | int os_noffset; |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 491 | #endif |
Marian Balakowicz | 5cf746c | 2008-01-31 13:59:09 +0100 | [diff] [blame] | 492 | |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 493 | /* find out kernel image address */ |
Marian Balakowicz | 5cf746c | 2008-01-31 13:59:09 +0100 | [diff] [blame] | 494 | if (argc < 2) { |
| 495 | img_addr = load_addr; |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 496 | debug ("* kernel: default image load address = 0x%08lx\n", |
| 497 | load_addr); |
| 498 | #if defined(CONFIG_FIT) |
| 499 | } else if (fit_parse_conf (argv[1], load_addr, &img_addr, |
| 500 | &fit_uname_config)) { |
| 501 | debug ("* kernel: config '%s' from image at 0x%08lx\n", |
| 502 | fit_uname_config, img_addr); |
| 503 | } else if (fit_parse_subimage (argv[1], load_addr, &img_addr, |
| 504 | &fit_uname_kernel)) { |
| 505 | debug ("* kernel: subimage '%s' from image at 0x%08lx\n", |
| 506 | fit_uname_kernel, img_addr); |
| 507 | #endif |
Marian Balakowicz | 5cf746c | 2008-01-31 13:59:09 +0100 | [diff] [blame] | 508 | } else { |
| 509 | img_addr = simple_strtoul(argv[1], NULL, 16); |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 510 | debug ("* kernel: cmdline image address = 0x%08lx\n", img_addr); |
Marian Balakowicz | 5cf746c | 2008-01-31 13:59:09 +0100 | [diff] [blame] | 511 | } |
| 512 | |
| 513 | show_boot_progress (1); |
Marian Balakowicz | 5cf746c | 2008-01-31 13:59:09 +0100 | [diff] [blame] | 514 | |
Marian Balakowicz | fff888a1 | 2008-02-21 17:20:19 +0100 | [diff] [blame] | 515 | /* copy from dataflash if needed */ |
Marian Balakowicz | 9a4daad | 2008-02-29 14:58:34 +0100 | [diff] [blame] | 516 | img_addr = genimg_get_image (img_addr); |
Marian Balakowicz | 5cf746c | 2008-01-31 13:59:09 +0100 | [diff] [blame] | 517 | |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 518 | /* check image type, for FIT images get FIT kernel node */ |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 519 | *os_data = *os_len = 0; |
Marian Balakowicz | 9a4daad | 2008-02-29 14:58:34 +0100 | [diff] [blame] | 520 | switch (genimg_get_format ((void *)img_addr)) { |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 521 | case IMAGE_FORMAT_LEGACY: |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 522 | printf ("## Booting kernel from Legacy Image at %08lx ...\n", |
| 523 | img_addr); |
Marian Balakowicz | 1efd436 | 2008-02-27 11:02:07 +0100 | [diff] [blame] | 524 | hdr = image_get_kernel (img_addr, images->verify); |
| 525 | if (!hdr) |
Marian Balakowicz | 5cf746c | 2008-01-31 13:59:09 +0100 | [diff] [blame] | 526 | return NULL; |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 527 | show_boot_progress (5); |
| 528 | |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 529 | /* get os_data and os_len */ |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 530 | switch (image_get_type (hdr)) { |
| 531 | case IH_TYPE_KERNEL: |
| 532 | *os_data = image_get_data (hdr); |
| 533 | *os_len = image_get_data_size (hdr); |
| 534 | break; |
| 535 | case IH_TYPE_MULTI: |
| 536 | image_multi_getimg (hdr, 0, os_data, os_len); |
| 537 | break; |
| 538 | default: |
| 539 | printf ("Wrong Image Type for %s command\n", cmdtp->name); |
| 540 | show_boot_progress (-5); |
| 541 | return NULL; |
| 542 | } |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 543 | |
Marian Balakowicz | cb1c489 | 2008-04-11 11:07:49 +0200 | [diff] [blame^] | 544 | /* |
| 545 | * copy image header to allow for image overwrites during kernel |
| 546 | * decompression. |
| 547 | */ |
| 548 | memmove (&images->legacy_hdr_os_copy, hdr, sizeof(image_header_t)); |
| 549 | |
| 550 | /* save pointer to image header */ |
| 551 | images->legacy_hdr_os = hdr; |
| 552 | |
| 553 | images->legacy_hdr_valid = 1; |
Marian Balakowicz | 1372cce | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 554 | show_boot_progress (6); |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 555 | break; |
| 556 | #if defined(CONFIG_FIT) |
| 557 | case IMAGE_FORMAT_FIT: |
| 558 | fit_hdr = (void *)img_addr; |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 559 | printf ("## Booting kernel from FIT Image at %08lx ...\n", |
| 560 | img_addr); |
| 561 | |
| 562 | if (!fit_check_format (fit_hdr)) { |
| 563 | puts ("Bad FIT kernel image format!\n"); |
Marian Balakowicz | 1372cce | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 564 | show_boot_progress (-100); |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 565 | return NULL; |
| 566 | } |
Marian Balakowicz | 1372cce | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 567 | show_boot_progress (100); |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 568 | |
| 569 | if (!fit_uname_kernel) { |
| 570 | /* |
| 571 | * no kernel image node unit name, try to get config |
| 572 | * node first. If config unit node name is NULL |
| 573 | * fit_conf_get_node() will try to find default config node |
| 574 | */ |
Marian Balakowicz | 1372cce | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 575 | show_boot_progress (101); |
Marian Balakowicz | f773bea | 2008-03-12 10:35:46 +0100 | [diff] [blame] | 576 | cfg_noffset = fit_conf_get_node (fit_hdr, fit_uname_config); |
| 577 | if (cfg_noffset < 0) { |
Marian Balakowicz | 1372cce | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 578 | show_boot_progress (-101); |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 579 | return NULL; |
Marian Balakowicz | 1372cce | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 580 | } |
Marian Balakowicz | f773bea | 2008-03-12 10:35:46 +0100 | [diff] [blame] | 581 | /* save configuration uname provided in the first |
| 582 | * bootm argument |
| 583 | */ |
| 584 | images->fit_uname_cfg = fdt_get_name (fit_hdr, cfg_noffset, NULL); |
| 585 | printf (" Using '%s' configuration\n", images->fit_uname_cfg); |
| 586 | show_boot_progress (103); |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 587 | |
Marian Balakowicz | f773bea | 2008-03-12 10:35:46 +0100 | [diff] [blame] | 588 | os_noffset = fit_conf_get_kernel_node (fit_hdr, cfg_noffset); |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 589 | fit_uname_kernel = fit_get_name (fit_hdr, os_noffset, NULL); |
| 590 | } else { |
| 591 | /* get kernel component image node offset */ |
Marian Balakowicz | 1372cce | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 592 | show_boot_progress (102); |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 593 | os_noffset = fit_image_get_node (fit_hdr, fit_uname_kernel); |
| 594 | } |
Marian Balakowicz | 1372cce | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 595 | if (os_noffset < 0) { |
| 596 | show_boot_progress (-103); |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 597 | return NULL; |
Marian Balakowicz | 1372cce | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 598 | } |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 599 | |
| 600 | printf (" Trying '%s' kernel subimage\n", fit_uname_kernel); |
| 601 | |
Marian Balakowicz | 1372cce | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 602 | show_boot_progress (104); |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 603 | if (!fit_check_kernel (fit_hdr, os_noffset, images->verify)) |
| 604 | return NULL; |
| 605 | |
| 606 | /* get kernel image data address and length */ |
| 607 | if (fit_image_get_data (fit_hdr, os_noffset, &data, &len)) { |
| 608 | puts ("Could not find kernel subimage data!\n"); |
Marian Balakowicz | 1372cce | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 609 | show_boot_progress (-107); |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 610 | return NULL; |
| 611 | } |
Marian Balakowicz | 1372cce | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 612 | show_boot_progress (108); |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 613 | |
| 614 | *os_len = len; |
| 615 | *os_data = (ulong)data; |
| 616 | images->fit_hdr_os = fit_hdr; |
| 617 | images->fit_uname_os = fit_uname_kernel; |
Marian Balakowicz | 3dfe110 | 2008-03-12 10:32:59 +0100 | [diff] [blame] | 618 | images->fit_noffset_os = os_noffset; |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 619 | break; |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 620 | #endif |
Marian Balakowicz | 5cf746c | 2008-01-31 13:59:09 +0100 | [diff] [blame] | 621 | default: |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 622 | printf ("Wrong Image Format for %s command\n", cmdtp->name); |
Marian Balakowicz | 1372cce | 2008-03-12 10:33:01 +0100 | [diff] [blame] | 623 | show_boot_progress (-108); |
Marian Balakowicz | 5cf746c | 2008-01-31 13:59:09 +0100 | [diff] [blame] | 624 | return NULL; |
| 625 | } |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 626 | |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 627 | debug (" kernel data at 0x%08lx, len = 0x%08lx (%d)\n", |
| 628 | *os_data, *os_len, *os_len); |
Marian Balakowicz | 5cf746c | 2008-01-31 13:59:09 +0100 | [diff] [blame] | 629 | |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 630 | return (void *)img_addr; |
Marian Balakowicz | 5cf746c | 2008-01-31 13:59:09 +0100 | [diff] [blame] | 631 | } |
| 632 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 633 | U_BOOT_CMD( |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 634 | bootm, CFG_MAXARGS, 1, do_bootm, |
| 635 | "bootm - boot application image from memory\n", |
| 636 | "[addr [arg ...]]\n - boot application image stored in memory\n" |
| 637 | "\tpassing arguments 'arg ...'; when booting a Linux kernel,\n" |
| 638 | "\t'arg' can be the address of an initrd image\n" |
Marian Balakowicz | 4a2ad5f | 2008-01-31 13:20:07 +0100 | [diff] [blame] | 639 | #if defined(CONFIG_OF_LIBFDT) |
Matthew McClintock | 98a9c4d | 2006-06-28 10:41:37 -0500 | [diff] [blame] | 640 | "\tWhen booting a Linux kernel which requires a flat device-tree\n" |
Detlev Zundel | 5441f61 | 2007-10-19 16:47:26 +0200 | [diff] [blame] | 641 | "\ta third argument is required which is the address of the\n" |
Matthew McClintock | 98a9c4d | 2006-06-28 10:41:37 -0500 | [diff] [blame] | 642 | "\tdevice-tree blob. To boot that kernel without an initrd image,\n" |
| 643 | "\tuse a '-' for the second argument. If you do not pass a third\n" |
| 644 | "\ta bd_info struct will be passed instead\n" |
| 645 | #endif |
Marian Balakowicz | 6986a38 | 2008-03-12 10:01:05 +0100 | [diff] [blame] | 646 | #if defined(CONFIG_FIT) |
| 647 | "\t\nFor the new multi component uImage format (FIT) addresses\n" |
| 648 | "\tmust be extened to include component or configuration unit name:\n" |
| 649 | "\taddr:<subimg_uname> - direct component image specification\n" |
| 650 | "\taddr#<conf_uname> - configuration specification\n" |
| 651 | "\tUse iminfo command to get the list of existing component\n" |
| 652 | "\timages and configurations.\n" |
| 653 | #endif |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 654 | ); |
| 655 | |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 656 | /*******************************************************************/ |
| 657 | /* bootd - boot default image */ |
| 658 | /*******************************************************************/ |
Jon Loeliger | baa26db | 2007-07-08 17:51:39 -0500 | [diff] [blame] | 659 | #if defined(CONFIG_CMD_BOOTD) |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 660 | int do_bootd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 661 | { |
| 662 | int rcode = 0; |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 663 | |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 664 | #ifndef CFG_HUSH_PARSER |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 665 | if (run_command (getenv ("bootcmd"), flag) < 0) |
| 666 | rcode = 1; |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 667 | #else |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 668 | if (parse_string_outer (getenv ("bootcmd"), |
| 669 | FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP) != 0) |
| 670 | rcode = 1; |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 671 | #endif |
| 672 | return rcode; |
| 673 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 674 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 675 | U_BOOT_CMD( |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 676 | boot, 1, 1, do_bootd, |
| 677 | "boot - boot default, i.e., run 'bootcmd'\n", |
wdenk | 9d2b18a | 2003-06-28 23:11:04 +0000 | [diff] [blame] | 678 | NULL |
| 679 | ); |
| 680 | |
| 681 | /* keep old command name "bootd" for backward compatibility */ |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 682 | U_BOOT_CMD( |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 683 | bootd, 1, 1, do_bootd, |
| 684 | "bootd - boot default, i.e., run 'bootcmd'\n", |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 685 | NULL |
| 686 | ); |
| 687 | |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 688 | #endif |
| 689 | |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 690 | |
| 691 | /*******************************************************************/ |
| 692 | /* iminfo - print header info for a requested image */ |
| 693 | /*******************************************************************/ |
Jon Loeliger | baa26db | 2007-07-08 17:51:39 -0500 | [diff] [blame] | 694 | #if defined(CONFIG_CMD_IMI) |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 695 | int do_iminfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 696 | { |
| 697 | int arg; |
| 698 | ulong addr; |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 699 | int rcode = 0; |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 700 | |
| 701 | if (argc < 2) { |
| 702 | return image_info (load_addr); |
| 703 | } |
| 704 | |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 705 | for (arg = 1; arg < argc; ++arg) { |
| 706 | addr = simple_strtoul (argv[arg], NULL, 16); |
| 707 | if (image_info (addr) != 0) |
| 708 | rcode = 1; |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 709 | } |
| 710 | return rcode; |
| 711 | } |
| 712 | |
| 713 | static int image_info (ulong addr) |
| 714 | { |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 715 | void *hdr = (void *)addr; |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 716 | |
| 717 | printf ("\n## Checking Image at %08lx ...\n", addr); |
| 718 | |
Marian Balakowicz | 9a4daad | 2008-02-29 14:58:34 +0100 | [diff] [blame] | 719 | switch (genimg_get_format (hdr)) { |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 720 | case IMAGE_FORMAT_LEGACY: |
| 721 | puts (" Legacy image found\n"); |
| 722 | if (!image_check_magic (hdr)) { |
| 723 | puts (" Bad Magic Number\n"); |
| 724 | return 1; |
| 725 | } |
| 726 | |
| 727 | if (!image_check_hcrc (hdr)) { |
| 728 | puts (" Bad Header Checksum\n"); |
| 729 | return 1; |
| 730 | } |
| 731 | |
| 732 | image_print_contents (hdr); |
| 733 | |
| 734 | puts (" Verifying Checksum ... "); |
| 735 | if (!image_check_dcrc (hdr)) { |
| 736 | puts (" Bad Data CRC\n"); |
| 737 | return 1; |
| 738 | } |
| 739 | puts ("OK\n"); |
| 740 | return 0; |
| 741 | #if defined(CONFIG_FIT) |
| 742 | case IMAGE_FORMAT_FIT: |
| 743 | puts (" FIT image found\n"); |
Marian Balakowicz | e32fea6 | 2008-03-11 12:35:20 +0100 | [diff] [blame] | 744 | |
| 745 | if (!fit_check_format (hdr)) { |
| 746 | puts ("Bad FIT image format!\n"); |
| 747 | return 1; |
| 748 | } |
| 749 | |
| 750 | fit_print_contents (hdr); |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 751 | return 0; |
| 752 | #endif |
| 753 | default: |
| 754 | puts ("Unknown image format!\n"); |
| 755 | break; |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 756 | } |
| 757 | |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 758 | return 1; |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 759 | } |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 760 | |
| 761 | U_BOOT_CMD( |
| 762 | iminfo, CFG_MAXARGS, 1, do_iminfo, |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 763 | "iminfo - print header information for application image\n", |
| 764 | "addr [addr ...]\n" |
| 765 | " - print header information for application image starting at\n" |
| 766 | " address 'addr' in memory; this includes verification of the\n" |
| 767 | " image contents (magic number, header and payload checksums)\n" |
| 768 | ); |
Jon Loeliger | 9025317 | 2007-07-10 11:02:44 -0500 | [diff] [blame] | 769 | #endif |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 770 | |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 771 | |
| 772 | /*******************************************************************/ |
| 773 | /* imls - list all images found in flash */ |
| 774 | /*******************************************************************/ |
Jon Loeliger | baa26db | 2007-07-08 17:51:39 -0500 | [diff] [blame] | 775 | #if defined(CONFIG_CMD_IMLS) |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 776 | int do_imls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 777 | { |
| 778 | flash_info_t *info; |
| 779 | int i, j; |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 780 | void *hdr; |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 781 | |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 782 | for (i = 0, info = &flash_info[0]; |
| 783 | i < CFG_MAX_FLASH_BANKS; ++i, ++info) { |
| 784 | |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 785 | if (info->flash_id == FLASH_UNKNOWN) |
| 786 | goto next_bank; |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 787 | for (j = 0; j < info->sector_count; ++j) { |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 788 | |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 789 | hdr = (void *)info->start[j]; |
| 790 | if (!hdr) |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 791 | goto next_sector; |
| 792 | |
Marian Balakowicz | 9a4daad | 2008-02-29 14:58:34 +0100 | [diff] [blame] | 793 | switch (genimg_get_format (hdr)) { |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 794 | case IMAGE_FORMAT_LEGACY: |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 795 | if (!image_check_hcrc (hdr)) |
| 796 | goto next_sector; |
| 797 | |
| 798 | printf ("Legacy Image at %08lX:\n", (ulong)hdr); |
| 799 | image_print_contents (hdr); |
| 800 | |
| 801 | puts (" Verifying Checksum ... "); |
| 802 | if (!image_check_dcrc (hdr)) { |
| 803 | puts ("Bad Data CRC\n"); |
| 804 | } else { |
| 805 | puts ("OK\n"); |
| 806 | } |
| 807 | break; |
| 808 | #if defined(CONFIG_FIT) |
| 809 | case IMAGE_FORMAT_FIT: |
Marian Balakowicz | e32fea6 | 2008-03-11 12:35:20 +0100 | [diff] [blame] | 810 | if (!fit_check_format (hdr)) |
| 811 | goto next_sector; |
| 812 | |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 813 | printf ("FIT Image at %08lX:\n", (ulong)hdr); |
Marian Balakowicz | e32fea6 | 2008-03-11 12:35:20 +0100 | [diff] [blame] | 814 | fit_print_contents (hdr); |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 815 | break; |
| 816 | #endif |
| 817 | default: |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 818 | goto next_sector; |
wdenk | 5bb226e | 2003-11-17 21:14:37 +0000 | [diff] [blame] | 819 | } |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 820 | |
wdenk | bdccc4f | 2003-08-05 17:43:17 +0000 | [diff] [blame] | 821 | next_sector: ; |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 822 | } |
wdenk | bdccc4f | 2003-08-05 17:43:17 +0000 | [diff] [blame] | 823 | next_bank: ; |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 824 | } |
| 825 | |
| 826 | return (0); |
| 827 | } |
| 828 | |
| 829 | U_BOOT_CMD( |
| 830 | imls, 1, 1, do_imls, |
| 831 | "imls - list all images found in flash\n", |
| 832 | "\n" |
| 833 | " - Prints information about all images found at sector\n" |
| 834 | " boundaries in flash.\n" |
| 835 | ); |
Jon Loeliger | 9025317 | 2007-07-10 11:02:44 -0500 | [diff] [blame] | 836 | #endif |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 837 | |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 838 | /*******************************************************************/ |
Marian Balakowicz | 5cf746c | 2008-01-31 13:59:09 +0100 | [diff] [blame] | 839 | /* helper routines */ |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 840 | /*******************************************************************/ |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 841 | #ifdef CONFIG_SILENT_CONSOLE |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 842 | static void fixup_silent_linux () |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 843 | { |
| 844 | char buf[256], *start, *end; |
| 845 | char *cmdline = getenv ("bootargs"); |
| 846 | |
| 847 | /* Only fix cmdline when requested */ |
| 848 | if (!(gd->flags & GD_FLG_SILENT)) |
| 849 | return; |
| 850 | |
| 851 | debug ("before silent fix-up: %s\n", cmdline); |
| 852 | if (cmdline) { |
| 853 | if ((start = strstr (cmdline, "console=")) != NULL) { |
| 854 | end = strchr (start, ' '); |
| 855 | strncpy (buf, cmdline, (start - cmdline + 8)); |
| 856 | if (end) |
| 857 | strcpy (buf + (start - cmdline + 8), end); |
| 858 | else |
| 859 | buf[start - cmdline + 8] = '\0'; |
| 860 | } else { |
| 861 | strcpy (buf, cmdline); |
| 862 | strcat (buf, " console="); |
| 863 | } |
| 864 | } else { |
| 865 | strcpy (buf, "console="); |
| 866 | } |
| 867 | |
| 868 | setenv ("bootargs", buf); |
| 869 | debug ("after silent fix-up: %s\n", buf); |
| 870 | } |
| 871 | #endif /* CONFIG_SILENT_CONSOLE */ |
| 872 | |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 873 | |
| 874 | /*******************************************************************/ |
| 875 | /* OS booting routines */ |
| 876 | /*******************************************************************/ |
| 877 | |
| 878 | static void do_bootm_netbsd (cmd_tbl_t *cmdtp, int flag, |
Marian Balakowicz | f13e7b2 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 879 | int argc, char *argv[], |
Marian Balakowicz | 8a5ea3e | 2008-02-27 11:01:04 +0100 | [diff] [blame] | 880 | bootm_headers_t *images) |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 881 | { |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 882 | void (*loader)(bd_t *, image_header_t *, char *, char *); |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 883 | image_header_t *os_hdr, *hdr; |
Marian Balakowicz | f13e7b2 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 884 | ulong kernel_data, kernel_len; |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 885 | char *consdev; |
| 886 | char *cmdline; |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 887 | |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 888 | #if defined(CONFIG_FIT) |
| 889 | if (!images->legacy_hdr_valid) { |
| 890 | fit_unsupported_reset ("NetBSD"); |
| 891 | do_reset (cmdtp, flag, argc, argv); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 892 | } |
| 893 | #endif |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 894 | hdr = images->legacy_hdr_os; |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 895 | |
| 896 | /* |
| 897 | * Booting a (NetBSD) kernel image |
| 898 | * |
| 899 | * This process is pretty similar to a standalone application: |
| 900 | * The (first part of an multi-) image must be a stage-2 loader, |
| 901 | * which in turn is responsible for loading & invoking the actual |
| 902 | * kernel. The only differences are the parameters being passed: |
| 903 | * besides the board info strucure, the loader expects a command |
| 904 | * line, the name of the console device, and (optionally) the |
| 905 | * address of the original image header. |
| 906 | */ |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 907 | os_hdr = NULL; |
Marian Balakowicz | cb1c489 | 2008-04-11 11:07:49 +0200 | [diff] [blame^] | 908 | if (image_check_type (&images->legacy_hdr_os_copy, IH_TYPE_MULTI)) { |
Marian Balakowicz | f13e7b2 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 909 | image_multi_getimg (hdr, 1, &kernel_data, &kernel_len); |
| 910 | if (kernel_len) |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 911 | os_hdr = hdr; |
Marian Balakowicz | f13e7b2 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 912 | } |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 913 | |
| 914 | consdev = ""; |
| 915 | #if defined (CONFIG_8xx_CONS_SMC1) |
| 916 | consdev = "smc1"; |
| 917 | #elif defined (CONFIG_8xx_CONS_SMC2) |
| 918 | consdev = "smc2"; |
| 919 | #elif defined (CONFIG_8xx_CONS_SCC2) |
| 920 | consdev = "scc2"; |
| 921 | #elif defined (CONFIG_8xx_CONS_SCC3) |
| 922 | consdev = "scc3"; |
| 923 | #endif |
| 924 | |
| 925 | if (argc > 2) { |
| 926 | ulong len; |
| 927 | int i; |
| 928 | |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 929 | for (i = 2, len = 0; i < argc; i += 1) |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 930 | len += strlen (argv[i]) + 1; |
| 931 | cmdline = malloc (len); |
| 932 | |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 933 | for (i = 2, len = 0; i < argc; i += 1) { |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 934 | if (i > 2) |
| 935 | cmdline[len++] = ' '; |
| 936 | strcpy (&cmdline[len], argv[i]); |
| 937 | len += strlen (argv[i]); |
| 938 | } |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 939 | } else if ((cmdline = getenv ("bootargs")) == NULL) { |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 940 | cmdline = ""; |
| 941 | } |
| 942 | |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 943 | loader = (void (*)(bd_t *, image_header_t *, char *, char *))image_get_ep (hdr); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 944 | |
| 945 | printf ("## Transferring control to NetBSD stage-2 loader (at address %08lx) ...\n", |
| 946 | (ulong)loader); |
| 947 | |
| 948 | show_boot_progress (15); |
| 949 | |
| 950 | /* |
| 951 | * NetBSD Stage-2 Loader Parameters: |
| 952 | * r3: ptr to board info data |
| 953 | * r4: image address |
| 954 | * r5: console device |
| 955 | * r6: boot args string |
| 956 | */ |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 957 | (*loader) (gd->bd, os_hdr, consdev, cmdline); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 958 | } |
| 959 | |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 960 | #ifdef CONFIG_LYNXKDI |
| 961 | static void do_bootm_lynxkdi (cmd_tbl_t *cmdtp, int flag, |
| 962 | int argc, char *argv[], |
Marian Balakowicz | 8a5ea3e | 2008-02-27 11:01:04 +0100 | [diff] [blame] | 963 | bootm_headers_t *images) |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 964 | { |
Marian Balakowicz | cb1c489 | 2008-04-11 11:07:49 +0200 | [diff] [blame^] | 965 | image_header_t *hdr = &images->legacy_hdr_os_copy; |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 966 | |
| 967 | #if defined(CONFIG_FIT) |
| 968 | if (!images->legacy_hdr_valid) { |
| 969 | fit_unsupported_reset ("Lynx"); |
| 970 | do_reset (cmdtp, flag, argc, argv); |
| 971 | } |
| 972 | #endif |
| 973 | |
| 974 | lynxkdi_boot ((image_header_t *)hdr); |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 975 | } |
| 976 | #endif /* CONFIG_LYNXKDI */ |
| 977 | |
| 978 | static void do_bootm_rtems (cmd_tbl_t *cmdtp, int flag, |
| 979 | int argc, char *argv[], |
Marian Balakowicz | 8a5ea3e | 2008-02-27 11:01:04 +0100 | [diff] [blame] | 980 | bootm_headers_t *images) |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 981 | { |
Marian Balakowicz | cb1c489 | 2008-04-11 11:07:49 +0200 | [diff] [blame^] | 982 | image_header_t *hdr = &images->legacy_hdr_os_copy; |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 983 | void (*entry_point)(bd_t *); |
wdenk | d791b1d | 2003-04-20 14:04:18 +0000 | [diff] [blame] | 984 | |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 985 | #if defined(CONFIG_FIT) |
| 986 | if (!images->legacy_hdr_valid) { |
| 987 | fit_unsupported_reset ("RTEMS"); |
| 988 | do_reset (cmdtp, flag, argc, argv); |
| 989 | } |
| 990 | #endif |
| 991 | |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 992 | entry_point = (void (*)(bd_t *))image_get_ep (hdr); |
wdenk | d791b1d | 2003-04-20 14:04:18 +0000 | [diff] [blame] | 993 | |
| 994 | printf ("## Transferring control to RTEMS (at address %08lx) ...\n", |
| 995 | (ulong)entry_point); |
| 996 | |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 997 | show_boot_progress (15); |
wdenk | d791b1d | 2003-04-20 14:04:18 +0000 | [diff] [blame] | 998 | |
| 999 | /* |
| 1000 | * RTEMS Parameters: |
| 1001 | * r3: ptr to board info data |
| 1002 | */ |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 1003 | (*entry_point)(gd->bd); |
wdenk | d791b1d | 2003-04-20 14:04:18 +0000 | [diff] [blame] | 1004 | } |
| 1005 | |
Jon Loeliger | baa26db | 2007-07-08 17:51:39 -0500 | [diff] [blame] | 1006 | #if defined(CONFIG_CMD_ELF) |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 1007 | static void do_bootm_vxworks (cmd_tbl_t *cmdtp, int flag, |
| 1008 | int argc, char *argv[], |
Marian Balakowicz | 8a5ea3e | 2008-02-27 11:01:04 +0100 | [diff] [blame] | 1009 | bootm_headers_t *images) |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 1010 | { |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 1011 | char str[80]; |
Marian Balakowicz | cb1c489 | 2008-04-11 11:07:49 +0200 | [diff] [blame^] | 1012 | image_header_t *hdr = &images->legacy_hdr_os_copy; |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 1013 | |
| 1014 | #if defined(CONFIG_FIT) |
Marian Balakowicz | cb1c489 | 2008-04-11 11:07:49 +0200 | [diff] [blame^] | 1015 | if (!images->legacy_hdr_valid) { |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 1016 | fit_unsupported_reset ("VxWorks"); |
| 1017 | do_reset (cmdtp, flag, argc, argv); |
| 1018 | } |
| 1019 | #endif |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 1020 | |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 1021 | sprintf(str, "%x", image_get_ep (hdr)); /* write entry-point into string */ |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 1022 | setenv("loadaddr", str); |
| 1023 | do_bootvx(cmdtp, 0, 0, NULL); |
| 1024 | } |
| 1025 | |
Marian Balakowicz | f13e7b2 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 1026 | static void do_bootm_qnxelf(cmd_tbl_t *cmdtp, int flag, |
| 1027 | int argc, char *argv[], |
Marian Balakowicz | 8a5ea3e | 2008-02-27 11:01:04 +0100 | [diff] [blame] | 1028 | bootm_headers_t *images) |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 1029 | { |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 1030 | char *local_args[2]; |
| 1031 | char str[16]; |
Marian Balakowicz | cb1c489 | 2008-04-11 11:07:49 +0200 | [diff] [blame^] | 1032 | image_header_t *hdr = &images->legacy_hdr_os_copy; |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 1033 | |
| 1034 | #if defined(CONFIG_FIT) |
| 1035 | if (!images->legacy_hdr_valid) { |
| 1036 | fit_unsupported_reset ("QNX"); |
| 1037 | do_reset (cmdtp, flag, argc, argv); |
| 1038 | } |
| 1039 | #endif |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 1040 | |
Marian Balakowicz | b97a2a0 | 2008-01-08 18:14:09 +0100 | [diff] [blame] | 1041 | sprintf(str, "%x", image_get_ep (hdr)); /* write entry-point into string */ |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 1042 | local_args[0] = argv[0]; |
| 1043 | local_args[1] = str; /* and provide it via the arguments */ |
| 1044 | do_bootelf(cmdtp, 0, 2, local_args); |
| 1045 | } |
Jon Loeliger | 9025317 | 2007-07-10 11:02:44 -0500 | [diff] [blame] | 1046 | #endif |
wdenk | 1f4bb37 | 2003-07-27 00:21:01 +0000 | [diff] [blame] | 1047 | |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 1048 | #if defined(CONFIG_ARTOS) && defined(CONFIG_PPC) |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 1049 | static void do_bootm_artos (cmd_tbl_t *cmdtp, int flag, |
| 1050 | int argc, char *argv[], |
Marian Balakowicz | 8a5ea3e | 2008-02-27 11:01:04 +0100 | [diff] [blame] | 1051 | bootm_headers_t *images) |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 1052 | { |
| 1053 | ulong top; |
| 1054 | char *s, *cmdline; |
| 1055 | char **fwenv, **ss; |
| 1056 | int i, j, nxt, len, envno, envsz; |
| 1057 | bd_t *kbd; |
| 1058 | void (*entry)(bd_t *bd, char *cmdline, char **fwenv, ulong top); |
Marian Balakowicz | cb1c489 | 2008-04-11 11:07:49 +0200 | [diff] [blame^] | 1059 | image_header_t *hdr = &images->legacy_hdr_os_copy; |
Marian Balakowicz | d5934ad | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 1060 | |
| 1061 | #if defined(CONFIG_FIT) |
| 1062 | if (!images->legacy_hdr_valid) { |
| 1063 | fit_unsupported_reset ("ARTOS"); |
| 1064 | do_reset (cmdtp, flag, argc, argv); |
| 1065 | } |
| 1066 | #endif |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 1067 | |
| 1068 | /* |
| 1069 | * Booting an ARTOS kernel image + application |
| 1070 | */ |
| 1071 | |
| 1072 | /* this used to be the top of memory, but was wrong... */ |
| 1073 | #ifdef CONFIG_PPC |
| 1074 | /* get stack pointer */ |
| 1075 | asm volatile ("mr %0,1" : "=r"(top) ); |
| 1076 | #endif |
| 1077 | debug ("## Current stack ends at 0x%08lX ", top); |
| 1078 | |
| 1079 | top -= 2048; /* just to be sure */ |
| 1080 | if (top > CFG_BOOTMAPSZ) |
| 1081 | top = CFG_BOOTMAPSZ; |
| 1082 | top &= ~0xF; |
| 1083 | |
| 1084 | debug ("=> set upper limit to 0x%08lX\n", top); |
| 1085 | |
| 1086 | /* first check the artos specific boot args, then the linux args*/ |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 1087 | if ((s = getenv( "abootargs")) == NULL && (s = getenv ("bootargs")) == NULL) |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 1088 | s = ""; |
| 1089 | |
| 1090 | /* get length of cmdline, and place it */ |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 1091 | len = strlen (s); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 1092 | top = (top - (len + 1)) & ~0xF; |
| 1093 | cmdline = (char *)top; |
| 1094 | debug ("## cmdline at 0x%08lX ", top); |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 1095 | strcpy (cmdline, s); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 1096 | |
| 1097 | /* copy bdinfo */ |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 1098 | top = (top - sizeof (bd_t)) & ~0xF; |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 1099 | debug ("## bd at 0x%08lX ", top); |
| 1100 | kbd = (bd_t *)top; |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 1101 | memcpy (kbd, gd->bd, sizeof (bd_t)); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 1102 | |
| 1103 | /* first find number of env entries, and their size */ |
| 1104 | envno = 0; |
| 1105 | envsz = 0; |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 1106 | for (i = 0; env_get_char (i) != '\0'; i = nxt + 1) { |
| 1107 | for (nxt = i; env_get_char (nxt) != '\0'; ++nxt) |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 1108 | ; |
| 1109 | envno++; |
| 1110 | envsz += (nxt - i) + 1; /* plus trailing zero */ |
| 1111 | } |
| 1112 | envno++; /* plus the terminating zero */ |
| 1113 | debug ("## %u envvars total size %u ", envno, envsz); |
| 1114 | |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 1115 | top = (top - sizeof (char **) * envno) & ~0xF; |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 1116 | fwenv = (char **)top; |
| 1117 | debug ("## fwenv at 0x%08lX ", top); |
| 1118 | |
| 1119 | top = (top - envsz) & ~0xF; |
| 1120 | s = (char *)top; |
| 1121 | ss = fwenv; |
| 1122 | |
| 1123 | /* now copy them */ |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 1124 | for (i = 0; env_get_char (i) != '\0'; i = nxt + 1) { |
| 1125 | for (nxt = i; env_get_char (nxt) != '\0'; ++nxt) |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 1126 | ; |
| 1127 | *ss++ = s; |
| 1128 | for (j = i; j < nxt; ++j) |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 1129 | *s++ = env_get_char (j); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 1130 | *s++ = '\0'; |
| 1131 | } |
| 1132 | *ss++ = NULL; /* terminate */ |
| 1133 | |
Marian Balakowicz | 1ee1180 | 2008-01-08 18:17:10 +0100 | [diff] [blame] | 1134 | entry = (void (*)(bd_t *, char *, char **, ulong))image_get_ep (hdr); |
| 1135 | (*entry) (kbd, cmdline, fwenv, top); |
wdenk | 47d1a6e | 2002-11-03 00:01:44 +0000 | [diff] [blame] | 1136 | } |
| 1137 | #endif |