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