1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| #ifdef CONFIG_AUTO_COMPLETE # define _CMD_COMPLETE(x) x, #else # define _CMD_COMPLETE(x) #endif #ifdef CONFIG_SYS_LONGHELP # define _CMD_HELP(x) x, #else # define _CMD_HELP(x) #endif
#define U_BOOT_CMD(_name, _maxargs, _rep, _cmd, _usage, _help) \ U_BOOT_CMD_COMPLETE(_name, _maxargs, _rep, _cmd, _usage, _help, NULL)
#define U_BOOT_CMD_COMPLETE(_name, _maxargs, _rep, _cmd, _usage, _help, _comp) \ ll_entry_declare(struct cmd_tbl, _name, cmd) = \ U_BOOT_CMD_MKENT_COMPLETE(_name, _maxargs, _rep, _cmd, \ _usage, _help, _comp)
struct cmd_tbl { char *name; int maxargs;
int (*cmd_rep)(struct cmd_tbl *cmd, int flags, int argc, char *const argv[], int *repeatable); int (*cmd)(struct cmd_tbl *cmd, int flags, int argc, char *const argv[]); char *usage; #ifdef CONFIG_SYS_LONGHELP const char *help; #endif #ifdef CONFIG_AUTO_COMPLETE int (*complete)(int argc, char *const argv[], char last_char, int maxv, char *cmdv[]); #endif };
#define U_BOOT_CMD_MKENT_COMPLETE(_name, _maxargs, _rep, _cmd, \ _usage, _help, _comp) \ { #_name, _maxargs, \ _rep ? cmd_always_repeatable : cmd_never_repeatable, \ _cmd, _usage, _CMD_HELP(_help) _CMD_COMPLETE(_comp) }
int cmd_always_repeatable(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], int *repeatable) { *repeatable = 1;
return cmdtp->cmd(cmdtp, flag, argc, argv); }
int cmd_never_repeatable(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], int *repeatable) { *repeatable = 0;
return cmdtp->cmd(cmdtp, flag, argc, argv); }
struct cmd_tbl *find_cmd(const char *cmd); struct cmd_tbl *find_cmd_tbl(const char *cmd, struct cmd_tbl *table, int table_len);
|