Linux Kernel Source Analysis--Kernel boot (6) Image kernel boot (do_basic_setup function) (Linux-3.0 ARMv7) "Go"

Source: Internet
Author: User
Tags andrew morton gcov

Original address: Linux kernel source Code Analysis--Kernel boot (6) Image kernel boot (do_basic_setup function) (Linux-3.0 ARMv7) Tekkamanninja

Transferred from: http://blog.chinaunix.net/uid-25909619-id-4938396.html

After the basic analysis of the kernel boot process, there is a more important initialization function is not analyzed, that is do_basic_setup. Called Do_basic_setup in the kernel init thread, this function also does a lot of initialization of the kernel and the driver, as follows:
  1. /*
  2. * Well, the device is now initialized to complete. But none of the devices have been initialized yet,
  3. * But the CPU subsystem is up and running,
  4. * and the memory and processor management systems are already working.
  5. *
  6. * Now we can finally start to do some practical work.
  7. */
  8. static void __init do_basic_setup (void)
  9. {
  10. CPUSET_INIT_SMP ();

    Click (here) to collapse or open

    1. For SMP systems, initialize the Cpuset subsystem of the kernel control group. If non-SMP, this function is empty.
    2. Cpuset is the operation of the Cgroup file system in the user space to perform the binding between the process and the CPU and process and memory nodes.
    3. This function updates cpus_allowed and mems_allwed to the online CPU and online memory nodes, registers the hook function for memory hot-plug, and finally creates a single-threaded work queue cpuset.
  11. Usermodehelper_init ();

    Click (here) to collapse or open

    1. Create a single-threaded work queue khelper. There is only one running system, the main role is to specify the user space of the program path and environment variables, the final run of the specified users of the program, the user space is a critical thread, cannot be closed.
  12. Init_tmpfs ();

    Click (here) to collapse or open

    1. Initializing the kernel Tmpfs file system
  13. Driver_init ();

    Click (here) to collapse or open

    1. Initializing the subsystems in the drive model, the visible phenomenon is the directories and files that appear in the/sys
  14. Init_irq_proc ();

    Click (here) to collapse or open

    1. Create an IRQ directory in the proc file system and initialize all interrupts in the system to the corresponding directory.
  15. Do_ctors ();

    Click (here) to collapse or open

    1. The call links to all the constructors in the kernel, that is, all the functions that are linked into the. Ctors segment.
    2. Kernel boot added support for constructors at the beginning of Linux-2.6.31.
    3. Git commits:

      Click (here) to collapse or open

        1. Commit B99b87f70c7785ab1e253c6220f4b0b57ce3a7f7
        2. Author:peter Oberparleiter<[email protected]>
        3. date:wed June 17 16:28:03 2009-0700
        4. Kernel:constructor Support
      Kernel: constructor support
      1. Call Constructors (gcc-generated initcall-like functions) during kernel
      2. Start and module load. Constructors is e.g. used for GCOV data
      3. Initialization.
      4. The constructor (the GCC-generated class initialization function) is called when the kernel boots and the module mounts. Constructor is
      5. For example, functions for initializing Gcov data
      6. Disable constructor support for UserMode Linux to prevent conflicts with
      7. Host glibc.
      8. For Linux User mode disable constructor support to avoid conflicts with glibc.
      9. Signed-off-by:peter Oberparleiter<[email protected]>
      10. Acked-by:rusty Russell<[email protected]>
      11. Acked-by:wang Cong<[email protected]>
      12. Cc:sam Ravnborg<[email protected]>
      13. Cc:jeff Dike<[email protected]>
      14. Cc:andi Kleen<[email protected]>
      15. Cc:huang Ying<[email protected]>
      16. Cc:li Wei<[email protected]>
      17. Cc:michael Ellerman<[email protected]>
      18. Cc:ingo Molnar<[email protected]>
      19. Cc:heiko Carstens<[email protected]>
      20. Cc:martin Schwidefsky<[email protected]>
      21. Cc:al Viro<[email protected]>
      22. Signed-off-by:andrew Morton<[email protected]>
      23. Signed-off-by:linus Torvalds<[email protected]>
      $ git tag--contains b99b87f7v2.6.31v2.6.31-rc1v2.6.31-rc2v2.6.31-rc3v2.6.31-rc4v2.6.31-rc5v2.6.31-rc6v2.6.31-rc7v2.6.31-rc8v2.6.31-rc9v2.6.32 V2.6.32-rc1v2.6.32-rc2v2.6.32-rc3v2.6.32-rc4v2.6.32-rc5v2.6.32-rc6v2.6.32-rc7v2.6.32-rc8
  16. Do_initcalls ();

    Click (here) to collapse or open

    1. Invokes the initialization function in the driver module of all compiled kernels.
    2. This is the step that drives the programmer to take care of, in which the function is initialized by the sequence of the boot level (1~7) that is defined by the initialization function of each kernel module.
    3. For the same level of initialization functions, installation compilation is the sequential invocation of the link, which is related to the writing of the kernel makefile.
    When writing kernel modules, you need to know this knowledge, such as the module you write using the I²c API, your module's initialization function level must be lower than the level of the I²C subsystem initialization function (that is, the number of levels (1~7) is greater than the I²C subsystem).  If you write a module that must be at the same level as the dependent module, you must be aware of the changes to the kernel makefile. This knowledge will be available at the time of the summary, there are related articles on the Internet.
  17. }
The above function calls the Driver_init function, which is to drive the initialization of the model subsystem, which is important for the kernel driver engineer, as follows: drivers/base/init.c:
  1. /**
  2. * Driver_init-Initialize the drive model.
  3. *
  4. * Call the drive model initialization function to initialize their subsystems.
  5. * Called by the early init/main.c.
  6. */
  7. void __init driver_init (void)
  8. {
  9. /* They are core components */
  10. Devtmpfs_init ();

    Click (here) to collapse or open

    1. Initializes the Devtmpfs file system, which drives the core devices to add their device nodes to the file system.
    2. This file system can be mounted automatically by the kernel after the root file system is mounted to/dev, or manually in the file system startup script.
  11. Devices_init ();

    Click (here) to collapse or open

    1. Initialize some subsystems and kobject in the drive model:
    2. Devices
    3. Dev
    4. Dev/block
    5. Dev/char
  12. Buses_init ();

    Click (here) to collapse or open

    1. Initializing the bus subsystem in the drive model
  13. Classes_init ();

    Click (here) to collapse or open

    1. Initialize the class subsystem in the drive model
  14. Firmware_init ();

    Click (here) to collapse or open

    1. Initializing the firmware subsystem in the drive model
  15. Hypervisor_init ();

    Click (here) to collapse or open

    1. Initializing the hypervisor subsystem in the drive model
  16. /* These are also core components, but must be
  17. * Called after the core components in the core above.
  18. */
  19. Platform_bus_init ();

    Click (here) to collapse or open

    1. Initializing the Bus/platform subsystem in the drive model
  20. System_bus_init ();

    Click (here) to collapse or open

    1. Initializing the Devices/system subsystem in the drive model
  21. Cpu_dev_init ();

    Click (here) to collapse or open

    1. Initializing the DEVICES/SYSTEM/CPU subsystem in the drive model
  22. Memory_dev_init ();

    Click (here) to collapse or open

    1. Initializing the Devices/system/memory subsystem in the drive model
    2. Although it looks like this from the code, I did not find the/sys/devices/system/memory directory in the actual system.
  23. }

Linux Kernel Source Analysis--Kernel boot (6) Image kernel boot (do_basic_setup function) (Linux-3.0 ARMv7) "Go"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.