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