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