Blame view
include/command.h
6.74 KB
78f6622a1 Initial revision |
1 |
/* |
2dce551e1 command.c: Expose... |
2 |
* (C) Copyright 2000-2009 |
78f6622a1 Initial revision |
3 4 |
* Wolfgang Denk, DENX Software Engineering, wd@denx.de. * |
1a4596601 Add GPL-2.0+ SPDX... |
5 |
* SPDX-License-Identifier: GPL-2.0+ |
78f6622a1 Initial revision |
6 7 8 9 10 11 12 |
*/ /* * Definitions for Command Processor */ #ifndef __COMMAND_H #define __COMMAND_H |
6c7c946ca common: Convert t... |
13 |
#include <linker_lists.h> |
f2302d443 Fix merge problems |
14 |
|
78f6622a1 Initial revision |
15 16 17 |
#ifndef NULL #define NULL 0 #endif |
2fb2604d5 Command usage cle... |
18 19 20 21 |
/* Default to a width of 8 characters for help message command width */ #ifndef CONFIG_SYS_HELP_CMD_WIDTH #define CONFIG_SYS_HELP_CMD_WIDTH 8 #endif |
78f6622a1 Initial revision |
22 23 24 25 26 27 28 |
#ifndef __ASSEMBLY__ /* * Monitor Command Table */ struct cmd_tbl_s { char *name; /* Command Name */ |
78f6622a1 Initial revision |
29 30 31 |
int maxargs; /* maximum number of arguments */ int repeatable; /* autorepeat allowed? */ /* Implementation function */ |
54841ab50 Make sure that ar... |
32 |
int (*cmd)(struct cmd_tbl_s *, int, int, char * const []); |
78f6622a1 Initial revision |
33 |
char *usage; /* Usage message (short) */ |
6d0f6bcf3 rename CFG_ macro... |
34 |
#ifdef CONFIG_SYS_LONGHELP |
78f6622a1 Initial revision |
35 36 |
char *help; /* Help message (long) */ #endif |
04a85b3b3 * Patches by Pant... |
37 38 |
#ifdef CONFIG_AUTO_COMPLETE /* do auto completion on the arguments */ |
54841ab50 Make sure that ar... |
39 |
int (*complete)(int argc, char * const argv[], char last_char, int maxv, char *cmdv[]); |
04a85b3b3 * Patches by Pant... |
40 |
#endif |
78f6622a1 Initial revision |
41 42 43 |
}; typedef struct cmd_tbl_s cmd_tbl_t; |
78f6622a1 Initial revision |
44 |
|
d09b1787a env: clean cmd_nv... |
45 46 47 |
#if defined(CONFIG_CMD_RUN) extern int do_run(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); #endif |
78f6622a1 Initial revision |
48 49 |
/* common/command.c */ |
2dce551e1 command.c: Expose... |
50 |
int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int |
54841ab50 Make sure that ar... |
51 |
flag, int argc, char * const argv[]); |
78f6622a1 Initial revision |
52 |
cmd_tbl_t *find_cmd(const char *cmd); |
b799cb4c0 Expose command ta... |
53 |
cmd_tbl_t *find_cmd_tbl (const char *cmd, cmd_tbl_t *table, int table_len); |
78f6622a1 Initial revision |
54 |
|
e84ffddbc cmd_usage: constify |
55 |
extern int cmd_usage(const cmd_tbl_t *cmdtp); |
62c3ae7c6 Standardize comma... |
56 |
|
04a85b3b3 * Patches by Pant... |
57 |
#ifdef CONFIG_AUTO_COMPLETE |
722b061b6 autocomplete: rem... |
58 |
extern int var_complete(int argc, char * const argv[], char last_char, int maxv, char *cmdv[]); |
04a85b3b3 * Patches by Pant... |
59 60 |
extern int cmd_auto_complete(const char *const prompt, char *buf, int *np, int *colp); #endif |
16ff99024 Add cmd_process_e... |
61 62 63 64 65 66 67 68 |
/** * cmd_process_error() - report and process a possible error * * @cmdtp: Command which caused the error * @err: Error code (0 if none, -ve for error, like -EIO) * @return 0 if there is not error, 1 (CMD_RET_FAILURE) if an error is found */ int cmd_process_error(cmd_tbl_t *cmdtp, int err); |
78f6622a1 Initial revision |
69 70 71 72 73 |
/* * Monitor Command * * All commands use a common argument format: * |
54841ab50 Make sure that ar... |
74 |
* void function (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); |
78f6622a1 Initial revision |
75 |
*/ |
6f62d7c4f Kconfig: Drop CON... |
76 77 78 79 |
#if defined(CONFIG_CMD_MEMORY) || \ defined(CONFIG_CMD_I2C) || \ defined(CONFIG_CMD_ITEST) || \ defined(CONFIG_CMD_PCI) |
8a40fb148 move cmd_get_data... |
80 81 82 |
#define CMD_DATA_SIZE extern int cmd_get_data_size(char* arg, int default_size); #endif |
7842fb7c4 do_bootd: unify d... |
83 84 85 |
#ifdef CONFIG_CMD_BOOTD extern int do_bootd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); #endif |
67d668bf9 autostart: unify ... |
86 |
#ifdef CONFIG_CMD_BOOTM |
36ebb7877 do_bootm: unify d... |
87 |
extern int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); |
67d668bf9 autostart: unify ... |
88 89 90 91 92 93 94 |
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) { return 0; } #endif |
7405a1331 combine block dev... |
95 |
|
da620222f bootz: un-statici... |
96 |
extern int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); |
8b5c738b8 pxe: add AArch64 ... |
97 |
extern int do_booti(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); |
7405a1331 combine block dev... |
98 99 |
extern int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc, char *const argv[]); |
882b7d726 do_reset: unify d... |
100 |
extern int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); |
4e42e29fd cmd_boot: Add a p... |
101 |
extern int do_poweroff(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); |
36ebb7877 do_bootm: unify d... |
102 |
|
9d12d5d41 Add cmd_process()... |
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
/* * Error codes that commands return to cmd_process(). We use the standard 0 * and 1 for success and failure, but add one more case - failure with a * request to call cmd_usage(). But the cmd_process() function handles * CMD_RET_USAGE itself and after calling cmd_usage() it will return 1. * This is just a convenience for commands to avoid them having to call * cmd_usage() all over the place. */ enum command_ret_t { CMD_RET_SUCCESS, /* 0 = Success */ CMD_RET_FAILURE, /* 1 = Failure */ CMD_RET_USAGE = -1, /* Failure, please report 'usage' error */ }; /** * Process a command with arguments. We look up the command and execute it * if valid. Otherwise we print a usage message. * * @param flag Some flags normally 0 (see CMD_FLAG_.. above) * @param argc Number of arguments (arg 0 must be the command text) * @param argv Arguments * @param repeatable This function sets this to 0 if the command is not * repeatable. If the command is repeatable, the value * is left unchanged. |
34765e885 cmd_time: merge r... |
127 128 |
* @param ticks If ticks is not null, this function set it to the * number of ticks the command took to complete. |
9d12d5d41 Add cmd_process()... |
129 130 131 |
* @return 0 if the command succeeded, 1 if it failed */ int cmd_process(int flag, int argc, char * const argv[], |
34765e885 cmd_time: merge r... |
132 |
int *repeatable, unsigned long *ticks); |
bdf8e34b9 Create a single c... |
133 |
|
cbb2df201 CONFIG_NEEDS_MANU... |
134 |
void fixup_cmdtable(cmd_tbl_t *cmdtp, int size); |
f8bb69643 Drop command-proc... |
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
/** * board_run_command() - Fallback function to execute a command * * When no command line features are enabled in U-Boot, this function is * called to execute a command. Typically the function can look at the * command and perform a few very specific tasks, such as booting the * system in a particular way. * * This function is only used when CONFIG_CMDLINE is not enabled. * * In normal situations this function should not return, since U-Boot will * simply hang. * * @cmdline: Command line string to execute * @return 0 if OK, 1 for error */ int board_run_command(const char *cmdline); |
78f6622a1 Initial revision |
153 154 155 156 157 158 159 |
#endif /* __ASSEMBLY__ */ /* * Command Flags: */ #define CMD_FLAG_REPEAT 0x0001 /* repeat last command */ #define CMD_FLAG_BOOTD 0x0002 /* command is from bootd */ |
87b6398b4 cli: hush: Adjust... |
160 |
#define CMD_FLAG_ENV 0x0004 /* command is from the environment */ |
78f6622a1 Initial revision |
161 |
|
722b061b6 autocomplete: rem... |
162 163 164 165 166 167 168 169 170 171 |
#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 |
8bde7f776 * Code cleanup: |
172 |
|
fb24112c1 Allow command cod... |
173 |
#ifdef CONFIG_CMDLINE |
6c7c946ca common: Convert t... |
174 175 176 177 |
#define U_BOOT_CMD_MKENT_COMPLETE(_name, _maxargs, _rep, _cmd, \ _usage, _help, _comp) \ { #_name, _maxargs, _rep, _cmd, _usage, \ _CMD_HELP(_help) _CMD_COMPLETE(_comp) } |
8bde7f776 * Code cleanup: |
178 |
|
6c7c946ca common: Convert t... |
179 |
#define U_BOOT_CMD_COMPLETE(_name, _maxargs, _rep, _cmd, _usage, _help, _comp) \ |
ef123c525 Refactor linker-g... |
180 |
ll_entry_declare(cmd_tbl_t, _name, cmd) = \ |
6c7c946ca common: Convert t... |
181 182 |
U_BOOT_CMD_MKENT_COMPLETE(_name, _maxargs, _rep, _cmd, \ _usage, _help, _comp); |
8bde7f776 * Code cleanup: |
183 |
|
fb24112c1 Allow command cod... |
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
#else #define U_BOOT_SUBCMD_START(name) static cmd_tbl_t name[] = {}; #define U_BOOT_SUBCMD_END #define _CMD_REMOVE(_name, _cmd) \ int __remove_ ## _name(void) \ { \ if (0) \ _cmd(NULL, 0, 0, NULL); \ return 0; \ } #define U_BOOT_CMD_MKENT_COMPLETE(_name, _maxargs, _rep, _cmd, _usage, \ _help, _comp) \ { #_name, _maxargs, _rep, 0 ? _cmd : NULL, _usage, \ _CMD_HELP(_help) _CMD_COMPLETE(_comp) } #define U_BOOT_CMD_COMPLETE(_name, _maxargs, _rep, _cmd, _usage, _help, \ _comp) \ _CMD_REMOVE(sub_ ## _name, _cmd) #endif /* CONFIG_CMDLINE */ |
6c7c946ca common: Convert t... |
205 206 |
#define U_BOOT_CMD(_name, _maxargs, _rep, _cmd, _usage, _help) \ U_BOOT_CMD_COMPLETE(_name, _maxargs, _rep, _cmd, _usage, _help, NULL) |
8bde7f776 * Code cleanup: |
207 |
|
fb24112c1 Allow command cod... |
208 209 210 |
#define U_BOOT_CMD_MKENT(_name, _maxargs, _rep, _cmd, _usage, _help) \ U_BOOT_CMD_MKENT_COMPLETE(_name, _maxargs, _rep, _cmd, \ _usage, _help, NULL) |
78f6622a1 Initial revision |
211 |
#endif /* __COMMAND_H */ |