summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo C2018-08-30 09:01:40 +0200
committerLeo C2018-08-30 09:01:40 +0200
commit85d34e1026065c340e2237e1d2ab56e868be86ec (patch)
tree87c3dcfc2b7e235773d7e7ae3238e05061a63bb6
parent022330eb94f180b0b626988d294ce43c2191ad61 (diff)
downloadz180-stamp-85d34e1026065c340e2237e1d2ab56e868be86ec.zip
new command: boot - boot default, i.e., run 'bootcmd'
-rw-r--r--avr/cmd_run.c22
-rw-r--r--avr/command_tbl.c5
-rw-r--r--include/cmd_run.h1
3 files changed, 16 insertions, 12 deletions
diff --git a/avr/cmd_run.c b/avr/cmd_run.c
index 9c6f20f..6482d0b 100644
--- a/avr/cmd_run.c
+++ b/avr/cmd_run.c
@@ -1,5 +1,5 @@
/*
- * (C) Copyright 2016 Leo C. <erbl259-lmu@yahoo.de>
+ * (C) Copyright 2016, 2018 Leo C. <erbl259-lmu@yahoo.de>
*
* SPDX-License-Identifier: GPL-2.0
*/
@@ -12,15 +12,12 @@
#include "env.h"
-command_ret_t do_run(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[])
+command_ret_t do_run(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag, int argc, char * const argv[])
{
- int i;
- (void) cmdtp;
-
if (argc < 2)
return CMD_RET_USAGE;
- for (i = 1; i < argc; ++i) {
+ for (int i = 1; i < argc; ++i) {
char *arg;
arg = getenv_str(argv[i]);
@@ -35,13 +32,16 @@ command_ret_t do_run(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const
return CMD_RET_SUCCESS;
}
-static int source(FIL *fp, uint_fast8_t flag, int argc, char * const argv[])
+command_ret_t do_bootd(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag, int argc UNUSED, char * const argv[] UNUSED)
+{
+ return run_command(getenv_str("bootcmd"), flag);
+}
+
+static int source(FIL *fp, uint_fast8_t flag, int argc UNUSED, char * const argv[] UNUSED)
{
int lineno = 0;
int res = 0;
- (void)argc; (void)argv;
-
while (!f_eof(fp) && !f_error(fp) && !res) {
lineno++;
if (f_gets(console_buffer, CONFIG_SYS_CBSIZE, fp)) {
@@ -62,13 +62,11 @@ static int source(FIL *fp, uint_fast8_t flag, int argc, char * const argv[])
return !f_eof(fp) || res;
}
-command_ret_t do_source(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[])
+command_ret_t do_source(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag, int argc, char * const argv[])
{
FIL File;
int res;
- (void) cmdtp;
-
if (argc < 2)
return CMD_RET_USAGE;
diff --git a/avr/command_tbl.c b/avr/command_tbl.c
index 1226180..d93294b 100644
--- a/avr/command_tbl.c
+++ b/avr/command_tbl.c
@@ -100,6 +100,11 @@ CMD_TBL_ITEM_COMPLETE(
" - run the commands in the environment variable(s) 'var'",
var_complete
),
+CMD_TBL_ITEM(
+ boot, 1, 1, do_bootd,
+ "boot default, i.e., run 'bootcmd'",
+ ""
+),
CMD_TBL_ITEM_COMPLETE(
source, CONFIG_SYS_MAXARGS, 1, do_source,
"run commands from a file",
diff --git a/include/cmd_run.h b/include/cmd_run.h
index 4691a55..fc81267 100644
--- a/include/cmd_run.h
+++ b/include/cmd_run.h
@@ -9,6 +9,7 @@
#include "command.h"
+command_ret_t do_bootd(cmd_tbl_t *, uint_fast8_t, int, char * const []);
command_ret_t do_source(cmd_tbl_t *, uint_fast8_t, int, char * const []);
command_ret_t do_run(cmd_tbl_t *, uint_fast8_t, int, char * const []);