2 * Copyright (c) 2012, Google Inc. All rights reserved.
4 * See file CREDITS for list of people who contributed to this
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 #ifndef CONFIG_BOOTSTAGE_STASH
26 #define CONFIG_BOOTSTAGE_STASH -1UL
27 #define CONFIG_BOOTSTAGE_STASH_SIZE -1
30 static int do_bootstage_report(cmd_tbl_t *cmdtp, int flag, int argc,
38 static int get_base_size(int argc, char * const argv[], ulong *basep,
43 *basep = CONFIG_BOOTSTAGE_STASH;
44 *sizep = CONFIG_BOOTSTAGE_STASH_SIZE;
47 *basep = simple_strtoul(argv[1], &endp, 16);
48 if (*argv[1] == 0 || *endp != 0)
52 *sizep = simple_strtoul(argv[2], &endp, 16);
53 if (*argv[2] == 0 || *endp != 0)
59 static int do_bootstage_stash(cmd_tbl_t *cmdtp, int flag, int argc,
65 if (get_base_size(argc, argv, &base, &size))
68 printf("No bootstage stash area defined\n");
72 if (0 == strcmp(argv[0], "stash"))
73 ret = bootstage_stash((void *)base, size);
75 ret = bootstage_unstash((void *)base, size);
82 static cmd_tbl_t cmd_bootstage_sub[] = {
83 U_BOOT_CMD_MKENT(report, 2, 1, do_bootstage_report, "", ""),
84 U_BOOT_CMD_MKENT(stash, 4, 0, do_bootstage_stash, "", ""),
85 U_BOOT_CMD_MKENT(unstash, 4, 0, do_bootstage_stash, "", ""),
89 * Process a bootstage sub-command
91 static int do_boostage(cmd_tbl_t *cmdtp, int flag, int argc,
96 /* Strip off leading 'bootstage' command argument */
100 c = find_cmd_tbl(argv[0], cmd_bootstage_sub,
101 ARRAY_SIZE(cmd_bootstage_sub));
104 return c->cmd(cmdtp, flag, argc, argv);
106 return CMD_RET_USAGE;
110 U_BOOT_CMD(bootstage, 4, 1, do_boostage,
111 "Boot stage command",
112 " - check boot progress and timing\n"
113 "report - Print a report\n"
114 "stash [<start> [<size>]] - Stash data into memory\n"
115 "unstash [<start> [<size>]] - Unstash data from memory"