3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
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.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
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
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 #include <environment.h>
31 #include <asm/byteorder.h>
33 DECLARE_GLOBAL_DATA_PTR;
37 #define LINUX_MAX_ENVS 256
38 #define LINUX_MAX_ARGS 256
40 #ifdef CONFIG_SHOW_BOOT_PROGRESS
41 # include <status_led.h>
42 # define SHOW_BOOT_PROGRESS(arg) show_boot_progress(arg)
44 # define SHOW_BOOT_PROGRESS(arg)
47 static ulong get_sp (void);
49 void do_bootm_linux(cmd_tbl_t * cmdtp, int flag,
50 int argc, char *argv[],
51 image_header_t *hdr, int verify)
55 ulong rd_data_start, rd_data_end, rd_len;
56 ulong initrd_start, initrd_end;
58 ulong cmd_start, cmd_end;
62 void (*kernel) (bd_t *, ulong, ulong, ulong, ulong);
65 * Booting a (Linux) kernel image
67 * Allocate space for command line and board info - the
68 * address should be as high as possible within the reach of
69 * the kernel (see CFG_BOOTMAPSZ settings), but in unused
70 * memory, which means far enough below the current stack
75 debug("## Current stack ends at 0x%08lX ", sp_limit);
77 sp_limit -= 2048; /* just to be sure */
78 if (sp_limit > CFG_BOOTMAPSZ)
79 sp_limit = CFG_BOOTMAPSZ;
82 debug("=> set upper limit to 0x%08lX\n", sp_limit);
84 cmdline = (char *)((sp_limit - CFG_BARGSIZE) & ~0xF);
85 kbd = (bd_t *) (((ulong) cmdline - sizeof(bd_t)) & ~0xF);
87 if ((s = getenv("bootargs")) == NULL)
92 cmd_start = (ulong) & cmdline[0];
93 cmd_end = cmd_start + strlen(cmdline);
98 printf("## cmdline at 0x%08lX ... 0x%08lX\n", cmd_start, cmd_end);
100 do_bdinfo(NULL, 0, 0, NULL);
103 if ((s = getenv("clocks_in_mhz")) != NULL) {
104 /* convert all clock information to MHz */
105 kbd->bi_intfreq /= 1000000L;
106 kbd->bi_busfreq /= 1000000L;
111 (void (*)(bd_t *, ulong, ulong, ulong, ulong))image_get_ep (hdr);
114 get_ramdisk (cmdtp, flag, argc, argv, hdr, verify,
115 IH_ARCH_M68K, &rd_data_start, &rd_data_end);
117 rd_len = rd_data_end - rd_data_start;
118 ramdisk_high (rd_data_start, rd_len, kdb, sp_limit, get_sp (),
119 &initrd_start, &initrd_end);
121 debug("## Transferring control to Linux (at address %08lx) ...\n",
124 SHOW_BOOT_PROGRESS(15);
127 * Linux Kernel Parameters (passing board info data):
128 * r3: ptr to board info data
129 * r4: initrd_start or 0 if no initrd
130 * r5: initrd_end - unused if r4 is 0
131 * r6: Start of command line string
132 * r7: End of command line string
134 (*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end);
135 /* does not return */
138 static ulong get_sp (void)
142 asm("movel %%a7, %%d0\n"
143 "movel %%d0, %0\n": "=d"(sp): :"%d0");