wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2003 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 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 | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
wdenk | abf7a7c | 2003-12-08 01:34:36 +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 | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 21 | * |
| 22 | */ |
| 23 | |
| 24 | #include <common.h> |
| 25 | #include <command.h> |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 26 | #include <image.h> |
| 27 | #include <zlib.h> |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 28 | #include <bzlib.h> |
TsiChungLiew | 890adcb | 2007-10-25 17:14:00 -0500 | [diff] [blame] | 29 | #include <watchdog.h> |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 30 | #include <environment.h> |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 31 | #include <asm/byteorder.h> |
| 32 | |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 33 | DECLARE_GLOBAL_DATA_PTR; |
| 34 | |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 35 | #define PHYSADDR(x) x |
| 36 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 37 | #define LINUX_MAX_ENVS 256 |
| 38 | #define LINUX_MAX_ARGS 256 |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 39 | |
TsiChungLiew | 890adcb | 2007-10-25 17:14:00 -0500 | [diff] [blame] | 40 | #define CHUNKSZ (64 * 1024) |
| 41 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 42 | #ifdef CONFIG_SHOW_BOOT_PROGRESS |
| 43 | # include <status_led.h> |
| 44 | # define SHOW_BOOT_PROGRESS(arg) show_boot_progress(arg) |
| 45 | #else |
| 46 | # define SHOW_BOOT_PROGRESS(arg) |
| 47 | #endif |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 48 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 49 | extern image_header_t header; |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 50 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 51 | void do_bootm_linux(cmd_tbl_t * cmdtp, int flag, |
| 52 | int argc, char *argv[], |
| 53 | ulong addr, ulong * len_ptr, int verify) |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 54 | { |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 55 | ulong sp; |
| 56 | ulong len, checksum; |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 57 | ulong initrd_start, initrd_end; |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 58 | ulong cmd_start, cmd_end; |
| 59 | ulong initrd_high; |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 60 | ulong data; |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 61 | int initrd_copy_to_ram = 1; |
| 62 | char *cmdline; |
| 63 | char *s; |
| 64 | bd_t *kbd; |
| 65 | void (*kernel) (bd_t *, ulong, ulong, ulong, ulong); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 66 | image_header_t *hdr = &header; |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 67 | |
| 68 | if ((s = getenv("initrd_high")) != NULL) { |
| 69 | /* a value of "no" or a similar string will act like 0, |
| 70 | * turning the "load high" feature off. This is intentional. |
| 71 | */ |
| 72 | initrd_high = simple_strtoul(s, NULL, 16); |
| 73 | if (initrd_high == ~0) |
| 74 | initrd_copy_to_ram = 0; |
| 75 | } else { /* not set, no restrictions to load high */ |
| 76 | initrd_high = ~0; |
| 77 | } |
| 78 | |
| 79 | #ifdef CONFIG_LOGBUFFER |
| 80 | kbd = gd->bd; |
| 81 | /* Prevent initrd from overwriting logbuffer */ |
| 82 | if (initrd_high < (kbd->bi_memsize - LOGBUFF_LEN - LOGBUFF_OVERHEAD)) |
| 83 | initrd_high = kbd->bi_memsize - LOGBUFF_LEN - LOGBUFF_OVERHEAD; |
| 84 | debug("## Logbuffer at 0x%08lX ", kbd->bi_memsize - LOGBUFF_LEN); |
| 85 | #endif |
| 86 | |
| 87 | /* |
| 88 | * Booting a (Linux) kernel image |
| 89 | * |
| 90 | * Allocate space for command line and board info - the |
| 91 | * address should be as high as possible within the reach of |
| 92 | * the kernel (see CFG_BOOTMAPSZ settings), but in unused |
| 93 | * memory, which means far enough below the current stack |
| 94 | * pointer. |
| 95 | */ |
| 96 | asm("movel %%a7, %%d0\n" |
| 97 | "movel %%d0, %0\n": "=d"(sp): :"%d0"); |
Stefan Roese | fe9dae6 | 2007-08-18 14:33:02 +0200 | [diff] [blame] | 98 | |
| 99 | debug("## Current stack ends at 0x%08lX ", sp); |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 100 | |
| 101 | sp -= 2048; /* just to be sure */ |
| 102 | if (sp > CFG_BOOTMAPSZ) |
| 103 | sp = CFG_BOOTMAPSZ; |
| 104 | sp &= ~0xF; |
| 105 | |
| 106 | debug("=> set upper limit to 0x%08lX\n", sp); |
| 107 | |
| 108 | cmdline = (char *)((sp - CFG_BARGSIZE) & ~0xF); |
| 109 | kbd = (bd_t *) (((ulong) cmdline - sizeof(bd_t)) & ~0xF); |
| 110 | |
| 111 | if ((s = getenv("bootargs")) == NULL) |
| 112 | s = ""; |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 113 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 114 | strcpy(cmdline, s); |
| 115 | |
| 116 | cmd_start = (ulong) & cmdline[0]; |
| 117 | cmd_end = cmd_start + strlen(cmdline); |
| 118 | |
| 119 | *kbd = *(gd->bd); |
| 120 | |
| 121 | #ifdef DEBUG |
| 122 | printf("## cmdline at 0x%08lX ... 0x%08lX\n", cmd_start, cmd_end); |
| 123 | |
| 124 | do_bdinfo(NULL, 0, 0, NULL); |
| 125 | #endif |
| 126 | |
| 127 | if ((s = getenv("clocks_in_mhz")) != NULL) { |
| 128 | /* convert all clock information to MHz */ |
| 129 | kbd->bi_intfreq /= 1000000L; |
| 130 | kbd->bi_busfreq /= 1000000L; |
| 131 | } |
| 132 | |
| 133 | kernel = |
| 134 | (void (*)(bd_t *, ulong, ulong, ulong, ulong))ntohl(hdr->ih_ep); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 135 | |
| 136 | /* |
| 137 | * Check if there is an initrd image |
| 138 | */ |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 139 | |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 140 | if (argc >= 3) { |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 141 | debug("Not skipping initrd\n"); |
| 142 | SHOW_BOOT_PROGRESS(9); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 143 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 144 | addr = simple_strtoul(argv[2], NULL, 16); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 145 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 146 | printf("## Loading RAMDisk Image at %08lx ...\n", addr); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 147 | |
| 148 | /* Copy header so we can blank CRC field for re-calculation */ |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 149 | memmove(&header, (char *)addr, sizeof(image_header_t)); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 150 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 151 | if (ntohl(hdr->ih_magic) != IH_MAGIC) { |
| 152 | puts("Bad Magic Number\n"); |
| 153 | SHOW_BOOT_PROGRESS(-10); |
| 154 | do_reset(cmdtp, flag, argc, argv); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | data = (ulong) & header; |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 158 | len = sizeof(image_header_t); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 159 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 160 | checksum = ntohl(hdr->ih_hcrc); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 161 | hdr->ih_hcrc = 0; |
| 162 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 163 | if (crc32(0, (uchar *) data, len) != checksum) { |
| 164 | puts("Bad Header Checksum\n"); |
| 165 | SHOW_BOOT_PROGRESS(-11); |
| 166 | do_reset(cmdtp, flag, argc, argv); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 167 | } |
| 168 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 169 | SHOW_BOOT_PROGRESS(10); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 170 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 171 | print_image_hdr(hdr); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 172 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 173 | data = addr + sizeof(image_header_t); |
| 174 | len = ntohl(hdr->ih_size); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 175 | |
| 176 | if (verify) { |
| 177 | ulong csum = 0; |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 178 | #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG) |
| 179 | ulong cdata = data, edata = cdata + len; |
| 180 | #endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */ |
| 181 | |
| 182 | puts(" Verifying Checksum ... "); |
| 183 | |
| 184 | #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG) |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 185 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 186 | while (cdata < edata) { |
| 187 | ulong chunk = edata - cdata; |
| 188 | |
| 189 | if (chunk > CHUNKSZ) |
| 190 | chunk = CHUNKSZ; |
| 191 | csum = crc32(csum, (uchar *) cdata, chunk); |
| 192 | cdata += chunk; |
| 193 | |
| 194 | WATCHDOG_RESET(); |
| 195 | } |
| 196 | #else /* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */ |
| 197 | csum = crc32(0, (uchar *) data, len); |
| 198 | #endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */ |
| 199 | |
| 200 | if (csum != ntohl(hdr->ih_dcrc)) { |
| 201 | puts("Bad Data CRC\n"); |
| 202 | SHOW_BOOT_PROGRESS(-12); |
| 203 | do_reset(cmdtp, flag, argc, argv); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 204 | } |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 205 | puts("OK\n"); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 206 | } |
| 207 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 208 | SHOW_BOOT_PROGRESS(11); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 209 | |
| 210 | if ((hdr->ih_os != IH_OS_LINUX) || |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 211 | (hdr->ih_arch != IH_CPU_M68K) || |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 212 | (hdr->ih_type != IH_TYPE_RAMDISK)) { |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 213 | puts("No Linux ColdFire Ramdisk Image\n"); |
| 214 | SHOW_BOOT_PROGRESS(-13); |
| 215 | do_reset(cmdtp, flag, argc, argv); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | /* |
| 219 | * Now check if we have a multifile image |
| 220 | */ |
| 221 | } else if ((hdr->ih_type == IH_TYPE_MULTI) && (len_ptr[1])) { |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 222 | u_long tail = ntohl(len_ptr[0]) % 4; |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 223 | int i; |
| 224 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 225 | SHOW_BOOT_PROGRESS(13); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 226 | |
| 227 | /* skip kernel length and terminator */ |
| 228 | data = (ulong) (&len_ptr[2]); |
| 229 | /* skip any additional image length fields */ |
| 230 | for (i = 1; len_ptr[i]; ++i) |
| 231 | data += 4; |
| 232 | /* add kernel length, and align */ |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 233 | data += ntohl(len_ptr[0]); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 234 | if (tail) { |
| 235 | data += 4 - tail; |
| 236 | } |
| 237 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 238 | len = ntohl(len_ptr[1]); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 239 | |
| 240 | } else { |
| 241 | /* |
| 242 | * no initrd image |
| 243 | */ |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 244 | SHOW_BOOT_PROGRESS(14); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 245 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 246 | len = data = 0; |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 247 | } |
| 248 | |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 249 | if (!data) { |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 250 | debug("No initrd\n"); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 251 | } |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 252 | |
| 253 | if (data) { |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 254 | if (!initrd_copy_to_ram) { /* zero-copy ramdisk support */ |
| 255 | initrd_start = data; |
| 256 | initrd_end = initrd_start + len; |
| 257 | } else { |
| 258 | initrd_start = (ulong) kbd - len; |
| 259 | initrd_start &= ~(4096 - 1); /* align on page */ |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 260 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 261 | if (initrd_high) { |
| 262 | ulong nsp; |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 263 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 264 | /* |
| 265 | * the inital ramdisk does not need to be within |
| 266 | * CFG_BOOTMAPSZ as it is not accessed until after |
| 267 | * the mm system is initialised. |
| 268 | * |
| 269 | * do the stack bottom calculation again and see if |
| 270 | * the initrd will fit just below the monitor stack |
| 271 | * bottom without overwriting the area allocated |
| 272 | * above for command line args and board info. |
| 273 | */ |
| 274 | asm("movel %%a7, %%d0\n" |
| 275 | "movel %%d0, %0\n": "=d"(nsp): :"%d0"); |
Stefan Roese | fe9dae6 | 2007-08-18 14:33:02 +0200 | [diff] [blame] | 276 | |
| 277 | nsp -= 2048; /* just to be sure */ |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 278 | nsp &= ~0xF; |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 279 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 280 | if (nsp > initrd_high) /* limit as specified */ |
| 281 | nsp = initrd_high; |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 282 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 283 | nsp -= len; |
| 284 | nsp &= ~(4096 - 1); /* align on page */ |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 285 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 286 | if (nsp >= sp) |
| 287 | initrd_start = nsp; |
| 288 | } |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 289 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 290 | SHOW_BOOT_PROGRESS(12); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 291 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 292 | debug |
| 293 | ("## initrd at 0x%08lX ... 0x%08lX (len=%ld=0x%lX)\n", |
| 294 | data, data + len - 1, len, len); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 295 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 296 | initrd_end = initrd_start + len; |
| 297 | printf(" Loading Ramdisk to %08lx, end %08lx ... ", |
| 298 | initrd_start, initrd_end); |
| 299 | #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG) |
| 300 | { |
| 301 | size_t l = len; |
| 302 | void *to = (void *)initrd_start; |
| 303 | void *from = (void *)data; |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 304 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 305 | while (l > 0) { |
| 306 | size_t tail = |
| 307 | (l > CHUNKSZ) ? CHUNKSZ : l; |
| 308 | WATCHDOG_RESET(); |
| 309 | memmove(to, from, tail); |
| 310 | to += tail; |
| 311 | from += tail; |
| 312 | l -= tail; |
| 313 | } |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 314 | } |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 315 | #else /* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */ |
| 316 | memmove((void *)initrd_start, (void *)data, len); |
| 317 | #endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */ |
| 318 | puts("OK\n"); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 319 | } |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 320 | } else { |
| 321 | initrd_start = 0; |
| 322 | initrd_end = 0; |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 323 | } |
| 324 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 325 | debug("## Transferring control to Linux (at address %08lx) ...\n", |
| 326 | (ulong) kernel); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 327 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 328 | SHOW_BOOT_PROGRESS(15); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 329 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 330 | /* |
| 331 | * Linux Kernel Parameters (passing board info data): |
| 332 | * r3: ptr to board info data |
| 333 | * r4: initrd_start or 0 if no initrd |
| 334 | * r5: initrd_end - unused if r4 is 0 |
| 335 | * r6: Start of command line string |
| 336 | * r7: End of command line string |
| 337 | */ |
| 338 | (*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end); |
| 339 | /* does not return */ |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 340 | } |