nvedit.c 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2000-2013
  4. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. *
  6. * (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  7. * Andreas Heppel <aheppel@sysgo.de>
  8. *
  9. * Copyright 2011 Freescale Semiconductor, Inc.
  10. */
  11. /*
  12. * Support for persistent environment data
  13. *
  14. * The "environment" is stored on external storage as a list of '\0'
  15. * terminated "name=value" strings. The end of the list is marked by
  16. * a double '\0'. The environment is preceded by a 32 bit CRC over
  17. * the data part and, in case of redundant environment, a byte of
  18. * flags.
  19. *
  20. * This linearized representation will also be used before
  21. * relocation, i. e. as long as we don't have a full C runtime
  22. * environment. After that, we use a hash table.
  23. */
  24. #include <common.h>
  25. #include <cli.h>
  26. #include <command.h>
  27. #include <console.h>
  28. #include <environment.h>
  29. #include <search.h>
  30. #include <errno.h>
  31. #include <malloc.h>
  32. #include <mapmem.h>
  33. #include <watchdog.h>
  34. #include <linux/stddef.h>
  35. #include <asm/byteorder.h>
  36. #include <asm/io.h>
  37. DECLARE_GLOBAL_DATA_PTR;
  38. #if !defined(CONFIG_ENV_IS_IN_EEPROM) && \
  39. !defined(CONFIG_ENV_IS_IN_FLASH) && \
  40. !defined(CONFIG_ENV_IS_IN_MMC) && \
  41. !defined(CONFIG_ENV_IS_IN_FAT) && \
  42. !defined(CONFIG_ENV_IS_IN_EXT4) && \
  43. !defined(CONFIG_ENV_IS_IN_NAND) && \
  44. !defined(CONFIG_ENV_IS_IN_NVRAM) && \
  45. !defined(CONFIG_ENV_IS_IN_ONENAND) && \
  46. !defined(CONFIG_ENV_IS_IN_SATA) && \
  47. !defined(CONFIG_ENV_IS_IN_SPI_FLASH) && \
  48. !defined(CONFIG_ENV_IS_IN_REMOTE) && \
  49. !defined(CONFIG_ENV_IS_IN_UBI) && \
  50. !defined(CONFIG_ENV_IS_NOWHERE)
  51. # error Define one of CONFIG_ENV_IS_IN_{EEPROM|FLASH|MMC|FAT|EXT4|\
  52. NAND|NVRAM|ONENAND|SATA|SPI_FLASH|REMOTE|UBI} or CONFIG_ENV_IS_NOWHERE
  53. #endif
  54. /*
  55. * Maximum expected input data size for import command
  56. */
  57. #define MAX_ENV_SIZE (1 << 20) /* 1 MiB */
  58. /*
  59. * This variable is incremented on each do_env_set(), so it can
  60. * be used via get_env_id() as an indication, if the environment
  61. * has changed or not. So it is possible to reread an environment
  62. * variable only if the environment was changed ... done so for
  63. * example in NetInitLoop()
  64. */
  65. static int env_id = 1;
  66. int get_env_id(void)
  67. {
  68. return env_id;
  69. }
  70. #ifndef CONFIG_SPL_BUILD
  71. /*
  72. * Command interface: print one or all environment variables
  73. *
  74. * Returns 0 in case of error, or length of printed string
  75. */
  76. static int env_print(char *name, int flag)
  77. {
  78. char *res = NULL;
  79. ssize_t len;
  80. if (name) { /* print a single name */
  81. ENTRY e, *ep;
  82. e.key = name;
  83. e.data = NULL;
  84. hsearch_r(e, FIND, &ep, &env_htab, flag);
  85. if (ep == NULL)
  86. return 0;
  87. len = printf("%s=%s\n", ep->key, ep->data);
  88. return len;
  89. }
  90. /* print whole list */
  91. len = hexport_r(&env_htab, '\n', flag, &res, 0, 0, NULL);
  92. if (len > 0) {
  93. puts(res);
  94. free(res);
  95. return len;
  96. }
  97. /* should never happen */
  98. printf("## Error: cannot export environment\n");
  99. return 0;
  100. }
  101. static int do_env_print(cmd_tbl_t *cmdtp, int flag, int argc,
  102. char * const argv[])
  103. {
  104. int i;
  105. int rcode = 0;
  106. int env_flag = H_HIDE_DOT;
  107. if (argc > 1 && argv[1][0] == '-' && argv[1][1] == 'a') {
  108. argc--;
  109. argv++;
  110. env_flag &= ~H_HIDE_DOT;
  111. }
  112. if (argc == 1) {
  113. /* print all env vars */
  114. rcode = env_print(NULL, env_flag);
  115. if (!rcode)
  116. return 1;
  117. printf("\nEnvironment size: %d/%ld bytes\n",
  118. rcode, (ulong)ENV_SIZE);
  119. return 0;
  120. }
  121. /* print selected env vars */
  122. env_flag &= ~H_HIDE_DOT;
  123. for (i = 1; i < argc; ++i) {
  124. int rc = env_print(argv[i], env_flag);
  125. if (!rc) {
  126. printf("## Error: \"%s\" not defined\n", argv[i]);
  127. ++rcode;
  128. }
  129. }
  130. return rcode;
  131. }
  132. #ifdef CONFIG_CMD_GREPENV
  133. static int do_env_grep(cmd_tbl_t *cmdtp, int flag,
  134. int argc, char * const argv[])
  135. {
  136. char *res = NULL;
  137. int len, grep_how, grep_what;
  138. if (argc < 2)
  139. return CMD_RET_USAGE;
  140. grep_how = H_MATCH_SUBSTR; /* default: substring search */
  141. grep_what = H_MATCH_BOTH; /* default: grep names and values */
  142. while (--argc > 0 && **++argv == '-') {
  143. char *arg = *argv;
  144. while (*++arg) {
  145. switch (*arg) {
  146. #ifdef CONFIG_REGEX
  147. case 'e': /* use regex matching */
  148. grep_how = H_MATCH_REGEX;
  149. break;
  150. #endif
  151. case 'n': /* grep for name */
  152. grep_what = H_MATCH_KEY;
  153. break;
  154. case 'v': /* grep for value */
  155. grep_what = H_MATCH_DATA;
  156. break;
  157. case 'b': /* grep for both */
  158. grep_what = H_MATCH_BOTH;
  159. break;
  160. case '-':
  161. goto DONE;
  162. default:
  163. return CMD_RET_USAGE;
  164. }
  165. }
  166. }
  167. DONE:
  168. len = hexport_r(&env_htab, '\n',
  169. flag | grep_what | grep_how,
  170. &res, 0, argc, argv);
  171. if (len > 0) {
  172. puts(res);
  173. free(res);
  174. }
  175. if (len < 2)
  176. return 1;
  177. return 0;
  178. }
  179. #endif
  180. #endif /* CONFIG_SPL_BUILD */
  181. /*
  182. * Set a new environment variable,
  183. * or replace or delete an existing one.
  184. */
  185. static int _do_env_set(int flag, int argc, char * const argv[], int env_flag)
  186. {
  187. int i, len;
  188. char *name, *value, *s;
  189. ENTRY e, *ep;
  190. debug("Initial value for argc=%d\n", argc);
  191. while (argc > 1 && **(argv + 1) == '-') {
  192. char *arg = *++argv;
  193. --argc;
  194. while (*++arg) {
  195. switch (*arg) {
  196. case 'f': /* force */
  197. env_flag |= H_FORCE;
  198. break;
  199. default:
  200. return CMD_RET_USAGE;
  201. }
  202. }
  203. }
  204. debug("Final value for argc=%d\n", argc);
  205. name = argv[1];
  206. if (strchr(name, '=')) {
  207. printf("## Error: illegal character '='"
  208. "in variable name \"%s\"\n", name);
  209. return 1;
  210. }
  211. env_id++;
  212. /* Delete only ? */
  213. if (argc < 3 || argv[2] == NULL) {
  214. int rc = hdelete_r(name, &env_htab, env_flag);
  215. return !rc;
  216. }
  217. /*
  218. * Insert / replace new value
  219. */
  220. for (i = 2, len = 0; i < argc; ++i)
  221. len += strlen(argv[i]) + 1;
  222. value = malloc(len);
  223. if (value == NULL) {
  224. printf("## Can't malloc %d bytes\n", len);
  225. return 1;
  226. }
  227. for (i = 2, s = value; i < argc; ++i) {
  228. char *v = argv[i];
  229. while ((*s++ = *v++) != '\0')
  230. ;
  231. *(s - 1) = ' ';
  232. }
  233. if (s != value)
  234. *--s = '\0';
  235. e.key = name;
  236. e.data = value;
  237. hsearch_r(e, ENTER, &ep, &env_htab, env_flag);
  238. free(value);
  239. if (!ep) {
  240. printf("## Error inserting \"%s\" variable, errno=%d\n",
  241. name, errno);
  242. return 1;
  243. }
  244. return 0;
  245. }
  246. int env_set(const char *varname, const char *varvalue)
  247. {
  248. const char * const argv[4] = { "setenv", varname, varvalue, NULL };
  249. /* before import into hashtable */
  250. if (!(gd->flags & GD_FLG_ENV_READY))
  251. return 1;
  252. if (varvalue == NULL || varvalue[0] == '\0')
  253. return _do_env_set(0, 2, (char * const *)argv, H_PROGRAMMATIC);
  254. else
  255. return _do_env_set(0, 3, (char * const *)argv, H_PROGRAMMATIC);
  256. }
  257. /**
  258. * Set an environment variable to an integer value
  259. *
  260. * @param varname Environment variable to set
  261. * @param value Value to set it to
  262. * @return 0 if ok, 1 on error
  263. */
  264. int env_set_ulong(const char *varname, ulong value)
  265. {
  266. /* TODO: this should be unsigned */
  267. char *str = simple_itoa(value);
  268. return env_set(varname, str);
  269. }
  270. /**
  271. * Set an environment variable to an value in hex
  272. *
  273. * @param varname Environment variable to set
  274. * @param value Value to set it to
  275. * @return 0 if ok, 1 on error
  276. */
  277. int env_set_hex(const char *varname, ulong value)
  278. {
  279. char str[17];
  280. sprintf(str, "%lx", value);
  281. return env_set(varname, str);
  282. }
  283. ulong env_get_hex(const char *varname, ulong default_val)
  284. {
  285. const char *s;
  286. ulong value;
  287. char *endp;
  288. s = env_get(varname);
  289. if (s)
  290. value = simple_strtoul(s, &endp, 16);
  291. if (!s || endp == s)
  292. return default_val;
  293. return value;
  294. }
  295. void eth_parse_enetaddr(const char *addr, uint8_t *enetaddr)
  296. {
  297. char *end;
  298. int i;
  299. for (i = 0; i < 6; ++i) {
  300. enetaddr[i] = addr ? simple_strtoul(addr, &end, 16) : 0;
  301. if (addr)
  302. addr = (*end) ? end + 1 : end;
  303. }
  304. }
  305. int eth_env_get_enetaddr(const char *name, uint8_t *enetaddr)
  306. {
  307. eth_parse_enetaddr(env_get(name), enetaddr);
  308. return is_valid_ethaddr(enetaddr);
  309. }
  310. int eth_env_set_enetaddr(const char *name, const uint8_t *enetaddr)
  311. {
  312. char buf[ARP_HLEN_ASCII + 1];
  313. if (eth_env_get_enetaddr(name, (uint8_t *)buf))
  314. return -EEXIST;
  315. sprintf(buf, "%pM", enetaddr);
  316. return env_set(name, buf);
  317. }
  318. #ifndef CONFIG_SPL_BUILD
  319. static int do_env_set(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  320. {
  321. if (argc < 2)
  322. return CMD_RET_USAGE;
  323. return _do_env_set(flag, argc, argv, H_INTERACTIVE);
  324. }
  325. /*
  326. * Prompt for environment variable
  327. */
  328. #if defined(CONFIG_CMD_ASKENV)
  329. int do_env_ask(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  330. {
  331. char message[CONFIG_SYS_CBSIZE];
  332. int i, len, pos, size;
  333. char *local_args[4];
  334. char *endptr;
  335. local_args[0] = argv[0];
  336. local_args[1] = argv[1];
  337. local_args[2] = NULL;
  338. local_args[3] = NULL;
  339. /*
  340. * Check the syntax:
  341. *
  342. * env_ask envname [message1 ...] [size]
  343. */
  344. if (argc == 1)
  345. return CMD_RET_USAGE;
  346. /*
  347. * We test the last argument if it can be converted
  348. * into a decimal number. If yes, we assume it's
  349. * the size. Otherwise we echo it as part of the
  350. * message.
  351. */
  352. i = simple_strtoul(argv[argc - 1], &endptr, 10);
  353. if (*endptr != '\0') { /* no size */
  354. size = CONFIG_SYS_CBSIZE - 1;
  355. } else { /* size given */
  356. size = i;
  357. --argc;
  358. }
  359. if (argc <= 2) {
  360. sprintf(message, "Please enter '%s': ", argv[1]);
  361. } else {
  362. /* env_ask envname message1 ... messagen [size] */
  363. for (i = 2, pos = 0; i < argc && pos+1 < sizeof(message); i++) {
  364. if (pos)
  365. message[pos++] = ' ';
  366. strncpy(message + pos, argv[i], sizeof(message) - pos);
  367. pos += strlen(argv[i]);
  368. }
  369. if (pos < sizeof(message) - 1) {
  370. message[pos++] = ' ';
  371. message[pos] = '\0';
  372. } else
  373. message[CONFIG_SYS_CBSIZE - 1] = '\0';
  374. }
  375. if (size >= CONFIG_SYS_CBSIZE)
  376. size = CONFIG_SYS_CBSIZE - 1;
  377. if (size <= 0)
  378. return 1;
  379. /* prompt for input */
  380. len = cli_readline(message);
  381. if (size < len)
  382. console_buffer[size] = '\0';
  383. len = 2;
  384. if (console_buffer[0] != '\0') {
  385. local_args[2] = console_buffer;
  386. len = 3;
  387. }
  388. /* Continue calling setenv code */
  389. return _do_env_set(flag, len, local_args, H_INTERACTIVE);
  390. }
  391. #endif
  392. #if defined(CONFIG_CMD_ENV_CALLBACK)
  393. static int print_static_binding(const char *var_name, const char *callback_name,
  394. void *priv)
  395. {
  396. printf("\t%-20s %-20s\n", var_name, callback_name);
  397. return 0;
  398. }
  399. static int print_active_callback(ENTRY *entry)
  400. {
  401. struct env_clbk_tbl *clbkp;
  402. int i;
  403. int num_callbacks;
  404. if (entry->callback == NULL)
  405. return 0;
  406. /* look up the callback in the linker-list */
  407. num_callbacks = ll_entry_count(struct env_clbk_tbl, env_clbk);
  408. for (i = 0, clbkp = ll_entry_start(struct env_clbk_tbl, env_clbk);
  409. i < num_callbacks;
  410. i++, clbkp++) {
  411. #if defined(CONFIG_NEEDS_MANUAL_RELOC)
  412. if (entry->callback == clbkp->callback + gd->reloc_off)
  413. #else
  414. if (entry->callback == clbkp->callback)
  415. #endif
  416. break;
  417. }
  418. if (i == num_callbacks)
  419. /* this should probably never happen, but just in case... */
  420. printf("\t%-20s %p\n", entry->key, entry->callback);
  421. else
  422. printf("\t%-20s %-20s\n", entry->key, clbkp->name);
  423. return 0;
  424. }
  425. /*
  426. * Print the callbacks available and what they are bound to
  427. */
  428. int do_env_callback(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  429. {
  430. struct env_clbk_tbl *clbkp;
  431. int i;
  432. int num_callbacks;
  433. /* Print the available callbacks */
  434. puts("Available callbacks:\n");
  435. puts("\tCallback Name\n");
  436. puts("\t-------------\n");
  437. num_callbacks = ll_entry_count(struct env_clbk_tbl, env_clbk);
  438. for (i = 0, clbkp = ll_entry_start(struct env_clbk_tbl, env_clbk);
  439. i < num_callbacks;
  440. i++, clbkp++)
  441. printf("\t%s\n", clbkp->name);
  442. puts("\n");
  443. /* Print the static bindings that may exist */
  444. puts("Static callback bindings:\n");
  445. printf("\t%-20s %-20s\n", "Variable Name", "Callback Name");
  446. printf("\t%-20s %-20s\n", "-------------", "-------------");
  447. env_attr_walk(ENV_CALLBACK_LIST_STATIC, print_static_binding, NULL);
  448. puts("\n");
  449. /* walk through each variable and print the callback if it has one */
  450. puts("Active callback bindings:\n");
  451. printf("\t%-20s %-20s\n", "Variable Name", "Callback Name");
  452. printf("\t%-20s %-20s\n", "-------------", "-------------");
  453. hwalk_r(&env_htab, print_active_callback);
  454. return 0;
  455. }
  456. #endif
  457. #if defined(CONFIG_CMD_ENV_FLAGS)
  458. static int print_static_flags(const char *var_name, const char *flags,
  459. void *priv)
  460. {
  461. enum env_flags_vartype type = env_flags_parse_vartype(flags);
  462. enum env_flags_varaccess access = env_flags_parse_varaccess(flags);
  463. printf("\t%-20s %-20s %-20s\n", var_name,
  464. env_flags_get_vartype_name(type),
  465. env_flags_get_varaccess_name(access));
  466. return 0;
  467. }
  468. static int print_active_flags(ENTRY *entry)
  469. {
  470. enum env_flags_vartype type;
  471. enum env_flags_varaccess access;
  472. if (entry->flags == 0)
  473. return 0;
  474. type = (enum env_flags_vartype)
  475. (entry->flags & ENV_FLAGS_VARTYPE_BIN_MASK);
  476. access = env_flags_parse_varaccess_from_binflags(entry->flags);
  477. printf("\t%-20s %-20s %-20s\n", entry->key,
  478. env_flags_get_vartype_name(type),
  479. env_flags_get_varaccess_name(access));
  480. return 0;
  481. }
  482. /*
  483. * Print the flags available and what variables have flags
  484. */
  485. int do_env_flags(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  486. {
  487. /* Print the available variable types */
  488. printf("Available variable type flags (position %d):\n",
  489. ENV_FLAGS_VARTYPE_LOC);
  490. puts("\tFlag\tVariable Type Name\n");
  491. puts("\t----\t------------------\n");
  492. env_flags_print_vartypes();
  493. puts("\n");
  494. /* Print the available variable access types */
  495. printf("Available variable access flags (position %d):\n",
  496. ENV_FLAGS_VARACCESS_LOC);
  497. puts("\tFlag\tVariable Access Name\n");
  498. puts("\t----\t--------------------\n");
  499. env_flags_print_varaccess();
  500. puts("\n");
  501. /* Print the static flags that may exist */
  502. puts("Static flags:\n");
  503. printf("\t%-20s %-20s %-20s\n", "Variable Name", "Variable Type",
  504. "Variable Access");
  505. printf("\t%-20s %-20s %-20s\n", "-------------", "-------------",
  506. "---------------");
  507. env_attr_walk(ENV_FLAGS_LIST_STATIC, print_static_flags, NULL);
  508. puts("\n");
  509. /* walk through each variable and print the flags if non-default */
  510. puts("Active flags:\n");
  511. printf("\t%-20s %-20s %-20s\n", "Variable Name", "Variable Type",
  512. "Variable Access");
  513. printf("\t%-20s %-20s %-20s\n", "-------------", "-------------",
  514. "---------------");
  515. hwalk_r(&env_htab, print_active_flags);
  516. return 0;
  517. }
  518. #endif
  519. /*
  520. * Interactively edit an environment variable
  521. */
  522. #if defined(CONFIG_CMD_EDITENV)
  523. static int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc,
  524. char * const argv[])
  525. {
  526. char buffer[CONFIG_SYS_CBSIZE];
  527. char *init_val;
  528. if (argc < 2)
  529. return CMD_RET_USAGE;
  530. /* before import into hashtable */
  531. if (!(gd->flags & GD_FLG_ENV_READY))
  532. return 1;
  533. /* Set read buffer to initial value or empty sting */
  534. init_val = env_get(argv[1]);
  535. if (init_val)
  536. snprintf(buffer, CONFIG_SYS_CBSIZE, "%s", init_val);
  537. else
  538. buffer[0] = '\0';
  539. if (cli_readline_into_buffer("edit: ", buffer, 0) < 0)
  540. return 1;
  541. if (buffer[0] == '\0') {
  542. const char * const _argv[3] = { "setenv", argv[1], NULL };
  543. return _do_env_set(0, 2, (char * const *)_argv, H_INTERACTIVE);
  544. } else {
  545. const char * const _argv[4] = { "setenv", argv[1], buffer,
  546. NULL };
  547. return _do_env_set(0, 3, (char * const *)_argv, H_INTERACTIVE);
  548. }
  549. }
  550. #endif /* CONFIG_CMD_EDITENV */
  551. #endif /* CONFIG_SPL_BUILD */
  552. /*
  553. * Look up variable from environment,
  554. * return address of storage for that variable,
  555. * or NULL if not found
  556. */
  557. char *env_get(const char *name)
  558. {
  559. if (gd->flags & GD_FLG_ENV_READY) { /* after import into hashtable */
  560. ENTRY e, *ep;
  561. WATCHDOG_RESET();
  562. e.key = name;
  563. e.data = NULL;
  564. hsearch_r(e, FIND, &ep, &env_htab, 0);
  565. return ep ? ep->data : NULL;
  566. }
  567. /* restricted capabilities before import */
  568. if (env_get_f(name, (char *)(gd->env_buf), sizeof(gd->env_buf)) > 0)
  569. return (char *)(gd->env_buf);
  570. return NULL;
  571. }
  572. /*
  573. * Look up variable from environment for restricted C runtime env.
  574. */
  575. int env_get_f(const char *name, char *buf, unsigned len)
  576. {
  577. int i, nxt, c;
  578. for (i = 0; env_get_char(i) != '\0'; i = nxt + 1) {
  579. int val, n;
  580. for (nxt = i; (c = env_get_char(nxt)) != '\0'; ++nxt) {
  581. if (c < 0)
  582. return c;
  583. if (nxt >= CONFIG_ENV_SIZE)
  584. return -1;
  585. }
  586. val = envmatch((uchar *)name, i);
  587. if (val < 0)
  588. continue;
  589. /* found; copy out */
  590. for (n = 0; n < len; ++n, ++buf) {
  591. c = env_get_char(val++);
  592. if (c < 0)
  593. return c;
  594. *buf = c;
  595. if (*buf == '\0')
  596. return n;
  597. }
  598. if (n)
  599. *--buf = '\0';
  600. printf("env_buf [%d bytes] too small for value of \"%s\"\n",
  601. len, name);
  602. return n;
  603. }
  604. return -1;
  605. }
  606. /**
  607. * Decode the integer value of an environment variable and return it.
  608. *
  609. * @param name Name of environment variable
  610. * @param base Number base to use (normally 10, or 16 for hex)
  611. * @param default_val Default value to return if the variable is not
  612. * found
  613. * @return the decoded value, or default_val if not found
  614. */
  615. ulong env_get_ulong(const char *name, int base, ulong default_val)
  616. {
  617. /*
  618. * We can use env_get() here, even before relocation, since the
  619. * environment variable value is an integer and thus short.
  620. */
  621. const char *str = env_get(name);
  622. return str ? simple_strtoul(str, NULL, base) : default_val;
  623. }
  624. #ifndef CONFIG_SPL_BUILD
  625. #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
  626. static int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc,
  627. char * const argv[])
  628. {
  629. return env_save() ? 1 : 0;
  630. }
  631. U_BOOT_CMD(
  632. saveenv, 1, 0, do_env_save,
  633. "save environment variables to persistent storage",
  634. ""
  635. );
  636. #endif
  637. #endif /* CONFIG_SPL_BUILD */
  638. /*
  639. * Match a name / name=value pair
  640. *
  641. * s1 is either a simple 'name', or a 'name=value' pair.
  642. * i2 is the environment index for a 'name2=value2' pair.
  643. * If the names match, return the index for the value2, else -1.
  644. */
  645. int envmatch(uchar *s1, int i2)
  646. {
  647. if (s1 == NULL)
  648. return -1;
  649. while (*s1 == env_get_char(i2++))
  650. if (*s1++ == '=')
  651. return i2;
  652. if (*s1 == '\0' && env_get_char(i2-1) == '=')
  653. return i2;
  654. return -1;
  655. }
  656. #ifndef CONFIG_SPL_BUILD
  657. static int do_env_default(cmd_tbl_t *cmdtp, int flag,
  658. int argc, char * const argv[])
  659. {
  660. int all = 0, env_flag = H_INTERACTIVE;
  661. debug("Initial value for argc=%d\n", argc);
  662. while (--argc > 0 && **++argv == '-') {
  663. char *arg = *argv;
  664. while (*++arg) {
  665. switch (*arg) {
  666. case 'a': /* default all */
  667. all = 1;
  668. break;
  669. case 'f': /* force */
  670. env_flag |= H_FORCE;
  671. break;
  672. default:
  673. return cmd_usage(cmdtp);
  674. }
  675. }
  676. }
  677. debug("Final value for argc=%d\n", argc);
  678. if (all && (argc == 0)) {
  679. /* Reset the whole environment */
  680. set_default_env("## Resetting to default environment\n",
  681. env_flag);
  682. return 0;
  683. }
  684. if (!all && (argc > 0)) {
  685. /* Reset individual variables */
  686. set_default_vars(argc, argv, env_flag);
  687. return 0;
  688. }
  689. return cmd_usage(cmdtp);
  690. }
  691. static int do_env_delete(cmd_tbl_t *cmdtp, int flag,
  692. int argc, char * const argv[])
  693. {
  694. int env_flag = H_INTERACTIVE;
  695. int ret = 0;
  696. debug("Initial value for argc=%d\n", argc);
  697. while (argc > 1 && **(argv + 1) == '-') {
  698. char *arg = *++argv;
  699. --argc;
  700. while (*++arg) {
  701. switch (*arg) {
  702. case 'f': /* force */
  703. env_flag |= H_FORCE;
  704. break;
  705. default:
  706. return CMD_RET_USAGE;
  707. }
  708. }
  709. }
  710. debug("Final value for argc=%d\n", argc);
  711. env_id++;
  712. while (--argc > 0) {
  713. char *name = *++argv;
  714. if (!hdelete_r(name, &env_htab, env_flag))
  715. ret = 1;
  716. }
  717. return ret;
  718. }
  719. #ifdef CONFIG_CMD_EXPORTENV
  720. /*
  721. * env export [-t | -b | -c] [-s size] addr [var ...]
  722. * -t: export as text format; if size is given, data will be
  723. * padded with '\0' bytes; if not, one terminating '\0'
  724. * will be added (which is included in the "filesize"
  725. * setting so you can for exmple copy this to flash and
  726. * keep the termination).
  727. * -b: export as binary format (name=value pairs separated by
  728. * '\0', list end marked by double "\0\0")
  729. * -c: export as checksum protected environment format as
  730. * used for example by "saveenv" command
  731. * -s size:
  732. * size of output buffer
  733. * addr: memory address where environment gets stored
  734. * var... List of variable names that get included into the
  735. * export. Without arguments, the whole environment gets
  736. * exported.
  737. *
  738. * With "-c" and size is NOT given, then the export command will
  739. * format the data as currently used for the persistent storage,
  740. * i. e. it will use CONFIG_ENV_SECT_SIZE as output block size and
  741. * prepend a valid CRC32 checksum and, in case of redundant
  742. * environment, a "current" redundancy flag. If size is given, this
  743. * value will be used instead of CONFIG_ENV_SECT_SIZE; again, CRC32
  744. * checksum and redundancy flag will be inserted.
  745. *
  746. * With "-b" and "-t", always only the real data (including a
  747. * terminating '\0' byte) will be written; here the optional size
  748. * argument will be used to make sure not to overflow the user
  749. * provided buffer; the command will abort if the size is not
  750. * sufficient. Any remaining space will be '\0' padded.
  751. *
  752. * On successful return, the variable "filesize" will be set.
  753. * Note that filesize includes the trailing/terminating '\0' byte(s).
  754. *
  755. * Usage scenario: create a text snapshot/backup of the current settings:
  756. *
  757. * => env export -t 100000
  758. * => era ${backup_addr} +${filesize}
  759. * => cp.b 100000 ${backup_addr} ${filesize}
  760. *
  761. * Re-import this snapshot, deleting all other settings:
  762. *
  763. * => env import -d -t ${backup_addr}
  764. */
  765. static int do_env_export(cmd_tbl_t *cmdtp, int flag,
  766. int argc, char * const argv[])
  767. {
  768. char buf[32];
  769. ulong addr;
  770. char *ptr, *cmd, *res;
  771. size_t size = 0;
  772. ssize_t len;
  773. env_t *envp;
  774. char sep = '\n';
  775. int chk = 0;
  776. int fmt = 0;
  777. cmd = *argv;
  778. while (--argc > 0 && **++argv == '-') {
  779. char *arg = *argv;
  780. while (*++arg) {
  781. switch (*arg) {
  782. case 'b': /* raw binary format */
  783. if (fmt++)
  784. goto sep_err;
  785. sep = '\0';
  786. break;
  787. case 'c': /* external checksum format */
  788. if (fmt++)
  789. goto sep_err;
  790. sep = '\0';
  791. chk = 1;
  792. break;
  793. case 's': /* size given */
  794. if (--argc <= 0)
  795. return cmd_usage(cmdtp);
  796. size = simple_strtoul(*++argv, NULL, 16);
  797. goto NXTARG;
  798. case 't': /* text format */
  799. if (fmt++)
  800. goto sep_err;
  801. sep = '\n';
  802. break;
  803. default:
  804. return CMD_RET_USAGE;
  805. }
  806. }
  807. NXTARG: ;
  808. }
  809. if (argc < 1)
  810. return CMD_RET_USAGE;
  811. addr = simple_strtoul(argv[0], NULL, 16);
  812. ptr = map_sysmem(addr, size);
  813. if (size)
  814. memset(ptr, '\0', size);
  815. argc--;
  816. argv++;
  817. if (sep) { /* export as text file */
  818. len = hexport_r(&env_htab, sep,
  819. H_MATCH_KEY | H_MATCH_IDENT,
  820. &ptr, size, argc, argv);
  821. if (len < 0) {
  822. pr_err("## Error: Cannot export environment: errno = %d\n",
  823. errno);
  824. return 1;
  825. }
  826. sprintf(buf, "%zX", (size_t)len);
  827. env_set("filesize", buf);
  828. return 0;
  829. }
  830. envp = (env_t *)ptr;
  831. if (chk) /* export as checksum protected block */
  832. res = (char *)envp->data;
  833. else /* export as raw binary data */
  834. res = ptr;
  835. len = hexport_r(&env_htab, '\0',
  836. H_MATCH_KEY | H_MATCH_IDENT,
  837. &res, ENV_SIZE, argc, argv);
  838. if (len < 0) {
  839. pr_err("## Error: Cannot export environment: errno = %d\n",
  840. errno);
  841. return 1;
  842. }
  843. if (chk) {
  844. envp->crc = crc32(0, envp->data,
  845. size ? size - offsetof(env_t, data) : ENV_SIZE);
  846. #ifdef CONFIG_ENV_ADDR_REDUND
  847. envp->flags = ACTIVE_FLAG;
  848. #endif
  849. }
  850. env_set_hex("filesize", len + offsetof(env_t, data));
  851. return 0;
  852. sep_err:
  853. printf("## Error: %s: only one of \"-b\", \"-c\" or \"-t\" allowed\n",
  854. cmd);
  855. return 1;
  856. }
  857. #endif
  858. #ifdef CONFIG_CMD_IMPORTENV
  859. /*
  860. * env import [-d] [-t [-r] | -b | -c] addr [size] [var ...]
  861. * -d: delete existing environment before importing if no var is
  862. * passed; if vars are passed, if one var is in the current
  863. * environment but not in the environment at addr, delete var from
  864. * current environment;
  865. * otherwise overwrite / append to existing definitions
  866. * -t: assume text format; either "size" must be given or the
  867. * text data must be '\0' terminated
  868. * -r: handle CRLF like LF, that means exported variables with
  869. * a content which ends with \r won't get imported. Used
  870. * to import text files created with editors which are using CRLF
  871. * for line endings. Only effective in addition to -t.
  872. * -b: assume binary format ('\0' separated, "\0\0" terminated)
  873. * -c: assume checksum protected environment format
  874. * addr: memory address to read from
  875. * size: length of input data; if missing, proper '\0'
  876. * termination is mandatory
  877. * if var is set and size should be missing (i.e. '\0'
  878. * termination), set size to '-'
  879. * var... List of the names of the only variables that get imported from
  880. * the environment at address 'addr'. Without arguments, the whole
  881. * environment gets imported.
  882. */
  883. static int do_env_import(cmd_tbl_t *cmdtp, int flag,
  884. int argc, char * const argv[])
  885. {
  886. ulong addr;
  887. char *cmd, *ptr;
  888. char sep = '\n';
  889. int chk = 0;
  890. int fmt = 0;
  891. int del = 0;
  892. int crlf_is_lf = 0;
  893. int wl = 0;
  894. size_t size;
  895. cmd = *argv;
  896. while (--argc > 0 && **++argv == '-') {
  897. char *arg = *argv;
  898. while (*++arg) {
  899. switch (*arg) {
  900. case 'b': /* raw binary format */
  901. if (fmt++)
  902. goto sep_err;
  903. sep = '\0';
  904. break;
  905. case 'c': /* external checksum format */
  906. if (fmt++)
  907. goto sep_err;
  908. sep = '\0';
  909. chk = 1;
  910. break;
  911. case 't': /* text format */
  912. if (fmt++)
  913. goto sep_err;
  914. sep = '\n';
  915. break;
  916. case 'r': /* handle CRLF like LF */
  917. crlf_is_lf = 1;
  918. break;
  919. case 'd':
  920. del = 1;
  921. break;
  922. default:
  923. return CMD_RET_USAGE;
  924. }
  925. }
  926. }
  927. if (argc < 1)
  928. return CMD_RET_USAGE;
  929. if (!fmt)
  930. printf("## Warning: defaulting to text format\n");
  931. if (sep != '\n' && crlf_is_lf )
  932. crlf_is_lf = 0;
  933. addr = simple_strtoul(argv[0], NULL, 16);
  934. ptr = map_sysmem(addr, 0);
  935. if (argc >= 2 && strcmp(argv[1], "-")) {
  936. size = simple_strtoul(argv[1], NULL, 16);
  937. } else if (chk) {
  938. puts("## Error: external checksum format must pass size\n");
  939. return CMD_RET_FAILURE;
  940. } else {
  941. char *s = ptr;
  942. size = 0;
  943. while (size < MAX_ENV_SIZE) {
  944. if ((*s == sep) && (*(s+1) == '\0'))
  945. break;
  946. ++s;
  947. ++size;
  948. }
  949. if (size == MAX_ENV_SIZE) {
  950. printf("## Warning: Input data exceeds %d bytes"
  951. " - truncated\n", MAX_ENV_SIZE);
  952. }
  953. size += 2;
  954. printf("## Info: input data size = %zu = 0x%zX\n", size, size);
  955. }
  956. if (argc > 2)
  957. wl = 1;
  958. if (chk) {
  959. uint32_t crc;
  960. env_t *ep = (env_t *)ptr;
  961. size -= offsetof(env_t, data);
  962. memcpy(&crc, &ep->crc, sizeof(crc));
  963. if (crc32(0, ep->data, size) != crc) {
  964. puts("## Error: bad CRC, import failed\n");
  965. return 1;
  966. }
  967. ptr = (char *)ep->data;
  968. }
  969. if (!himport_r(&env_htab, ptr, size, sep, del ? 0 : H_NOCLEAR,
  970. crlf_is_lf, wl ? argc - 2 : 0, wl ? &argv[2] : NULL)) {
  971. pr_err("## Error: Environment import failed: errno = %d\n",
  972. errno);
  973. return 1;
  974. }
  975. gd->flags |= GD_FLG_ENV_READY;
  976. return 0;
  977. sep_err:
  978. printf("## %s: only one of \"-b\", \"-c\" or \"-t\" allowed\n",
  979. cmd);
  980. return 1;
  981. }
  982. #endif
  983. #if defined(CONFIG_CMD_ENV_EXISTS)
  984. static int do_env_exists(cmd_tbl_t *cmdtp, int flag, int argc,
  985. char * const argv[])
  986. {
  987. ENTRY e, *ep;
  988. if (argc < 2)
  989. return CMD_RET_USAGE;
  990. e.key = argv[1];
  991. e.data = NULL;
  992. hsearch_r(e, FIND, &ep, &env_htab, 0);
  993. return (ep == NULL) ? 1 : 0;
  994. }
  995. #endif
  996. /*
  997. * New command line interface: "env" command with subcommands
  998. */
  999. static cmd_tbl_t cmd_env_sub[] = {
  1000. #if defined(CONFIG_CMD_ASKENV)
  1001. U_BOOT_CMD_MKENT(ask, CONFIG_SYS_MAXARGS, 1, do_env_ask, "", ""),
  1002. #endif
  1003. U_BOOT_CMD_MKENT(default, 1, 0, do_env_default, "", ""),
  1004. U_BOOT_CMD_MKENT(delete, CONFIG_SYS_MAXARGS, 0, do_env_delete, "", ""),
  1005. #if defined(CONFIG_CMD_EDITENV)
  1006. U_BOOT_CMD_MKENT(edit, 2, 0, do_env_edit, "", ""),
  1007. #endif
  1008. #if defined(CONFIG_CMD_ENV_CALLBACK)
  1009. U_BOOT_CMD_MKENT(callbacks, 1, 0, do_env_callback, "", ""),
  1010. #endif
  1011. #if defined(CONFIG_CMD_ENV_FLAGS)
  1012. U_BOOT_CMD_MKENT(flags, 1, 0, do_env_flags, "", ""),
  1013. #endif
  1014. #if defined(CONFIG_CMD_EXPORTENV)
  1015. U_BOOT_CMD_MKENT(export, 4, 0, do_env_export, "", ""),
  1016. #endif
  1017. #if defined(CONFIG_CMD_GREPENV)
  1018. U_BOOT_CMD_MKENT(grep, CONFIG_SYS_MAXARGS, 1, do_env_grep, "", ""),
  1019. #endif
  1020. #if defined(CONFIG_CMD_IMPORTENV)
  1021. U_BOOT_CMD_MKENT(import, 5, 0, do_env_import, "", ""),
  1022. #endif
  1023. U_BOOT_CMD_MKENT(print, CONFIG_SYS_MAXARGS, 1, do_env_print, "", ""),
  1024. #if defined(CONFIG_CMD_RUN)
  1025. U_BOOT_CMD_MKENT(run, CONFIG_SYS_MAXARGS, 1, do_run, "", ""),
  1026. #endif
  1027. #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
  1028. U_BOOT_CMD_MKENT(save, 1, 0, do_env_save, "", ""),
  1029. #endif
  1030. U_BOOT_CMD_MKENT(set, CONFIG_SYS_MAXARGS, 0, do_env_set, "", ""),
  1031. #if defined(CONFIG_CMD_ENV_EXISTS)
  1032. U_BOOT_CMD_MKENT(exists, 2, 0, do_env_exists, "", ""),
  1033. #endif
  1034. };
  1035. #if defined(CONFIG_NEEDS_MANUAL_RELOC)
  1036. void env_reloc(void)
  1037. {
  1038. fixup_cmdtable(cmd_env_sub, ARRAY_SIZE(cmd_env_sub));
  1039. }
  1040. #endif
  1041. static int do_env(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  1042. {
  1043. cmd_tbl_t *cp;
  1044. if (argc < 2)
  1045. return CMD_RET_USAGE;
  1046. /* drop initial "env" arg */
  1047. argc--;
  1048. argv++;
  1049. cp = find_cmd_tbl(argv[0], cmd_env_sub, ARRAY_SIZE(cmd_env_sub));
  1050. if (cp)
  1051. return cp->cmd(cmdtp, flag, argc, argv);
  1052. return CMD_RET_USAGE;
  1053. }
  1054. #ifdef CONFIG_SYS_LONGHELP
  1055. static char env_help_text[] =
  1056. #if defined(CONFIG_CMD_ASKENV)
  1057. "ask name [message] [size] - ask for environment variable\nenv "
  1058. #endif
  1059. #if defined(CONFIG_CMD_ENV_CALLBACK)
  1060. "callbacks - print callbacks and their associated variables\nenv "
  1061. #endif
  1062. "default [-f] -a - [forcibly] reset default environment\n"
  1063. "env default [-f] var [...] - [forcibly] reset variable(s) to their default values\n"
  1064. "env delete [-f] var [...] - [forcibly] delete variable(s)\n"
  1065. #if defined(CONFIG_CMD_EDITENV)
  1066. "env edit name - edit environment variable\n"
  1067. #endif
  1068. #if defined(CONFIG_CMD_ENV_EXISTS)
  1069. "env exists name - tests for existence of variable\n"
  1070. #endif
  1071. #if defined(CONFIG_CMD_EXPORTENV)
  1072. "env export [-t | -b | -c] [-s size] addr [var ...] - export environment\n"
  1073. #endif
  1074. #if defined(CONFIG_CMD_ENV_FLAGS)
  1075. "env flags - print variables that have non-default flags\n"
  1076. #endif
  1077. #if defined(CONFIG_CMD_GREPENV)
  1078. #ifdef CONFIG_REGEX
  1079. "env grep [-e] [-n | -v | -b] string [...] - search environment\n"
  1080. #else
  1081. "env grep [-n | -v | -b] string [...] - search environment\n"
  1082. #endif
  1083. #endif
  1084. #if defined(CONFIG_CMD_IMPORTENV)
  1085. "env import [-d] [-t [-r] | -b | -c] addr [size] [var ...] - import environment\n"
  1086. #endif
  1087. "env print [-a | name ...] - print environment\n"
  1088. #if defined(CONFIG_CMD_RUN)
  1089. "env run var [...] - run commands in an environment variable\n"
  1090. #endif
  1091. #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
  1092. "env save - save environment\n"
  1093. #endif
  1094. "env set [-f] name [arg ...]\n";
  1095. #endif
  1096. U_BOOT_CMD(
  1097. env, CONFIG_SYS_MAXARGS, 1, do_env,
  1098. "environment handling commands", env_help_text
  1099. );
  1100. /*
  1101. * Old command line interface, kept for compatibility
  1102. */
  1103. #if defined(CONFIG_CMD_EDITENV)
  1104. U_BOOT_CMD_COMPLETE(
  1105. editenv, 2, 0, do_env_edit,
  1106. "edit environment variable",
  1107. "name\n"
  1108. " - edit environment variable 'name'",
  1109. var_complete
  1110. );
  1111. #endif
  1112. U_BOOT_CMD_COMPLETE(
  1113. printenv, CONFIG_SYS_MAXARGS, 1, do_env_print,
  1114. "print environment variables",
  1115. "[-a]\n - print [all] values of all environment variables\n"
  1116. "printenv name ...\n"
  1117. " - print value of environment variable 'name'",
  1118. var_complete
  1119. );
  1120. #ifdef CONFIG_CMD_GREPENV
  1121. U_BOOT_CMD_COMPLETE(
  1122. grepenv, CONFIG_SYS_MAXARGS, 0, do_env_grep,
  1123. "search environment variables",
  1124. #ifdef CONFIG_REGEX
  1125. "[-e] [-n | -v | -b] string ...\n"
  1126. #else
  1127. "[-n | -v | -b] string ...\n"
  1128. #endif
  1129. " - list environment name=value pairs matching 'string'\n"
  1130. #ifdef CONFIG_REGEX
  1131. " \"-e\": enable regular expressions;\n"
  1132. #endif
  1133. " \"-n\": search variable names; \"-v\": search values;\n"
  1134. " \"-b\": search both names and values (default)",
  1135. var_complete
  1136. );
  1137. #endif
  1138. U_BOOT_CMD_COMPLETE(
  1139. setenv, CONFIG_SYS_MAXARGS, 0, do_env_set,
  1140. "set environment variables",
  1141. "[-f] name value ...\n"
  1142. " - [forcibly] set environment variable 'name' to 'value ...'\n"
  1143. "setenv [-f] name\n"
  1144. " - [forcibly] delete environment variable 'name'",
  1145. var_complete
  1146. );
  1147. #if defined(CONFIG_CMD_ASKENV)
  1148. U_BOOT_CMD(
  1149. askenv, CONFIG_SYS_MAXARGS, 1, do_env_ask,
  1150. "get environment variables from stdin",
  1151. "name [message] [size]\n"
  1152. " - get environment variable 'name' from stdin (max 'size' chars)"
  1153. );
  1154. #endif
  1155. #if defined(CONFIG_CMD_RUN)
  1156. U_BOOT_CMD_COMPLETE(
  1157. run, CONFIG_SYS_MAXARGS, 1, do_run,
  1158. "run commands in an environment variable",
  1159. "var [...]\n"
  1160. " - run the commands in the environment variable(s) 'var'",
  1161. var_complete
  1162. );
  1163. #endif
  1164. #endif /* CONFIG_SPL_BUILD */