Commit 2eba38cf849c9804aac6cf75a6aea590e8d7bf35
Committed by
Anatolij Gustschin
1 parent
fcf509b807
Exists in
master
and in
54 other branches
bootstage: Add bootstage command
Now that there are a few features, add a bootstage command to access them. bootstage report - prints a report bootstage stash/unstash - stashes bootstage records in memory, reads them back Signed-off-by: Simon Glass <sjg@chromium.org>
Showing 3 changed files with 121 additions and 0 deletions Side-by-side Diff
README
... | ... | @@ -2384,6 +2384,10 @@ |
2384 | 2384 | 29,916,167 26,005,792 bootm_start |
2385 | 2385 | 30,361,327 445,160 start_kernel |
2386 | 2386 | |
2387 | + CONFIG_CMD_BOOTSTAGE | |
2388 | + Add a 'bootstage' command which supports printing a report | |
2389 | + and un/stashing of bootstage data. | |
2390 | + | |
2387 | 2391 | CONFIG_BOOTSTAGE_FDT |
2388 | 2392 | Stash the bootstage information in the FDT. A root 'bootstage' |
2389 | 2393 | node is created with each bootstage id as a child. Each child |
common/Makefile
... | ... | @@ -69,6 +69,7 @@ |
69 | 69 | COBJS-$(CONFIG_CMD_BEDBUG) += bedbug.o cmd_bedbug.o |
70 | 70 | COBJS-$(CONFIG_CMD_BMP) += cmd_bmp.o |
71 | 71 | COBJS-$(CONFIG_CMD_BOOTLDR) += cmd_bootldr.o |
72 | +COBJS-$(CONFIG_CMD_BOOTSTAGE) += cmd_bootstage.o | |
72 | 73 | COBJS-$(CONFIG_CMD_CACHE) += cmd_cache.o |
73 | 74 | COBJS-$(CONFIG_CMD_CONSOLE) += cmd_console.o |
74 | 75 | COBJS-$(CONFIG_CMD_CPLBINFO) += cmd_cplbinfo.o |
common/cmd_bootstage.c
1 | +/* | |
2 | + * Copyright (c) 2012, Google Inc. All rights reserved. | |
3 | + * | |
4 | + * See file CREDITS for list of people who contributed to this | |
5 | + * project. | |
6 | + * | |
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. | |
11 | + * | |
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. | |
16 | + * | |
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, | |
20 | + * MA 02111-1307 USA | |
21 | + */ | |
22 | + | |
23 | +#include <common.h> | |
24 | + | |
25 | +#ifndef CONFIG_BOOTSTAGE_STASH | |
26 | +#define CONFIG_BOOTSTAGE_STASH -1UL | |
27 | +#define CONFIG_BOOTSTAGE_STASH_SIZE -1 | |
28 | +#endif | |
29 | + | |
30 | +static int do_bootstage_report(cmd_tbl_t *cmdtp, int flag, int argc, | |
31 | + char * const argv[]) | |
32 | +{ | |
33 | + bootstage_report(); | |
34 | + | |
35 | + return 0; | |
36 | +} | |
37 | + | |
38 | +static int get_base_size(int argc, char * const argv[], ulong *basep, | |
39 | + ulong *sizep) | |
40 | +{ | |
41 | + char *endp; | |
42 | + | |
43 | + *basep = CONFIG_BOOTSTAGE_STASH; | |
44 | + *sizep = CONFIG_BOOTSTAGE_STASH_SIZE; | |
45 | + if (argc < 2) | |
46 | + return 0; | |
47 | + *basep = simple_strtoul(argv[1], &endp, 16); | |
48 | + if (*argv[1] == 0 || *endp != 0) | |
49 | + return -1; | |
50 | + if (argc == 2) | |
51 | + return 0; | |
52 | + *sizep = simple_strtoul(argv[2], &endp, 16); | |
53 | + if (*argv[2] == 0 || *endp != 0) | |
54 | + return -1; | |
55 | + | |
56 | + return 0; | |
57 | +} | |
58 | + | |
59 | +static int do_bootstage_stash(cmd_tbl_t *cmdtp, int flag, int argc, | |
60 | + char * const argv[]) | |
61 | +{ | |
62 | + ulong base, size; | |
63 | + int ret; | |
64 | + | |
65 | + if (get_base_size(argc, argv, &base, &size)) | |
66 | + return CMD_RET_USAGE; | |
67 | + if (base == -1UL) { | |
68 | + printf("No bootstage stash area defined\n"); | |
69 | + return 1; | |
70 | + } | |
71 | + | |
72 | + if (0 == strcmp(argv[0], "stash")) | |
73 | + ret = bootstage_stash((void *)base, size); | |
74 | + else | |
75 | + ret = bootstage_unstash((void *)base, size); | |
76 | + if (ret) | |
77 | + return 1; | |
78 | + | |
79 | + return 0; | |
80 | +} | |
81 | + | |
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, "", ""), | |
86 | +}; | |
87 | + | |
88 | +/* | |
89 | + * Process a bootstage sub-command | |
90 | + */ | |
91 | +static int do_boostage(cmd_tbl_t *cmdtp, int flag, int argc, | |
92 | + char * const argv[]) | |
93 | +{ | |
94 | + cmd_tbl_t *c; | |
95 | + | |
96 | + /* Strip off leading 'bootstage' command argument */ | |
97 | + argc--; | |
98 | + argv++; | |
99 | + | |
100 | + c = find_cmd_tbl(argv[0], cmd_bootstage_sub, | |
101 | + ARRAY_SIZE(cmd_bootstage_sub)); | |
102 | + | |
103 | + if (c) | |
104 | + return c->cmd(cmdtp, flag, argc, argv); | |
105 | + else | |
106 | + return CMD_RET_USAGE; | |
107 | +} | |
108 | + | |
109 | + | |
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" | |
116 | +); |