1.相关的一些定义:
struct cmd_tbl_s
{
char *name;
int maxargs;
int repeatable;
int (*cmd)(struct cmd_tbl_s *, int ,int , char *[]);
char *usage;
char *help;
};
typedef struct cmd_tbl_s cmd_tbl_t;
#define struct_section __attribute ((unused, section(".u_boot_cmd")))
#define U_BOOT_CMD(name, maxargs, rep, cmd, usage, help)\
cmd_tbl_t __u_boot_cmd_##name struct_section = {#name, maxargs, rep, cmd, usage, help}
2.添加过程:
在命令文件cmd_name.c中:
2.1.U_BOOT_CMD(NAME, REP, DO_NAME, USAGE, HELP);定义命令NAME
2.2.int DO_NAME(cmd_tbl_t *cmd, int flag, int arg, char *argv[])
{
...
}
编写相应的命令处理函数,
3.Makefile中添加cmd_name.o
4.如有必要,添加条件编译开关
阅读(547) | 评论(0) | 转发(0) |