首页 > 系统服务 > 详细

linux kernel driver_init()

时间:2021-05-06 14:48:34      阅读:14      评论:0      收藏:0      [点我收藏+]

linux kernel driver_init()

Linux version 3.4.39

/* init/main.c */
asmlinkage void __init start_kernel(void)
    |
    ...
    /* Do the rest non-__init‘ed, we‘re now alive */
	rest_init();
        |
        ...
        kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND);
        ...
        pid = kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES);
        ...
        /* Call into cpu_idle with preempt disabled */
	    cpu_idle(); /* idle process, pid:0 */

static int __init kernel_init(void * unused)
    |
    ...
    /*
    * Ok, the machine is now initialized. None of the devices
    * have been touched yet, but the CPU subsystem is up and
    * running, and memory and process management works.
    *
    * Now we can finally start doing some real work..
    */
    static void __init do_basic_setup(void)
    {
	    cpuset_init_smp();
	    usermodehelper_init();
	    shmem_init();
	    driver_init();
	    init_irq_proc();
	    do_ctors();
	    usermodehelper_enable();
	    do_initcalls();
    }
    ...
    init_post()
        |
        run_init_process(); /* init prcess, pid:1 */
    ...

int kthreadd(void *unused) {
    /* kthreadd process, pid:2 */
}
static void __init do_initcalls(void)
{
	int level;

    for (level = 0; level < ARRAY_SIZE(initcall_levels) - 1; level++)
	    do_initcall_level(level);
}
/* drivers/base/init.c */
#include <linux/memory.h>

#include "base.h"

/**
 * driver_init - initialize driver model.
 *
 * Call the driver model init functions to initialize their
 * subsystems. Called early from init/main.c.
 */
void __init driver_init(void)
{
	/* These are the core pieces */
	devtmpfs_init();
	devices_init();
	buses_init();
	classes_init();
	firmware_init();
	hypervisor_init();

	/* These are also core pieces, but must come after the
	 * core core pieces.
	 */
	platform_bus_init();
	cpu_dev_init();
	memory_dev_init();
}

linux kernel driver_init()

原文:https://www.cnblogs.com/WangYangkai/p/14734329.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!