/********************************************************************************/
u-boot命令寻找分析
/**************************************************************************** find command table entry for a command*/
cmd_tbl_t *find_cmd (const char *cmd)
{cmd_tbl_t *cmdtp;cmd_tbl_t *cmdtp_temp = &__u_boot_cmd_start; /*Init value */const char *p;int len;int n_found = 0;/** Some commands allow length modifiers (like "cp.b");* compare command name only until first dot.*/len = ((p = strchr(cmd, '.')) == NULL) ? strlen (cmd) : (p - cmd);for (cmdtp = &__u_boot_cmd_start;cmdtp != &__u_boot_cmd_end;cmdtp++) {if (strncmp (cmd, cmdtp->name, len) == 0) {if (len == strlen (cmdtp->name))return cmdtp;   /* full match */cmdtp_temp = cmdtp;    /* abbreviated command ? */n_found++;}}if (n_found == 1) {          /* exactly one match */return cmdtp_temp;}return NULL;  /* not found or ambiguous command */
}for (cmdtp = &__u_boot_cmd_start;cmdtp != &__u_boot_cmd_end;cmdtp++)u-boot.lds的链接脚本之中也能传递变量
SECTIONS
{. = 0x00000000;. = ALIGN(4);.text      :{cpu/arm920t/start.o (.text)board/100ask24x0/boot_init.o (.text)*(.text)}. = ALIGN(4);.rodata : { *(.rodata) }. = ALIGN(4);.data : { *(.data) }. = ALIGN(4);.got : { *(.got) }. = .;__u_boot_cmd_start = .;.u_boot_cmd : { *(.u_boot_cmd) }__u_boot_cmd_end = .;. = ALIGN(4);__bss_start = .;.bss : { *(.bss) }_end = .;
}#define Struct_Section  __attribute__ ((unused,section (".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 */rep命令代表的是命令是否可重复
#define U_BOOT_CMD(name,maxargs,rep,cmd,usage,help) \
cmd_tbl_t __u_boot_cmd_##name Struct_Section = {#name, maxargs, rep, cmd, usage}        nand read.jffs2 0x30007FC0 kernel; bootm 0x30007FC0
U_BOOT_CMD(bootm,   CFG_MAXARGS,    1,  do_bootm,"bootm   - boot application image from memory\n","[addr [arg ...]]\n    - boot application image stored in memory\n""\tpassing arguments 'arg ...'; when booting a Linux kernel,\n""\t'arg' can be the address of an initrd image\n"
#ifdef CONFIG_OF_FLAT_TREE"\tWhen booting a Linux kernel which requires a flat device-tree\n""\ta third argument is required which is the address of the of the\n""\tdevice-tree blob. To boot that kernel without an initrd image,\n""\tuse a '-' for the second argument. If you do not pass a third\n""\ta bd_info struct will be passed instead\n"
#endif
);cmd_tbl_t __u_boot_cmd_bootm __attribute__ ((unused,section (".u_boot_cmd"))) =
{"bootm", CFG_MAXARGS, 1, do_bootm,  \
"bootm   - boot application image from memory\n", \"[addr [arg ...]]\n    - boot application image stored in memory\n""\tpassing arguments 'arg ...'; when booting a Linux kernel,\n""\t'arg' can be the address of an initrd image\n"}
在宏定义中  #是转化为字符串的意思
下面这句的意思是设置该结构体段属性为.u_boot_cmd
cmd_tbl_t __u_boot_cmd_bootm __attribute__ ((unused,section (".u_boot_cmd")))
因此只要是定义为  U_BOOT_CMD 类型的结构体都将被强制转化为 段的属性为  .u_boot_cmd     该属性在链接脚本中定义了
因此在find_cmd中能够使用
for (cmdtp = &__u_boot_cmd_start;cmdtp != &__u_boot_cmd_end;cmdtp++)
按照结构体的形式将命令挨个找出来

u-boot命令寻找分析--find_cmd函数相关推荐

  1. find_cmd函数分析

    一.概述 1.函数位置 common/command.c 2.函数功能分析 解析命令的关键环节是如何根据输入命令查找对应命令的信息,从而跳转到对应命令的函数处执行程序.这必然涉及到如何存放命令的详细信 ...

  2. DiscuzX系列命令执行分析公开(三连弹)

    tang3 · 2015/01/15 18:55 0x00 漏洞概要 昨天360补天发了这样的一条微博: 然后打听了一下细节,发现居然是我13年7月报给TSRC的漏洞,看今天大家玩的挺开心,与TSRC ...

  3. linux注册函数机制,Linux可信计算机制模块详细分析之函数实现机制(1)字符设备驱动...

    原标题:Linux可信计算机制模块详细分析之函数实现机制(1)字符设备驱动 2.3 函数实现机制 2.3.1 Linux 字符设备驱动 在linux 3.5.4中,用结构体cdev描述字符设备,cde ...

  4. Matlab命令集--常用字符串函数

    Matlab命令集--常用字符串函数 常用函数 eval  :运行字符串表示的表达式 char  :将数组变成字符串 double:将数字字符串变成数字 字符串操作 deblank :去掉字符串末尾的 ...

  5. linux input子系统分析--主要函数

    linux input子系统分析--主要函数 一. 各种注册函数 因为分析一所讲的每种数据结构都代表一类对象,所以每种数据结构都会对应一个注册函数,他们都定义在子系统核心的input.c文件中.主要有 ...

  6. GCC源码分析(十) — 函数节点的gimple高端化

    版权声明:本文为CSDN博主「ashimida@」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明. 原文链接:https://blog.csdn.net/lidan1 ...

  7. Win32的缓冲区溢出攻击(涉及用WinDbg分析 overflow函数的返回地址所在的地址与buffer首地址的距离 OFF_SET)

    Win32的缓冲区溢出攻击 一.学习过程 二.学习成果(求OFF_SET) 三.扩展阅读 一.学习过程 1.overflow函数的源代码 #include <stdio.h> #inclu ...

  8. GCC源码分析(十一) — 函数节点的gimple低端化

    版权声明:本文为CSDN博主「ashimida@」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明. 原文链接:https://blog.csdn.net/lidan1 ...

  9. jQuery源码分析-each函数

    本文部分截取自且行且思 jQuery.each方法用于遍历一个数组或对象,并对当前遍历的元素进行处理,在jQuery使用的频率非常大,下面就这个函数做了详细讲解: 复制代码代码 /*! * jQuer ...

最新文章

  1. Windows 7 with SP1中英文原版MSDN下载汇总(全版本收录完毕)
  2. 功能农业奠基人-农业大健康·万祥军:赵其国安康工作站揭牌
  3. Boost:序列化之text_iarchive和text_oarchive
  4. 面试官:为什么 HashMap 的加载因子是0.75?
  5. docker镜像、容器以及命令操作
  6. .Net Core 中间件之主机地址过滤(HostFiltering)源码解析
  7. Net平台下的B/S开发框架
  8. js小例子(标签页)
  9. 创建一个SpringBoot项目(IDEA版本,保姆级教程)
  10. EVE-NG模拟器综合
  11. visio2019 专业版,两种方法
  12. 文档隐写溯源技术分析
  13. html 水印插件,jquery图片水印插件
  14. Linux-新用户创建和删除
  15. 计算机网络实训报告局域网,计算机网络局域网实验报告.doc
  16. AQS是什么?都是怎么用的?
  17. HTML综合之实现耀炎食品有限公司网页
  18. mysql最高安全级别双一_MySQL技术体系之核心参数
  19. 马化腾:搜索、电子商务硬仗一定要坚持打
  20. 爬取得猫眼电影前top100排行榜

热门文章

  1. hdu 5481(数学期望+区间合并)
  2. NYOJ 485 A*B Problem
  3. NYOJ 6 喷水装置(一) 贪心算法 之 区间覆盖问题
  4. java web----servlet
  5. [洛谷P4430]小猴打架
  6. socket/WebSocket/WebService/http/https概念
  7. PAT1097:Deduplication on a Linked List
  8. 使用Hyper-V安装Ubuntu16.04 Server 网络配置
  9. 12月16号 双链表
  10. linux java so 历险