Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
wdenk | 5dfa25f | 2002-10-19 19:42:10 +0000 | [diff] [blame] | 2 | /* |
Detlev Zundel | 5e6c06b | 2009-03-25 17:27:52 +0100 | [diff] [blame] | 3 | * (C) Copyright 2000-2009 |
wdenk | 5dfa25f | 2002-10-19 19:42:10 +0000 | [diff] [blame] | 4 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
wdenk | 5dfa25f | 2002-10-19 19:42:10 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | /* |
| 8 | * Command Processor Table |
| 9 | */ |
| 10 | |
Tom Rini | dec7ea0 | 2024-05-20 13:35:03 -0600 | [diff] [blame] | 11 | #include <config.h> |
Simon Glass | 19f6733 | 2020-06-02 19:26:48 -0600 | [diff] [blame] | 12 | #include <compiler.h> |
wdenk | 5dfa25f | 2002-10-19 19:42:10 +0000 | [diff] [blame] | 13 | #include <command.h> |
Simon Glass | a73bda4 | 2015-11-08 23:47:45 -0700 | [diff] [blame] | 14 | #include <console.h> |
Simon Glass | bf4229c | 2019-08-01 09:46:40 -0600 | [diff] [blame] | 15 | #include <env.h> |
Simon Glass | daee3ba | 2023-01-06 08:52:28 -0600 | [diff] [blame] | 16 | #include <image.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 17 | #include <log.h> |
Simon Glass | daee3ba | 2023-01-06 08:52:28 -0600 | [diff] [blame] | 18 | #include <mapmem.h> |
Tom Rini | dec7ea0 | 2024-05-20 13:35:03 -0600 | [diff] [blame] | 19 | #include <time.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 20 | #include <asm/global_data.h> |
Jason Hobbs | cafa1aa | 2011-08-23 11:06:54 +0000 | [diff] [blame] | 21 | #include <linux/ctype.h> |
wdenk | 5dfa25f | 2002-10-19 19:42:10 +0000 | [diff] [blame] | 22 | |
Heinrich Schuchardt | 0ba04f0 | 2020-11-26 20:46:37 +0100 | [diff] [blame] | 23 | DECLARE_GLOBAL_DATA_PTR; |
| 24 | |
wdenk | 5dfa25f | 2002-10-19 19:42:10 +0000 | [diff] [blame] | 25 | /* |
| 26 | * Use puts() instead of printf() to avoid printf buffer overflow |
| 27 | * for long help messages |
| 28 | */ |
Detlev Zundel | 5e6c06b | 2009-03-25 17:27:52 +0100 | [diff] [blame] | 29 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 30 | int _do_help(struct cmd_tbl *cmd_start, int cmd_items, struct cmd_tbl *cmdtp, |
| 31 | int flag, int argc, char *const argv[]) |
wdenk | 5dfa25f | 2002-10-19 19:42:10 +0000 | [diff] [blame] | 32 | { |
| 33 | int i; |
| 34 | int rcode = 0; |
| 35 | |
Masahiro Yamada | 682195e | 2014-10-23 17:27:30 +0900 | [diff] [blame] | 36 | if (argc == 1) { /* show list of commands */ |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 37 | struct cmd_tbl *cmd_array[cmd_items]; |
wdenk | 3086a97 | 2003-06-28 23:11:04 +0000 | [diff] [blame] | 38 | int i, j, swaps; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 39 | |
wdenk | 3086a97 | 2003-06-28 23:11:04 +0000 | [diff] [blame] | 40 | /* Make array of commands from .uboot_cmd section */ |
Detlev Zundel | 5e6c06b | 2009-03-25 17:27:52 +0100 | [diff] [blame] | 41 | cmdtp = cmd_start; |
wdenk | 3086a97 | 2003-06-28 23:11:04 +0000 | [diff] [blame] | 42 | for (i = 0; i < cmd_items; i++) { |
| 43 | cmd_array[i] = cmdtp++; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 44 | } |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 45 | |
wdenk | 3086a97 | 2003-06-28 23:11:04 +0000 | [diff] [blame] | 46 | /* Sort command list (trivial bubble sort) */ |
| 47 | for (i = cmd_items - 1; i > 0; --i) { |
| 48 | swaps = 0; |
| 49 | for (j = 0; j < i; ++j) { |
Masahiro Yamada | 682195e | 2014-10-23 17:27:30 +0900 | [diff] [blame] | 50 | if (strcmp(cmd_array[j]->name, |
| 51 | cmd_array[j + 1]->name) > 0) { |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 52 | struct cmd_tbl *tmp; |
wdenk | 3086a97 | 2003-06-28 23:11:04 +0000 | [diff] [blame] | 53 | tmp = cmd_array[j]; |
| 54 | cmd_array[j] = cmd_array[j + 1]; |
| 55 | cmd_array[j + 1] = tmp; |
| 56 | ++swaps; |
| 57 | } |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 58 | } |
wdenk | 3086a97 | 2003-06-28 23:11:04 +0000 | [diff] [blame] | 59 | if (!swaps) |
| 60 | break; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | /* print short help (usage) */ |
wdenk | 3086a97 | 2003-06-28 23:11:04 +0000 | [diff] [blame] | 64 | for (i = 0; i < cmd_items; i++) { |
| 65 | const char *usage = cmd_array[i]->usage; |
| 66 | |
wdenk | 5dfa25f | 2002-10-19 19:42:10 +0000 | [diff] [blame] | 67 | /* allow user abort */ |
Masahiro Yamada | 682195e | 2014-10-23 17:27:30 +0900 | [diff] [blame] | 68 | if (ctrlc()) |
wdenk | 5dfa25f | 2002-10-19 19:42:10 +0000 | [diff] [blame] | 69 | return 1; |
wdenk | 3086a97 | 2003-06-28 23:11:04 +0000 | [diff] [blame] | 70 | if (usage == NULL) |
wdenk | 5dfa25f | 2002-10-19 19:42:10 +0000 | [diff] [blame] | 71 | continue; |
Tom Rini | 364d002 | 2023-01-10 11:19:45 -0500 | [diff] [blame] | 72 | printf("%-*s- %s\n", CFG_SYS_HELP_CMD_WIDTH, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 73 | cmd_array[i]->name, usage); |
wdenk | 5dfa25f | 2002-10-19 19:42:10 +0000 | [diff] [blame] | 74 | } |
wdenk | 5dfa25f | 2002-10-19 19:42:10 +0000 | [diff] [blame] | 75 | return 0; |
| 76 | } |
wdenk | 5dfa25f | 2002-10-19 19:42:10 +0000 | [diff] [blame] | 77 | /* |
| 78 | * command help (long version) |
| 79 | */ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 80 | for (i = 1; i < argc; ++i) { |
Masahiro Yamada | 682195e | 2014-10-23 17:27:30 +0900 | [diff] [blame] | 81 | cmdtp = find_cmd_tbl(argv[i], cmd_start, cmd_items); |
| 82 | if (cmdtp != NULL) { |
Wolfgang Denk | 9dd775b | 2009-05-24 19:17:29 +0200 | [diff] [blame] | 83 | rcode |= cmd_usage(cmdtp); |
wdenk | 7a428cc | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 84 | } else { |
Masahiro Yamada | 682195e | 2014-10-23 17:27:30 +0900 | [diff] [blame] | 85 | printf("Unknown command '%s' - try 'help' without arguments for list of all known commands\n\n", |
| 86 | argv[i]); |
wdenk | 5dfa25f | 2002-10-19 19:42:10 +0000 | [diff] [blame] | 87 | rcode = 1; |
| 88 | } |
| 89 | } |
| 90 | return rcode; |
| 91 | } |
| 92 | |
Masahiro Yamada | 682195e | 2014-10-23 17:27:30 +0900 | [diff] [blame] | 93 | /* find command table entry for a command */ |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 94 | struct cmd_tbl *find_cmd_tbl(const char *cmd, struct cmd_tbl *table, |
| 95 | int table_len) |
wdenk | 5dfa25f | 2002-10-19 19:42:10 +0000 | [diff] [blame] | 96 | { |
Simon Glass | 4ef90b7 | 2016-03-19 02:18:38 -0600 | [diff] [blame] | 97 | #ifdef CONFIG_CMDLINE |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 98 | struct cmd_tbl *cmdtp; |
| 99 | struct cmd_tbl *cmdtp_temp = table; /* Init value */ |
wdenk | 3086a97 | 2003-06-28 23:11:04 +0000 | [diff] [blame] | 100 | const char *p; |
| 101 | int len; |
| 102 | int n_found = 0; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 103 | |
Thomas Weber | 97ea46f | 2010-11-24 13:07:51 +0100 | [diff] [blame] | 104 | if (!cmd) |
| 105 | return NULL; |
wdenk | 3086a97 | 2003-06-28 23:11:04 +0000 | [diff] [blame] | 106 | /* |
| 107 | * Some commands allow length modifiers (like "cp.b"); |
| 108 | * compare command name only until first dot. |
| 109 | */ |
| 110 | len = ((p = strchr(cmd, '.')) == NULL) ? strlen (cmd) : (p - cmd); |
| 111 | |
Masahiro Yamada | 682195e | 2014-10-23 17:27:30 +0900 | [diff] [blame] | 112 | for (cmdtp = table; cmdtp != table + table_len; cmdtp++) { |
| 113 | if (strncmp(cmd, cmdtp->name, len) == 0) { |
| 114 | if (len == strlen(cmdtp->name)) |
wdenk | 3086a97 | 2003-06-28 23:11:04 +0000 | [diff] [blame] | 115 | return cmdtp; /* full match */ |
| 116 | |
| 117 | cmdtp_temp = cmdtp; /* abbreviated command ? */ |
| 118 | n_found++; |
| 119 | } |
wdenk | 5dfa25f | 2002-10-19 19:42:10 +0000 | [diff] [blame] | 120 | } |
wdenk | 3086a97 | 2003-06-28 23:11:04 +0000 | [diff] [blame] | 121 | if (n_found == 1) { /* exactly one match */ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 122 | return cmdtp_temp; |
wdenk | 3086a97 | 2003-06-28 23:11:04 +0000 | [diff] [blame] | 123 | } |
Simon Glass | 4ef90b7 | 2016-03-19 02:18:38 -0600 | [diff] [blame] | 124 | #endif /* CONFIG_CMDLINE */ |
wdenk | 5dfa25f | 2002-10-19 19:42:10 +0000 | [diff] [blame] | 125 | |
wdenk | 3086a97 | 2003-06-28 23:11:04 +0000 | [diff] [blame] | 126 | return NULL; /* not found or ambiguous command */ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 127 | } |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 128 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 129 | struct cmd_tbl *find_cmd(const char *cmd) |
Kumar Gala | ac2dad6 | 2008-09-23 10:05:02 -0500 | [diff] [blame] | 130 | { |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 131 | struct cmd_tbl *start = ll_entry_start(struct cmd_tbl, cmd); |
| 132 | const int len = ll_entry_count(struct cmd_tbl, cmd); |
Marek Vasut | 69c5e34 | 2012-10-12 10:27:04 +0000 | [diff] [blame] | 133 | return find_cmd_tbl(cmd, start, len); |
Kumar Gala | ac2dad6 | 2008-09-23 10:05:02 -0500 | [diff] [blame] | 134 | } |
| 135 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 136 | int cmd_usage(const struct cmd_tbl *cmdtp) |
Peter Tyser | ddb3af9 | 2009-01-27 18:03:10 -0600 | [diff] [blame] | 137 | { |
Wolfgang Denk | 9dd775b | 2009-05-24 19:17:29 +0200 | [diff] [blame] | 138 | printf("%s - %s\n\n", cmdtp->name, cmdtp->usage); |
| 139 | |
| 140 | #ifdef CONFIG_SYS_LONGHELP |
| 141 | printf("Usage:\n%s ", cmdtp->name); |
| 142 | |
| 143 | if (!cmdtp->help) { |
| 144 | puts ("- No additional help available.\n"); |
| 145 | return 1; |
| 146 | } |
| 147 | |
Masahiro Yamada | 682195e | 2014-10-23 17:27:30 +0900 | [diff] [blame] | 148 | puts(cmdtp->help); |
| 149 | putc('\n'); |
Wolfgang Denk | 9dd775b | 2009-05-24 19:17:29 +0200 | [diff] [blame] | 150 | #endif /* CONFIG_SYS_LONGHELP */ |
Wolfgang Denk | 3b68311 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 151 | return 1; |
Peter Tyser | ddb3af9 | 2009-01-27 18:03:10 -0600 | [diff] [blame] | 152 | } |
| 153 | |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 154 | #ifdef CONFIG_AUTO_COMPLETE |
Boris Brezillon | 619fc68 | 2018-12-05 09:26:50 +0100 | [diff] [blame] | 155 | static char env_complete_buf[512]; |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 156 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 157 | int var_complete(int argc, char *const argv[], char last_char, int maxv, |
| 158 | char *cmdv[]) |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 159 | { |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 160 | int space; |
| 161 | |
Jason Hobbs | cafa1aa | 2011-08-23 11:06:54 +0000 | [diff] [blame] | 162 | space = last_char == '\0' || isblank(last_char); |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 163 | |
| 164 | if (space && argc == 1) |
Boris Brezillon | 619fc68 | 2018-12-05 09:26:50 +0100 | [diff] [blame] | 165 | return env_complete("", maxv, cmdv, sizeof(env_complete_buf), |
| 166 | env_complete_buf, false); |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 167 | |
| 168 | if (!space && argc == 2) |
Boris Brezillon | 619fc68 | 2018-12-05 09:26:50 +0100 | [diff] [blame] | 169 | return env_complete(argv[1], maxv, cmdv, |
| 170 | sizeof(env_complete_buf), |
| 171 | env_complete_buf, false); |
Mike Frysinger | 8d88232 | 2010-12-17 16:51:59 -0500 | [diff] [blame] | 172 | |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 173 | return 0; |
| 174 | } |
| 175 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 176 | static int dollar_complete(int argc, char *const argv[], char last_char, |
Boris Brezillon | 619fc68 | 2018-12-05 09:26:50 +0100 | [diff] [blame] | 177 | int maxv, char *cmdv[]) |
| 178 | { |
| 179 | /* Make sure the last argument starts with a $. */ |
| 180 | if (argc < 1 || argv[argc - 1][0] != '$' || |
| 181 | last_char == '\0' || isblank(last_char)) |
| 182 | return 0; |
| 183 | |
| 184 | return env_complete(argv[argc - 1], maxv, cmdv, sizeof(env_complete_buf), |
| 185 | env_complete_buf, true); |
| 186 | } |
| 187 | |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 188 | /*************************************************************************************/ |
| 189 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 190 | int complete_subcmdv(struct cmd_tbl *cmdtp, int count, int argc, |
| 191 | char *const argv[], char last_char, |
Boris Brezillon | ae73c33 | 2018-12-03 22:54:19 +0100 | [diff] [blame] | 192 | int maxv, char *cmdv[]) |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 193 | { |
Simon Glass | 4ef90b7 | 2016-03-19 02:18:38 -0600 | [diff] [blame] | 194 | #ifdef CONFIG_CMDLINE |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 195 | const struct cmd_tbl *cmdend = cmdtp + count; |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 196 | const char *p; |
| 197 | int len, clen; |
| 198 | int n_found = 0; |
| 199 | const char *cmd; |
| 200 | |
| 201 | /* sanity? */ |
| 202 | if (maxv < 2) |
| 203 | return -2; |
| 204 | |
| 205 | cmdv[0] = NULL; |
| 206 | |
| 207 | if (argc == 0) { |
| 208 | /* output full list of commands */ |
Marek Vasut | 69c5e34 | 2012-10-12 10:27:04 +0000 | [diff] [blame] | 209 | for (; cmdtp != cmdend; cmdtp++) { |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 210 | if (n_found >= maxv - 2) { |
Andrew Gabbasov | a7c03b0 | 2013-12-27 10:05:14 -0600 | [diff] [blame] | 211 | cmdv[n_found++] = "..."; |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 212 | break; |
| 213 | } |
Andrew Gabbasov | a7c03b0 | 2013-12-27 10:05:14 -0600 | [diff] [blame] | 214 | cmdv[n_found++] = cmdtp->name; |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 215 | } |
| 216 | cmdv[n_found] = NULL; |
| 217 | return n_found; |
| 218 | } |
| 219 | |
| 220 | /* more than one arg or one but the start of the next */ |
Masahiro Yamada | 682195e | 2014-10-23 17:27:30 +0900 | [diff] [blame] | 221 | if (argc > 1 || last_char == '\0' || isblank(last_char)) { |
Boris Brezillon | ae73c33 | 2018-12-03 22:54:19 +0100 | [diff] [blame] | 222 | cmdtp = find_cmd_tbl(argv[0], cmdtp, count); |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 223 | if (cmdtp == NULL || cmdtp->complete == NULL) { |
| 224 | cmdv[0] = NULL; |
| 225 | return 0; |
| 226 | } |
| 227 | return (*cmdtp->complete)(argc, argv, last_char, maxv, cmdv); |
| 228 | } |
| 229 | |
| 230 | cmd = argv[0]; |
| 231 | /* |
| 232 | * Some commands allow length modifiers (like "cp.b"); |
| 233 | * compare command name only until first dot. |
| 234 | */ |
| 235 | p = strchr(cmd, '.'); |
| 236 | if (p == NULL) |
| 237 | len = strlen(cmd); |
| 238 | else |
| 239 | len = p - cmd; |
| 240 | |
| 241 | /* return the partial matches */ |
Marek Vasut | 69c5e34 | 2012-10-12 10:27:04 +0000 | [diff] [blame] | 242 | for (; cmdtp != cmdend; cmdtp++) { |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 243 | |
| 244 | clen = strlen(cmdtp->name); |
| 245 | if (clen < len) |
| 246 | continue; |
| 247 | |
| 248 | if (memcmp(cmd, cmdtp->name, len) != 0) |
| 249 | continue; |
| 250 | |
| 251 | /* too many! */ |
| 252 | if (n_found >= maxv - 2) { |
| 253 | cmdv[n_found++] = "..."; |
| 254 | break; |
| 255 | } |
| 256 | |
| 257 | cmdv[n_found++] = cmdtp->name; |
| 258 | } |
| 259 | |
| 260 | cmdv[n_found] = NULL; |
| 261 | return n_found; |
Simon Glass | 4ef90b7 | 2016-03-19 02:18:38 -0600 | [diff] [blame] | 262 | #else |
| 263 | return 0; |
| 264 | #endif |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 265 | } |
| 266 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 267 | static int complete_cmdv(int argc, char *const argv[], char last_char, |
Boris Brezillon | ae73c33 | 2018-12-03 22:54:19 +0100 | [diff] [blame] | 268 | int maxv, char *cmdv[]) |
| 269 | { |
| 270 | #ifdef CONFIG_CMDLINE |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 271 | return complete_subcmdv(ll_entry_start(struct cmd_tbl, cmd), |
| 272 | ll_entry_count(struct cmd_tbl, cmd), argc, argv, |
Boris Brezillon | ae73c33 | 2018-12-03 22:54:19 +0100 | [diff] [blame] | 273 | last_char, maxv, cmdv); |
| 274 | #else |
| 275 | return 0; |
| 276 | #endif |
| 277 | } |
| 278 | |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 279 | static int make_argv(char *s, int argvsz, char *argv[]) |
| 280 | { |
| 281 | int argc = 0; |
| 282 | |
| 283 | /* split into argv */ |
| 284 | while (argc < argvsz - 1) { |
| 285 | |
| 286 | /* skip any white space */ |
Jason Hobbs | cafa1aa | 2011-08-23 11:06:54 +0000 | [diff] [blame] | 287 | while (isblank(*s)) |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 288 | ++s; |
| 289 | |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 290 | if (*s == '\0') /* end of s, no more args */ |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 291 | break; |
| 292 | |
| 293 | argv[argc++] = s; /* begin of argument string */ |
| 294 | |
| 295 | /* find end of string */ |
Jason Hobbs | cafa1aa | 2011-08-23 11:06:54 +0000 | [diff] [blame] | 296 | while (*s && !isblank(*s)) |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 297 | ++s; |
| 298 | |
| 299 | if (*s == '\0') /* end of s, no more args */ |
| 300 | break; |
| 301 | |
| 302 | *s++ = '\0'; /* terminate current arg */ |
| 303 | } |
| 304 | argv[argc] = NULL; |
| 305 | |
| 306 | return argc; |
| 307 | } |
| 308 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 309 | static void print_argv(const char *banner, const char *leader, const char *sep, |
| 310 | int linemax, char *const argv[]) |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 311 | { |
| 312 | int ll = leader != NULL ? strlen(leader) : 0; |
| 313 | int sl = sep != NULL ? strlen(sep) : 0; |
| 314 | int len, i; |
| 315 | |
| 316 | if (banner) { |
| 317 | puts("\n"); |
| 318 | puts(banner); |
| 319 | } |
| 320 | |
| 321 | i = linemax; /* force leader and newline */ |
| 322 | while (*argv != NULL) { |
| 323 | len = strlen(*argv) + sl; |
| 324 | if (i + len >= linemax) { |
| 325 | puts("\n"); |
| 326 | if (leader) |
| 327 | puts(leader); |
| 328 | i = ll - sl; |
| 329 | } else if (sep) |
| 330 | puts(sep); |
| 331 | puts(*argv++); |
| 332 | i += len; |
| 333 | } |
| 334 | printf("\n"); |
| 335 | } |
| 336 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 337 | static int find_common_prefix(char *const argv[]) |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 338 | { |
| 339 | int i, len; |
| 340 | char *anchor, *s, *t; |
| 341 | |
| 342 | if (*argv == NULL) |
| 343 | return 0; |
| 344 | |
| 345 | /* begin with max */ |
| 346 | anchor = *argv++; |
| 347 | len = strlen(anchor); |
| 348 | while ((t = *argv++) != NULL) { |
| 349 | s = anchor; |
| 350 | for (i = 0; i < len; i++, t++, s++) { |
| 351 | if (*t != *s) |
| 352 | break; |
| 353 | } |
| 354 | len = s - anchor; |
| 355 | } |
| 356 | return len; |
| 357 | } |
| 358 | |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 359 | int cmd_auto_complete(const char *const prompt, char *buf, int *np, int *colp) |
| 360 | { |
Marek Vasut | 0639049 | 2023-12-02 21:52:31 +0100 | [diff] [blame] | 361 | char tmp_buf[CONFIG_SYS_CBSIZE + 1]; /* copy of console I/O buffer */ |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 362 | int n = *np, col = *colp; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 363 | char *argv[CONFIG_SYS_MAXARGS + 1]; /* NULL terminated */ |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 364 | char *cmdv[20]; |
| 365 | char *s, *t; |
| 366 | const char *sep; |
| 367 | int i, j, k, len, seplen, argc; |
| 368 | int cnt; |
| 369 | char last_char; |
Marek Vasut | fe6cdf3 | 2019-06-27 00:17:27 +0200 | [diff] [blame] | 370 | #ifdef CONFIG_CMDLINE_PS_SUPPORT |
| 371 | const char *ps_prompt = env_get("PS1"); |
| 372 | #else |
| 373 | const char *ps_prompt = CONFIG_SYS_PROMPT; |
| 374 | #endif |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 375 | |
Marek Vasut | fe6cdf3 | 2019-06-27 00:17:27 +0200 | [diff] [blame] | 376 | if (strcmp(prompt, ps_prompt) != 0) |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 377 | return 0; /* not in normal console */ |
| 378 | |
| 379 | cnt = strlen(buf); |
| 380 | if (cnt >= 1) |
| 381 | last_char = buf[cnt - 1]; |
| 382 | else |
| 383 | last_char = '\0'; |
| 384 | |
| 385 | /* copy to secondary buffer which will be affected */ |
| 386 | strcpy(tmp_buf, buf); |
| 387 | |
| 388 | /* separate into argv */ |
| 389 | argc = make_argv(tmp_buf, sizeof(argv)/sizeof(argv[0]), argv); |
| 390 | |
Boris Brezillon | 619fc68 | 2018-12-05 09:26:50 +0100 | [diff] [blame] | 391 | /* first try a $ completion */ |
| 392 | i = dollar_complete(argc, argv, last_char, |
| 393 | sizeof(cmdv) / sizeof(cmdv[0]), cmdv); |
| 394 | if (!i) { |
| 395 | /* do the completion and return the possible completions */ |
| 396 | i = complete_cmdv(argc, argv, last_char, |
| 397 | sizeof(cmdv) / sizeof(cmdv[0]), cmdv); |
| 398 | } |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 399 | |
| 400 | /* no match; bell and out */ |
| 401 | if (i == 0) { |
| 402 | if (argc > 1) /* allow tab for non command */ |
| 403 | return 0; |
| 404 | putc('\a'); |
| 405 | return 1; |
| 406 | } |
| 407 | |
| 408 | s = NULL; |
| 409 | len = 0; |
| 410 | sep = NULL; |
| 411 | seplen = 0; |
| 412 | if (i == 1) { /* one match; perfect */ |
Boris Brezillon | 8506ec6 | 2018-12-03 22:54:18 +0100 | [diff] [blame] | 413 | if (last_char != '\0' && !isblank(last_char)) |
| 414 | k = strlen(argv[argc - 1]); |
| 415 | else |
| 416 | k = 0; |
| 417 | |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 418 | s = cmdv[0] + k; |
| 419 | len = strlen(s); |
| 420 | sep = " "; |
| 421 | seplen = 1; |
Masahiro Yamada | 682195e | 2014-10-23 17:27:30 +0900 | [diff] [blame] | 422 | } else if (i > 1 && (j = find_common_prefix(cmdv)) != 0) { /* more */ |
Boris Brezillon | 8506ec6 | 2018-12-03 22:54:18 +0100 | [diff] [blame] | 423 | if (last_char != '\0' && !isblank(last_char)) |
| 424 | k = strlen(argv[argc - 1]); |
| 425 | else |
| 426 | k = 0; |
| 427 | |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 428 | j -= k; |
| 429 | if (j > 0) { |
| 430 | s = cmdv[0] + k; |
| 431 | len = j; |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | if (s != NULL) { |
| 436 | k = len + seplen; |
| 437 | /* make sure it fits */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 438 | if (n + k >= CONFIG_SYS_CBSIZE - 2) { |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 439 | putc('\a'); |
| 440 | return 1; |
| 441 | } |
| 442 | |
| 443 | t = buf + cnt; |
| 444 | for (i = 0; i < len; i++) |
| 445 | *t++ = *s++; |
| 446 | if (sep != NULL) |
| 447 | for (i = 0; i < seplen; i++) |
| 448 | *t++ = sep[i]; |
| 449 | *t = '\0'; |
| 450 | n += k; |
| 451 | col += k; |
| 452 | puts(t - k); |
| 453 | if (sep == NULL) |
| 454 | putc('\a'); |
| 455 | *np = n; |
| 456 | *colp = col; |
| 457 | } else { |
| 458 | print_argv(NULL, " ", " ", 78, cmdv); |
| 459 | |
| 460 | puts(prompt); |
| 461 | puts(buf); |
| 462 | } |
| 463 | return 1; |
| 464 | } |
| 465 | |
| 466 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 82290f2 | 2008-09-10 22:48:05 +0200 | [diff] [blame] | 467 | |
| 468 | #ifdef CMD_DATA_SIZE |
Rasmus Villemoes | 209329d | 2024-01-03 11:47:05 +0100 | [diff] [blame] | 469 | int cmd_get_data_size(const char *arg, int default_size) |
Jean-Christophe PLAGNIOL-VILLARD | 82290f2 | 2008-09-10 22:48:05 +0200 | [diff] [blame] | 470 | { |
| 471 | /* Check for a size specification .b, .w or .l. |
| 472 | */ |
| 473 | int len = strlen(arg); |
Rasmus Villemoes | 9d8e671 | 2024-01-03 11:47:06 +0100 | [diff] [blame] | 474 | if (len >= 2 && arg[len-2] == '.') { |
Masahiro Yamada | 682195e | 2014-10-23 17:27:30 +0900 | [diff] [blame] | 475 | switch (arg[len-1]) { |
Jean-Christophe PLAGNIOL-VILLARD | 82290f2 | 2008-09-10 22:48:05 +0200 | [diff] [blame] | 476 | case 'b': |
| 477 | return 1; |
| 478 | case 'w': |
| 479 | return 2; |
| 480 | case 'l': |
| 481 | return 4; |
| 482 | case 's': |
Simon Glass | 3d3c397 | 2020-11-01 14:15:36 -0700 | [diff] [blame] | 483 | return CMD_DATA_SIZE_STR; |
Simon Glass | 19f6733 | 2020-06-02 19:26:48 -0600 | [diff] [blame] | 484 | case 'q': |
| 485 | if (MEM_SUPPORT_64BIT_DATA) |
| 486 | return 8; |
| 487 | /* no break */ |
Jean-Christophe PLAGNIOL-VILLARD | 82290f2 | 2008-09-10 22:48:05 +0200 | [diff] [blame] | 488 | default: |
Simon Glass | 3d3c397 | 2020-11-01 14:15:36 -0700 | [diff] [blame] | 489 | return CMD_DATA_SIZE_ERR; |
Jean-Christophe PLAGNIOL-VILLARD | 82290f2 | 2008-09-10 22:48:05 +0200 | [diff] [blame] | 490 | } |
| 491 | } |
| 492 | return default_size; |
| 493 | } |
| 494 | #endif |
Heiko Schocher | 092cf16 | 2010-09-17 13:10:33 +0200 | [diff] [blame] | 495 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 496 | void fixup_cmdtable(struct cmd_tbl *cmdtp, int size) |
Heiko Schocher | 092cf16 | 2010-09-17 13:10:33 +0200 | [diff] [blame] | 497 | { |
| 498 | int i; |
| 499 | |
| 500 | if (gd->reloc_off == 0) |
| 501 | return; |
| 502 | |
| 503 | for (i = 0; i < size; i++) { |
| 504 | ulong addr; |
| 505 | |
Michal Simek | 8d76d2f | 2019-10-21 12:54:20 +0200 | [diff] [blame] | 506 | addr = (ulong)(cmdtp->cmd_rep) + gd->reloc_off; |
| 507 | cmdtp->cmd_rep = |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 508 | (int (*)(struct cmd_tbl *, int, int, |
Michal Simek | 8d76d2f | 2019-10-21 12:54:20 +0200 | [diff] [blame] | 509 | char * const [], int *))addr; |
| 510 | |
Masahiro Yamada | 682195e | 2014-10-23 17:27:30 +0900 | [diff] [blame] | 511 | addr = (ulong)(cmdtp->cmd) + gd->reloc_off; |
Kun-Hua Huang | 89299e2 | 2015-08-24 14:52:35 +0800 | [diff] [blame] | 512 | #ifdef DEBUG_COMMANDS |
Heiko Schocher | 092cf16 | 2010-09-17 13:10:33 +0200 | [diff] [blame] | 513 | printf("Command \"%s\": 0x%08lx => 0x%08lx\n", |
Masahiro Yamada | 682195e | 2014-10-23 17:27:30 +0900 | [diff] [blame] | 514 | cmdtp->name, (ulong)(cmdtp->cmd), addr); |
Heiko Schocher | 092cf16 | 2010-09-17 13:10:33 +0200 | [diff] [blame] | 515 | #endif |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 516 | cmdtp->cmd = (int (*)(struct cmd_tbl *, int, int, |
| 517 | char *const []))addr; |
Heiko Schocher | 092cf16 | 2010-09-17 13:10:33 +0200 | [diff] [blame] | 518 | addr = (ulong)(cmdtp->name) + gd->reloc_off; |
| 519 | cmdtp->name = (char *)addr; |
| 520 | if (cmdtp->usage) { |
| 521 | addr = (ulong)(cmdtp->usage) + gd->reloc_off; |
| 522 | cmdtp->usage = (char *)addr; |
| 523 | } |
| 524 | #ifdef CONFIG_SYS_LONGHELP |
| 525 | if (cmdtp->help) { |
| 526 | addr = (ulong)(cmdtp->help) + gd->reloc_off; |
| 527 | cmdtp->help = (char *)addr; |
| 528 | } |
| 529 | #endif |
Daniel Schwierzeck | e516622 | 2011-10-13 06:07:39 +0000 | [diff] [blame] | 530 | #ifdef CONFIG_AUTO_COMPLETE |
| 531 | if (cmdtp->complete) { |
| 532 | addr = (ulong)(cmdtp->complete) + gd->reloc_off; |
Daniel Schwierzeck | 76deb6c | 2011-10-18 11:12:22 +0000 | [diff] [blame] | 533 | cmdtp->complete = |
| 534 | (int (*)(int, char * const [], char, int, char * []))addr; |
Daniel Schwierzeck | e516622 | 2011-10-13 06:07:39 +0000 | [diff] [blame] | 535 | } |
| 536 | #endif |
Heiko Schocher | 092cf16 | 2010-09-17 13:10:33 +0200 | [diff] [blame] | 537 | cmdtp++; |
| 538 | } |
| 539 | } |
Simon Glass | 2176d60 | 2012-02-14 19:59:23 +0000 | [diff] [blame] | 540 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 541 | int cmd_always_repeatable(struct cmd_tbl *cmdtp, int flag, int argc, |
| 542 | char *const argv[], int *repeatable) |
Boris Brezillon | c71dfd1 | 2018-12-03 22:54:20 +0100 | [diff] [blame] | 543 | { |
| 544 | *repeatable = 1; |
| 545 | |
| 546 | return cmdtp->cmd(cmdtp, flag, argc, argv); |
| 547 | } |
| 548 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 549 | int cmd_never_repeatable(struct cmd_tbl *cmdtp, int flag, int argc, |
| 550 | char *const argv[], int *repeatable) |
Boris Brezillon | c71dfd1 | 2018-12-03 22:54:20 +0100 | [diff] [blame] | 551 | { |
| 552 | *repeatable = 0; |
| 553 | |
| 554 | return cmdtp->cmd(cmdtp, flag, argc, argv); |
| 555 | } |
| 556 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 557 | int cmd_discard_repeatable(struct cmd_tbl *cmdtp, int flag, int argc, |
| 558 | char *const argv[]) |
Boris Brezillon | c71dfd1 | 2018-12-03 22:54:20 +0100 | [diff] [blame] | 559 | { |
| 560 | int repeatable; |
| 561 | |
| 562 | return cmdtp->cmd_rep(cmdtp, flag, argc, argv, &repeatable); |
| 563 | } |
| 564 | |
Simon Glass | 2176d60 | 2012-02-14 19:59:23 +0000 | [diff] [blame] | 565 | /** |
| 566 | * Call a command function. This should be the only route in U-Boot to call |
| 567 | * a command, so that we can track whether we are waiting for input or |
| 568 | * executing a command. |
| 569 | * |
| 570 | * @param cmdtp Pointer to the command to execute |
| 571 | * @param flag Some flags normally 0 (see CMD_FLAG_.. above) |
| 572 | * @param argc Number of arguments (arg 0 must be the command text) |
| 573 | * @param argv Arguments |
Boris Brezillon | c71dfd1 | 2018-12-03 22:54:20 +0100 | [diff] [blame] | 574 | * @param repeatable Can the command be repeated |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 575 | * Return: 0 if command succeeded, else non-zero (CMD_RET_...) |
Simon Glass | 2176d60 | 2012-02-14 19:59:23 +0000 | [diff] [blame] | 576 | */ |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 577 | static int cmd_call(struct cmd_tbl *cmdtp, int flag, int argc, |
| 578 | char *const argv[], int *repeatable) |
Simon Glass | 2176d60 | 2012-02-14 19:59:23 +0000 | [diff] [blame] | 579 | { |
| 580 | int result; |
| 581 | |
Boris Brezillon | c71dfd1 | 2018-12-03 22:54:20 +0100 | [diff] [blame] | 582 | result = cmdtp->cmd_rep(cmdtp, flag, argc, argv, repeatable); |
Simon Glass | 2176d60 | 2012-02-14 19:59:23 +0000 | [diff] [blame] | 583 | if (result) |
Peng Fan | d6c09ba | 2015-07-28 22:45:37 +0800 | [diff] [blame] | 584 | debug("Command failed, result=%d\n", result); |
Simon Glass | 2176d60 | 2012-02-14 19:59:23 +0000 | [diff] [blame] | 585 | return result; |
| 586 | } |
Simon Glass | 1727b94 | 2012-02-14 19:59:25 +0000 | [diff] [blame] | 587 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 588 | enum command_ret_t cmd_process(int flag, int argc, char *const argv[], |
Richard Genoud | 94ff067 | 2012-12-03 06:28:28 +0000 | [diff] [blame] | 589 | int *repeatable, ulong *ticks) |
Simon Glass | 1727b94 | 2012-02-14 19:59:25 +0000 | [diff] [blame] | 590 | { |
| 591 | enum command_ret_t rc = CMD_RET_SUCCESS; |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 592 | struct cmd_tbl *cmdtp; |
Simon Glass | 1727b94 | 2012-02-14 19:59:25 +0000 | [diff] [blame] | 593 | |
Christoph Muellner | 388b145 | 2019-04-05 13:03:46 +0200 | [diff] [blame] | 594 | #if defined(CONFIG_SYS_XTRACE) |
| 595 | char *xtrace; |
| 596 | |
| 597 | xtrace = env_get("xtrace"); |
| 598 | if (xtrace) { |
| 599 | puts("+"); |
| 600 | for (int i = 0; i < argc; i++) { |
| 601 | puts(" "); |
| 602 | puts(argv[i]); |
| 603 | } |
| 604 | puts("\n"); |
| 605 | } |
| 606 | #endif |
| 607 | |
Simon Glass | 1727b94 | 2012-02-14 19:59:25 +0000 | [diff] [blame] | 608 | /* Look up command in command table */ |
| 609 | cmdtp = find_cmd(argv[0]); |
| 610 | if (cmdtp == NULL) { |
| 611 | printf("Unknown command '%s' - try 'help'\n", argv[0]); |
| 612 | return 1; |
| 613 | } |
| 614 | |
| 615 | /* found - check max args */ |
| 616 | if (argc > cmdtp->maxargs) |
| 617 | rc = CMD_RET_USAGE; |
| 618 | |
| 619 | #if defined(CONFIG_CMD_BOOTD) |
| 620 | /* avoid "bootd" recursion */ |
| 621 | else if (cmdtp->cmd == do_bootd) { |
| 622 | if (flag & CMD_FLAG_BOOTD) { |
| 623 | puts("'bootd' recursion detected\n"); |
| 624 | rc = CMD_RET_FAILURE; |
| 625 | } else { |
| 626 | flag |= CMD_FLAG_BOOTD; |
| 627 | } |
| 628 | } |
| 629 | #endif |
| 630 | |
| 631 | /* If OK so far, then do the command */ |
| 632 | if (!rc) { |
Boris Brezillon | c71dfd1 | 2018-12-03 22:54:20 +0100 | [diff] [blame] | 633 | int newrep; |
| 634 | |
Richard Genoud | 94ff067 | 2012-12-03 06:28:28 +0000 | [diff] [blame] | 635 | if (ticks) |
| 636 | *ticks = get_timer(0); |
Boris Brezillon | c71dfd1 | 2018-12-03 22:54:20 +0100 | [diff] [blame] | 637 | rc = cmd_call(cmdtp, flag, argc, argv, &newrep); |
Richard Genoud | 94ff067 | 2012-12-03 06:28:28 +0000 | [diff] [blame] | 638 | if (ticks) |
| 639 | *ticks = get_timer(*ticks); |
Boris Brezillon | c71dfd1 | 2018-12-03 22:54:20 +0100 | [diff] [blame] | 640 | *repeatable &= newrep; |
Simon Glass | 1727b94 | 2012-02-14 19:59:25 +0000 | [diff] [blame] | 641 | } |
| 642 | if (rc == CMD_RET_USAGE) |
| 643 | rc = cmd_usage(cmdtp); |
| 644 | return rc; |
| 645 | } |
Simon Glass | d738553 | 2014-02-26 15:59:15 -0700 | [diff] [blame] | 646 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 647 | int cmd_process_error(struct cmd_tbl *cmdtp, int err) |
Simon Glass | d738553 | 2014-02-26 15:59:15 -0700 | [diff] [blame] | 648 | { |
Michal Simek | 2e1b90b | 2018-06-21 14:49:26 +0200 | [diff] [blame] | 649 | if (err == CMD_RET_USAGE) |
| 650 | return CMD_RET_USAGE; |
| 651 | |
Simon Glass | d738553 | 2014-02-26 15:59:15 -0700 | [diff] [blame] | 652 | if (err) { |
| 653 | printf("Command '%s' failed: Error %d\n", cmdtp->name, err); |
Michal Simek | 44bdb57 | 2018-06-04 13:29:49 +0200 | [diff] [blame] | 654 | return CMD_RET_FAILURE; |
Simon Glass | d738553 | 2014-02-26 15:59:15 -0700 | [diff] [blame] | 655 | } |
| 656 | |
Michal Simek | 44bdb57 | 2018-06-04 13:29:49 +0200 | [diff] [blame] | 657 | return CMD_RET_SUCCESS; |
Simon Glass | d738553 | 2014-02-26 15:59:15 -0700 | [diff] [blame] | 658 | } |
Simon Glass | daee3ba | 2023-01-06 08:52:28 -0600 | [diff] [blame] | 659 | |
| 660 | int cmd_source_script(ulong addr, const char *fit_uname, const char *confname) |
| 661 | { |
| 662 | char *data; |
| 663 | void *buf; |
| 664 | uint len; |
| 665 | int ret; |
| 666 | |
| 667 | buf = map_sysmem(addr, 0); |
| 668 | ret = image_locate_script(buf, 0, fit_uname, confname, &data, &len); |
| 669 | unmap_sysmem(buf); |
| 670 | if (ret) |
| 671 | return CMD_RET_FAILURE; |
| 672 | |
| 673 | debug("** Script length: %d\n", len); |
| 674 | return run_command_list(data, len, 0); |
| 675 | } |