blob: f70cad8cbc16c7a72d116b51a110dcaf55c4a918 [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>
wdenkeb9401e2002-11-11 02:11:37 +000049#include <cmd_spi.h>
wdenk5dfa25f2002-10-19 19:42:10 +000050#include <cmd_immap.h>
51#include <cmd_rtc.h>
52
53#include <cmd_elf.h>
54#include <cmd_fdc.h> /* Floppy support */
55#include <cmd_usb.h> /* USB support */
56#include <cmd_scsi.h>
57#include <cmd_pci.h>
58#include <cmd_mii.h>
59#include <cmd_dcr.h> /* 4xx DCR register access */
60#include <cmd_doc.h>
61#include <cmd_jffs2.h>
62#include <cmd_fpga.h>
63
64#include <cmd_bsp.h> /* board special functions */
65
66#include <cmd_bedbug.h>
67#include <cmd_elf.h>
68
69#include <cmd_dtt.h>
70
71#include <cmd_vfd.h> /* load a bitmap to the VFDs on TRAB */
wdenk56f94be2002-11-05 16:35:14 +000072#include <cmd_log.h>
wdenk5dfa25f2002-10-19 19:42:10 +000073
74/*
75 * HELP command
76 */
77#define CMD_TBL_HELP MK_CMD_TBL_ENTRY( \
78 "help", 1, CFG_MAXARGS, 1, do_help, \
79 "help - print online help\n", \
80 "[command ...]\n" \
81 " - show help information (for 'command')\n" \
82 "'help' prints online help for the monitor commands.\n\n" \
83 "Without arguments, it prints a short usage message for all commands.\n\n" \
84 "To get detailed help information for specific commands you can type\n" \
85 "'help' with one or more command names as arguments.\n" \
86 ),
87
88#define CMD_TBL_QUES MK_CMD_TBL_ENTRY( \
89 "?", 1, CFG_MAXARGS, 1, do_help, \
90 "? - alias for 'help'\n", \
91 NULL \
92 ),
93
94#define CMD_TBL_VERS MK_CMD_TBL_ENTRY( \
95 "version", 4, 1, 1, do_version, \
96 "version - print monitor version\n", \
97 NULL \
98 ),
99
100#define CMD_TBL_ECHO MK_CMD_TBL_ENTRY( \
101 "echo", 4, CFG_MAXARGS, 1, do_echo, \
102 "echo - echo args to console\n", \
103 "[args..]\n" \
104 " - echo args to console; \\c suppresses newline\n" \
105 ),
106
107int
108do_version (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
109{
110 extern char version_string[];
111 printf ("\n%s\n", version_string);
112 return 0;
113}
114
115int
116do_echo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
117{
118 int i, putnl = 1;
119
120 for (i = 1; i < argc; i++) {
121 char *p = argv[i], c;
122
123 if (i > 1)
124 putc(' ');
125 while ((c = *p++) != '\0')
126 if (c == '\\' && *p == 'c') {
127 putnl = 0;
128 p++;
129 }
130 else
131 putc(c);
132 }
133
134 if (putnl)
135 putc('\n');
136 return 0;
137}
138
139/*
140 * Use puts() instead of printf() to avoid printf buffer overflow
141 * for long help messages
142 */
143int
144do_help (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
145{
146 int i;
147 int rcode = 0;
148
149 if (argc == 1) { /* print short help (usage) */
150
151 for (cmdtp=&cmd_tbl[0]; cmdtp->name; cmdtp++) {
152 /* allow user abort */
153 if (ctrlc())
154 return 1;
155
156 if (cmdtp->usage == NULL)
157 continue;
158 puts (cmdtp->usage);
159 }
160
161 return 0;
162 }
163
164 /*
165 * command help (long version)
166 */
167 for (i=1; i<argc; ++i) {
168 if ((cmdtp = find_cmd(argv[i])) != NULL) {
169#ifdef CFG_LONGHELP
170 /* found - print (long) help info */
171 puts (cmdtp->name);
172 putc (' ');
173 if (cmdtp->help) {
174 puts (cmdtp->help);
175 } else {
176 puts ("- No help available.\n");
177 rcode = 1;
178 }
179 putc ('\n');
180#else /* no long help available */
181 if (cmdtp->usage)
182 puts (cmdtp->usage);
183#endif /* CFG_LONGHELP */
184 }
185 else {
186 printf ("Unknown command '%s' - try 'help'"
187 " without arguments for list of all"
188 " known commands\n\n",
189 argv[i]
190 );
191 rcode = 1;
192 }
193 }
194 return rcode;
195}
196
197/***************************************************************************
198 * find command table entry for a command
199 */
200cmd_tbl_t *find_cmd(const char *cmd)
201{
202 cmd_tbl_t *cmdtp;
203
204 /* Search command table - Use linear search - it's a small table */
205 for (cmdtp = &cmd_tbl[0]; cmdtp->name; cmdtp++) {
206 if (strncmp (cmd, cmdtp->name, cmdtp->lmin) == 0)
207 return cmdtp;
208 }
209 return NULL; /* not found */
210}
211
212/*
213 * The commands in this table are sorted alphabetically by the
214 * command name and in descending order by the command name string
215 * length. This is to prevent conflicts in command name parsing.
216 * Please ensure that new commands are added according to that rule.
217 * Please use $(TOPDIR)/doc/README.commands as a reference AND make
218 * sure it gets updated.
219 */
220
221cmd_tbl_t cmd_tbl[] = {
222 CMD_TBL_ASKENV
223 CMD_TBL_ASM
224 CMD_TBL_AUTOSCRIPT
225 CMD_TBL_BASE
226 CMD_TBL_BDINFO
227 CMD_TBL_BOOTELF
228 CMD_TBL_BOOTM
229 CMD_TBL_BOOTP
230 CMD_TBL_BOOTVX
231 CMD_TBL_BOOTD
232 CMD_TBL_BREAK
233 CMD_TBL_BRGINFO
234 CMD_TBL_CARINFO
235 CMD_TBL_JFFS2_CHPART
236 CMD_TBL_CMP
237 CMD_TBL_CONINFO
238 CMD_TBL_CONTINUE
239 CMD_TBL_CP
240 CMD_TBL_CRC
241 CMD_TBL_DATE
242 CMD_TBL_DCACHE
243 CMD_TBL_DHCP
244 CMD_TBL_DIAG
245 CMD_TBL_DISK
246 CMD_TBL_DMAINFO
247 CMD_TBL_DIS
248 CMD_TBL_DOCBOOT
249 CMD_TBL_DOC
250 CMD_TBL_DTT
251 CMD_TBL_ECHO
252 CMD_TBL_EEPROM
253 CMD_TBL_FCCINFO
254 CMD_TBL_FLERASE
255 CMD_TBL_FDC
256 CMD_TBL_FLINFO
257 CMD_TBL_FPGA
258 CMD_TBL_JFFS2_FSINFO
259 CMD_TBL_JFFS2_FSLOAD
260 CMD_TBL_GETDCR
261 CMD_TBL_GO
262 CMD_TBL_HELP
263 CMD_TBL_HWFLOW
264 CMD_TBL_I2CINFO
265 CMD_TBL_ICACHE
266#ifdef CONFIG_8260
267 CMD_TBL_ICINFO
268#endif
269 CMD_TBL_IMD
270 CMD_TBL_IMM
271 CMD_TBL_INM
272 CMD_TBL_IMW
273 CMD_TBL_ICRC
274 CMD_TBL_IPROBE
275 CMD_TBL_ILOOP
276 CMD_TBL_ISDRAM
277 CMD_TBL_IDE
278 CMD_TBL_IMINFO
279 CMD_TBL_IOPINFO
280 CMD_TBL_IOPSET
281 CMD_TBL_IRQINFO
282 CMD_TBL_KGDB
283 CMD_TBL_LOADB
284 CMD_TBL_LOADS
wdenk56f94be2002-11-05 16:35:14 +0000285 CMD_TBL_LOG
wdenk5dfa25f2002-10-19 19:42:10 +0000286 CMD_TBL_LOOP
287 CMD_TBL_JFFS2_LS
288 CMD_TBL_MCCINFO
289 CMD_TBL_MD
290 CMD_TBL_MEMCINFO
291 CMD_TBL_MII
292 CMD_TBL_MM
293 CMD_TBL_MTEST
294 CMD_TBL_MUXINFO
295 CMD_TBL_MW
296 CMD_TBL_NEXT
297 CMD_TBL_NM
298 CMD_TBL_PCI
299 CMD_TBL_PRINTENV
300 CMD_TBL_PROTECT
301 CMD_TBL_RARPB
302 CMD_TBL_RDUMP
303 CMD_TBL_PINIT
304 CMD_TBL_REGINFO
305 CMD_TBL_RESET
306 CMD_TBL_RUN
307 CMD_TBL_SAVEENV
308 CMD_TBL_SAVES
309 CMD_TBL_SCCINFO
310 CMD_TBL_SCSIBOOT
311 CMD_TBL_SCSI
312 CMD_TBL_SETDCR
313 CMD_TBL_SETENV
314 CMD_TBL_SIINFO
315 CMD_TBL_SITINFO
316 CMD_TBL_SIUINFO
317 CMD_TBL_MISC /* sleep */
318 CMD_TBL_SMCINFO
319 CMD_TBL_SPIINFO
wdenkeb9401e2002-11-11 02:11:37 +0000320 CMD_TBL_SPI
wdenk5dfa25f2002-10-19 19:42:10 +0000321 CMD_TBL_STACK
322 CMD_TBL_STEP
323 CMD_TBL_TFTPB
324 CMD_TBL_USBBOOT
325 CMD_TBL_USB
326 CMD_TBL_VERS
327 CMD_TBL_BSP
328 CMD_TBL_VFD
329 CMD_TBL_QUES /* keep this ("help") the last entry */
330 /* the following entry terminates this table */
331 MK_CMD_TBL_ENTRY( NULL, 0, 0, 0, NULL, NULL, NULL )
332};