summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLeo C2018-07-21 13:13:16 +0200
committerLeo C2018-07-21 13:13:16 +0200
commitfcf1d5b30bd3b341fb7596aef395f347c6dc97b4 (patch)
treead2620ca61db64ccad3440b7168cfe59f9cc245f /include
parent862110cc1e0a71418f350758eb229ecfcb0d7b37 (diff)
downloadz180-stamp-fcf1d5b30bd3b341fb7596aef395f347c6dc97b4.zip
commandtable, flags: int --> uint8_t/uint_fast8_t. Macro UNUSED for Parameters/Variables
# Conflicts: # avr/cmd_fat.c
Diffstat (limited to 'include')
-rw-r--r--include/cli.h8
-rw-r--r--include/cmd_mem.h24
-rw-r--r--include/command.h35
-rw-r--r--include/common.h3
4 files changed, 39 insertions, 31 deletions
diff --git a/include/cli.h b/include/cli.h
index 28e92be..e6df408 100644
--- a/include/cli.h
+++ b/include/cli.h
@@ -10,6 +10,8 @@
#ifndef CLI_H
#define CLI_H
+#include "common.h"
+
/**
* Go into the command loop
*
@@ -30,7 +32,7 @@ void cli_loop(void);
* (If cmd is NULL or "" or longer than CONFIG_SYS_CBSIZE-1 it is
* considered unrecognized)
*/
-//int cli_simple_run_command(const char *cmd, int flag);
+//int cli_simple_run_command(const char *cmd, uint_fast8_t flag);
/**
* cli_simple_run_command_list() - Execute a list of command
@@ -45,7 +47,7 @@ void cli_loop(void);
* @param flag Execution flags (CMD_FLAG_...)
* @return 0 on success, or != 0 on error.
*/
-//int cli_simple_run_command_list(char *cmd, int flag);
+//int cli_simple_run_command_list(char *cmd, uint_fast8_t flag);
/**
* parse_line() - split a command line down into separate arguments
@@ -73,7 +75,7 @@ void cli_loop(void);
* @param flag Execution flags (CMD_FLAG_...)
* @return 0 on success, or != 0 on error.
*/
-int run_command(const char *cmd, int flag);
+int run_command(const char *cmd, uint_fast8_t flag);
int run_command_list(const char *cmd, int len);
diff --git a/include/cmd_mem.h b/include/cmd_mem.h
index 782c10a..625ab8d 100644
--- a/include/cmd_mem.h
+++ b/include/cmd_mem.h
@@ -1,7 +1,7 @@
/*
* (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
*
- * SPDX-License-Identifier: GPL-2.0+
+ * SPDX-License-Identifier: GPL-2.0
*/
#ifndef CMD_MEM_H
@@ -11,20 +11,20 @@
#include "cmd_mem.h"
-extern command_ret_t do_mem_md(cmd_tbl_t *, int, int, char * const []);
-extern command_ret_t do_mem_mm(cmd_tbl_t *, int, int, char * const []);
-extern command_ret_t do_mem_nm(cmd_tbl_t *, int, int, char * const []);
-extern command_ret_t do_mem_mw(cmd_tbl_t *, int, int, char * const []);
-extern command_ret_t do_mem_cp(cmd_tbl_t *, int, int, char * const []);
-extern command_ret_t do_mem_cmp(cmd_tbl_t *, int, int, char * const []);
-extern command_ret_t do_mem_base(cmd_tbl_t *, int, int, char * const []);
-extern command_ret_t do_mem_loop(cmd_tbl_t *, int, int, char * const []);
-extern command_ret_t do_mem_loopw(cmd_tbl_t *, int, int, char * const []);
+extern command_ret_t do_mem_md(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+extern command_ret_t do_mem_mm(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+extern command_ret_t do_mem_nm(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+extern command_ret_t do_mem_mw(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+extern command_ret_t do_mem_cp(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+extern command_ret_t do_mem_cmp(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+extern command_ret_t do_mem_base(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+extern command_ret_t do_mem_loop(cmd_tbl_t *, uint_fast8_t, int, char * const []);
+extern command_ret_t do_mem_loopw(cmd_tbl_t *, uint_fast8_t, int, char * const []);
#ifdef CONFIG_CMD_MEMTEST
-extern command_ret_t do_mem_mtest(cmd_tbl_t *, int, int, char * const []);
+extern command_ret_t do_mem_mtest(cmd_tbl_t *, uint_fast8_t, int, char * const []);
#endif
#ifdef CONFIG_MX_CYCLIC
-extern command_ret_t do_mem_mdc(cmd_tbl_t *, int, int, char * const []);
+extern command_ret_t do_mem_mdc(cmd_tbl_t *, uint_fast8_t, int, char * const []);
#endif /* CONFIG_MX_CYCLIC */
#endif /* CMD_MEM_H */
diff --git a/include/command.h b/include/command.h
index 9ca460d..75b5a0d 100644
--- a/include/command.h
+++ b/include/command.h
@@ -46,10 +46,10 @@ typedef enum {
struct cmd_tbl_s {
const FLASH char *name; /* Command Name */
- int maxargs; /* maximum number of arguments */
- int repeatable; /* autorepeat allowed? */
+ uint8_t maxargs; /* maximum number of arguments */
+ uint8_t flags; /* autorepeat allowed? */
/* Implementation function */
- command_ret_t (*cmd)(const FLASH struct cmd_tbl_s *, int, int, char * const []);
+ command_ret_t (*cmd)(const FLASH struct cmd_tbl_s *, uint_fast8_t, int, char * const []);
const FLASH char *usage; /* Usage message (short) */
#ifdef CONFIG_SYS_LONGHELP
const FLASH char *help; /* Help message (long) */
@@ -75,12 +75,11 @@ typedef const FLASH struct cmd_tbl_s cmd_tbl_t;
* @return 0 if the command succeeded, 1 if it failed
*/
command_ret_t
-cmd_process(int flag, int argc, char * const argv[], uint_fast8_t *repeatable);
+cmd_process(uint_fast8_t flag, int argc, char * const argv[], uint_fast8_t *repeatable);
/* command.c */
-command_ret_t _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int
- flag, int argc, char * const argv[]);
+command_ret_t _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, uint_fast8_t flag, int argc, char * const argv[]);
cmd_tbl_t *find_cmd(const char *cmd);
cmd_tbl_t *find_cmd_tbl (const char *cmd, cmd_tbl_t *table, int table_len);
@@ -106,21 +105,19 @@ int cmd_process_error(cmd_tbl_t *cmdtp, int err);
*
* All commands use a common argument format:
*
- * void function (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
+ * void function (cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[]);
*/
#ifdef CONFIG_CMD_BOOTD
-extern command_ret_t do_bootd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
+extern command_ret_t do_bootd(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[]);
#endif
#ifdef CONFIG_CMD_BOOTM
-extern command_ret_t do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
+extern command_ret_t do_bootm(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[]);
extern int bootm_maybe_autostart(cmd_tbl_t *cmdtp, const char *cmd);
#else
-static inline int bootm_maybe_autostart(cmd_tbl_t *cmdtp, const char *cmd)
+static inline int bootm_maybe_autostart(cmd_tbl_t *cmdtp UNUSED, const char *cmd UNUSED)
{
- (void) cmdtp; (void) cmd;
-
return 0;
}
#endif
@@ -128,13 +125,19 @@ static inline int bootm_maybe_autostart(cmd_tbl_t *cmdtp, const char *cmd)
extern int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc,
char *const argv[]);
-extern command_ret_t do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
+extern command_ret_t do_reset(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[]);
/*
* Command Flags:
*/
-#define CMD_FLAG_REPEAT 0x0001 /* repeat last command */
-#define CMD_FLAG_BOOTD 0x0002 /* command is from bootd */
+#define CMD_FLAG_REPEAT 0x01 /* repeat last command */
+#define CMD_FLAG_BOOTD 0x02 /* command is from bootd */
+
+/*
+ * Flags for command table:
+ */
+#define CTBL_REPEAT 0x01 /* command is repeatable */
+#define CTBL_SUBCMD 0x02 /* command has subcommands */
#ifdef CONFIG_AUTO_COMPLETE
# define _CMD_COMPLETE(x) x,
@@ -157,7 +160,7 @@ extern command_ret_t do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const
CMD_TBL_ITEM_COMPLETE(_name, _maxargs, _rep, _cmd, \
_usage, _help, NULL)
-typedef command_ret_t (*do_cmd_t)(cmd_tbl_t *, int, int, char * const []);
+typedef command_ret_t (*do_cmd_t)(cmd_tbl_t *, uint_fast8_t, int, char * const []);
extern cmd_tbl_t cmd_tbl[];
diff --git a/include/common.h b/include/common.h
index e22b7a1..1064bf3 100644
--- a/include/common.h
+++ b/include/common.h
@@ -12,6 +12,9 @@
#define GCC_VERSION (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__)
+#define USED __attribute__((used))
+#define UNUSED __attribute__((unused))
+
#ifdef __AVR__
#include <avr/io.h>
#include <avr/pgmspace.h>