宏定义,用于定义一个U_BOOT命令
#define U_BOOT_CMD(name,maxargs,rep,cmd,usage) /
cmd_tbl_t __u_boot_cmd_##name Struct_Section = {#name, maxargs, rep, cmd, usage}
#define Struct_Section __attribute__ ((unused,section (".u_boot_cmd")))//设置属性,存在.u_boot_cmd段中
Struct cmd_tbl_s:
struct cmd_tbl_s {
char *name; /* Command Name */
int maxargs; /* maximum number of arguments */
int repeatable; /* autorepeat allowed? */
/* Implementation function */
int (*cmd)(struct cmd_tbl_s *, int, int, char *[]);
char *usage; /* Usage message (short) */
char *help; /* Help message (long) */
#ifdef CONFIG_AUTO_COMPLETE
/* do auto completion on the arguments */
int (*complete)(int argc, char *argv[], char last_char, int maxv, char *cmdv[]);
#endif
};
typedef struct cmd_tbl_s cmd_tbl_t;
例如:
U_BOOT_CMD(
bootm, CONFIG_SYS_MAXARGS, 1, do_bootm,
"boot application image from memory", bootm_help_text
);
展开后:cmd_tbl_t __u_boot_cmd_##namebootm Struct_Section__attribute__ ((unused,section (".u_boot_cmd"))) =
{#name"bootm", maxargs16, rep1, cmddo_bootm, usage"boot application image from memory"}