little kernel代码片段

来源:互联网 发布:安捷伦数据采集仪 编辑:程序博客网 时间:2024/06/16 23:51
/* 对LK中这段代码的理解 */
void apps_init(void)
{
    const struct app_descriptor *app;

    /* call all the init routines */
    /* 遍历所有在__apps_start 到__apps_end段里的函数,并调用其init函数 */
    /* __apps_start 和__apps_end包含的段的段名在下面这个文件里指定为.apps段
     *    arch/arm/system-twosegment.ld
     *    在下面的文件里定义了一个宏来指定怎么样的函数放到上面的段中去,即被该红修饰的函数
     *    include/app.h
     * #define APP_START(appname) struct app_descriptor _app_##appname __SECTION(".apps") = {
     *    .name = #appname,
     * #define APP_END };    
     */
    for (app = &__apps_start; app != &__apps_end; app++) {
        if (app->init)
            app->init(app);
    }

    /* start any that want to start on boot */
    for (app = &__apps_start; app != &__apps_end; app++) {
        if (app->entry && (app->flags & APP_FLAG_DONT_START_ON_BOOT) == 0) {
            start_app(app);
        }
    }
}

0 0
原创粉丝点击