uboot-命令实现分析
2015-04-10 01:20
344 查看
uboot 命令实现分析
uboot 命令实现分析命令实现
命令执行过程
1. 命令实现
命令由宏 U_BOOT_CMD 定义,该宏具体为#ifdef CFG_LONGHELP #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} #else /* no long help info */ #define U_BOOT_CMD(name,maxargs,rep,cmd,usage,help) \ cmd_tbl_t __u_boot_cmd_##name Struct_Section = {#name, maxargs, rep, cmd, usage} #endif
其中
1. 数据类型为 cmd_tbl_t,该结构体为
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) */ #ifdef CFG_LONGHELP char *help; /* Help message (long) */ #endif };
2. 宏Struct_Section的定义为
#define Struct_Section __attribute__ ((unused,section (".u_boot_cmd")))
即申明该结构体放置在段 .u_boot_cmd 中
使用宏 U_BOOT_CMD 定义命令,则生成一个 _u_boot_cmd命令名称 的结构体,该结构体代码放置的 .u_boot_cmd 代码段,其中
参数 | 意义 |
---|---|
name | 命令名称 |
maxargs | 最多参数 |
repeatable | 是否可重复 |
cmd | 命令实现函数指针 |
usage | 使用方法 |
help | 帮助信息 |
2. 命令执行过程
调用函数 run_command 解析输入命令调用函数 parse_line 分解输入命令
调用 find_cmd 寻找命令结构体
执行 cmd 命令
相关文章推荐
- uboot命令分析+实现【转】
- uboot命令分析+实现
- 实现uboot 命令自动补全 及 修正设置环境变量时自启动内核
- uboot 源码分析(2)uboot 环境变量实现简析
- Linux grep命令分析以及C语言版本的实现
- uboot 命令分析(一) — bootm
- uboot 命令分析(二)
- Uboot常用烧写命令及其源码分析
- quagga 命令定义的代码分析--从定义到实现
- U_BOOT_CMD 命令实现分析
- uboot命令的实现以及解析
- uboot命令解释与运行分析
- uboot源码分析(1)uboot 命令解析流程简析
- 一步步学Linux网络编程--ping命令的实现分析
- date 命令实现源码分析
- uboot命令解释与运行分析
- uboot命令模式的实现
- 分析shell命令中 >/dev/null 2>&1的语法实现原理
- uboot之bootm命令分析
- javap命令分析java的i=i++,i=++i的底层实现