command.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. * Definitions for Command Processor
  25. */
  26. #ifndef __COMMAND_H
  27. #define __COMMAND_H
  28. #include <config.h>
  29. #ifndef NULL
  30. #define NULL 0
  31. #endif
  32. #ifndef __ASSEMBLY__
  33. /*
  34. * Monitor Command Table
  35. */
  36. struct cmd_tbl_s {
  37. char *name; /* Command Name */
  38. int maxargs; /* maximum number of arguments */
  39. int repeatable; /* autorepeat allowed? */
  40. /* Implementation function */
  41. int (*cmd)(struct cmd_tbl_s *, int, int, char *[]);
  42. char *usage; /* Usage message (short) */
  43. #ifdef CFG_LONGHELP
  44. char *help; /* Help message (long) */
  45. #endif
  46. #ifdef CONFIG_AUTO_COMPLETE
  47. /* do auto completion on the arguments */
  48. int (*complete)(int argc, char *argv[], char last_char, int maxv, char *cmdv[]);
  49. #endif
  50. };
  51. typedef struct cmd_tbl_s cmd_tbl_t;
  52. extern cmd_tbl_t __u_boot_cmd_start;
  53. extern cmd_tbl_t __u_boot_cmd_end;
  54. /* common/command.c */
  55. cmd_tbl_t *find_cmd(const char *cmd);
  56. #ifdef CONFIG_AUTO_COMPLETE
  57. extern void install_auto_complete(void);
  58. extern int cmd_auto_complete(const char *const prompt, char *buf, int *np, int *colp);
  59. #endif
  60. /*
  61. * Monitor Command
  62. *
  63. * All commands use a common argument format:
  64. *
  65. * void function (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
  66. */
  67. typedef void command_t (cmd_tbl_t *, int, int, char *[]);
  68. #if defined(CONFIG_CMD_MEMORY) \
  69. || defined(CONFIG_CMD_I2C) \
  70. || defined(CONFIG_CMD_ITEST) \
  71. || defined(CONFIG_CMD_PCI) \
  72. || defined(CONFIG_CMD_PORTIO)
  73. #define CMD_DATA_SIZE
  74. extern int cmd_get_data_size(char* arg, int default_size);
  75. #endif
  76. #endif /* __ASSEMBLY__ */
  77. /*
  78. * Command Flags:
  79. */
  80. #define CMD_FLAG_REPEAT 0x0001 /* repeat last command */
  81. #define CMD_FLAG_BOOTD 0x0002 /* command is from bootd */
  82. #define Struct_Section __attribute__ ((unused,section (".u_boot_cmd")))
  83. #ifdef CFG_LONGHELP
  84. #define U_BOOT_CMD(name,maxargs,rep,cmd,usage,help) \
  85. cmd_tbl_t __u_boot_cmd_##name Struct_Section = {#name, maxargs, rep, cmd, usage, help}
  86. #else /* no long help info */
  87. #define U_BOOT_CMD(name,maxargs,rep,cmd,usage,help) \
  88. cmd_tbl_t __u_boot_cmd_##name Struct_Section = {#name, maxargs, rep, cmd, usage}
  89. #endif /* CFG_LONGHELP */
  90. #endif /* __COMMAND_H */