Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2011 |
| 2 | * Corscience GmbH & Co. KG - Simon Schwarz <schwarz@corscience.de> |
| 3 | * - Added prep subcommand support |
| 4 | * - Reorganized source - modeled after powerpc version |
| 5 | * |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 6 | * (C) Copyright 2002 |
| 7 | * Sysgo Real-Time Solutions, GmbH <www.elinos.com> |
| 8 | * Marius Groeger <mgroeger@sysgo.de> |
| 9 | * |
| 10 | * Copyright (C) 2001 Erik Mouw (J.A.K.Mouw@its.tudelft.nl) |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify |
| 13 | * it under the terms of the GNU General Public License as published by |
| 14 | * the Free Software Foundation; either version 2 of the License, or |
| 15 | * (at your option) any later version. |
| 16 | * |
| 17 | * This program is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 20 | * GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program; if not, write to the Free Software |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 25 | * |
| 26 | */ |
| 27 | |
| 28 | #include <common.h> |
| 29 | #include <command.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 30 | #include <image.h> |
Jean-Christophe PLAGNIOL-VILLARD | a31e091 | 2009-04-04 12:49:11 +0200 | [diff] [blame] | 31 | #include <u-boot/zlib.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 32 | #include <asm/byteorder.h> |
John Rigby | 2d1916e | 2010-10-13 13:57:36 -0600 | [diff] [blame] | 33 | #include <fdt.h> |
| 34 | #include <libfdt.h> |
| 35 | #include <fdt_support.h> |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 36 | #include <asm/bootm.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 37 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 38 | DECLARE_GLOBAL_DATA_PTR; |
| 39 | |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 40 | #if defined(CONFIG_SETUP_MEMORY_TAGS) || \ |
| 41 | defined(CONFIG_CMDLINE_TAG) || \ |
| 42 | defined(CONFIG_INITRD_TAG) || \ |
| 43 | defined(CONFIG_SERIAL_TAG) || \ |
| 44 | defined(CONFIG_REVISION_TAG) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 45 | static struct tag *params; |
John Rigby | 2d1916e | 2010-10-13 13:57:36 -0600 | [diff] [blame] | 46 | #endif |
| 47 | |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 48 | static ulong get_sp(void) |
| 49 | { |
| 50 | ulong ret; |
| 51 | |
| 52 | asm("mov %0, sp" : "=r"(ret) : ); |
| 53 | return ret; |
| 54 | } |
| 55 | |
John Rigby | 2d1916e | 2010-10-13 13:57:36 -0600 | [diff] [blame] | 56 | void arch_lmb_reserve(struct lmb *lmb) |
| 57 | { |
| 58 | ulong sp; |
| 59 | |
| 60 | /* |
| 61 | * Booting a (Linux) kernel image |
| 62 | * |
| 63 | * Allocate space for command line and board info - the |
| 64 | * address should be as high as possible within the reach of |
| 65 | * the kernel (see CONFIG_SYS_BOOTMAPSZ settings), but in unused |
| 66 | * memory, which means far enough below the current stack |
| 67 | * pointer. |
| 68 | */ |
| 69 | sp = get_sp(); |
| 70 | debug("## Current stack ends at 0x%08lx ", sp); |
| 71 | |
| 72 | /* adjust sp by 1K to be safe */ |
| 73 | sp -= 1024; |
| 74 | lmb_reserve(lmb, sp, |
| 75 | gd->bd->bi_dram[0].start + gd->bd->bi_dram[0].size - sp); |
| 76 | } |
| 77 | |
John Rigby | 2d1916e | 2010-10-13 13:57:36 -0600 | [diff] [blame] | 78 | #ifdef CONFIG_OF_LIBFDT |
John Rigby | 2d1916e | 2010-10-13 13:57:36 -0600 | [diff] [blame] | 79 | static int fixup_memory_node(void *blob) |
| 80 | { |
| 81 | bd_t *bd = gd->bd; |
| 82 | int bank; |
| 83 | u64 start[CONFIG_NR_DRAM_BANKS]; |
| 84 | u64 size[CONFIG_NR_DRAM_BANKS]; |
| 85 | |
| 86 | for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) { |
| 87 | start[bank] = bd->bi_dram[bank].start; |
| 88 | size[bank] = bd->bi_dram[bank].size; |
| 89 | } |
| 90 | |
| 91 | return fdt_fixup_memory_banks(blob, start, size, CONFIG_NR_DRAM_BANKS); |
| 92 | } |
John Rigby | 2d1916e | 2010-10-13 13:57:36 -0600 | [diff] [blame] | 93 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 94 | |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 95 | static void announce_and_cleanup(void) |
| 96 | { |
| 97 | printf("\nStarting kernel ...\n\n"); |
| 98 | bootstage_mark_name(BOOTSTAGE_ID_BOOTM_HANDOFF, "start_kernel"); |
| 99 | #ifdef CONFIG_BOOTSTAGE_REPORT |
| 100 | bootstage_report(); |
| 101 | #endif |
| 102 | |
| 103 | #ifdef CONFIG_USB_DEVICE |
| 104 | udc_disconnect(); |
| 105 | #endif |
| 106 | cleanup_before_linux(); |
| 107 | } |
| 108 | |
| 109 | #if defined(CONFIG_SETUP_MEMORY_TAGS) || \ |
| 110 | defined(CONFIG_CMDLINE_TAG) || \ |
| 111 | defined(CONFIG_INITRD_TAG) || \ |
| 112 | defined(CONFIG_SERIAL_TAG) || \ |
| 113 | defined(CONFIG_REVISION_TAG) |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 114 | static void setup_start_tag (bd_t *bd) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 115 | { |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 116 | params = (struct tag *)bd->bi_boot_params; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 117 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 118 | params->hdr.tag = ATAG_CORE; |
| 119 | params->hdr.size = tag_size (tag_core); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 120 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 121 | params->u.core.flags = 0; |
| 122 | params->u.core.pagesize = 0; |
| 123 | params->u.core.rootdev = 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 124 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 125 | params = tag_next (params); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 126 | } |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 127 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 128 | |
wdenk | 699b13a | 2002-11-03 18:03:52 +0000 | [diff] [blame] | 129 | #ifdef CONFIG_SETUP_MEMORY_TAGS |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 130 | static void setup_memory_tags(bd_t *bd) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 131 | { |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 132 | int i; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 133 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 134 | for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { |
| 135 | params->hdr.tag = ATAG_MEM; |
| 136 | params->hdr.size = tag_size (tag_mem32); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 137 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 138 | params->u.mem.start = bd->bi_dram[i].start; |
| 139 | params->u.mem.size = bd->bi_dram[i].size; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 140 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 141 | params = tag_next (params); |
| 142 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 143 | } |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 144 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 145 | |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 146 | #ifdef CONFIG_CMDLINE_TAG |
| 147 | static void setup_commandline_tag(bd_t *bd, char *commandline) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 148 | { |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 149 | char *p; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 150 | |
wdenk | 109c0e3 | 2004-03-23 21:43:07 +0000 | [diff] [blame] | 151 | if (!commandline) |
| 152 | return; |
| 153 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 154 | /* eat leading white space */ |
| 155 | for (p = commandline; *p == ' '; p++); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 156 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 157 | /* skip non-existent command lines so the kernel will still |
| 158 | * use its default command line. |
| 159 | */ |
| 160 | if (*p == '\0') |
| 161 | return; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 162 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 163 | params->hdr.tag = ATAG_CMDLINE; |
| 164 | params->hdr.size = |
| 165 | (sizeof (struct tag_header) + strlen (p) + 1 + 4) >> 2; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 166 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 167 | strcpy (params->u.cmdline.cmdline, p); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 168 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 169 | params = tag_next (params); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 170 | } |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 171 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 172 | |
wdenk | 699b13a | 2002-11-03 18:03:52 +0000 | [diff] [blame] | 173 | #ifdef CONFIG_INITRD_TAG |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 174 | static void setup_initrd_tag(bd_t *bd, ulong initrd_start, ulong initrd_end) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 175 | { |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 176 | /* an ATAG_INITRD node tells the kernel where the compressed |
| 177 | * ramdisk can be found. ATAG_RDIMG is a better name, actually. |
| 178 | */ |
wdenk | 498b8db | 2004-04-18 22:26:17 +0000 | [diff] [blame] | 179 | params->hdr.tag = ATAG_INITRD2; |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 180 | params->hdr.size = tag_size (tag_initrd); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 181 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 182 | params->u.initrd.start = initrd_start; |
| 183 | params->u.initrd.size = initrd_end - initrd_start; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 184 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 185 | params = tag_next (params); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 186 | } |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 187 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 188 | |
wdenk | 3a574cb | 2005-05-19 22:39:42 +0000 | [diff] [blame] | 189 | #ifdef CONFIG_SERIAL_TAG |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 190 | void setup_serial_tag(struct tag **tmp) |
wdenk | 3a574cb | 2005-05-19 22:39:42 +0000 | [diff] [blame] | 191 | { |
| 192 | struct tag *params = *tmp; |
| 193 | struct tag_serialnr serialnr; |
| 194 | void get_board_serial(struct tag_serialnr *serialnr); |
| 195 | |
| 196 | get_board_serial(&serialnr); |
| 197 | params->hdr.tag = ATAG_SERIAL; |
| 198 | params->hdr.size = tag_size (tag_serialnr); |
| 199 | params->u.serialnr.low = serialnr.low; |
| 200 | params->u.serialnr.high= serialnr.high; |
| 201 | params = tag_next (params); |
| 202 | *tmp = params; |
| 203 | } |
| 204 | #endif |
| 205 | |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 206 | #ifdef CONFIG_REVISION_TAG |
| 207 | void setup_revision_tag(struct tag **in_params) |
| 208 | { |
| 209 | u32 rev = 0; |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 210 | u32 get_board_rev(void); |
| 211 | |
| 212 | rev = get_board_rev(); |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 213 | params->hdr.tag = ATAG_REVISION; |
| 214 | params->hdr.size = tag_size (tag_revision); |
| 215 | params->u.revision.rev = rev; |
| 216 | params = tag_next (params); |
| 217 | } |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 218 | #endif |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 219 | |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 220 | #if defined(CONFIG_SETUP_MEMORY_TAGS) || \ |
| 221 | defined(CONFIG_CMDLINE_TAG) || \ |
| 222 | defined(CONFIG_INITRD_TAG) || \ |
| 223 | defined(CONFIG_SERIAL_TAG) || \ |
| 224 | defined(CONFIG_REVISION_TAG) |
| 225 | static void setup_end_tag(bd_t *bd) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 226 | { |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 227 | params->hdr.tag = ATAG_NONE; |
| 228 | params->hdr.size = 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 229 | } |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 230 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 231 | |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 232 | #ifdef CONFIG_OF_LIBFDT |
| 233 | static int create_fdt(bootm_headers_t *images) |
John Rigby | 2d1916e | 2010-10-13 13:57:36 -0600 | [diff] [blame] | 234 | { |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 235 | ulong of_size = images->ft_len; |
| 236 | char **of_flat_tree = &images->ft_addr; |
| 237 | ulong *initrd_start = &images->initrd_start; |
| 238 | ulong *initrd_end = &images->initrd_end; |
| 239 | struct lmb *lmb = &images->lmb; |
| 240 | ulong rd_len; |
| 241 | int ret; |
John Rigby | 2d1916e | 2010-10-13 13:57:36 -0600 | [diff] [blame] | 242 | |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 243 | debug("using: FDT\n"); |
| 244 | |
| 245 | boot_fdt_add_mem_rsv_regions(lmb, *of_flat_tree); |
| 246 | |
| 247 | rd_len = images->rd_end - images->rd_start; |
| 248 | ret = boot_ramdisk_high(lmb, images->rd_start, rd_len, |
| 249 | initrd_start, initrd_end); |
| 250 | if (ret) |
| 251 | return ret; |
| 252 | |
| 253 | ret = boot_relocate_fdt(lmb, of_flat_tree, &of_size); |
| 254 | if (ret) |
| 255 | return ret; |
| 256 | |
| 257 | fdt_chosen(*of_flat_tree, 1); |
| 258 | fixup_memory_node(*of_flat_tree); |
Stephen Warren | 9e02a6b | 2012-04-19 11:09:49 +0000 | [diff] [blame] | 259 | fdt_fixup_ethernet(*of_flat_tree); |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 260 | fdt_initrd(*of_flat_tree, *initrd_start, *initrd_end, 1); |
| 261 | |
| 262 | return 0; |
| 263 | } |
| 264 | #endif |
| 265 | |
| 266 | /* Subcommand: PREP */ |
| 267 | static void boot_prep_linux(bootm_headers_t *images) |
| 268 | { |
| 269 | #ifdef CONFIG_CMDLINE_TAG |
| 270 | char *commandline = getenv("bootargs"); |
| 271 | #endif |
| 272 | |
| 273 | #ifdef CONFIG_OF_LIBFDT |
| 274 | if (images->ft_len) { |
| 275 | debug("using: FDT\n"); |
| 276 | if (create_fdt(images)) { |
| 277 | printf("FDT creation failed! hanging..."); |
| 278 | hang(); |
| 279 | } |
| 280 | } else |
| 281 | #endif |
| 282 | { |
| 283 | #if defined(CONFIG_SETUP_MEMORY_TAGS) || \ |
| 284 | defined(CONFIG_CMDLINE_TAG) || \ |
| 285 | defined(CONFIG_INITRD_TAG) || \ |
| 286 | defined(CONFIG_SERIAL_TAG) || \ |
| 287 | defined(CONFIG_REVISION_TAG) |
| 288 | debug("using: ATAGS\n"); |
| 289 | setup_start_tag(gd->bd); |
| 290 | #ifdef CONFIG_SERIAL_TAG |
| 291 | setup_serial_tag(¶ms); |
| 292 | #endif |
| 293 | #ifdef CONFIG_CMDLINE_TAG |
| 294 | setup_commandline_tag(gd->bd, commandline); |
| 295 | #endif |
| 296 | #ifdef CONFIG_REVISION_TAG |
| 297 | setup_revision_tag(¶ms); |
| 298 | #endif |
| 299 | #ifdef CONFIG_SETUP_MEMORY_TAGS |
| 300 | setup_memory_tags(gd->bd); |
| 301 | #endif |
| 302 | #ifdef CONFIG_INITRD_TAG |
| 303 | if (images->rd_start && images->rd_end) |
| 304 | setup_initrd_tag(gd->bd, images->rd_start, |
| 305 | images->rd_end); |
| 306 | #endif |
| 307 | setup_end_tag(gd->bd); |
| 308 | #else /* all tags */ |
| 309 | printf("FDT and ATAGS support not compiled in - hanging\n"); |
| 310 | hang(); |
| 311 | #endif /* all tags */ |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | /* Subcommand: GO */ |
| 316 | static void boot_jump_linux(bootm_headers_t *images) |
| 317 | { |
| 318 | unsigned long machid = gd->bd->bi_arch_number; |
| 319 | char *s; |
| 320 | void (*kernel_entry)(int zero, int arch, uint params); |
Stephen Warren | 1723997 | 2012-04-19 11:34:00 +0000 | [diff] [blame] | 321 | unsigned long r2; |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 322 | |
| 323 | kernel_entry = (void (*)(int, int, uint))images->ep; |
| 324 | |
| 325 | s = getenv("machid"); |
| 326 | if (s) { |
| 327 | strict_strtoul(s, 16, &machid); |
| 328 | printf("Using machid 0x%lx from environment\n", machid); |
| 329 | } |
| 330 | |
| 331 | debug("## Transferring control to Linux (at address %08lx)" \ |
| 332 | "...\n", (ulong) kernel_entry); |
| 333 | bootstage_mark(BOOTSTAGE_ID_RUN_OS); |
| 334 | announce_and_cleanup(); |
Stephen Warren | 1723997 | 2012-04-19 11:34:00 +0000 | [diff] [blame] | 335 | |
| 336 | #ifdef CONFIG_OF_LIBFDT |
| 337 | if (images->ft_len) |
| 338 | r2 = (unsigned long)images->ft_addr; |
| 339 | else |
| 340 | #endif |
| 341 | r2 = gd->bd->bi_boot_params; |
| 342 | |
| 343 | kernel_entry(0, machid, r2); |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | /* Main Entry point for arm bootm implementation |
| 347 | * |
| 348 | * Modeled after the powerpc implementation |
| 349 | * DIFFERENCE: Instead of calling prep and go at the end |
| 350 | * they are called if subcommand is equal 0. |
| 351 | */ |
| 352 | int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) |
| 353 | { |
| 354 | /* No need for those on ARM */ |
| 355 | if (flag & BOOTM_STATE_OS_BD_T || flag & BOOTM_STATE_OS_CMDLINE) |
| 356 | return -1; |
| 357 | |
| 358 | if (flag & BOOTM_STATE_OS_PREP) { |
| 359 | boot_prep_linux(images); |
| 360 | return 0; |
| 361 | } |
| 362 | |
| 363 | if (flag & BOOTM_STATE_OS_GO) { |
| 364 | boot_jump_linux(images); |
| 365 | return 0; |
| 366 | } |
| 367 | |
| 368 | boot_prep_linux(images); |
| 369 | boot_jump_linux(images); |
| 370 | return 0; |
John Rigby | 2d1916e | 2010-10-13 13:57:36 -0600 | [diff] [blame] | 371 | } |
Marek Vasut | 44f074c | 2012-03-14 21:52:45 +0000 | [diff] [blame] | 372 | |
| 373 | #ifdef CONFIG_CMD_BOOTZ |
| 374 | |
| 375 | struct zimage_header { |
| 376 | uint32_t code[9]; |
| 377 | uint32_t zi_magic; |
| 378 | uint32_t zi_start; |
| 379 | uint32_t zi_end; |
| 380 | }; |
| 381 | |
| 382 | #define LINUX_ARM_ZIMAGE_MAGIC 0x016f2818 |
| 383 | |
| 384 | int bootz_setup(void *image, void **start, void **end) |
| 385 | { |
| 386 | struct zimage_header *zi = (struct zimage_header *)image; |
| 387 | |
| 388 | if (zi->zi_magic != LINUX_ARM_ZIMAGE_MAGIC) { |
| 389 | puts("Bad Linux ARM zImage magic!\n"); |
| 390 | return 1; |
| 391 | } |
| 392 | |
| 393 | *start = (void *)zi->zi_start; |
| 394 | *end = (void *)zi->zi_end; |
| 395 | |
| 396 | debug("Kernel image @ 0x%08x [ 0x%08x - 0x%08x ]\n", |
| 397 | (uint32_t)image, (uint32_t)*start, (uint32_t)*end); |
| 398 | |
| 399 | return 0; |
| 400 | } |
| 401 | #endif /* CONFIG_CMD_BOOTZ */ |