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