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...
ram
[TOC] ram-uclass.c类信息1234UCLASS_DRIVER(ram) = { .id = UCLASS_RAM, .name = "ram",}; stm32_sdram.c驱动信息123456789U_BOOT_DRIVER(stm32_fmc) = { .name = "stm32_fmc", .id = UCLASS_RAM, .of_match = stm32_fmc_ids, .ops = &stm32_fmc_ops, .of_to_plat = stm32_fmc_of_to_plat, .probe = stm32_fmc_probe, .plat_auto = sizeof(struct stm32_sdram_params),}; dts1234567891011121314151617fmc@52004000 { compatible = "st,stm32h7-fmc"; reg = <0x52004000 ...
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 是一个特殊的宏参数,表示传递给宏的所有可变参数。## 是预处理器的连接运算符,用于将两个...
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...
test
[TOC] testtest.hUNIT_TEST12345678//在段中定义一个测试用例函数#define UNIT_TEST(_name, _flags, _suite) \ ll_entry_declare(struct unit_test, _name, ut_ ## _suite) = { \ .file = __FILE__, \ .name = #_name, \ .flags = _flags, \ .func = _name, \ } ut.c 单元测试相关函数 参考Unity测试框架,不在分析
autoboot
autoboot.cautoboot_command 自动启动命令1234567891011121314151617181920212223242526272829void autoboot_command(const char *s){ debug("### main_loop: bootcmd=\"%s\"\n", s ? s : "<UNDEFINED>"); if (s //有bootcmd && (stored_bootdelay == -2 || //有延迟时间,且没有按键中断 (stored_bootdelay != -1 && !abortboot(stored_bootdelay)))) { bool lock; int prev; lock = autoboot_keyed() && !IS_ENABLED(CO...
cli
CTL_CH 转换为控制字符1#define CTL_CH(c) ((c) - 'a' + 1) 控制字符通常用于表示特定的控制操作,例如回车、换行、退格等。在 ASCII 码表中,控制字符的值通常在 1 到 31 之间。 cli.ccli_init u_boot_hush_start(); 123456789101112int u_boot_hush_start(void){ if (top_vars == NULL) { top_vars = malloc(sizeof(struct variables)); top_vars->name = "HUSH_VERSION"; top_vars->value = "0.01"; top_vars->next = NULL; top_vars->flg_export = 0; top_vars->flg_read_only = 1; } return 0;} cli_process...
command
command.cU_BOOT_CMD12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273#ifdef CONFIG_AUTO_COMPLETE# define _CMD_COMPLETE(x) x,#else# define _CMD_COMPLETE(x)#endif#ifdef CONFIG_SYS_LONGHELP# define _CMD_HELP(x) x,#else# define _CMD_HELP(x)#endif//cmd名称,最大参数个数,是否可重复,cmd调用函数,使用说明,帮助信息#define U_BOOT_CMD(_name, _maxargs, _rep, _cmd, _usage, _help) \ U_BOOT_CMD_COMPLETE(_name, _maxargs, _rep, _cmd, _usage, ...
board
[TOC] init/board_init.cboard_init_f_alloc_reserve 板级初始化第一次分配保留空间12345678910111213141516// //Fast alloc// top:栈顶地址,即堆栈指针地址sp传入ulong board_init_f_alloc_reserve(ulong top){ /* Reserve early malloc arena */#ifndef CFG_MALLOC_F_ADDR //没有定义快速分配地址#if CONFIG_IS_ENABLED(SYS_MALLOC_F) //配置系统自动快速分配 top -= CONFIG_VAL(SYS_MALLOC_F_LEN);#endif#endif /* LAST : 保留 GD (四舍五入为 16 字节的倍数) */ top = rounddown(top-sizeof(struct global_data), 16); return top;} board_init_f_init_reserve 板级初始化第一次始化保留 将传...









