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