- 论坛徽章:
- 0
|
原帖由 eexplorer 于 2009-4-21 20:06 发表
在你load module的时候,sys_init_module() -> do_one_initcall(mod->init), mod->init就是你的init_test()
我的kernel版本是2.6.18,还没有你说的do_one_initcall()函数。
我也没有手动打过patch。
2.6.18中sys_init_module()的实现如下:
- /* This is where the real work happens */
- asmlinkage long
- sys_init_module(void __user *umod,
- unsigned long len,
- const char __user *uargs)
- {
- struct module *mod;
- int ret = 0;
- /* Must have permission */
- if (!capable(CAP_SYS_MODULE))
- return -EPERM;
- /* Only one module load at a time, please */
- if (mutex_lock_interruptible(&module_mutex) != 0)
- return -EINTR;
- /* Do all the hard work */
- mod = load_module(umod, len, uargs);
- if (IS_ERR(mod)) {
- mutex_unlock(&module_mutex);
- return PTR_ERR(mod);
- }
- /* Now sew it into the lists. They won't access us, since
- strong_try_module_get() will fail. */
- stop_machine_run(__link_module, mod, NR_CPUS);
- /* Drop lock so they can recurse */
- mutex_unlock(&module_mutex);
- blocking_notifier_call_chain(&module_notify_list,
- MODULE_STATE_COMING, mod);
- /* Start the module */
- if (mod->init != NULL)
- ret = mod->init(); /*这里是我自己的module的init函数吧?如果在这里关闭了中断,后面的代码没有看到有重新打开中断的地方。。。*/
- if (ret < 0) {
- /* Init routine failed: abort. Try to protect us from
- buggy refcounters. */
- mod->state = MODULE_STATE_GOING;
- synchronize_sched();
- if (mod->unsafe)
- printk(KERN_ERR "%s: module is now stuck!\n",
- mod->name);
- else {
- module_put(mod);
- mutex_lock(&module_mutex);
- free_module(mod);
- mutex_unlock(&module_mutex);
- }
- return ret;
- }
- /* Now it's a first class citizen! */
- mutex_lock(&module_mutex);
- mod->state = MODULE_STATE_LIVE;
- /* Drop initial reference. */
- module_put(mod);
- unwind_remove_table(mod->unwind_info, 1);
- module_free(mod, mod->module_init);
- mod->module_init = NULL;
- mod->init_size = 0;
- mod->init_text_size = 0;
- mutex_unlock(&module_mutex);
- return 0;
- }
复制代码
其中,代码
是在执行我写的module的init函数吧,如果我在init里关闭了中断,在mod->init()的后面我没有看到有其他地方重新打开中断啊?
请指教... |
|