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
68
69int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int
70 flag, int argc, char * const argv[]);
71cmd_tbl_t *find_cmd(const char *cmd);
72cmd_tbl_t *find_cmd_tbl (const char *cmd, cmd_tbl_t *table, int table_len);
73
74extern int cmd_usage(const cmd_tbl_t *cmdtp);
75
76#ifdef CONFIG_AUTO_COMPLETE
77extern int var_complete(int argc, char * const argv[], char last_char, int maxv, char *cmdv[]);
78extern int cmd_auto_complete(const char *const prompt, char *buf, int *np, int *colp);
79#endif
80
81
82
83
84
85
86
87
88
89#if defined(CONFIG_CMD_MEMORY) \
90 || defined(CONFIG_CMD_I2C) \
91 || defined(CONFIG_CMD_ITEST) \
92 || defined(CONFIG_CMD_PCI) \
93 || defined(CONFIG_CMD_PORTIO)
94#define CMD_DATA_SIZE
95extern int cmd_get_data_size(char* arg, int default_size);
96#endif
97
98#ifdef CONFIG_CMD_BOOTD
99extern int do_bootd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
100#endif
101#ifdef CONFIG_CMD_BOOTM
102extern int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
103extern int bootm_maybe_autostart(cmd_tbl_t *cmdtp, const char *cmd);
104#else
105static inline int bootm_maybe_autostart(cmd_tbl_t *cmdtp, const char *cmd)
106{
107 return 0;
108}
109#endif
110extern int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
111
112#endif
113
114
115
116
117#define CMD_FLAG_REPEAT 0x0001
118#define CMD_FLAG_BOOTD 0x0002
119
120#define Struct_Section __attribute__ ((unused,section (".u_boot_cmd")))
121
122#ifdef CONFIG_AUTO_COMPLETE
123# define _CMD_COMPLETE(x) x,
124#else
125# define _CMD_COMPLETE(x)
126#endif
127#ifdef CONFIG_SYS_LONGHELP
128# define _CMD_HELP(x) x,
129#else
130# define _CMD_HELP(x)
131#endif
132
133#define U_BOOT_CMD_MKENT_COMPLETE(name,maxargs,rep,cmd,usage,help,comp) \
134 {#name, maxargs, rep, cmd, usage, _CMD_HELP(help) _CMD_COMPLETE(comp)}
135
136#define U_BOOT_CMD_MKENT(name,maxargs,rep,cmd,usage,help) \
137 U_BOOT_CMD_MKENT_COMPLETE(name,maxargs,rep,cmd,usage,help,NULL)
138
139#define U_BOOT_CMD_COMPLETE(name,maxargs,rep,cmd,usage,help,comp) \
140 cmd_tbl_t __u_boot_cmd_##name Struct_Section = \
141 U_BOOT_CMD_MKENT_COMPLETE(name,maxargs,rep,cmd,usage,help,comp)
142
143#define U_BOOT_CMD(name,maxargs,rep,cmd,usage,help) \
144 U_BOOT_CMD_COMPLETE(name,maxargs,rep,cmd,usage,help,NULL)
145
146#if defined(CONFIG_NEEDS_MANUAL_RELOC)
147void fixup_cmdtable(cmd_tbl_t *cmdtp, int size);
148#endif
149#endif
150