blob: 2f50e6d1f8193f4a8ab06dc462c8107b9837f818 [file] [log] [blame]
wdenk5dfa25f2002-10-19 19:42:10 +00001/*
2 * (C) Copyright 2000
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24/*
25 * Command Processor Table
26 */
27
28#include <common.h>
29#include <command.h>
30#include <cmd_cache.h>
31#include <cmd_mem.h>
32#include <cmd_boot.h>
33#include <cmd_flash.h>
34#include <cmd_bootm.h>
35#include <cmd_net.h>
36#include <cmd_nvedit.h>
37#include <cmd_misc.h>
38#include <cmd_kgdb.h>
39#include <cmd_ide.h>
40#include <cmd_disk.h>
41#include <cmd_console.h>
42#include <cmd_reginfo.h>
43#include <cmd_pcmcia.h>
44#include <cmd_autoscript.h>
45#include <cmd_diag.h>
46
47#include <cmd_eeprom.h>
48#include <cmd_i2c.h>
49#include <cmd_immap.h>
50#include <cmd_rtc.h>
51
52#include <cmd_elf.h>
53#include <cmd_fdc.h> /* Floppy support */
54#include <cmd_usb.h> /* USB support */
55#include <cmd_scsi.h>
56#include <cmd_pci.h>
57#include <cmd_mii.h>
58#include <cmd_dcr.h> /* 4xx DCR register access */
59#include <cmd_doc.h>
60#include <cmd_jffs2.h>
61#include <cmd_fpga.h>
62
63#include <cmd_bsp.h> /* board special functions */
64
65#include <cmd_bedbug.h>
66#include <cmd_elf.h>
67
68#include <cmd_dtt.h>
69
70#include <cmd_vfd.h> /* load a bitmap to the VFDs on TRAB */
71
72/*
73 * HELP command
74 */
75#define CMD_TBL_HELP MK_CMD_TBL_ENTRY( \
76 "help", 1, CFG_MAXARGS, 1, do_help, \
77 "help - print online help\n", \
78 "[command ...]\n" \
79 " - show help information (for 'command')\n" \
80 "'help' prints online help for the monitor commands.\n\n" \
81 "Without arguments, it prints a short usage message for all commands.\n\n" \
82 "To get detailed help information for specific commands you can type\n" \
83 "'help' with one or more command names as arguments.\n" \
84 ),
85
86#define CMD_TBL_QUES MK_CMD_TBL_ENTRY( \
87 "?", 1, CFG_MAXARGS, 1, do_help, \
88 "? - alias for 'help'\n", \
89 NULL \
90 ),
91
92#define CMD_TBL_VERS MK_CMD_TBL_ENTRY( \
93 "version", 4, 1, 1, do_version, \
94 "version - print monitor version\n", \
95 NULL \
96 ),
97
98#define CMD_TBL_ECHO MK_CMD_TBL_ENTRY( \
99 "echo", 4, CFG_MAXARGS, 1, do_echo, \
100 "echo - echo args to console\n", \
101 "[args..]\n" \
102 " - echo args to console; \\c suppresses newline\n" \
103 ),
104
105int
106do_version (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
107{
108 extern char version_string[];
109 printf ("\n%s\n", version_string);
110 return 0;
111}
112
113int
114do_echo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
115{
116 int i, putnl = 1;
117
118 for (i = 1; i < argc; i++) {
119 char *p = argv[i], c;
120
121 if (i > 1)
122 putc(' ');
123 while ((c = *p++) != '\0')
124 if (c == '\\' && *p == 'c') {
125 putnl = 0;
126 p++;
127 }
128 else
129 putc(c);
130 }
131
132 if (putnl)
133 putc('\n');
134 return 0;
135}
136
137/*
138 * Use puts() instead of printf() to avoid printf buffer overflow
139 * for long help messages
140 */
141int
142do_help (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
143{
144 int i;
145 int rcode = 0;
146
147 if (argc == 1) { /* print short help (usage) */
148
149 for (cmdtp=&cmd_tbl[0]; cmdtp->name; cmdtp++) {
150 /* allow user abort */
151 if (ctrlc())
152 return 1;
153
154 if (cmdtp->usage == NULL)
155 continue;
156 puts (cmdtp->usage);
157 }
158
159 return 0;
160 }
161
162 /*
163 * command help (long version)
164 */
165 for (i=1; i<argc; ++i) {
166 if ((cmdtp = find_cmd(argv[i])) != NULL) {
167#ifdef CFG_LONGHELP
168 /* found - print (long) help info */
169 puts (cmdtp->name);
170 putc (' ');
171 if (cmdtp->help) {
172 puts (cmdtp->help);
173 } else {
174 puts ("- No help available.\n");
175 rcode = 1;
176 }
177 putc ('\n');
178#else /* no long help available */
179 if (cmdtp->usage)
180 puts (cmdtp->usage);
181#endif /* CFG_LONGHELP */
182 }
183 else {
184 printf ("Unknown command '%s' - try 'help'"
185 " without arguments for list of all"
186 " known commands\n\n",
187 argv[i]
188 );
189 rcode = 1;
190 }
191 }
192 return rcode;
193}
194
195/***************************************************************************
196 * find command table entry for a command
197 */
198cmd_tbl_t *find_cmd(const char *cmd)
199{
200 cmd_tbl_t *cmdtp;
201
202 /* Search command table - Use linear search - it's a small table */
203 for (cmdtp = &cmd_tbl[0]; cmdtp->name; cmdtp++) {
204 if (strncmp (cmd, cmdtp->name, cmdtp->lmin) == 0)
205 return cmdtp;
206 }
207 return NULL; /* not found */
208}
209
210/*
211 * The commands in this table are sorted alphabetically by the
212 * command name and in descending order by the command name string
213 * length. This is to prevent conflicts in command name parsing.
214 * Please ensure that new commands are added according to that rule.
215 * Please use $(TOPDIR)/doc/README.commands as a reference AND make
216 * sure it gets updated.
217 */
218
219cmd_tbl_t cmd_tbl[] = {
220 CMD_TBL_ASKENV
221 CMD_TBL_ASM
222 CMD_TBL_AUTOSCRIPT
223 CMD_TBL_BASE
224 CMD_TBL_BDINFO
225 CMD_TBL_BOOTELF
226 CMD_TBL_BOOTM
227 CMD_TBL_BOOTP
228 CMD_TBL_BOOTVX
229 CMD_TBL_BOOTD
230 CMD_TBL_BREAK
231 CMD_TBL_BRGINFO
232 CMD_TBL_CARINFO
233 CMD_TBL_JFFS2_CHPART
234 CMD_TBL_CMP
235 CMD_TBL_CONINFO
236 CMD_TBL_CONTINUE
237 CMD_TBL_CP
238 CMD_TBL_CRC
239 CMD_TBL_DATE
240 CMD_TBL_DCACHE
241 CMD_TBL_DHCP
242 CMD_TBL_DIAG
243 CMD_TBL_DISK
244 CMD_TBL_DMAINFO
245 CMD_TBL_DIS
246 CMD_TBL_DOCBOOT
247 CMD_TBL_DOC
248 CMD_TBL_DTT
249 CMD_TBL_ECHO
250 CMD_TBL_EEPROM
251 CMD_TBL_FCCINFO
252 CMD_TBL_FLERASE
253 CMD_TBL_FDC
254 CMD_TBL_FLINFO
255 CMD_TBL_FPGA
256 CMD_TBL_JFFS2_FSINFO
257 CMD_TBL_JFFS2_FSLOAD
258 CMD_TBL_GETDCR
259 CMD_TBL_GO
260 CMD_TBL_HELP
261 CMD_TBL_HWFLOW
262 CMD_TBL_I2CINFO
263 CMD_TBL_ICACHE
264#ifdef CONFIG_8260
265 CMD_TBL_ICINFO
266#endif
267 CMD_TBL_IMD
268 CMD_TBL_IMM
269 CMD_TBL_INM
270 CMD_TBL_IMW
271 CMD_TBL_ICRC
272 CMD_TBL_IPROBE
273 CMD_TBL_ILOOP
274 CMD_TBL_ISDRAM
275 CMD_TBL_IDE
276 CMD_TBL_IMINFO
277 CMD_TBL_IOPINFO
278 CMD_TBL_IOPSET
279 CMD_TBL_IRQINFO
280 CMD_TBL_KGDB
281 CMD_TBL_LOADB
282 CMD_TBL_LOADS
283 CMD_TBL_LOOP
284 CMD_TBL_JFFS2_LS
285 CMD_TBL_MCCINFO
286 CMD_TBL_MD
287 CMD_TBL_MEMCINFO
288 CMD_TBL_MII
289 CMD_TBL_MM
290 CMD_TBL_MTEST
291 CMD_TBL_MUXINFO
292 CMD_TBL_MW
293 CMD_TBL_NEXT
294 CMD_TBL_NM
295 CMD_TBL_PCI
296 CMD_TBL_PRINTENV
297 CMD_TBL_PROTECT
298 CMD_TBL_RARPB
299 CMD_TBL_RDUMP
300 CMD_TBL_PINIT
301 CMD_TBL_REGINFO
302 CMD_TBL_RESET
303 CMD_TBL_RUN
304 CMD_TBL_SAVEENV
305 CMD_TBL_SAVES
306 CMD_TBL_SCCINFO
307 CMD_TBL_SCSIBOOT
308 CMD_TBL_SCSI
309 CMD_TBL_SETDCR
310 CMD_TBL_SETENV
311 CMD_TBL_SIINFO
312 CMD_TBL_SITINFO
313 CMD_TBL_SIUINFO
314 CMD_TBL_MISC /* sleep */
315 CMD_TBL_SMCINFO
316 CMD_TBL_SPIINFO
317 CMD_TBL_STACK
318 CMD_TBL_STEP
319 CMD_TBL_TFTPB
320 CMD_TBL_USBBOOT
321 CMD_TBL_USB
322 CMD_TBL_VERS
323 CMD_TBL_BSP
324 CMD_TBL_VFD
325 CMD_TBL_QUES /* keep this ("help") the last entry */
326 /* the following entry terminates this table */
327 MK_CMD_TBL_ENTRY( NULL, 0, 0, 0, NULL, NULL, NULL )
328};