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 | 232c150 | 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 | 232c150 | 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> |
| 27 | #include <zlib.h> |
| 28 | #include <asm/byteorder.h> |
wdenk | 2abbe07 | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 29 | #ifdef CONFIG_HAS_DATAFLASH |
| 30 | #include <dataflash.h> |
| 31 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 32 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 33 | /*cmd_boot.c*/ |
| 34 | extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); |
| 35 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 36 | #if defined (CONFIG_SETUP_MEMORY_TAGS) || \ |
| 37 | defined (CONFIG_CMDLINE_TAG) || \ |
| 38 | defined (CONFIG_INITRD_TAG) || \ |
wdenk | b6e4c40 | 2004-01-02 16:05:07 +0000 | [diff] [blame] | 39 | defined (CONFIG_SERIAL_TAG) || \ |
| 40 | defined (CONFIG_REVISION_TAG) || \ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 41 | defined (CONFIG_VFD) |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 42 | static void setup_start_tag (bd_t *bd); |
| 43 | |
wdenk | 699b13a | 2002-11-03 18:03:52 +0000 | [diff] [blame] | 44 | # ifdef CONFIG_SETUP_MEMORY_TAGS |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 45 | static void setup_memory_tags (bd_t *bd); |
wdenk | 699b13a | 2002-11-03 18:03:52 +0000 | [diff] [blame] | 46 | # endif |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 47 | static void setup_commandline_tag (bd_t *bd, char *commandline); |
| 48 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 49 | #if 0 |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 50 | static void setup_ramdisk_tag (bd_t *bd); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 51 | #endif |
wdenk | 699b13a | 2002-11-03 18:03:52 +0000 | [diff] [blame] | 52 | # ifdef CONFIG_INITRD_TAG |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 53 | static void setup_initrd_tag (bd_t *bd, ulong initrd_start, |
| 54 | ulong initrd_end); |
wdenk | 699b13a | 2002-11-03 18:03:52 +0000 | [diff] [blame] | 55 | # endif |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 56 | static void setup_end_tag (bd_t *bd); |
| 57 | |
wdenk | 699b13a | 2002-11-03 18:03:52 +0000 | [diff] [blame] | 58 | # if defined (CONFIG_VFD) |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 59 | static void setup_videolfb_tag (gd_t *gd); |
wdenk | 699b13a | 2002-11-03 18:03:52 +0000 | [diff] [blame] | 60 | # endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 61 | |
| 62 | |
| 63 | static struct tag *params; |
| 64 | #endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */ |
| 65 | |
wdenk | 384ae02 | 2002-11-05 00:17:55 +0000 | [diff] [blame] | 66 | #ifdef CONFIG_SHOW_BOOT_PROGRESS |
| 67 | # include <status_led.h> |
| 68 | # define SHOW_BOOT_PROGRESS(arg) show_boot_progress(arg) |
| 69 | #else |
| 70 | # define SHOW_BOOT_PROGRESS(arg) |
| 71 | #endif |
| 72 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 73 | extern image_header_t header; /* from cmd_bootm.c */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 74 | |
| 75 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 76 | void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], |
| 77 | ulong addr, ulong *len_ptr, int verify) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 78 | { |
| 79 | DECLARE_GLOBAL_DATA_PTR; |
| 80 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 81 | ulong len = 0, checksum; |
| 82 | ulong initrd_start, initrd_end; |
| 83 | ulong data; |
wdenk | a2663ea | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 84 | void (*theKernel)(int zero, int arch, uint params); |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 85 | image_header_t *hdr = &header; |
| 86 | bd_t *bd = gd->bd; |
| 87 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 88 | #ifdef CONFIG_CMDLINE_TAG |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 89 | char *commandline = getenv ("bootargs"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 90 | #endif |
| 91 | |
wdenk | a2663ea | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 92 | theKernel = (void (*)(int, int, uint))ntohl(hdr->ih_ep); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 93 | |
| 94 | /* |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 95 | * Check if there is an initrd image |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 96 | */ |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 97 | if (argc >= 3) { |
| 98 | SHOW_BOOT_PROGRESS (9); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 99 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 100 | addr = simple_strtoul (argv[2], NULL, 16); |
wdenk | 384ae02 | 2002-11-05 00:17:55 +0000 | [diff] [blame] | 101 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 102 | printf ("## Loading Ramdisk Image at %08lx ...\n", addr); |
| 103 | |
| 104 | /* Copy header so we can blank CRC field for re-calculation */ |
| 105 | #ifdef CONFIG_HAS_DATAFLASH |
| 106 | if (addr_dataflash (addr)) { |
| 107 | read_dataflash (addr, sizeof (image_header_t), |
| 108 | (char *) &header); |
| 109 | } else |
| 110 | #endif |
| 111 | memcpy (&header, (char *) addr, |
| 112 | sizeof (image_header_t)); |
| 113 | |
| 114 | if (ntohl (hdr->ih_magic) != IH_MAGIC) { |
| 115 | printf ("Bad Magic Number\n"); |
| 116 | SHOW_BOOT_PROGRESS (-10); |
| 117 | do_reset (cmdtp, flag, argc, argv); |
| 118 | } |
| 119 | |
| 120 | data = (ulong) & header; |
| 121 | len = sizeof (image_header_t); |
| 122 | |
| 123 | checksum = ntohl (hdr->ih_hcrc); |
| 124 | hdr->ih_hcrc = 0; |
| 125 | |
| 126 | if (crc32 (0, (char *) data, len) != checksum) { |
| 127 | printf ("Bad Header Checksum\n"); |
| 128 | SHOW_BOOT_PROGRESS (-11); |
| 129 | do_reset (cmdtp, flag, argc, argv); |
| 130 | } |
| 131 | |
| 132 | SHOW_BOOT_PROGRESS (10); |
| 133 | |
| 134 | print_image_hdr (hdr); |
| 135 | |
| 136 | data = addr + sizeof (image_header_t); |
| 137 | len = ntohl (hdr->ih_size); |
| 138 | |
| 139 | #ifdef CONFIG_HAS_DATAFLASH |
| 140 | if (addr_dataflash (addr)) { |
| 141 | read_dataflash (data, len, (char *) CFG_LOAD_ADDR); |
| 142 | data = CFG_LOAD_ADDR; |
| 143 | } |
| 144 | #endif |
| 145 | |
| 146 | if (verify) { |
| 147 | ulong csum = 0; |
| 148 | |
| 149 | printf (" Verifying Checksum ... "); |
| 150 | csum = crc32 (0, (char *) data, len); |
| 151 | if (csum != ntohl (hdr->ih_dcrc)) { |
| 152 | printf ("Bad Data CRC\n"); |
| 153 | SHOW_BOOT_PROGRESS (-12); |
| 154 | do_reset (cmdtp, flag, argc, argv); |
| 155 | } |
| 156 | printf ("OK\n"); |
| 157 | } |
| 158 | |
| 159 | SHOW_BOOT_PROGRESS (11); |
| 160 | |
| 161 | if ((hdr->ih_os != IH_OS_LINUX) || |
| 162 | (hdr->ih_arch != IH_CPU_ARM) || |
| 163 | (hdr->ih_type != IH_TYPE_RAMDISK)) { |
| 164 | printf ("No Linux ARM Ramdisk Image\n"); |
| 165 | SHOW_BOOT_PROGRESS (-13); |
| 166 | do_reset (cmdtp, flag, argc, argv); |
| 167 | } |
| 168 | |
wdenk | a1f4a3d | 2004-07-11 22:19:26 +0000 | [diff] [blame^] | 169 | #if defined(CONFIG_B2) || defined(CONFIG_EVB4510) |
wdenk | 074cff0 | 2004-02-24 00:16:43 +0000 | [diff] [blame] | 170 | /* |
| 171 | *we need to copy the ramdisk to SRAM to let Linux boot |
| 172 | */ |
| 173 | memmove ((void *) ntohl(hdr->ih_load), (uchar *)data, len); |
| 174 | data = ntohl(hdr->ih_load); |
wdenk | a1f4a3d | 2004-07-11 22:19:26 +0000 | [diff] [blame^] | 175 | #endif /* CONFIG_B2 || CONFIG_EVB4510 */ |
wdenk | 074cff0 | 2004-02-24 00:16:43 +0000 | [diff] [blame] | 176 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 177 | /* |
| 178 | * Now check if we have a multifile image |
| 179 | */ |
| 180 | } else if ((hdr->ih_type == IH_TYPE_MULTI) && (len_ptr[1])) { |
| 181 | ulong tail = ntohl (len_ptr[0]) % 4; |
| 182 | int i; |
| 183 | |
| 184 | SHOW_BOOT_PROGRESS (13); |
| 185 | |
| 186 | /* skip kernel length and terminator */ |
| 187 | data = (ulong) (&len_ptr[2]); |
| 188 | /* skip any additional image length fields */ |
| 189 | for (i = 1; len_ptr[i]; ++i) |
| 190 | data += 4; |
| 191 | /* add kernel length, and align */ |
| 192 | data += ntohl (len_ptr[0]); |
| 193 | if (tail) { |
| 194 | data += 4 - tail; |
| 195 | } |
| 196 | |
| 197 | len = ntohl (len_ptr[1]); |
| 198 | |
| 199 | } else { |
| 200 | /* |
| 201 | * no initrd image |
| 202 | */ |
| 203 | SHOW_BOOT_PROGRESS (14); |
| 204 | |
| 205 | len = data = 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 206 | } |
| 207 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 208 | #ifdef DEBUG |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 209 | if (!data) { |
| 210 | printf ("No initrd\n"); |
| 211 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 212 | #endif |
| 213 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 214 | if (data) { |
| 215 | initrd_start = data; |
| 216 | initrd_end = initrd_start + len; |
| 217 | } else { |
| 218 | initrd_start = 0; |
| 219 | initrd_end = 0; |
| 220 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 221 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 222 | SHOW_BOOT_PROGRESS (15); |
wdenk | 384ae02 | 2002-11-05 00:17:55 +0000 | [diff] [blame] | 223 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 224 | debug ("## Transferring control to Linux (at address %08lx) ...\n", |
| 225 | (ulong) theKernel); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 226 | |
| 227 | #if defined (CONFIG_SETUP_MEMORY_TAGS) || \ |
| 228 | defined (CONFIG_CMDLINE_TAG) || \ |
| 229 | defined (CONFIG_INITRD_TAG) || \ |
wdenk | b6e4c40 | 2004-01-02 16:05:07 +0000 | [diff] [blame] | 230 | defined (CONFIG_SERIAL_TAG) || \ |
| 231 | defined (CONFIG_REVISION_TAG) || \ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 232 | defined (CONFIG_VFD) |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 233 | setup_start_tag (bd); |
wdenk | b6e4c40 | 2004-01-02 16:05:07 +0000 | [diff] [blame] | 234 | #ifdef CONFIG_SERIAL_TAG |
| 235 | setup_serial_tag (¶ms); |
| 236 | #endif |
| 237 | #ifdef CONFIG_REVISION_TAG |
| 238 | setup_revision_tag (¶ms); |
| 239 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 240 | #ifdef CONFIG_SETUP_MEMORY_TAGS |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 241 | setup_memory_tags (bd); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 242 | #endif |
| 243 | #ifdef CONFIG_CMDLINE_TAG |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 244 | setup_commandline_tag (bd, commandline); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 245 | #endif |
| 246 | #ifdef CONFIG_INITRD_TAG |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 247 | if (initrd_start && initrd_end) |
| 248 | setup_initrd_tag (bd, initrd_start, initrd_end); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 249 | #endif |
| 250 | #if defined (CONFIG_VFD) |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 251 | setup_videolfb_tag ((gd_t *) gd); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 252 | #endif |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 253 | setup_end_tag (bd); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 254 | #endif |
| 255 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 256 | /* we assume that the kernel is in place */ |
| 257 | printf ("\nStarting kernel ...\n\n"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 258 | |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 259 | #ifdef CONFIG_USB_DEVICE |
| 260 | { |
| 261 | extern void udc_disconnect (void); |
| 262 | udc_disconnect (); |
| 263 | } |
| 264 | #endif |
| 265 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 266 | cleanup_before_linux (); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 267 | |
wdenk | a2663ea | 2003-12-07 18:32:37 +0000 | [diff] [blame] | 268 | theKernel (0, bd->bi_arch_number, bd->bi_boot_params); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | |
| 272 | #if defined (CONFIG_SETUP_MEMORY_TAGS) || \ |
| 273 | defined (CONFIG_CMDLINE_TAG) || \ |
| 274 | defined (CONFIG_INITRD_TAG) || \ |
wdenk | b6e4c40 | 2004-01-02 16:05:07 +0000 | [diff] [blame] | 275 | defined (CONFIG_SERIAL_TAG) || \ |
| 276 | defined (CONFIG_REVISION_TAG) || \ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 277 | defined (CONFIG_VFD) |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 278 | static void setup_start_tag (bd_t *bd) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 279 | { |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 280 | params = (struct tag *) bd->bi_boot_params; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 281 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 282 | params->hdr.tag = ATAG_CORE; |
| 283 | params->hdr.size = tag_size (tag_core); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 284 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 285 | params->u.core.flags = 0; |
| 286 | params->u.core.pagesize = 0; |
| 287 | params->u.core.rootdev = 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 288 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 289 | params = tag_next (params); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | |
wdenk | 699b13a | 2002-11-03 18:03:52 +0000 | [diff] [blame] | 293 | #ifdef CONFIG_SETUP_MEMORY_TAGS |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 294 | static void setup_memory_tags (bd_t *bd) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 295 | { |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 296 | int i; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 297 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 298 | for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { |
| 299 | params->hdr.tag = ATAG_MEM; |
| 300 | params->hdr.size = tag_size (tag_mem32); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 301 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 302 | params->u.mem.start = bd->bi_dram[i].start; |
| 303 | params->u.mem.size = bd->bi_dram[i].size; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 304 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 305 | params = tag_next (params); |
| 306 | } |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 307 | } |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 308 | #endif /* CONFIG_SETUP_MEMORY_TAGS */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 309 | |
| 310 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 311 | static void setup_commandline_tag (bd_t *bd, char *commandline) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 312 | { |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 313 | char *p; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 314 | |
wdenk | 109c0e3 | 2004-03-23 21:43:07 +0000 | [diff] [blame] | 315 | if (!commandline) |
| 316 | return; |
| 317 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 318 | /* eat leading white space */ |
| 319 | for (p = commandline; *p == ' '; p++); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 320 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 321 | /* skip non-existent command lines so the kernel will still |
| 322 | * use its default command line. |
| 323 | */ |
| 324 | if (*p == '\0') |
| 325 | return; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 326 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 327 | params->hdr.tag = ATAG_CMDLINE; |
| 328 | params->hdr.size = |
| 329 | (sizeof (struct tag_header) + strlen (p) + 1 + 4) >> 2; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 330 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 331 | strcpy (params->u.cmdline.cmdline, p); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 332 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 333 | params = tag_next (params); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 334 | } |
| 335 | |
| 336 | |
wdenk | 699b13a | 2002-11-03 18:03:52 +0000 | [diff] [blame] | 337 | #ifdef CONFIG_INITRD_TAG |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 338 | 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] | 339 | { |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 340 | /* an ATAG_INITRD node tells the kernel where the compressed |
| 341 | * ramdisk can be found. ATAG_RDIMG is a better name, actually. |
| 342 | */ |
wdenk | 498b8db | 2004-04-18 22:26:17 +0000 | [diff] [blame] | 343 | params->hdr.tag = ATAG_INITRD2; |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 344 | params->hdr.size = tag_size (tag_initrd); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 345 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 346 | params->u.initrd.start = initrd_start; |
| 347 | params->u.initrd.size = initrd_end - initrd_start; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 348 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 349 | params = tag_next (params); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 350 | } |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 351 | #endif /* CONFIG_INITRD_TAG */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 352 | |
| 353 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 354 | #if defined (CONFIG_VFD) |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 355 | static void setup_videolfb_tag (gd_t *gd) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 356 | { |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 357 | /* An ATAG_VIDEOLFB node tells the kernel where and how large |
| 358 | * the framebuffer for video was allocated (among other things). |
| 359 | * Note that a _physical_ address is passed ! |
| 360 | * |
| 361 | * We only use it to pass the address and size, the other entries |
| 362 | * in the tag_videolfb are not of interest. |
| 363 | */ |
| 364 | params->hdr.tag = ATAG_VIDEOLFB; |
| 365 | params->hdr.size = tag_size (tag_videolfb); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 366 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 367 | params->u.videolfb.lfb_base = (u32) gd->fb_base; |
| 368 | /* 7168 = 256*4*56/8 - actually 2 pages (8192 bytes) are allocated */ |
| 369 | params->u.videolfb.lfb_size = 7168; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 370 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 371 | params = tag_next (params); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 372 | } |
| 373 | #endif |
| 374 | |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 375 | static void setup_end_tag (bd_t *bd) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 376 | { |
wdenk | 5779d8d | 2003-12-06 23:55:10 +0000 | [diff] [blame] | 377 | params->hdr.tag = ATAG_NONE; |
| 378 | params->hdr.size = 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 379 | } |
| 380 | |
| 381 | #endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */ |