wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2002 |
| 3 | * Sysgo Real-Time Solutions, GmbH <www.elinos.com> |
| 4 | * Marius Groeger <mgroeger@sysgo.de> |
| 5 | * |
| 6 | * Copyright (C) 2001 Erik Mouw (J.A.K.Mouw@its.tudelft.nl) |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (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 |
wdenk | 29e7f5a | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 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 |
wdenk | 29e7f5a | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 21 | * |
| 22 | */ |
| 23 | |
| 24 | #include <common.h> |
| 25 | #include <command.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 26 | #include <image.h> |
Jean-Christophe PLAGNIOL-VILLARD | 6bb9449 | 2009-04-04 12:49:11 +0200 | [diff] [blame] | 27 | #include <u-boot/zlib.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 28 | #include <asm/byteorder.h> |
John Rigby | ab51f1e | 2010-10-13 13:57:36 -0600 | [diff] [blame] | 29 | #include <fdt.h> |
| 30 | #include <libfdt.h> |
| 31 | #include <fdt_support.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 32 | |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 33 | DECLARE_GLOBAL_DATA_PTR; |
| 34 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 35 | #if defined (CONFIG_SETUP_MEMORY_TAGS) || \ |
| 36 | defined (CONFIG_CMDLINE_TAG) || \ |
| 37 | defined (CONFIG_INITRD_TAG) || \ |
wdenk | bc01dd5 | 2004-01-02 16:05:07 +0000 | [diff] [blame] | 38 | defined (CONFIG_SERIAL_TAG) || \ |
Minkyu Kang | 977e3b6 | 2010-06-18 19:31:10 +0900 | [diff] [blame] | 39 | defined (CONFIG_REVISION_TAG) |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 40 | static void setup_start_tag (bd_t *bd); |
| 41 | |
wdenk | 699b13a | 2002-11-03 18:03:52 +0000 | [diff] [blame] | 42 | # ifdef CONFIG_SETUP_MEMORY_TAGS |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 43 | static void setup_memory_tags (bd_t *bd); |
wdenk | 699b13a | 2002-11-03 18:03:52 +0000 | [diff] [blame] | 44 | # endif |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 45 | static void setup_commandline_tag (bd_t *bd, char *commandline); |
| 46 | |
wdenk | 699b13a | 2002-11-03 18:03:52 +0000 | [diff] [blame] | 47 | # ifdef CONFIG_INITRD_TAG |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 48 | static void setup_initrd_tag (bd_t *bd, ulong initrd_start, |
| 49 | ulong initrd_end); |
wdenk | 699b13a | 2002-11-03 18:03:52 +0000 | [diff] [blame] | 50 | # endif |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 51 | static void setup_end_tag (bd_t *bd); |
| 52 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 53 | static struct tag *params; |
| 54 | #endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */ |
| 55 | |
John Rigby | ab51f1e | 2010-10-13 13:57:36 -0600 | [diff] [blame] | 56 | static ulong get_sp(void); |
| 57 | #if defined(CONFIG_OF_LIBFDT) |
| 58 | static int bootm_linux_fdt(int machid, bootm_headers_t *images); |
| 59 | #endif |
| 60 | |
| 61 | void arch_lmb_reserve(struct lmb *lmb) |
| 62 | { |
| 63 | ulong sp; |
| 64 | |
| 65 | /* |
| 66 | * Booting a (Linux) kernel image |
| 67 | * |
| 68 | * Allocate space for command line and board info - the |
| 69 | * address should be as high as possible within the reach of |
| 70 | * the kernel (see CONFIG_SYS_BOOTMAPSZ settings), but in unused |
| 71 | * memory, which means far enough below the current stack |
| 72 | * pointer. |
| 73 | */ |
| 74 | sp = get_sp(); |
| 75 | debug("## Current stack ends at 0x%08lx ", sp); |
| 76 | |
| 77 | /* adjust sp by 1K to be safe */ |
| 78 | sp -= 1024; |
| 79 | lmb_reserve(lmb, sp, |
| 80 | gd->bd->bi_dram[0].start + gd->bd->bi_dram[0].size - sp); |
| 81 | } |
| 82 | |
| 83 | static void announce_and_cleanup(void) |
| 84 | { |
| 85 | printf("\nStarting kernel ...\n\n"); |
| 86 | |
| 87 | #ifdef CONFIG_USB_DEVICE |
| 88 | { |
| 89 | extern void udc_disconnect(void); |
| 90 | udc_disconnect(); |
| 91 | } |
| 92 | #endif |
| 93 | cleanup_before_linux(); |
| 94 | } |
| 95 | |
| 96 | int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 97 | { |
Marian Balakowicz | dbdd16a | 2008-02-04 08:28:09 +0100 | [diff] [blame] | 98 | bd_t *bd = gd->bd; |
| 99 | char *s; |
| 100 | int machid = bd->bi_arch_number; |
John Rigby | ab51f1e | 2010-10-13 13:57:36 -0600 | [diff] [blame] | 101 | void (*kernel_entry)(int zero, int arch, uint params); |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 102 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 103 | #ifdef CONFIG_CMDLINE_TAG |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 104 | char *commandline = getenv ("bootargs"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 105 | #endif |
| 106 | |
Ilko Iliev | bcbc8e4 | 2008-11-09 15:53:14 +0100 | [diff] [blame] | 107 | if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) |
Kumar Gala | 18178bc | 2008-10-21 17:25:45 -0500 | [diff] [blame] | 108 | return 1; |
| 109 | |
Uwe Kleine-König | 533937d | 2008-01-30 09:08:49 +0100 | [diff] [blame] | 110 | s = getenv ("machid"); |
| 111 | if (s) { |
| 112 | machid = simple_strtoul (s, NULL, 16); |
| 113 | printf ("Using machid 0x%x from environment\n", machid); |
| 114 | } |
| 115 | |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 116 | show_boot_progress (15); |
wdenk | 384ae02 | 2002-11-05 00:17:55 +0000 | [diff] [blame] | 117 | |
John Rigby | ab51f1e | 2010-10-13 13:57:36 -0600 | [diff] [blame] | 118 | #ifdef CONFIG_OF_LIBFDT |
| 119 | if (images->ft_len) |
| 120 | return bootm_linux_fdt(machid, images); |
| 121 | #endif |
| 122 | |
| 123 | kernel_entry = (void (*)(int, int, uint))images->ep; |
| 124 | |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 125 | debug ("## Transferring control to Linux (at address %08lx) ...\n", |
John Rigby | ab51f1e | 2010-10-13 13:57:36 -0600 | [diff] [blame] | 126 | (ulong) kernel_entry); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 127 | |
| 128 | #if defined (CONFIG_SETUP_MEMORY_TAGS) || \ |
| 129 | defined (CONFIG_CMDLINE_TAG) || \ |
| 130 | defined (CONFIG_INITRD_TAG) || \ |
wdenk | bc01dd5 | 2004-01-02 16:05:07 +0000 | [diff] [blame] | 131 | defined (CONFIG_SERIAL_TAG) || \ |
Minkyu Kang | 977e3b6 | 2010-06-18 19:31:10 +0900 | [diff] [blame] | 132 | defined (CONFIG_REVISION_TAG) |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 133 | setup_start_tag (bd); |
wdenk | bc01dd5 | 2004-01-02 16:05:07 +0000 | [diff] [blame] | 134 | #ifdef CONFIG_SERIAL_TAG |
| 135 | setup_serial_tag (¶ms); |
| 136 | #endif |
| 137 | #ifdef CONFIG_REVISION_TAG |
| 138 | setup_revision_tag (¶ms); |
| 139 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 140 | #ifdef CONFIG_SETUP_MEMORY_TAGS |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 141 | setup_memory_tags (bd); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 142 | #endif |
| 143 | #ifdef CONFIG_CMDLINE_TAG |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 144 | setup_commandline_tag (bd, commandline); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 145 | #endif |
| 146 | #ifdef CONFIG_INITRD_TAG |
Kumar Gala | fffb143 | 2008-08-15 08:24:37 -0500 | [diff] [blame] | 147 | if (images->rd_start && images->rd_end) |
| 148 | setup_initrd_tag (bd, images->rd_start, images->rd_end); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 149 | #endif |
John Rigby | ab51f1e | 2010-10-13 13:57:36 -0600 | [diff] [blame] | 150 | setup_end_tag(bd); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 151 | #endif |
| 152 | |
John Rigby | ab51f1e | 2010-10-13 13:57:36 -0600 | [diff] [blame] | 153 | announce_and_cleanup(); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 154 | |
John Rigby | ab51f1e | 2010-10-13 13:57:36 -0600 | [diff] [blame] | 155 | kernel_entry(0, machid, bd->bi_boot_params); |
| 156 | /* does not return */ |
| 157 | |
| 158 | return 1; |
| 159 | } |
| 160 | |
| 161 | #if defined(CONFIG_OF_LIBFDT) |
| 162 | static int fixup_memory_node(void *blob) |
| 163 | { |
| 164 | bd_t *bd = gd->bd; |
| 165 | int bank; |
| 166 | u64 start[CONFIG_NR_DRAM_BANKS]; |
| 167 | u64 size[CONFIG_NR_DRAM_BANKS]; |
| 168 | |
| 169 | for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) { |
| 170 | start[bank] = bd->bi_dram[bank].start; |
| 171 | size[bank] = bd->bi_dram[bank].size; |
wdenk | 29e7f5a | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 172 | } |
John Rigby | ab51f1e | 2010-10-13 13:57:36 -0600 | [diff] [blame] | 173 | |
| 174 | return fdt_fixup_memory_banks(blob, start, size, CONFIG_NR_DRAM_BANKS); |
| 175 | } |
| 176 | |
| 177 | static int bootm_linux_fdt(int machid, bootm_headers_t *images) |
| 178 | { |
| 179 | ulong rd_len; |
John Rigby | ab51f1e | 2010-10-13 13:57:36 -0600 | [diff] [blame] | 180 | void (*kernel_entry)(int zero, int dt_machid, void *dtblob); |
John Rigby | ab51f1e | 2010-10-13 13:57:36 -0600 | [diff] [blame] | 181 | ulong of_size = images->ft_len; |
| 182 | char **of_flat_tree = &images->ft_addr; |
| 183 | ulong *initrd_start = &images->initrd_start; |
| 184 | ulong *initrd_end = &images->initrd_end; |
| 185 | struct lmb *lmb = &images->lmb; |
| 186 | int ret; |
| 187 | |
| 188 | kernel_entry = (void (*)(int, int, void *))images->ep; |
wdenk | 29e7f5a | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 189 | |
Grant Likely | 20f5492 | 2011-03-28 09:59:01 +0000 | [diff] [blame] | 190 | boot_fdt_add_mem_rsv_regions(lmb, *of_flat_tree); |
| 191 | |
John Rigby | ab51f1e | 2010-10-13 13:57:36 -0600 | [diff] [blame] | 192 | rd_len = images->rd_end - images->rd_start; |
| 193 | ret = boot_ramdisk_high(lmb, images->rd_start, rd_len, |
| 194 | initrd_start, initrd_end); |
| 195 | if (ret) |
| 196 | return ret; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 197 | |
Grant Likely | dfff7a2 | 2011-03-28 09:58:34 +0000 | [diff] [blame] | 198 | ret = boot_relocate_fdt(lmb, of_flat_tree, &of_size); |
John Rigby | ab51f1e | 2010-10-13 13:57:36 -0600 | [diff] [blame] | 199 | if (ret) |
| 200 | return ret; |
| 201 | |
| 202 | debug("## Transferring control to Linux (at address %08lx) ...\n", |
| 203 | (ulong) kernel_entry); |
| 204 | |
| 205 | fdt_chosen(*of_flat_tree, 1); |
| 206 | |
| 207 | fixup_memory_node(*of_flat_tree); |
| 208 | |
Heiko Schocher | 95b644b | 2011-09-14 19:16:30 +0000 | [diff] [blame] | 209 | fdt_fixup_ethernet(*of_flat_tree); |
| 210 | |
John Rigby | ab51f1e | 2010-10-13 13:57:36 -0600 | [diff] [blame] | 211 | fdt_initrd(*of_flat_tree, *initrd_start, *initrd_end, 1); |
| 212 | |
| 213 | announce_and_cleanup(); |
| 214 | |
| 215 | kernel_entry(0, machid, *of_flat_tree); |
Marian Balakowicz | df8ff33 | 2008-03-12 10:33:00 +0100 | [diff] [blame] | 216 | /* does not return */ |
Wolfgang Denk | 20ec367 | 2008-09-08 23:26:22 +0200 | [diff] [blame] | 217 | |
Kumar Gala | 48626aa | 2008-08-15 08:24:45 -0500 | [diff] [blame] | 218 | return 1; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 219 | } |
John Rigby | ab51f1e | 2010-10-13 13:57:36 -0600 | [diff] [blame] | 220 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 221 | |
| 222 | #if defined (CONFIG_SETUP_MEMORY_TAGS) || \ |
| 223 | defined (CONFIG_CMDLINE_TAG) || \ |
| 224 | defined (CONFIG_INITRD_TAG) || \ |
wdenk | bc01dd5 | 2004-01-02 16:05:07 +0000 | [diff] [blame] | 225 | defined (CONFIG_SERIAL_TAG) || \ |
Minkyu Kang | 977e3b6 | 2010-06-18 19:31:10 +0900 | [diff] [blame] | 226 | defined (CONFIG_REVISION_TAG) |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 227 | static void setup_start_tag (bd_t *bd) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 228 | { |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 229 | params = (struct tag *) bd->bi_boot_params; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 230 | |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 231 | params->hdr.tag = ATAG_CORE; |
| 232 | params->hdr.size = tag_size (tag_core); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 233 | |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 234 | params->u.core.flags = 0; |
| 235 | params->u.core.pagesize = 0; |
| 236 | params->u.core.rootdev = 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 237 | |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 238 | params = tag_next (params); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | |
wdenk | 699b13a | 2002-11-03 18:03:52 +0000 | [diff] [blame] | 242 | #ifdef CONFIG_SETUP_MEMORY_TAGS |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 243 | static void setup_memory_tags (bd_t *bd) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 244 | { |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 245 | int i; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 246 | |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 247 | for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { |
| 248 | params->hdr.tag = ATAG_MEM; |
| 249 | params->hdr.size = tag_size (tag_mem32); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 250 | |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 251 | params->u.mem.start = bd->bi_dram[i].start; |
| 252 | params->u.mem.size = bd->bi_dram[i].size; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 253 | |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 254 | params = tag_next (params); |
| 255 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 256 | } |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 257 | #endif /* CONFIG_SETUP_MEMORY_TAGS */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 258 | |
| 259 | |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 260 | static void setup_commandline_tag (bd_t *bd, char *commandline) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 261 | { |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 262 | char *p; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 263 | |
wdenk | f16b516 | 2004-03-23 21:43:07 +0000 | [diff] [blame] | 264 | if (!commandline) |
| 265 | return; |
| 266 | |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 267 | /* eat leading white space */ |
| 268 | for (p = commandline; *p == ' '; p++); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 269 | |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 270 | /* skip non-existent command lines so the kernel will still |
| 271 | * use its default command line. |
| 272 | */ |
| 273 | if (*p == '\0') |
| 274 | return; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 275 | |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 276 | params->hdr.tag = ATAG_CMDLINE; |
| 277 | params->hdr.size = |
| 278 | (sizeof (struct tag_header) + strlen (p) + 1 + 4) >> 2; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 279 | |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 280 | strcpy (params->u.cmdline.cmdline, p); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 281 | |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 282 | params = tag_next (params); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | |
wdenk | 699b13a | 2002-11-03 18:03:52 +0000 | [diff] [blame] | 286 | #ifdef CONFIG_INITRD_TAG |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 287 | 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] | 288 | { |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 289 | /* an ATAG_INITRD node tells the kernel where the compressed |
| 290 | * ramdisk can be found. ATAG_RDIMG is a better name, actually. |
| 291 | */ |
wdenk | 19c8fb7 | 2004-04-18 22:26:17 +0000 | [diff] [blame] | 292 | params->hdr.tag = ATAG_INITRD2; |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 293 | params->hdr.size = tag_size (tag_initrd); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 294 | |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 295 | params->u.initrd.start = initrd_start; |
| 296 | params->u.initrd.size = initrd_end - initrd_start; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 297 | |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 298 | params = tag_next (params); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 299 | } |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 300 | #endif /* CONFIG_INITRD_TAG */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 301 | |
wdenk | a21ad7b | 2005-05-19 22:39:42 +0000 | [diff] [blame] | 302 | #ifdef CONFIG_SERIAL_TAG |
| 303 | void setup_serial_tag (struct tag **tmp) |
| 304 | { |
| 305 | struct tag *params = *tmp; |
| 306 | struct tag_serialnr serialnr; |
| 307 | void get_board_serial(struct tag_serialnr *serialnr); |
| 308 | |
| 309 | get_board_serial(&serialnr); |
| 310 | params->hdr.tag = ATAG_SERIAL; |
| 311 | params->hdr.size = tag_size (tag_serialnr); |
| 312 | params->u.serialnr.low = serialnr.low; |
| 313 | params->u.serialnr.high= serialnr.high; |
| 314 | params = tag_next (params); |
| 315 | *tmp = params; |
| 316 | } |
| 317 | #endif |
| 318 | |
wdenk | cb99da5 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 319 | #ifdef CONFIG_REVISION_TAG |
| 320 | void setup_revision_tag(struct tag **in_params) |
| 321 | { |
| 322 | u32 rev = 0; |
wdenk | cb99da5 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 323 | u32 get_board_rev(void); |
| 324 | |
| 325 | rev = get_board_rev(); |
wdenk | cb99da5 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 326 | params->hdr.tag = ATAG_REVISION; |
| 327 | params->hdr.size = tag_size (tag_revision); |
| 328 | params->u.revision.rev = rev; |
| 329 | params = tag_next (params); |
| 330 | } |
| 331 | #endif /* CONFIG_REVISION_TAG */ |
| 332 | |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 333 | static void setup_end_tag (bd_t *bd) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 334 | { |
wdenk | 8676590 | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 335 | params->hdr.tag = ATAG_NONE; |
| 336 | params->hdr.size = 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 337 | } |
Po-Yu Chuang | e6b836e | 2011-02-15 22:54:35 +0000 | [diff] [blame] | 338 | #endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 339 | |
John Rigby | ab51f1e | 2010-10-13 13:57:36 -0600 | [diff] [blame] | 340 | static ulong get_sp(void) |
| 341 | { |
| 342 | ulong ret; |
| 343 | |
| 344 | asm("mov %0, sp" : "=r"(ret) : ); |
| 345 | return ret; |
| 346 | } |