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#ifndef __COMMAND_H
28#define __COMMAND_H
29
30#include <config.h>
31
32#ifndef NULL
33#define NULL 0
34#endif
35
36
37#ifndef CONFIG_SYS_HELP_CMD_WIDTH
38#define CONFIG_SYS_HELP_CMD_WIDTH 8
39#endif
40
41#ifndef __ASSEMBLY__
42
43
44
45
46struct cmd_tbl_s {
47 char *name;
48 int maxargs;
49 int repeatable;
50
51 int (*cmd)(struct cmd_tbl_s *, int, int, char * const []);
52 char *usage;
53#ifdef CONFIG_SYS_LONGHELP
54 char *help;
55#endif
56#ifdef CONFIG_AUTO_COMPLETE
57
58 int (*complete)(int argc, char * const argv[], char last_char, int maxv, char *cmdv[]);
59#endif
60};
61
62typedef struct cmd_tbl_s cmd_tbl_t;
63
64extern cmd_tbl_t __u_boot_cmd_start;
65extern cmd_tbl_t __u_boot_cmd_end;
66
67#if defined(CONFIG_CMD_RUN)
68extern int do_run(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
69#endif
70
71
72int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int
73 flag, int argc, char * const argv[]);
74cmd_tbl_t *find_cmd(const char *cmd);
75cmd_tbl_t *find_cmd_tbl (const char *cmd, cmd_tbl_t *table, int table_len);
76
77extern int cmd_usage(const cmd_tbl_t *cmdtp);
78
79#ifdef CONFIG_AUTO_COMPLETE
80extern int var_complete(int argc, char * const argv[], char last_char, int maxv, char *cmdv[]);
81extern int cmd_auto_complete(const char *const prompt, char *buf, int *np, int *colp);
82#endif
83
84
85
86
87
88
89
90
91
92#if defined(CONFIG_CMD_MEMORY) \
93 || defined(CONFIG_CMD_I2C) \
94 || defined(CONFIG_CMD_ITEST) \
95 || defined(CONFIG_CMD_PCI) \
96 || defined(CONFIG_CMD_PORTIO)
97#define CMD_DATA_SIZE
98extern int cmd_get_data_size(char* arg, int default_size);
99#endif
100
101#ifdef CONFIG_CMD_BOOTD
102extern int do_bootd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
103#endif
104#ifdef CONFIG_CMD_BOOTM
105extern int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
106extern int bootm_maybe_autostart(cmd_tbl_t *cmdtp, const char *cmd);
107#else
108static inline int bootm_maybe_autostart(cmd_tbl_t *cmdtp, const char *cmd)
109{
110 return 0;
111}
112#endif
113
114extern int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc,
115 char *const argv[]);
116
117extern int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
118
119
120
121
122
123
124
125
126
127enum command_ret_t {
128 CMD_RET_SUCCESS,
129 CMD_RET_FAILURE,
130 CMD_RET_USAGE = -1,
131};
132
133
134
135
136
137
138
139
140
141
142
143
144
145int cmd_process(int flag, int argc, char * const argv[],
146 int *repeatable);
147
148#endif
149
150
151
152
153#define CMD_FLAG_REPEAT 0x0001
154#define CMD_FLAG_BOOTD 0x0002
155
156#define Struct_Section __attribute__((unused, section(".u_boot_cmd"), \
157 aligned(4)))
158
159#ifdef CONFIG_AUTO_COMPLETE
160# define _CMD_COMPLETE(x) x,
161#else
162# define _CMD_COMPLETE(x)
163#endif
164#ifdef CONFIG_SYS_LONGHELP
165# define _CMD_HELP(x) x,
166#else
167# define _CMD_HELP(x)
168#endif
169
170#define U_BOOT_CMD_MKENT_COMPLETE(name,maxargs,rep,cmd,usage,help,comp) \
171 {#name, maxargs, rep, cmd, usage, _CMD_HELP(help) _CMD_COMPLETE(comp)}
172
173#define U_BOOT_CMD_MKENT(name,maxargs,rep,cmd,usage,help) \
174 U_BOOT_CMD_MKENT_COMPLETE(name,maxargs,rep,cmd,usage,help,NULL)
175
176#define U_BOOT_CMD_COMPLETE(name,maxargs,rep,cmd,usage,help,comp) \
177 cmd_tbl_t __u_boot_cmd_##name Struct_Section = \
178 U_BOOT_CMD_MKENT_COMPLETE(name,maxargs,rep,cmd,usage,help,comp)
179
180#define U_BOOT_CMD(name,maxargs,rep,cmd,usage,help) \
181 U_BOOT_CMD_COMPLETE(name,maxargs,rep,cmd,usage,help,NULL)
182
183#if defined(CONFIG_NEEDS_MANUAL_RELOC)
184void fixup_cmdtable(cmd_tbl_t *cmdtp, int size);
185#endif
186
187#endif
188