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 | #include <common.h> |
| 28 | #include <command.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 29 | #include <image.h> |
Jean-Christophe PLAGNIOL-VILLARD | a31e091 | 2009-04-04 12:49:11 +0200 | [diff] [blame] | 30 | #include <u-boot/zlib.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 31 | #include <asm/byteorder.h> |
John Rigby | 2d1916e | 2010-10-13 13:57:36 -0600 | [diff] [blame] | 32 | #include <libfdt.h> |
| 33 | #include <fdt_support.h> |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 34 | #include <asm/bootm.h> |
Pali Rohár | 89e6f13 | 2012-10-19 02:00:04 +0000 | [diff] [blame] | 35 | #include <linux/compiler.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 36 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 37 | DECLARE_GLOBAL_DATA_PTR; |
| 38 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 39 | static struct tag *params; |
John Rigby | 2d1916e | 2010-10-13 13:57:36 -0600 | [diff] [blame] | 40 | |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 41 | static ulong get_sp(void) |
| 42 | { |
| 43 | ulong ret; |
| 44 | |
| 45 | asm("mov %0, sp" : "=r"(ret) : ); |
| 46 | return ret; |
| 47 | } |
| 48 | |
John Rigby | 2d1916e | 2010-10-13 13:57:36 -0600 | [diff] [blame] | 49 | void arch_lmb_reserve(struct lmb *lmb) |
| 50 | { |
| 51 | ulong sp; |
| 52 | |
| 53 | /* |
| 54 | * Booting a (Linux) kernel image |
| 55 | * |
| 56 | * Allocate space for command line and board info - the |
| 57 | * address should be as high as possible within the reach of |
| 58 | * the kernel (see CONFIG_SYS_BOOTMAPSZ settings), but in unused |
| 59 | * memory, which means far enough below the current stack |
| 60 | * pointer. |
| 61 | */ |
| 62 | sp = get_sp(); |
| 63 | debug("## Current stack ends at 0x%08lx ", sp); |
| 64 | |
Rob Herring | fcfa696 | 2012-06-28 03:54:11 +0000 | [diff] [blame] | 65 | /* adjust sp by 4K to be safe */ |
| 66 | sp -= 4096; |
John Rigby | 2d1916e | 2010-10-13 13:57:36 -0600 | [diff] [blame] | 67 | lmb_reserve(lmb, sp, |
| 68 | gd->bd->bi_dram[0].start + gd->bd->bi_dram[0].size - sp); |
| 69 | } |
| 70 | |
Simon Glass | bce1b92 | 2013-06-19 21:15:10 -0700 | [diff] [blame] | 71 | /** |
| 72 | * announce_and_cleanup() - Print message and prepare for kernel boot |
| 73 | * |
| 74 | * @fake: non-zero to do everything except actually boot |
| 75 | */ |
| 76 | static void announce_and_cleanup(int fake) |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 77 | { |
Simon Glass | bce1b92 | 2013-06-19 21:15:10 -0700 | [diff] [blame] | 78 | printf("\nStarting kernel ...%s\n\n", fake ? |
| 79 | "(fake run for tracing)" : ""); |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 80 | bootstage_mark_name(BOOTSTAGE_ID_BOOTM_HANDOFF, "start_kernel"); |
Simon Glass | 94fd131 | 2012-09-28 08:56:37 +0000 | [diff] [blame] | 81 | #ifdef CONFIG_BOOTSTAGE_FDT |
Simon Glass | bce1b92 | 2013-06-19 21:15:10 -0700 | [diff] [blame] | 82 | if (flag == BOOTM_STATE_OS_FAKE_GO) |
| 83 | bootstage_fdt_add_report(); |
Simon Glass | 94fd131 | 2012-09-28 08:56:37 +0000 | [diff] [blame] | 84 | #endif |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 85 | #ifdef CONFIG_BOOTSTAGE_REPORT |
| 86 | bootstage_report(); |
| 87 | #endif |
| 88 | |
| 89 | #ifdef CONFIG_USB_DEVICE |
| 90 | udc_disconnect(); |
| 91 | #endif |
| 92 | cleanup_before_linux(); |
| 93 | } |
| 94 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 95 | static void setup_start_tag (bd_t *bd) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 96 | { |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 97 | params = (struct tag *)bd->bi_boot_params; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 98 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 99 | params->hdr.tag = ATAG_CORE; |
| 100 | params->hdr.size = tag_size (tag_core); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 101 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 102 | params->u.core.flags = 0; |
| 103 | params->u.core.pagesize = 0; |
| 104 | params->u.core.rootdev = 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 105 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 106 | params = tag_next (params); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 107 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 108 | |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 109 | static void setup_memory_tags(bd_t *bd) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 110 | { |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 111 | int i; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 112 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 113 | for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { |
| 114 | params->hdr.tag = ATAG_MEM; |
| 115 | params->hdr.size = tag_size (tag_mem32); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 116 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 117 | params->u.mem.start = bd->bi_dram[i].start; |
| 118 | params->u.mem.size = bd->bi_dram[i].size; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 119 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 120 | params = tag_next (params); |
| 121 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 122 | } |
| 123 | |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 124 | static void setup_commandline_tag(bd_t *bd, char *commandline) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 125 | { |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 126 | char *p; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 127 | |
wdenk | 109c0e3 | 2004-03-23 21:43:07 +0000 | [diff] [blame] | 128 | if (!commandline) |
| 129 | return; |
| 130 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 131 | /* eat leading white space */ |
| 132 | for (p = commandline; *p == ' '; p++); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 133 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 134 | /* skip non-existent command lines so the kernel will still |
| 135 | * use its default command line. |
| 136 | */ |
| 137 | if (*p == '\0') |
| 138 | return; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 139 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 140 | params->hdr.tag = ATAG_CMDLINE; |
| 141 | params->hdr.size = |
| 142 | (sizeof (struct tag_header) + strlen (p) + 1 + 4) >> 2; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 143 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 144 | strcpy (params->u.cmdline.cmdline, p); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 145 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 146 | params = tag_next (params); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 147 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 148 | |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 149 | 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] | 150 | { |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 151 | /* an ATAG_INITRD node tells the kernel where the compressed |
| 152 | * ramdisk can be found. ATAG_RDIMG is a better name, actually. |
| 153 | */ |
wdenk | 498b8db | 2004-04-18 22:26:17 +0000 | [diff] [blame] | 154 | params->hdr.tag = ATAG_INITRD2; |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 155 | params->hdr.size = tag_size (tag_initrd); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 156 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 157 | params->u.initrd.start = initrd_start; |
| 158 | params->u.initrd.size = initrd_end - initrd_start; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 159 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 160 | params = tag_next (params); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 161 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 162 | |
Simon Glass | c19d13b | 2013-05-08 08:06:02 +0000 | [diff] [blame] | 163 | static void setup_serial_tag(struct tag **tmp) |
wdenk | 3a574cb | 2005-05-19 22:39:42 +0000 | [diff] [blame] | 164 | { |
| 165 | struct tag *params = *tmp; |
| 166 | struct tag_serialnr serialnr; |
wdenk | 3a574cb | 2005-05-19 22:39:42 +0000 | [diff] [blame] | 167 | |
| 168 | get_board_serial(&serialnr); |
| 169 | params->hdr.tag = ATAG_SERIAL; |
| 170 | params->hdr.size = tag_size (tag_serialnr); |
| 171 | params->u.serialnr.low = serialnr.low; |
| 172 | params->u.serialnr.high= serialnr.high; |
| 173 | params = tag_next (params); |
| 174 | *tmp = params; |
| 175 | } |
wdenk | 3a574cb | 2005-05-19 22:39:42 +0000 | [diff] [blame] | 176 | |
Simon Glass | c19d13b | 2013-05-08 08:06:02 +0000 | [diff] [blame] | 177 | static void setup_revision_tag(struct tag **in_params) |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 178 | { |
| 179 | u32 rev = 0; |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 180 | |
| 181 | rev = get_board_rev(); |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 182 | params->hdr.tag = ATAG_REVISION; |
| 183 | params->hdr.size = tag_size (tag_revision); |
| 184 | params->u.revision.rev = rev; |
| 185 | params = tag_next (params); |
| 186 | } |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 187 | |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 188 | static void setup_end_tag(bd_t *bd) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 189 | { |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 190 | params->hdr.tag = ATAG_NONE; |
| 191 | params->hdr.size = 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 192 | } |
| 193 | |
Pali Rohár | 89e6f13 | 2012-10-19 02:00:04 +0000 | [diff] [blame] | 194 | __weak void setup_board_tags(struct tag **in_params) {} |
| 195 | |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 196 | /* Subcommand: PREP */ |
| 197 | static void boot_prep_linux(bootm_headers_t *images) |
| 198 | { |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 199 | char *commandline = getenv("bootargs"); |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 200 | |
Simon Glass | c19d13b | 2013-05-08 08:06:02 +0000 | [diff] [blame] | 201 | if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) { |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 202 | #ifdef CONFIG_OF_LIBFDT |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 203 | debug("using: FDT\n"); |
Simon Glass | 6caa195 | 2013-05-08 08:06:03 +0000 | [diff] [blame] | 204 | if (image_setup_linux(images)) { |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 205 | printf("FDT creation failed! hanging..."); |
| 206 | hang(); |
| 207 | } |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 208 | #endif |
Simon Glass | c19d13b | 2013-05-08 08:06:02 +0000 | [diff] [blame] | 209 | } else if (BOOTM_ENABLE_TAGS) { |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 210 | debug("using: ATAGS\n"); |
| 211 | setup_start_tag(gd->bd); |
Simon Glass | c19d13b | 2013-05-08 08:06:02 +0000 | [diff] [blame] | 212 | if (BOOTM_ENABLE_SERIAL_TAG) |
| 213 | setup_serial_tag(¶ms); |
| 214 | if (BOOTM_ENABLE_CMDLINE_TAG) |
| 215 | setup_commandline_tag(gd->bd, commandline); |
| 216 | if (BOOTM_ENABLE_REVISION_TAG) |
| 217 | setup_revision_tag(¶ms); |
| 218 | if (BOOTM_ENABLE_MEMORY_TAGS) |
| 219 | setup_memory_tags(gd->bd); |
| 220 | if (BOOTM_ENABLE_INITRD_TAG) { |
| 221 | if (images->rd_start && images->rd_end) { |
| 222 | setup_initrd_tag(gd->bd, images->rd_start, |
| 223 | images->rd_end); |
| 224 | } |
| 225 | } |
Pali Rohár | 89e6f13 | 2012-10-19 02:00:04 +0000 | [diff] [blame] | 226 | setup_board_tags(¶ms); |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 227 | setup_end_tag(gd->bd); |
Simon Glass | c19d13b | 2013-05-08 08:06:02 +0000 | [diff] [blame] | 228 | } else { |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 229 | printf("FDT and ATAGS support not compiled in - hanging\n"); |
| 230 | hang(); |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 231 | } |
| 232 | } |
| 233 | |
| 234 | /* Subcommand: GO */ |
Simon Glass | bce1b92 | 2013-06-19 21:15:10 -0700 | [diff] [blame] | 235 | static void boot_jump_linux(bootm_headers_t *images, int flag) |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 236 | { |
| 237 | unsigned long machid = gd->bd->bi_arch_number; |
| 238 | char *s; |
| 239 | void (*kernel_entry)(int zero, int arch, uint params); |
Stephen Warren | 1723997 | 2012-04-19 11:34:00 +0000 | [diff] [blame] | 240 | unsigned long r2; |
Simon Glass | bce1b92 | 2013-06-19 21:15:10 -0700 | [diff] [blame] | 241 | int fake = (flag & BOOTM_STATE_OS_FAKE_GO); |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 242 | |
| 243 | kernel_entry = (void (*)(int, int, uint))images->ep; |
| 244 | |
| 245 | s = getenv("machid"); |
| 246 | if (s) { |
| 247 | strict_strtoul(s, 16, &machid); |
| 248 | printf("Using machid 0x%lx from environment\n", machid); |
| 249 | } |
| 250 | |
| 251 | debug("## Transferring control to Linux (at address %08lx)" \ |
| 252 | "...\n", (ulong) kernel_entry); |
| 253 | bootstage_mark(BOOTSTAGE_ID_RUN_OS); |
Simon Glass | bce1b92 | 2013-06-19 21:15:10 -0700 | [diff] [blame] | 254 | announce_and_cleanup(fake); |
Stephen Warren | 1723997 | 2012-04-19 11:34:00 +0000 | [diff] [blame] | 255 | |
Simon Glass | c19d13b | 2013-05-08 08:06:02 +0000 | [diff] [blame] | 256 | if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) |
Stephen Warren | 1723997 | 2012-04-19 11:34:00 +0000 | [diff] [blame] | 257 | r2 = (unsigned long)images->ft_addr; |
| 258 | else |
Stephen Warren | 1723997 | 2012-04-19 11:34:00 +0000 | [diff] [blame] | 259 | r2 = gd->bd->bi_boot_params; |
| 260 | |
Simon Glass | bce1b92 | 2013-06-19 21:15:10 -0700 | [diff] [blame] | 261 | if (!fake) |
| 262 | kernel_entry(0, machid, r2); |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | /* Main Entry point for arm bootm implementation |
| 266 | * |
| 267 | * Modeled after the powerpc implementation |
| 268 | * DIFFERENCE: Instead of calling prep and go at the end |
| 269 | * they are called if subcommand is equal 0. |
| 270 | */ |
| 271 | int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) |
| 272 | { |
| 273 | /* No need for those on ARM */ |
| 274 | if (flag & BOOTM_STATE_OS_BD_T || flag & BOOTM_STATE_OS_CMDLINE) |
| 275 | return -1; |
| 276 | |
| 277 | if (flag & BOOTM_STATE_OS_PREP) { |
| 278 | boot_prep_linux(images); |
| 279 | return 0; |
| 280 | } |
| 281 | |
Simon Glass | bce1b92 | 2013-06-19 21:15:10 -0700 | [diff] [blame] | 282 | if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) { |
| 283 | boot_jump_linux(images, flag); |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 284 | return 0; |
| 285 | } |
| 286 | |
| 287 | boot_prep_linux(images); |
Simon Glass | bce1b92 | 2013-06-19 21:15:10 -0700 | [diff] [blame] | 288 | boot_jump_linux(images, flag); |
Simon Schwarz | 0a672d4 | 2012-03-15 04:01:45 +0000 | [diff] [blame] | 289 | return 0; |
John Rigby | 2d1916e | 2010-10-13 13:57:36 -0600 | [diff] [blame] | 290 | } |
Marek Vasut | 44f074c | 2012-03-14 21:52:45 +0000 | [diff] [blame] | 291 | |
| 292 | #ifdef CONFIG_CMD_BOOTZ |
| 293 | |
| 294 | struct zimage_header { |
| 295 | uint32_t code[9]; |
| 296 | uint32_t zi_magic; |
| 297 | uint32_t zi_start; |
| 298 | uint32_t zi_end; |
| 299 | }; |
| 300 | |
| 301 | #define LINUX_ARM_ZIMAGE_MAGIC 0x016f2818 |
| 302 | |
| 303 | int bootz_setup(void *image, void **start, void **end) |
| 304 | { |
| 305 | struct zimage_header *zi = (struct zimage_header *)image; |
| 306 | |
| 307 | if (zi->zi_magic != LINUX_ARM_ZIMAGE_MAGIC) { |
| 308 | puts("Bad Linux ARM zImage magic!\n"); |
| 309 | return 1; |
| 310 | } |
| 311 | |
| 312 | *start = (void *)zi->zi_start; |
| 313 | *end = (void *)zi->zi_end; |
| 314 | |
| 315 | debug("Kernel image @ 0x%08x [ 0x%08x - 0x%08x ]\n", |
| 316 | (uint32_t)image, (uint32_t)*start, (uint32_t)*end); |
| 317 | |
| 318 | return 0; |
| 319 | } |
| 320 | #endif /* CONFIG_CMD_BOOTZ */ |