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