3 * Corscience GmbH & Co. KG - Simon Schwarz <schwarz@corscience.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
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (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,
28 DECLARE_GLOBAL_DATA_PTR;
30 static const char **subcmd_list[] = {
32 [SPL_EXPORT_FDT] = (const char * []) {
33 #ifdef CONFIG_OF_LIBFDT
36 #ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
46 [SPL_EXPORT_ATAGS] = (const char * []) {
47 #if defined(CONFIG_SETUP_MEMORY_TAGS) || \
48 defined(CONFIG_CMDLINE_TAG) || \
49 defined(CONFIG_INITRD_TAG) || \
50 defined(CONFIG_SERIAL_TAG) || \
51 defined(CONFIG_REVISION_TAG)
54 #ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
66 /* Calls bootm with the parameters given */
67 static int call_bootm(int argc, char * const argv[], const char *subcommand[])
75 /* create paramter array */
76 bootm_argv[0] = "do_bootm";
79 bootm_argv[4] = argv[2]; /* fdt addr */
81 bootm_argv[3] = argv[1]; /* initrd addr */
83 bootm_argv[2] = argv[0]; /* kernel addr */
89 * exec subcommands of do_bootm to init the images
92 while (subcommand[i] != NULL) {
93 bootm_argv[1] = (char *)subcommand[i];
94 debug("args %d: %s %s ", argc, bootm_argv[0], bootm_argv[1]);
95 for (j = 0; j < argc; j++)
96 debug("%s ", bootm_argv[j + 2]);
99 ret = do_bootm(find_cmd("do_bootm"), 0, argc+2,
101 debug("Subcommand retcode: %d\n", ret);
106 printf("ERROR prep subcommand failed!\n");
113 static cmd_tbl_t cmd_spl_export_sub[] = {
114 U_BOOT_CMD_MKENT(fdt, 0, 1, (void *)SPL_EXPORT_FDT, "", ""),
115 U_BOOT_CMD_MKENT(atags, 0, 1, (void *)SPL_EXPORT_ATAGS, "", ""),
118 static int spl_export(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
122 if (argc < 2) /* no subcommand */
123 return cmd_usage(cmdtp);
125 c = find_cmd_tbl(argv[1], &cmd_spl_export_sub[0],
126 ARRAY_SIZE(cmd_spl_export_sub));
127 if ((c) && ((int)c->cmd <= SPL_EXPORT_LAST)) {
130 if (call_bootm(argc, argv, subcmd_list[(int)c->cmd]))
132 switch ((int)c->cmd) {
133 #ifdef CONFIG_OF_LIBFDT
135 printf("Argument image is now in RAM: 0x%p\n",
136 (void *)images.ft_addr);
139 case SPL_EXPORT_ATAGS:
140 printf("Argument image is now in RAM at: 0x%p\n",
141 (void *)gd->bd->bi_boot_params);
145 /* Unrecognized command */
146 return cmd_usage(cmdtp);
152 static cmd_tbl_t cmd_spl_sub[] = {
153 U_BOOT_CMD_MKENT(export, 0, 1, (void *)SPL_EXPORT, "", ""),
156 static int do_spl(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
161 if (argc < 2) /* no subcommand */
162 return cmd_usage(cmdtp);
164 c = find_cmd_tbl(argv[1], &cmd_spl_sub[0], ARRAY_SIZE(cmd_spl_sub));
171 if (spl_export(cmdtp, flag, argc, argv))
172 printf("Subcommand failed\n");
175 /* unrecognized command */
176 return cmd_usage(cmdtp);
179 /* Unrecognized command */
180 return cmd_usage(cmdtp);
186 spl, 6 , 1, do_spl, "SPL configuration",
187 "export <img=atags|fdt> [kernel_addr] [initrd_addr] "
188 "[fdt_addr if <img> = fdt] - export a kernel parameter image\n"
189 "\t initrd_img can be set to \"-\" if fdt_addr without initrd img is"