u-boot内核启动分析
菜单的实现函数 - cmd_menu.c
pc机上都有分区,但是在嵌入式设备中的flash没有分区
所谓的嵌入式中的分区就是使用代码进行写死
sourceinsight 中搜索函数的快捷键是: Alt + G 或者 F7
搜索文件的快捷键是 Ctrl + O
u-boot 与内核的参数交互,u-boot将参数信息存在一个指定的地址(和内核约定好的,按照双方约定好的格式进行);
定义的格式是tag,地址是30000100
/********************************************************************************/
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内核启动分析相关推荐
- 内核启动分析(三)——zImage 解压缩阶段
在上阶段,主要是U-BOOT 向内核传递一些参数.而这些参数是通过 struct tag来传递的.U-boot 把要传递给 kernel 的东西保存在 struct tag 数据结构中,启 ...
- uboot源码——内核启动分析
以下内容源于朱有鹏嵌入式课程的学习,如有侵权,请告知删除. 参考资料:http://www.cnblogs.com/biaohc/p/6403863.html 总结:uboot启动linux内核的整个 ...
- 第3阶段——内核启动分析之prepare_namespace()如何挂载根文件系统和mtd分区介绍(6)...
内核启动并初始化后,最终目的是像Windows一样能启动应用程序,在windows中每个应用程序都存在C盘.D盘等,而linux中每个应用程序是存放在根文件系统里面,那么挂载根文件系统在哪里,怎么实现 ...
- linux内核启动分析 三,Linux内核分析 实验三:跟踪分析Linux内核的启动过程
贺邦 + 原创作品转载请注明出处 + <Linux内核分析>MOOC课程 http://mooc.study.163.com/course/USTC-1000029000 一. 实验过程 ...
- linux内核启动分析(一)
文章目录 1.HEAD 1.preserve_boot_args 1.1 __inval_dcache_area 2.el2_setup 3. set_cpu_boot_mode_flag 4. __ ...
- Hi3518ev200:内核启动分析
1)从DDR地址0x82000000加载内核镜像 hisilicon # bootm 82000000 ## Booting kernel from Legacy Image at 82000000 ...
- Linux内核启动流程分析(一)【转】
转自:http://blog.chinaunix.net/uid-25909619-id-3380535.html 很久以前分析的,一直在电脑的一个角落,今天发现贴出来和大家分享下.由于是word直接 ...
- 低温linux内核启动readl,Linux内核启动流程分析(一)
很久以前分析的,一直在电脑的一个角落,今天发现贴出来和大家分享下.由于是word直接粘过来的有点乱,敬请谅解! S3C2410 Linux 2.6.35.7启动分析(第一阶段) 1.依据arch/ar ...
- 通过从代码层面分析Linux内核启动来探知操作系统的启动过程
通过从代码层面分析Linux内核启动来探知操作系统的启动过程 前言说明 本篇为网易云课堂Linux内核分析课程的第三周作业,我将围绕Linux 3.18的内核中的start_kernel到init进程 ...
最新文章
- CentOs下卸载程序
- 提高大数据量并发访问时效率
- java中table是什么标签_[Java教程]javascript格式化table标签内容
- mysql学习【第14篇】:pymysql
- 当今世界最受人们重视的十大经典算法
- FPGA与MCU,DSP(如C6000,C5000等)等设计思想的异同
- C++类的构造函数 后单冒号加基类 例如:CAboutDlg::CAboutDlg() : CDialogEx(CAboutDlg::IDD)
- 监督分类空白处也被分类了_监督学习(2)|本质是分类的“逻辑回归”
- 学习日报 1028 分支结构 if分支语句
- sed学习笔记(1) - 入门知识
- SAP Client Copy
- ccf中文期刊目录_37本!中国计算机学会CCF首次发布推荐中文科技期刊目录
- Mac软件下载提示:“已损坏,无法打开”解决办法
- 广西建筑行业人才市场暴涨
- 为什么元宇宙有可能成为企业下一个最大机遇?
- 个人自媒体技术分享博客网站模板
- springboot使用logback
- 手机与计算机之间的文件传输,电脑与手机如何快速传输文件
- permission denied什么意思
- instagram分享_存档instagram帐户正在教被忘记的历史