bootstage_mark_name函数的作用
时间: 2023-08-02 14:06:58 浏览: 40
`bootstage_mark_name` 函数是 U-Boot 中的一个用于性能分析和跟踪的函数,它的作用是在 U-Boot 启动过程中标记一个阶段的名称和时间戳。
具体来说,`bootstage_mark_name` 函数会记录当前时间,并将该时间与指定的阶段名称一起保存在一个全局的数据结构中。在 U-Boot 启动过程中的不同阶段调用 `bootstage_mark_name` 函数,可以记录不同阶段的时间戳,并最终生成一个启动时间轴,用于分析和优化 U-Boot 启动性能。
`bootstage_mark_name` 函数的定义如下:
```c
void bootstage_mark_name(enum bootstage_id id, const char *name)
{
if (!bootstage_started(id)) {
return;
}
if (!name || !*name) {
debug("bootstage: empty name (id=%d)\n", id);
return;
}
debug("bootstage: %s (%d) @ %llu\n", name, id, timer_get_us());
bootstage_add_record(id, name, timer_get_us());
}
```
该函数的参数包括 `enum bootstage_id id` 和 `const char *name`,分别表示阶段的 ID 和名称。
函数首先通过 `bootstage_started` 函数检查指定 ID 的阶段是否已经启动,如果没有启动,则直接返回。然后检查指定的名称是否为空,如果为空,则打印一条调试信息并返回。最后,调用 `bootstage_add_record` 函数,将该阶段的 ID、名称和时间戳添加到全局的数据结构中。
`bootstage_add_record` 函数的作用是将指定的阶段信息添加到全局的数据结构中,用于生成启动时间轴。
总之,`bootstage_mark_name` 函数是 U-Boot 中用于性能分析和跟踪的函数,它的作用是在 U-Boot 启动过程中标记一个阶段的名称和时间戳。通过调用该函数,可以记录 U-Boot 启动过程中的不同阶段的时间戳,并最终生成一个启动时间轴,用于分析和优化 U-Boot 启动性能。