u-boot log_init函数分析
log_init,
int log_init(void)
{
struct log_driver *drv = ll_entry_start(struct log_driver, log_driver);
#define ll_entry_start(_type, _list) \
({ \
static char start[0] __aligned(4) __attribute__((unused, section(".u_boot_list_2_"#_list"_1"))); \
(_type *)&start; \
})
//等价于:
//struct log_driver *drv = {static char start[0];(struct log_driver*)&start;},其中start[0]放置在.u_boot_list_2_log_driver_1段
/*.u_boot_list在u-boot.lds定义
.u_boot_list : {
KEEP(*(SORT(.u_boot_list*)));}
并按照u_boot_list后面的字符进行排序*/
const int count = ll_entry_count(struct log_driver, log_driver);
#define ll_entry_count(_type, _list) \
({ \
_type *start = ll_entry_start(_type, _list); \
_type *end = ll_entry_end(_type, _list); \
unsigned int _ll_result = end - start; \
_ll_result; \
})
//等价于const int count=ll_entry_end(_type, _list)-ll_entry_start(_type, _list),即计算.u_boot_list_2_log_driver_3和.u_boot_list_2_log_driver_1之间有多少个struct log_driver结构体
struct log_driver *end = drv + count; //指向.u_boot_list_2_log_driver_3处
INIT_LIST_HEAD((struct list_head *)&gd->log_head);
static inline void INIT_LIST_HEAD(struct list_head *list)
{
list->next = list;
list->prev = list;
}
//即将gd->log_head设置为循环链表的头
while (drv < end) {
struct log_device *ldev;
ldev = calloc(1, sizeof(*ldev)); //给ldev分配空间
if (!ldev) {
debug("%s: Cannot allocate memory\n", __func__);
return -ENOMEM;
}
INIT_LIST_HEAD(&ldev->filter_head); //将ldev->filter_head成员初始化为循环链表
ldev->drv = drv; //将ldev->drv成员指向当前的log_driver
list_add_tail(&ldev->sibling_node,
(struct list_head *)&gd->log_head); //把ldev->sibling_node成员加入到gd->log_head的循环链表中
drv++;
}
//通过该循环,将.u_boot_list_2_log_driver_3和.u_boot_list_2_log_driver_1之间的所有struct log_driver结构体都加入到了gd->log_head的循环链表中
gd->flags |= GD_FLG_LOG_READY;
//之前gd->flags=0,此时设置gd->flags为GD_FLG_LOG_READY,即gd->flags=0x08000
if (!gd->default_log_level)
gd->default_log_level = LOGL_INFO; //设置gd->default_log_level为LOGL_INFO
gd->log_fmt = LOGF_DEFAULT; //设置gd->log_fmt为LOGF_DEFAULT
return 0;
}
log_init的主要功能是将.u_boot_list_2_log_driver_3和.u_boot_list_2_log_driver_1之间的所有struct log_driver结构体都加入到了gd->log_head的循环链表中,并初始化gd->default_log_level和gd->log_fmt
————————————————
版权声明:本文为CSDN博主「yanggx0929」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/yanggx0929/article/details/88785318
u-boot log_init函数分析的更多相关文章
- 精尽Spring Boot源码分析 - SpringApplication 启动类的启动过程
该系列文章是笔者在学习 Spring Boot 过程中总结下来的,里面涉及到相关源码,可能对读者不太友好,请结合我的源码注释 Spring Boot 源码分析 GitHub 地址 进行阅读 Sprin ...
- 精尽Spring Boot源码分析 - 配置加载
该系列文章是笔者在学习 Spring Boot 过程中总结下来的,里面涉及到相关源码,可能对读者不太友好,请结合我的源码注释 Spring Boot 源码分析 GitHub 地址 进行阅读 Sprin ...
- split(),preg_split()与explode()函数分析与介
split(),preg_split()与explode()函数分析与介 发布时间:2013-06-01 18:32:45 来源:尔玉毕业设计 评论:0 点击:965 split()函数可以实 ...
- string函数分析
string函数分析string函数包含在string.c文件中,经常被C文件使用.1. strcpy函数原型: char* strcpy(char* str1,char* str2);函数功能: 把 ...
- start_amboot()函数分析
一.整体流程 start_amboot()函数是执行完start.S汇编文件后第一个C语言函数,完成的功能自然还是初始化的工作 . 1.全局变量指针r8设定,以及全局变量区清零 2.执行一些类初始化函 ...
- uboot的jumptable_init函数分析
一.函数说明 函数功能:安装系统函数指针 函数位置:common/exports.c 二.函数分析 void jumptable_init (void) { int i; gd->jt = (v ...
- Linux-0.11内核源代码分析系列:内存管理get_free_page()函数分析
Linux-0.11内存管理模块是源码中比較难以理解的部分,如今把笔者个人的理解发表 先发Linux-0.11内核内存管理get_free_page()函数分析 有时间再写其它函数或者文件的:) /* ...
- 31.QPainter-rotate()函数分析-文字旋转不倾斜,图片旋转实现等待
在上章和上上上章: 28.QT-QPainter介绍 30.QT-渐变之QLinearGradient. QConicalGradient.QRadialGradient 学习了QPainter基础绘 ...
- Spring Boot 入门详细分析
推荐阅读: 我们为什么要学习 Spring Boot 我们搭建 Spring Boot 项目,可以使用 Spring 为我们提供的初始化网站,那个可能不太方便,今天呢,我们就来说说如何使用 IDEA ...
随机推荐
- Javadoc常见的标记和含义
1.@param 方法参数的说明 2.@return 对 方法返回值的说明 3.@throws 方法抛出异常的描述 4.@version模块的版本号 5.see参数转向 6.@deprecated标记 ...
- ControlTemplate in WPF —— ListBox
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" x ...
- jquery用formada发送文件到服务器
var formdata = new FormData(); formdata.append("file", $("#Input")[0].files[0]); ...
- Python 的列表生成器
列表生成器为创建列表提供了一种简洁的方式. 比如说,我们可以这样实现一个平方数列表 squares=[x**2 for x in range(10)] 或者这样迭代一个字符串来生成列表 >> ...
- shell脚本判断端口是否打开
[root@www zabbix_scripts]# cat check_httpd.sh #!/bin/bash a=`lsof -i: | wc -l` " ];then " ...
- JS获取表单元素的value
<!-- 1.option selected属性,如果我们在下拉列表里面选择了一个option那么他的selected="true" ,如果我们想设置当前的option是选中 ...
- GO——beego简单开发实例(二)
在新建项目成功之后我们可以做一个简单的动态增删查改. 1.在models文件夹下新建models.go,根据模型新建表 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 ...
- JWT的实现原理
前言最近在做一个python项目的改造,将python项目重构为java项目,过程中遇到了这个知识点,觉得这个蛮实用的,所以下班后回来趁热打铁写下这篇总结,希望后面的人能够有所借鉴,少走弯路. 一.优 ...
- IDEA 一次启动多个微服务模块项目
1,打开IDEA项目 .idea 下 的workspace.xml 2,查找“RunDashboard” 节点 3,添加如下内容 <option name="configuration ...
- CF486B OR in Matrix(构造+思维)
CF486B 一道有趣的思维题 由于or的性质可知只要a[i][j]为1那么b中第i行,第j列将都变成1 相反的,如果b[i][j]是0那么a中第i行,第j列都必须是0 根据第二个性质我们可以构造出a ...