您的位置:首页 > 大数据 > 人工智能

xenomai-3.0 初始化

2016-09-09 18:21 239 查看
static int __init xenomai_init(void)
{
int ret, __maybe_unused cpu;

setup_init_state();/*检查是否使能xenomai*/
/*如果没有使能就退出*/
if (!realtime_core_enabled()) {
printk(XENO_WARNING "disabled on kernel command line\n");
return 0;
}

#ifdef CONFIG_SMP
//检查cpu屏蔽字
cpumask_clear(&xnsched_realtime_cpus);
for_each_online_cpu(cpu) {
if (supported_cpus_arg & (1UL << cpu))
cpumask_set_cpu(cpu, &xnsched_realtime_cpus);
}
if (cpumask_empty(&xnsched_realtime_cpus)) {
printk(XENO_WARNING "disabled via empty real-time CPU mask\n");
set_realtime_core_state(COBALT_STATE_DISABLED);
return 0;
}
cobalt_cpu_affinity = xnsched_realtime_cpus;
#endif /* CONFIG_SMP */
//注册调度的类:idle 和 rt schedule.
xnsched_register_classes();
//proc 文件初始化
ret = xnprocfs_init_tree();
if (ret)
goto fail;
//初始化具体的machine,比如时钟等。一般相关的值是让cobalt自动获取,不要手动设置。
ret = mach_setup();
if (ret)
goto cleanup_proc;
//xenomai中断相关初始化
xnintr_mount();
//创建实时任务的管道,可与用户实时任务交互的/dev/rtp*,可做IPC通信。
//同时,注册了一个唤醒任务  xnpipe_wakeup_apc =
//    xnapc_alloc("pipe_wakeup", &xnpipe_wakeup_proc, NULL);
ret = xnpipe_mount();
if (ret)
goto cleanup_mach;
//注册select唤醒删除任务
//  deletion_apc = xnapc_alloc("selector_list_destroy",
//             xnselector_destroy_loop, NULL);
ret = xnselect_mount();
if (ret)
goto cleanup_pipe;
/*
1.xenomai堆区申请
2.proc目录下文件架构组织
*/
ret = sys_init();
if (ret)
goto cleanup_select;
/*
延迟初始化
*/
ret = mach_late_setup();
if (ret)
goto cleanup_sys;
/*
rtdm的class初始化
*/
ret = rtdm_init();
if (ret)
goto cleanup_sys;

ret = cobalt_init();
if (ret)
goto cleanup_rtdm;

rtdm_fd_init();

printk(XENO_INFO "Cobalt v%s (%s) %s%s%s%s\n",
XENO_VERSION_STRING,
XENO_VERSION_NAME,
boot_debug_notice,
boot_lat_trace_notice,
boot_evt_trace_notice,
boot_state_notice);

return 0;

cleanup_rtdm:
rtdm_cleanup();
cleanup_sys:
sys_shutdown();
cleanup_select:
xnselect_umount();
cleanup_pipe:
xnpipe_umount();
cleanup_mach:
mach_cleanup();
cleanup_proc:
xnprocfs_cleanup_tree();
fail:
set_realtime_core_state(COBALT_STATE_DISABLED);
printk(XENO_ERR "init failed, code %d\n", ret);

return ret;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  xenomai