xref: /rk3399_rockchip-uboot/include/command.h (revision 2e5167ccad93ca9cfa6a2acfab5e4785418e477e)
178f6622aSwdenk /*
22dce551eSDetlev Zundel  * (C) Copyright 2000-2009
378f6622aSwdenk  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
478f6622aSwdenk  *
578f6622aSwdenk  * See file CREDITS for list of people who contributed to this
678f6622aSwdenk  * project.
778f6622aSwdenk  *
878f6622aSwdenk  * This program is free software; you can redistribute it and/or
978f6622aSwdenk  * modify it under the terms of the GNU General Public License as
1078f6622aSwdenk  * published by the Free Software Foundation; either version 2 of
1178f6622aSwdenk  * the License, or (at your option) any later version.
1278f6622aSwdenk  *
1378f6622aSwdenk  * This program is distributed in the hope that it will be useful,
1478f6622aSwdenk  * but WITHOUT ANY WARRANTY; without even the implied warranty of
1578f6622aSwdenk  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1678f6622aSwdenk  * GNU General Public License for more details.
1778f6622aSwdenk  *
1878f6622aSwdenk  * You should have received a copy of the GNU General Public License
1978f6622aSwdenk  * along with this program; if not, write to the Free Software
2078f6622aSwdenk  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
2178f6622aSwdenk  * MA 02111-1307 USA
2278f6622aSwdenk  */
2378f6622aSwdenk 
2478f6622aSwdenk /*
2578f6622aSwdenk  *  Definitions for Command Processor
2678f6622aSwdenk  */
2778f6622aSwdenk #ifndef __COMMAND_H
2878f6622aSwdenk #define __COMMAND_H
2978f6622aSwdenk 
30f2302d44SStefan Roese #include <config.h>
31f2302d44SStefan Roese 
3278f6622aSwdenk #ifndef NULL
3378f6622aSwdenk #define NULL	0
3478f6622aSwdenk #endif
3578f6622aSwdenk 
362fb2604dSPeter Tyser /* Default to a width of 8 characters for help message command width */
372fb2604dSPeter Tyser #ifndef CONFIG_SYS_HELP_CMD_WIDTH
382fb2604dSPeter Tyser #define CONFIG_SYS_HELP_CMD_WIDTH	8
392fb2604dSPeter Tyser #endif
402fb2604dSPeter Tyser 
4178f6622aSwdenk #ifndef	__ASSEMBLY__
4278f6622aSwdenk /*
4378f6622aSwdenk  * Monitor Command Table
4478f6622aSwdenk  */
4578f6622aSwdenk 
4678f6622aSwdenk struct cmd_tbl_s {
4778f6622aSwdenk 	char		*name;		/* Command Name			*/
4878f6622aSwdenk 	int		maxargs;	/* maximum number of arguments	*/
4978f6622aSwdenk 	int		repeatable;	/* autorepeat allowed?		*/
5078f6622aSwdenk 					/* Implementation function	*/
5154841ab5SWolfgang Denk 	int		(*cmd)(struct cmd_tbl_s *, int, int, char * const []);
5278f6622aSwdenk 	char		*usage;		/* Usage message	(short)	*/
536d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #ifdef	CONFIG_SYS_LONGHELP
5478f6622aSwdenk 	char		*help;		/* Help  message	(long)	*/
5578f6622aSwdenk #endif
5604a85b3bSwdenk #ifdef CONFIG_AUTO_COMPLETE
5704a85b3bSwdenk 	/* do auto completion on the arguments */
5854841ab5SWolfgang Denk 	int		(*complete)(int argc, char * const argv[], char last_char, int maxv, char *cmdv[]);
5904a85b3bSwdenk #endif
6078f6622aSwdenk };
6178f6622aSwdenk 
6278f6622aSwdenk typedef struct cmd_tbl_s	cmd_tbl_t;
6378f6622aSwdenk 
648bde7f77Swdenk extern cmd_tbl_t  __u_boot_cmd_start;
658bde7f77Swdenk extern cmd_tbl_t  __u_boot_cmd_end;
6678f6622aSwdenk 
6778f6622aSwdenk 
6878f6622aSwdenk /* common/command.c */
692dce551eSDetlev Zundel int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int
7054841ab5SWolfgang Denk 	      flag, int argc, char * const argv[]);
7178f6622aSwdenk cmd_tbl_t *find_cmd(const char *cmd);
72b799cb4cSKumar Gala cmd_tbl_t *find_cmd_tbl (const char *cmd, cmd_tbl_t *table, int table_len);
7378f6622aSwdenk 
7494796d85SWolfgang Denk extern int cmd_usage(cmd_tbl_t *cmdtp);
7562c3ae7cSPeter Tyser 
7604a85b3bSwdenk #ifdef CONFIG_AUTO_COMPLETE
7704a85b3bSwdenk extern void install_auto_complete(void);
7804a85b3bSwdenk extern int cmd_auto_complete(const char *const prompt, char *buf, int *np, int *colp);
7904a85b3bSwdenk #endif
8004a85b3bSwdenk 
8178f6622aSwdenk /*
8278f6622aSwdenk  * Monitor Command
8378f6622aSwdenk  *
8478f6622aSwdenk  * All commands use a common argument format:
8578f6622aSwdenk  *
8654841ab5SWolfgang Denk  * void function (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
8778f6622aSwdenk  */
8878f6622aSwdenk 
8978f6622aSwdenk typedef	void	command_t (cmd_tbl_t *, int, int, char *[]);
9078f6622aSwdenk 
918a40fb14SJean-Christophe PLAGNIOL-VILLARD #if defined(CONFIG_CMD_MEMORY)		\
928a40fb14SJean-Christophe PLAGNIOL-VILLARD     || defined(CONFIG_CMD_I2C)		\
938a40fb14SJean-Christophe PLAGNIOL-VILLARD     || defined(CONFIG_CMD_ITEST)	\
948a40fb14SJean-Christophe PLAGNIOL-VILLARD     || defined(CONFIG_CMD_PCI)		\
958a40fb14SJean-Christophe PLAGNIOL-VILLARD     || defined(CONFIG_CMD_PORTIO)
968a40fb14SJean-Christophe PLAGNIOL-VILLARD #define CMD_DATA_SIZE
978a40fb14SJean-Christophe PLAGNIOL-VILLARD extern int cmd_get_data_size(char* arg, int default_size);
988a40fb14SJean-Christophe PLAGNIOL-VILLARD #endif
998a40fb14SJean-Christophe PLAGNIOL-VILLARD 
10078f6622aSwdenk #endif	/* __ASSEMBLY__ */
10178f6622aSwdenk 
10278f6622aSwdenk /*
10378f6622aSwdenk  * Command Flags:
10478f6622aSwdenk  */
10578f6622aSwdenk #define CMD_FLAG_REPEAT		0x0001	/* repeat last command		*/
10678f6622aSwdenk #define CMD_FLAG_BOOTD		0x0002	/* command is from bootd	*/
10778f6622aSwdenk 
1088bde7f77Swdenk #define Struct_Section  __attribute__ ((unused,section (".u_boot_cmd")))
1098bde7f77Swdenk 
1106d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #ifdef  CONFIG_SYS_LONGHELP
1118bde7f77Swdenk 
1120d498393Swdenk #define U_BOOT_CMD(name,maxargs,rep,cmd,usage,help) \
1130d498393Swdenk cmd_tbl_t __u_boot_cmd_##name Struct_Section = {#name, maxargs, rep, cmd, usage, help}
1148bde7f77Swdenk 
115b799cb4cSKumar Gala #define U_BOOT_CMD_MKENT(name,maxargs,rep,cmd,usage,help) \
116b799cb4cSKumar Gala {#name, maxargs, rep, cmd, usage, help}
117b799cb4cSKumar Gala 
1188bde7f77Swdenk #else	/* no long help info */
1198bde7f77Swdenk 
1200d498393Swdenk #define U_BOOT_CMD(name,maxargs,rep,cmd,usage,help) \
1210d498393Swdenk cmd_tbl_t __u_boot_cmd_##name Struct_Section = {#name, maxargs, rep, cmd, usage}
1228bde7f77Swdenk 
123b799cb4cSKumar Gala #define U_BOOT_CMD_MKENT(name,maxargs,rep,cmd,usage,help) \
124b799cb4cSKumar Gala {#name, maxargs, rep, cmd, usage}
125b799cb4cSKumar Gala 
1266d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #endif	/* CONFIG_SYS_LONGHELP */
1278bde7f77Swdenk 
128*2e5167ccSWolfgang Denk #if defined(CONFIG_NEEDS_MANUAL_RELOC)
129620f1f6aSHeiko Schocher void fixup_cmdtable(cmd_tbl_t *cmdtp, int size);
130620f1f6aSHeiko Schocher #endif
13178f6622aSwdenk #endif	/* __COMMAND_H */
132