xref: /openbmc/u-boot/arch/sh/lib/zimageboot.c (revision 4e3349b6)
1 /*
2  * (C) Copyright 2010
3  *   Renesas Solutions Corp.
4  *   Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
5  *
6  * See file CREDITS for list of people who contributed to this
7  * project.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 2 of
12  * the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22  * MA 02111-1307 USA
23  */
24 
25 /*
26  * Linux SuperH zImage loading and boot
27  */
28 
29 #include <common.h>
30 #include <asm/io.h>
31 #include <asm/zimage.h>
32 
33 int do_sh_zimageboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
34 {
35 	ulong (*zboot_entry)(int, char * const []) = NULL;
36 	char *s0, *s1;
37 	unsigned char *param = NULL;
38 	char *cmdline;
39 	char *bootargs;
40 
41 	disable_interrupts();
42 
43 	if (argc >= 3) {
44 		/* argv[1] holds the address of the zImage */
45 		s0 = argv[1];
46 		/* argv[2] holds the address of zero page */
47 		s1 = argv[2];
48 	} else {
49 		goto exit;
50 	}
51 
52 	if (s0)
53 		zboot_entry = (ulong (*)(int, char * const []))simple_strtoul(s0, NULL, 16);
54 
55 	/* empty_zero_page */
56 	if (s1)
57 		param = (unsigned char*)simple_strtoul(s1, NULL, 16);
58 
59 	/* Linux kernel command line */
60 	cmdline = (char *)param + COMMAND_LINE;
61 	bootargs = getenv("bootargs");
62 
63 	/* Clear zero page */
64 	memset(param, 0, 0x1000);
65 
66 	/* Set commandline */
67 	strcpy(cmdline, bootargs);
68 
69 	/* Boot */
70 	zboot_entry(0, NULL);
71 
72 exit:
73 	return -1;
74 }
75 
76 U_BOOT_CMD(
77 	zimageboot, 3, 0,	do_sh_zimageboot,
78 	"Boot zImage for Renesas SH",
79 	""
80 );
81