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 板级初始化第一次始化保留 将传...
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, ...
console
common/console.cputs 输出字符串 暂不分析***
dmalloc
dlmalloc.cdlmalloc 是 Doug Lea 实现的一种动态内存分配器,广泛用于嵌入式系统和操作系统中。它以其高效和灵活的内存管理机制而著称。以下是 dlmalloc 的工作原理和关键概念: 内存池(Memory Pool)dlmalloc 使用一个或多个内存池来管理内存。内存池是由操作系统分配的一大块连续内存区域,dlmalloc 在这个区域内进行内存分配和释放操作。 空闲块和已分配块(Free and Allocated Blocks)内存池被分割成多个块,每个块可以是空闲的或已分配的。每个块都有一个头部(header),包含块的大小和状态(空闲或已分配)。 双向链表(Doubly Linked List)空闲块通过双向链表链接在一起。每个空闲块的头部包含指向前一个和后一个空闲块的指针。这使得 dlmalloc 可以高效地插入和删除空闲块。 分割和合并(Splitting and Coalescing)分割:当请求的内存大小小于某个空闲块的大小时,dlmalloc 会将这个空闲块分割成两个块,一个满足请求大小,另一个继续作为空闲块。合并:当释放一个块时,...
event
event.c event 声明事件类型12345678910//复杂事件声明#define EVENT_SPY_FULL(_type, _func) \ __used ll_entry_declare(struct evspy_info, _type ## _3_ ## _func, \ evspy_info) = _ESPY_REC(_type, _func)//简单事件声明#define EVENT_SPY_SIMPLE(_type, _func) \ __used ll_entry_declare(struct evspy_info_simple, \ _type ## _3_ ## _func, \ evspy_info) = _ESPY_REC_SIMPLE(_type, _func) notify_static 以静态方式通知事件12345678910111213141516171819202122232425262728293031323334static int notify_static(struct event *ev){ struct ...
fdt
fdtdec 扁平设备树解析 devicetree devicetree-specification devicetree-specification.pdf 设备树BLLOB结构 123456789101112131415161718struct fdt_header { fdt32_t magic; /* magic word FDT_MAGIC */ fdt32_t totalsize; /* total size of DT block */ fdt32_t off_dt_struct; /* offset to structure */ fdt32_t off_dt_strings; /* offset to strings */ fdt32_t off_mem_rsvmap; /* offset to memory reserve map */ fdt32_t version; /* format version */ fdt32_t last_comp_version; /* last compatible version *...
adc
[TOC] stm32-adc-core.c驱动信息12345678910111213static const struct udevice_id stm32_adc_core_ids[] = { { .compatible = "st,stm32h7-adc-core" }, { .compatible = "st,stm32mp1-adc-core" }, {}};U_BOOT_DRIVER(stm32_adc_core) = { .name = "stm32-adc-core", .id = UCLASS_SIMPLE_BUS, .of_match = stm32_adc_core_ids, .probe = stm32_adc_core_probe, .priv_auto = sizeof(struct stm32_adc_common),}; stm32_adc_core_probe 获取 base 地址 ...
button
[TOC] common/button_cmd.c 在执行到这里的时候,按键必须已经按下;代码没有循环与延时 且只能处理一个按键,不支持多个按键同时按下 使用时,需要在env中设置button_cmd_N_name= 和button_cmd_N=fastboot usb 0(执行的CMD命令) 参考test/dm/button.c中的button_cmd测试的用法 123456789101112131415void process_button_cmds(void){ struct button_cmd cmd = {0}; int i = 0; while (get_button_cmd(i++, &cmd) && i < MAX_BTN_CMDS) { if (!cmd.pressed) continue; log_info("BTN '%s'> %s\n", cmd.btn_name, cmd.cmd); run_co...
log
## common/log.c 暂不分析***