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