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