blob: dd32a3ed845cfa4cbe459ee38af32b314ba5c344 [file] [log] [blame]
Nobuhiro Iwamatsu0b135cf2007-05-13 20:58:00 +09001/*
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
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
23
24#include <common.h>
25#include <command.h>
26#include <asm/byteorder.h>
27
Nobuhiro Iwamatsu0b135cf2007-05-13 20:58:00 +090028/* The SH kernel reads arguments from the empty zero page at location
Wolfgang Denk61fb15c52007-12-27 01:52:50 +010029 * 0 at the start of SDRAM. The following are copied from
Nobuhiro Iwamatsu0b135cf2007-05-13 20:58:00 +090030 * arch/sh/kernel/setup.c and may require tweaking if the kernel sources
31 * change.
32 */
Wolfgang Denk438a4c12008-03-26 11:48:46 +010033#define PARAM ((unsigned char *)CFG_SDRAM_BASE + 0x1000)
Nobuhiro Iwamatsu0b135cf2007-05-13 20:58:00 +090034
35#define MOUNT_ROOT_RDONLY (*(unsigned long *) (PARAM+0x000))
36#define RAMDISK_FLAGS (*(unsigned long *) (PARAM+0x004))
37#define ORIG_ROOT_DEV (*(unsigned long *) (PARAM+0x008))
38#define LOADER_TYPE (*(unsigned long *) (PARAM+0x00c))
39#define INITRD_START (*(unsigned long *) (PARAM+0x010))
40#define INITRD_SIZE (*(unsigned long *) (PARAM+0x014))
41/* ... */
42#define COMMAND_LINE ((char *) (PARAM+0x100))
43
Wolfgang Denk438a4c12008-03-26 11:48:46 +010044#define RAMDISK_IMAGE_START_MASK 0x07FF
Nobuhiro Iwamatsu0b135cf2007-05-13 20:58:00 +090045
Marian Balakowiczd5934ad2008-02-04 08:28:09 +010046extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
47
Nobuhiro Iwamatsu0b135cf2007-05-13 20:58:00 +090048#ifdef CFG_DEBUG
49static void hexdump (unsigned char *buf, int len)
50{
51 int i;
52
53 for (i = 0; i < len; i++) {
54 if ((i % 16) == 0)
55 printf ("%s%08x: ", i ? "\n" : "", (unsigned int) &buf[i]);
56 printf ("%02x ", buf[i]);
57 }
58 printf ("\n");
59}
60#endif
61
62void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
Wolfgang Denk438a4c12008-03-26 11:48:46 +010063 bootm_headers_t *images)
Nobuhiro Iwamatsu0b135cf2007-05-13 20:58:00 +090064{
Marian Balakowiczd5934ad2008-02-04 08:28:09 +010065 ulong ep = 0;
66 char *bootargs = getenv("bootargs");
67
68 /* find kernel entry point */
69 if (images->legacy_hdr_valid) {
Marian Balakowiczcb1c4892008-04-11 11:07:49 +020070 ep = image_get_ep (&images->legacy_hdr_os_copy);
Marian Balakowiczd5934ad2008-02-04 08:28:09 +010071#if defined(CONFIG_FIT)
72 } else if (images->fit_uname_os) {
Marian Balakowiczcd7c5962008-03-12 10:33:00 +010073 int ret = fit_image_get_entry (images->fit_hdr_os,
74 images->fit_noffset_os, &ep);
75 if (ret) {
76 puts ("Can't get entry point property!\n");
77 goto error;
78 }
Marian Balakowiczd5934ad2008-02-04 08:28:09 +010079#endif
80 } else {
81 puts ("Could not find kernel entry point!\n");
Marian Balakowiczcd7c5962008-03-12 10:33:00 +010082 goto error;
Marian Balakowiczd5934ad2008-02-04 08:28:09 +010083 }
84 void (*kernel) (void) = (void (*)(void))ep;
Nobuhiro Iwamatsu0b135cf2007-05-13 20:58:00 +090085
Kumar Gala75fa0022008-02-27 21:51:51 -060086 if (!images->autostart)
87 return ;
88
Nobuhiro Iwamatsu0b135cf2007-05-13 20:58:00 +090089 /* Setup parameters */
90 memset(PARAM, 0, 0x1000); /* Clear zero page */
91 strcpy(COMMAND_LINE, bootargs);
Nobuhiro Iwamatsub02bad12007-09-23 02:12:30 +090092
Nobuhiro Iwamatsu0b135cf2007-05-13 20:58:00 +090093 kernel();
Marian Balakowiczcd7c5962008-03-12 10:33:00 +010094 /* does not return */
95 return;
96
97error:
98 if (images->autostart)
99 do_reset (cmdtp, flag, argc, argv);
100 return;
Nobuhiro Iwamatsu0b135cf2007-05-13 20:58:00 +0900101}