Blame view
include/command.h
5.11 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 |
f2302d443 Fix merge problems |
13 |
#include <config.h> |
6c7c946ca common: Convert t... |
14 |
#include <linker_lists.h> |
f2302d443 Fix merge problems |
15 |
|
78f6622a1 Initial revision |
16 17 18 |
#ifndef NULL #define NULL 0 #endif |
2fb2604d5 Command usage cle... |
19 20 21 22 |
/* 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 |
23 24 25 26 27 28 29 |
#ifndef __ASSEMBLY__ /* * Monitor Command Table */ struct cmd_tbl_s { char *name; /* Command Name */ |
78f6622a1 Initial revision |
30 31 32 |
int maxargs; /* maximum number of arguments */ int repeatable; /* autorepeat allowed? */ /* Implementation function */ |
54841ab50 Make sure that ar... |
33 |
int (*cmd)(struct cmd_tbl_s *, int, int, char * const []); |
78f6622a1 Initial revision |
34 |
char *usage; /* Usage message (short) */ |
6d0f6bcf3 rename CFG_ macro... |
35 |
#ifdef CONFIG_SYS_LONGHELP |
78f6622a1 Initial revision |
36 37 |
char *help; /* Help message (long) */ #endif |
04a85b3b3 * Patches by Pant... |
38 39 |
#ifdef CONFIG_AUTO_COMPLETE /* do auto completion on the arguments */ |
54841ab50 Make sure that ar... |
40 |
int (*complete)(int argc, char * const argv[], char last_char, int maxv, char *cmdv[]); |
04a85b3b3 * Patches by Pant... |
41 |
#endif |
78f6622a1 Initial revision |
42 43 44 |
}; typedef struct cmd_tbl_s cmd_tbl_t; |
78f6622a1 Initial revision |
45 |
|
d09b1787a env: clean cmd_nv... |
46 47 48 |
#if defined(CONFIG_CMD_RUN) extern int do_run(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); #endif |
78f6622a1 Initial revision |
49 50 |
/* common/command.c */ |
2dce551e1 command.c: Expose... |
51 |
int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int |
54841ab50 Make sure that ar... |
52 |
flag, int argc, char * const argv[]); |
78f6622a1 Initial revision |
53 |
cmd_tbl_t *find_cmd(const char *cmd); |
b799cb4c0 Expose command ta... |
54 |
cmd_tbl_t *find_cmd_tbl (const char *cmd, cmd_tbl_t *table, int table_len); |
78f6622a1 Initial revision |
55 |
|
e84ffddbc cmd_usage: constify |
56 |
extern int cmd_usage(const cmd_tbl_t *cmdtp); |
62c3ae7c6 Standardize comma... |
57 |
|
04a85b3b3 * Patches by Pant... |
58 |
#ifdef CONFIG_AUTO_COMPLETE |
722b061b6 autocomplete: rem... |
59 |
extern int var_complete(int argc, char * const argv[], char last_char, int maxv, char *cmdv[]); |
04a85b3b3 * Patches by Pant... |
60 61 |
extern int cmd_auto_complete(const char *const prompt, char *buf, int *np, int *colp); #endif |
78f6622a1 Initial revision |
62 63 64 65 66 |
/* * Monitor Command * * All commands use a common argument format: * |
54841ab50 Make sure that ar... |
67 |
* void function (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); |
78f6622a1 Initial revision |
68 |
*/ |
8a40fb148 move cmd_get_data... |
69 |
#if defined(CONFIG_CMD_MEMORY) \ |
9ad557be2 Add console comma... |
70 71 72 73 |
|| defined(CONFIG_CMD_I2C) \ || defined(CONFIG_CMD_ITEST) \ || defined(CONFIG_CMD_PCI) \ || defined(CONFIG_CMD_PORTIO) |
8a40fb148 move cmd_get_data... |
74 75 76 |
#define CMD_DATA_SIZE extern int cmd_get_data_size(char* arg, int default_size); #endif |
7842fb7c4 do_bootd: unify d... |
77 78 79 |
#ifdef CONFIG_CMD_BOOTD extern int do_bootd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); #endif |
67d668bf9 autostart: unify ... |
80 |
#ifdef CONFIG_CMD_BOOTM |
36ebb7877 do_bootm: unify d... |
81 |
extern int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); |
67d668bf9 autostart: unify ... |
82 83 84 85 86 87 88 |
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... |
89 |
|
da620222f bootz: un-statici... |
90 |
extern int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); |
7405a1331 combine block dev... |
91 92 |
extern int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc, char *const argv[]); |
882b7d726 do_reset: unify d... |
93 |
extern int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); |
36ebb7877 do_bootm: unify d... |
94 |
|
9d12d5d41 Add cmd_process()... |
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
/* * 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... |
119 120 |
* @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()... |
121 122 123 |
* @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... |
124 |
int *repeatable, unsigned long *ticks); |
bdf8e34b9 Create a single c... |
125 |
|
78f6622a1 Initial revision |
126 127 128 129 130 131 132 |
#endif /* __ASSEMBLY__ */ /* * Command Flags: */ #define CMD_FLAG_REPEAT 0x0001 /* repeat last command */ #define CMD_FLAG_BOOTD 0x0002 /* command is from bootd */ |
722b061b6 autocomplete: rem... |
133 134 135 136 137 138 139 140 141 142 |
#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: |
143 |
|
6c7c946ca common: Convert t... |
144 145 146 147 |
#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: |
148 |
|
6c7c946ca common: Convert t... |
149 150 151 |
#define U_BOOT_CMD_MKENT(_name, _maxargs, _rep, _cmd, _usage, _help) \ U_BOOT_CMD_MKENT_COMPLETE(_name, _maxargs, _rep, _cmd, \ _usage, _help, NULL) |
b799cb4c0 Expose command ta... |
152 |
|
6c7c946ca common: Convert t... |
153 |
#define U_BOOT_CMD_COMPLETE(_name, _maxargs, _rep, _cmd, _usage, _help, _comp) \ |
ef123c525 Refactor linker-g... |
154 |
ll_entry_declare(cmd_tbl_t, _name, cmd) = \ |
6c7c946ca common: Convert t... |
155 156 |
U_BOOT_CMD_MKENT_COMPLETE(_name, _maxargs, _rep, _cmd, \ _usage, _help, _comp); |
8bde7f776 * Code cleanup: |
157 |
|
6c7c946ca common: Convert t... |
158 159 |
#define U_BOOT_CMD(_name, _maxargs, _rep, _cmd, _usage, _help) \ U_BOOT_CMD_COMPLETE(_name, _maxargs, _rep, _cmd, _usage, _help, NULL) |
8bde7f776 * Code cleanup: |
160 |
|
2e5167cca Replace CONFIG_RE... |
161 |
#if defined(CONFIG_NEEDS_MANUAL_RELOC) |
620f1f6a6 relocation: fixup... |
162 163 |
void fixup_cmdtable(cmd_tbl_t *cmdtp, int size); #endif |
bdf8e34b9 Create a single c... |
164 |
|
78f6622a1 Initial revision |
165 |
#endif /* __COMMAND_H */ |