blob: ae1f869f10d9b31da0e69a4ab75797a955045276 [file] [log] [blame]
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +09001/*
2 * (C) Copyright 2003
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
Nobuhiro Iwamatsu752a5952008-09-17 11:08:36 +09005 * (c) Copyright 2008 Nobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com>
6 * (c) Copyright 2008 Renesas Solutions Corp.
7 *
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +09008 * See file CREDITS for list of people who contributed to this
9 * project.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 */
26
27#include <common.h>
28#include <command.h>
29#include <asm/byteorder.h>
30
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020031#ifdef CONFIG_SYS_DEBUG
Nobuhiro Iwamatsu752a5952008-09-17 11:08:36 +090032static void hexdump(unsigned char *buf, int len)
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +090033{
34 int i;
35
36 for (i = 0; i < len; i++) {
37 if ((i % 16) == 0)
Nobuhiro Iwamatsu752a5952008-09-17 11:08:36 +090038 printf("%s%08x: ", i ? "\n" : "",
39 (unsigned int)&buf[i]);
40 printf("%02x ", buf[i]);
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +090041 }
Nobuhiro Iwamatsu752a5952008-09-17 11:08:36 +090042 printf("\n");
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +090043}
44#endif
45
Kumar Gala48626aa2008-08-15 08:24:45 -050046int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +090047{
Nobuhiro Iwamatsu752a5952008-09-17 11:08:36 +090048 /* Linux kernel load address */
Kumar Gala93467bc2008-08-15 08:24:36 -050049 void (*kernel) (void) = (void (*)(void))images->ep;
Nobuhiro Iwamatsu752a5952008-09-17 11:08:36 +090050 /* empty_zero_page */
Nobuhiro Iwamatsue58917e2008-09-18 19:34:36 +090051 unsigned char *param
52 = (unsigned char *)image_get_load(images->legacy_hdr_os);
Nobuhiro Iwamatsu752a5952008-09-17 11:08:36 +090053 /* Linux kernel command line */
Nobuhiro Iwamatsue58917e2008-09-18 19:34:36 +090054 char *cmdline = (char *)param + 0x100;
Nobuhiro Iwamatsu752a5952008-09-17 11:08:36 +090055 /* PAGE_SIZE */
Nobuhiro Iwamatsue58917e2008-09-18 19:34:36 +090056 unsigned long size = images->ep - (unsigned long)param;
Nobuhiro Iwamatsu752a5952008-09-17 11:08:36 +090057 char *bootargs = getenv("bootargs");
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +090058
Kumar Gala18178bc2008-10-21 17:25:45 -050059 if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
60 return 1;
61
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +090062 /* Setup parameters */
Nobuhiro Iwamatsu752a5952008-09-17 11:08:36 +090063 memset(param, 0, size); /* Clear zero page */
64 strcpy(cmdline, bootargs);
Nobuhiro Iwamatsu547b67f2007-09-23 02:12:30 +090065
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +090066 kernel();
Marian Balakowiczdf8ff332008-03-12 10:33:00 +010067 /* does not return */
Marian Balakowiczdf8ff332008-03-12 10:33:00 +010068
Kumar Gala48626aa2008-08-15 08:24:45 -050069 return 1;
Nobuhiro Iwamatsu970dc332007-05-13 20:58:00 +090070}