driver: add dev_name inline
[barebox-mini2440.git] / include / command.h
bloba72f240a7db9e71e2e57bca3135876ffd4712ada
1 /*
2 * (C) Copyright 2000
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
6 * project.
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.
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.
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
25 * Definitions for Command Processor
27 #ifndef __COMMAND_H
28 #define __COMMAND_H
30 #include <list.h>
32 #ifndef NULL
33 #define NULL 0
34 #endif
36 #ifndef __ASSEMBLY__
38 extern struct list_head command_list;
40 #define for_each_command(cmd) list_for_each_entry(cmd, &command_list, list)
43 * Monitor Command Table
46 struct cmd_tbl_s {
47 const char *name; /* Command Name */
48 const char **aliases;
49 /* Implementation function */
50 int (*cmd)(struct cmd_tbl_s *, int, char *[]);
51 const char *usage; /* Usage message (short) */
53 struct list_head list; /* List of commands */
54 #ifdef CONFIG_LONGHELP
55 const char *help; /* Help message (long) */
56 #endif
58 #ifdef __x86_64__
59 /* This is required because the linker will put symbols on a 64 bit alignment */
60 __attribute__((aligned(64)))
61 #endif
65 typedef struct cmd_tbl_s cmd_tbl_t;
67 extern cmd_tbl_t __u_boot_cmd_start;
68 extern cmd_tbl_t __u_boot_cmd_end;
71 /* common/command.c */
72 cmd_tbl_t *find_cmd(const char *cmd);
73 int execute_command(int argc, char **argv);
74 void u_boot_cmd_usage(cmd_tbl_t *cmdtp);
76 #define COMMAND_SUCCESS 0
77 #define COMMAND_ERROR 1
78 #define COMMAND_ERROR_USAGE 2
80 #endif /* __ASSEMBLY__ */
83 * Configurable monitor commands definitions have been moved
84 * to include/cmd_confdefs.h
87 #define __stringify_1(x) #x
88 #define __stringify(x) __stringify_1(x)
91 #define Struct_Section __attribute__ ((unused,section (".u_boot_cmd")))
93 #define U_BOOT_CMD_START(_name) \
94 const cmd_tbl_t __u_boot_cmd_##_name \
95 __attribute__ ((unused,section (".u_boot_cmd_" __stringify(_name)))) = { \
96 .name = #_name,
98 #define U_BOOT_CMD_END \
101 #ifdef CONFIG_LONGHELP
102 #define U_BOOT_CMD_HELP(text) .help = text,
103 #else
104 #define U_BOOT_CMD_HELP(text)
105 #endif
107 int register_command(cmd_tbl_t *);
109 #endif /* __COMMAND_H */