"Das U-Boot" Source Tree
at master 101 lines 2.2 kB view raw
1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * Copyright (c) 2012, Google Inc. All rights reserved. 4 */ 5 6#include <bootstage.h> 7#include <command.h> 8#include <vsprintf.h> 9 10static int do_bootstage_report(struct cmd_tbl *cmdtp, int flag, int argc, 11 char *const argv[]) 12{ 13 bootstage_report(); 14 15 return 0; 16} 17 18#if IS_ENABLED(CONFIG_BOOTSTAGE_STASH) 19static int get_base_size(int argc, char *const argv[], ulong *basep, 20 ulong *sizep) 21{ 22 char *endp; 23 24 *basep = CONFIG_BOOTSTAGE_STASH_ADDR; 25 *sizep = CONFIG_BOOTSTAGE_STASH_SIZE; 26 if (argc < 2) 27 return 0; 28 *basep = hextoul(argv[1], &endp); 29 if (*argv[1] == 0 || *endp != 0) 30 return -1; 31 if (argc == 2) 32 return 0; 33 *sizep = hextoul(argv[2], &endp); 34 if (*argv[2] == 0 || *endp != 0) 35 return -1; 36 37 return 0; 38} 39 40static int do_bootstage_stash(struct cmd_tbl *cmdtp, int flag, int argc, 41 char *const argv[]) 42{ 43 ulong base, size; 44 int ret; 45 46 if (get_base_size(argc, argv, &base, &size)) 47 return CMD_RET_USAGE; 48 if (base == -1UL) { 49 printf("No bootstage stash area defined\n"); 50 return 1; 51 } 52 53 if (0 == strcmp(argv[0], "stash")) 54 ret = bootstage_stash((void *)base, size); 55 else 56 ret = bootstage_unstash((void *)base, size); 57 if (ret) 58 return 1; 59 60 return 0; 61} 62#endif 63 64static struct cmd_tbl cmd_bootstage_sub[] = { 65 U_BOOT_CMD_MKENT(report, 2, 1, do_bootstage_report, "", ""), 66#if IS_ENABLED(CONFIG_BOOTSTAGE_STASH) 67 U_BOOT_CMD_MKENT(stash, 4, 0, do_bootstage_stash, "", ""), 68 U_BOOT_CMD_MKENT(unstash, 4, 0, do_bootstage_stash, "", ""), 69#endif 70}; 71 72/* 73 * Process a bootstage sub-command 74 */ 75static int do_boostage(struct cmd_tbl *cmdtp, int flag, int argc, 76 char *const argv[]) 77{ 78 struct cmd_tbl *c; 79 80 /* Strip off leading 'bootstage' command argument */ 81 argc--; 82 argv++; 83 84 c = find_cmd_tbl(argv[0], cmd_bootstage_sub, 85 ARRAY_SIZE(cmd_bootstage_sub)); 86 87 if (c) 88 return c->cmd(cmdtp, flag, argc, argv); 89 else 90 return CMD_RET_USAGE; 91} 92 93U_BOOT_CMD(bootstage, 4, 1, do_boostage, 94 "Boot stage command", 95 " - check boot progress and timing\n" 96 "report - Print a report\n" 97#if IS_ENABLED(CONFIG_BOOTSTAGE_STASH) 98 "stash [<start> [<size>]] - Stash data into memory\n" 99 "unstash [<start> [<size>]] - Unstash data from memory\n" 100#endif 101);