]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - include/command.h
Merge branch 'master' of git://www.denx.de/git/u-boot-mpc85xx
[karo-tx-uboot.git] / include / command.h
index f1accd0953ecf89785bf9fa3a9e10dd7fb527b6d..10bc2606c717f600de2af73e9857c4926ccd510e 100644 (file)
@@ -28,6 +28,7 @@
 #define __COMMAND_H
 
 #include <config.h>
+#include <linker_lists.h>
 
 #ifndef NULL
 #define NULL   0
@@ -61,9 +62,10 @@ struct cmd_tbl_s {
 
 typedef struct cmd_tbl_s       cmd_tbl_t;
 
-extern cmd_tbl_t  __u_boot_cmd_start;
-extern cmd_tbl_t  __u_boot_cmd_end;
 
+#if defined(CONFIG_CMD_RUN)
+extern int do_run(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
+#endif
 
 /* common/command.c */
 int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int
@@ -107,8 +109,41 @@ static inline int bootm_maybe_autostart(cmd_tbl_t *cmdtp, const char *cmd)
        return 0;
 }
 #endif
+
+extern int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc,
+                          char *const argv[]);
+
 extern int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 
+/*
+ * Error codes that commands return to cmd_process(). We use the standard 0
+ * and 1 for success and failure, but add one more case - failure with a
+ * request to call cmd_usage(). But the cmd_process() function handles
+ * CMD_RET_USAGE itself and after calling cmd_usage() it will return 1.
+ * This is just a convenience for commands to avoid them having to call
+ * cmd_usage() all over the place.
+ */
+enum command_ret_t {
+       CMD_RET_SUCCESS,        /* 0 = Success */
+       CMD_RET_FAILURE,        /* 1 = Failure */
+       CMD_RET_USAGE = -1,     /* Failure, please report 'usage' error */
+};
+
+/**
+ * Process a command with arguments. We look up the command and execute it
+ * if valid. Otherwise we print a usage message.
+ *
+ * @param flag         Some flags normally 0 (see CMD_FLAG_.. above)
+ * @param argc         Number of arguments (arg 0 must be the command text)
+ * @param argv         Arguments
+ * @param repeatable   This function sets this to 0 if the command is not
+ *                     repeatable. If the command is repeatable, the value
+ *                     is left unchanged.
+ * @return 0 if the command succeeded, 1 if it failed
+ */
+int cmd_process(int flag, int argc, char * const argv[],
+                              int *repeatable);
+
 #endif /* __ASSEMBLY__ */
 
 /*
@@ -117,8 +152,6 @@ extern int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 #define CMD_FLAG_REPEAT                0x0001  /* repeat last command          */
 #define CMD_FLAG_BOOTD         0x0002  /* command is from bootd        */
 
-#define Struct_Section  __attribute__ ((unused,section (".u_boot_cmd")))
-
 #ifdef CONFIG_AUTO_COMPLETE
 # define _CMD_COMPLETE(x) x,
 #else
@@ -130,20 +163,25 @@ extern int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 # define _CMD_HELP(x)
 #endif
 
-#define U_BOOT_CMD_MKENT_COMPLETE(name,maxargs,rep,cmd,usage,help,comp) \
-       {#name, maxargs, rep, cmd, usage, _CMD_HELP(help) _CMD_COMPLETE(comp)}
+#define U_BOOT_CMD_MKENT_COMPLETE(_name, _maxargs, _rep, _cmd,         \
+                               _usage, _help, _comp)                   \
+               { #_name, _maxargs, _rep, _cmd, _usage,                 \
+                       _CMD_HELP(_help) _CMD_COMPLETE(_comp) }
 
-#define U_BOOT_CMD_MKENT(name,maxargs,rep,cmd,usage,help) \
-       U_BOOT_CMD_MKENT_COMPLETE(name,maxargs,rep,cmd,usage,help,NULL)
+#define U_BOOT_CMD_MKENT(_name, _maxargs, _rep, _cmd, _usage, _help)   \
+       U_BOOT_CMD_MKENT_COMPLETE(_name, _maxargs, _rep, _cmd,          \
+                                       _usage, _help, NULL)
 
-#define U_BOOT_CMD_COMPLETE(name,maxargs,rep,cmd,usage,help,comp) \
-       cmd_tbl_t __u_boot_cmd_##name Struct_Section = \
-               U_BOOT_CMD_MKENT_COMPLETE(name,maxargs,rep,cmd,usage,help,comp)
+#define U_BOOT_CMD_COMPLETE(_name, _maxargs, _rep, _cmd, _usage, _help, _comp) \
+       ll_entry_declare(cmd_tbl_t, _name, cmd, cmd) =                  \
+               U_BOOT_CMD_MKENT_COMPLETE(_name, _maxargs, _rep, _cmd,  \
+                                               _usage, _help, _comp);
 
-#define U_BOOT_CMD(name,maxargs,rep,cmd,usage,help) \
-       U_BOOT_CMD_COMPLETE(name,maxargs,rep,cmd,usage,help,NULL)
+#define U_BOOT_CMD(_name, _maxargs, _rep, _cmd, _usage, _help)         \
+       U_BOOT_CMD_COMPLETE(_name, _maxargs, _rep, _cmd, _usage, _help, NULL)
 
 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
 void fixup_cmdtable(cmd_tbl_t *cmdtp, int size);
 #endif
+
 #endif /* __COMMAND_H */