syscon
[TOC] syscon - System Controller 系统控制器 Kconfig 1234567891011121314 config REGMAPbool "Support register maps"depends on DM/*help 硬件外设往往有一组或多组 registers可以访问它来控制硬件。A 寄存器映射使用简单的读/写接口对此进行建模。 原则上可以支持任何总线类型(I2C、SPI)、但到目前为止这仅支持直接内存访问。 */ config SYSCONbool "Support system controllers"depends on REGMAP/*help 许多 SoC 有许多系统控制器需要处理.作为一个组。提供了一些常见的功能. 通过这个 uclass,包括通过 regmap 和 每个 Cookie 分配一个唯一的编号。 */ DTS1234567891011121314soc { #address-cells = <0x01>; ...
kconfig
linux/kconfig.h__count_args 计算可变参数宏的参数数123456/* * 计算可变参数宏的参数数。目前只需要 * 它用于 1、2 或 3 个参数。 */#define __arg6(a1, a2, a3, a4, a5, a6, ...) a6#define __count_args(...) __arg6(dummy, ##__VA_ARGS__, 4, 3, 2, 1, 0) 传递一个虚拟参数 dummy和参数传入,并返回第6个参数; 例如传入 __count_args(a, b, c),则展开为 __arg6(dummy, a, b, c, 4, 3, 2, 1, 0),则返回3 dummy 是一个虚拟参数,用于确保宏展开时参数列表的长度一致。在 __count_args 宏中,dummy 被用作第一个参数,以确保即使没有传递任何参数,参数列表的长度也至少为 1。 ##__VA_ARGS__ 是一个预处理器技巧,用于处理可变参数宏。VA_ARGS 是一个特殊的宏参数,表示传递给宏的所有可变参数。## 是预处理器的连接运算符,用于将两个...
timer
[TOC] timer-uclass.cdm_timer_init 注意到这个函数在多个地方都可以被调; DM扫描识别之后 get_tick和get_tbclk时没有gd->timer的时候 但是只有在gd->timer为空的时候才会执行 12345678910111213141516171819202122232425262728293031323334353637383940int dm_timer_init(void){ struct udevice *dev = NULL; __maybe_unused ofnode node; int ret; if (gd->timer) return 0; if (gd->dm_root == NULL) return -EAGAIN; if (CONFIG_IS_ENABLED(OF_REAL)) { node = ofnode_get_chosen_node("tick-timer"); //优先使用tick-timer节点 if (ofnode_va...
linker_list
linker_lists.h linker_lists api手册 1234567891011121314151617181920212223242526272829303132333435363738// 声明一个链接生成的条目,以__u_boot_list_2_XXX_2_YYY命名#define ll_entry_declare(_type, _name, _list) \ _type _u_boot_list_2_##_list##_2_##_name __aligned(4) \ __attribute__((unused)) \ __section("__u_boot_list_2_"#_list"_2_"#_name)// 声明一个链接生成的列表,以__u_boot_list_2_XXX_2_YYY命名,但是是一个数组#define ll_entry_declare_list(_type, _name, _list) \ _type _u_boot_list_2_##_list##_2_##_nam...
杂项
system-constants.h 定义系统堆栈指针地址 定义了系统初始化的堆栈指针地址 其配置在include/generated/autoconf.h,由include/config.h->include/linux/kconfig.h->include/generated/autoconf.h include/generated/autoconf.h为自动生成的文件,包含了系统的配置信息,原始配置在configs/stm32h750-art-pi_defconfig 12345678/* * The most common case for our initial stack pointer address is to * say that we have defined a static intiial ram address location and * size and from that we subtract the generated global...
hash
[TOC] hash 哈希 散列 给定一个键,哈希表在常数时间内返回相应的值,无论哈希表中有多少个键 为了确定在多大数量以上哈希查找比线性查找和二分查找更快,我们需要考虑它们的时间复杂度和实际性能。 时间复杂度对比 哈希查找:O(1) 线性查找:O(n) 二分查找:O(log n) 实际性能分析 哈希查找:在理想情况下,哈希查找的时间复杂度是常数时间 O(1),即无论哈希表中有多少个键,查找时间都是固定的。然而,哈希查找的性能也依赖于哈希函数的质量和哈希冲突的处理方式。 线性查找:随着数据量的增加,查找时间线性增加。当数据量较小时,线性查找的性能可能还可以接受,但随着数据量的增加,性能会显著下降。 二分查找:需要数据是有序的,查找时间随着数据量的增加而对数增加。对于较大的数据量,二分查找的性能优于线性查找,但不如哈希查找。 数量级对比 特性 哈希表 线性查找 二分查找 插入时间 O(1) 平均 O(n) O(n) 删除时间 O(1) 平均 O(n) O(n) 修改时间 O(1) 平均 O(n) O(log n) 查找 + O(n) 修改 查找时间 O(...
of_live
[TOC] of_live 将平面设备树转换为分层设备树,将原来紧凑的二进制设备树转换为分层的设备树,以结构体的形式存储,便于查找和操作 of_live_build unflatten_device_tree, 创建活动设备树 of_alias_scan, 扫描设备树中的别名 struct device_node12345678910111213141516171819202122232425262728293031323334/** * struct device_node:设备树节点 * * 此树的顶部通常是 gd->of_root,它指向根节点。 * * 根节点(和任何其他节点)的子节点列表的头部为 * 在 @child 中,@sibling 提供指向下一个子项的链接。 * * 每个子项都有一个指向其父项的指针 @parent。 * * 节点可能具有属性,在这种情况下,属性列表的头部 * @properties指向第一个的指针,其中 struct property->@next 指向 * 到下一个。 * * @name:节点名称,根节点的 “” * @typ...
lib
initcall.cinitcall_run_list 初始化调用列表1234567891011121314151617181920212223242526272829303132333435363738394041int initcall_run_list(const init_fnc_t init_sequence[]){ ulong reloc_ofs; const init_fnc_t *ptr; enum event_t type; init_fnc_t func; int ret = 0; for (ptr = init_sequence; func = *ptr, func; ptr++) { reloc_ofs = calc_reloc_ofs(); //计算偏移 type = initcall_is_event(func); //判断是否是事件 //执行函数 是事件执行事件通知函数,否则执行函数 ret = type ? event_notify_null(type) : func(); if (ret) break; ...
regulator
[TOC] regulator-uclass.c类信息12345678UCLASS_DRIVER(regulator) = { .id = UCLASS_REGULATOR, .name = "regulator", .post_bind = regulator_post_bind, .pre_probe = regulator_pre_probe, .post_probe = regulator_post_probe, .per_device_plat_auto = sizeof(struct dm_regulator_uclass_plat),}; regulator_post_bind 读取设备属性用于设置设备属性,并检查设备是否是DM设备中唯一的12345678910111213141516171819202122232425262728293031323334static int regulator_post_bind(struct udevice *dev){ struct dm_regulator_uclass...