Linux Kernel Series One: opening and Kernel launch summary

Source: Internet
Author: User

Objective

In recent months, the Linux kernel has probably been studied, the following need to conduct in-depth detailed analysis. The main development Board of S3C2440 is a hardware entity. Probably includes the following content:

1 bootloader analysis, to Uboot-based, combined with the specific development Board situation. My goal is to explain how Uboot works (to be honest, the analysis does not want to be kidnapped by hardware, but requires a practical example

To do the analysis)

2 kernel Part, this is a lot of content. You intend to start the analysis from the kernel initiated process.

3 In addition to kernel itself, there is a lot of knowledge, such as LD input script analysis, and here will be introduced together.


Kernel START process Overview

One: The composition of kernel image1 ES (Embed System) when the CPU is power up, the first statement executed is bootloader, which is very similar to the BIOS on the PC. After the BL loads the kernel, the controller is handed over to LK 2 What is the first statement executed by LK? Vmlinux is the core representation of the monomer. Based on the previously mentioned kernel compilation connection knowledge, the first statement is head. S (for historical reasons, MD, there are many files called head. S) we need to re-analyze the composition of the kernel (here is the Zimage), (the method is simple, study the execution of make, get almost all the information by making v=1 Zimage)
    • Vmlinux, this is the uncompressed, strip kernel module, ELF structure
    • Image: A binary, uncompressed, but strip kernel
    • Head.o:arm related, the control is transferred to it by BL. That is the head mentioned earlier. S generation
    • gzip compression for Pigg.gz:Image files
    • PIGGY.O: Generated by PIGGY.S, this s file contains the image in the Include bin mode. Piggy means carrying and shouldering. It's an image, isn't it?
    • MISC.O: From the above, it involves some decompression aspects, while Misc provides some auxiliary functions
    • Vmlinux: Sad urge ..... This file is a vmlinux composed of Head+pigg+misc. The same name? It's really confusing!
    • Zimage: And then it's compressed by the vmlinux above.
Figure 1 shows the process very well.
Figure 1 The composition of the kernel3 Piggy's storyPiggy. S is interesting to set up a section and has a flag to indicate the boundary of the piggy.gz. Piggy corresponds to an image called Bootstrap, note that bootstrap and bootloader are not the same, it is a piece of code after the BL, used tounzip kernel, set memory and other functions. You can also call second stage boot.  4 Bootloadre and BootstraploaderWhat is the difference between BL and BSL?
    • BL simply initializes the hardware, does not rely on Linux, does not process Linux
    • BSL is executed after BL and relies on Linux because it wants to unzip Linux. Another important point is that BSL needs to build the environment for Linux to run
BSL's work includes:
    • Head. O: Initialize the CPU and other work
    • Misc. O: Unzip, reposition (e.g. move kernel to another location) Decompress_kernel
    • Other work
Init/main.c:start_kernelThe start call graph is shown in Figure 2.
Figure 2 Starting the call flowchartbelow to analyze this startup process1 kernel in the HEAD.O analysis: Try to keep the CPU series common, such as the arm of the CPU initialization is done. But how does a specific board (such as cpu+ other hardware) initialize? This is done by the initialization function in the Mach directory. Therefore, kernel initialization is divided into: Generic CPU initialization + The initialization of the specific board. After the HEAD.O is initialized, jump to MAIN.O's start_kernel and proceed to the following process2 Start_kernel: (INIT/MAIN.C): Transfer of Start_kernel by head. o, but the code is generally included in the more general Head_common. S Mediumafter you want to do kernel analysis, start with Main. What did Start_kernel do?
    • Just initialized CPU-related, and specific and board-related by Start_arch execution
3 Kernel parameter analysis: Kernel command line. Note that this parameter is passed to kernel by BL, but who set this parameter? Where does it exist? This line is placed in a global place,also, how do kernel handle these parameters? There is a better way, __SET_UP macros, to have some parameters and corresponding function pointers in a special section, and then loop through the functions in this section. (Much like in the driver module). defined in the init.h. The values for some special parameters are defined in ARCH/ARM/KERNEL/VMLINUX.LDS.S. (I have to see the Manual of LD later) __SET_UP This macro also has a flags such as early, indicating whether the processing phase is done in early-stage. The memory that the section of the __init is marked with will be discarded.4 subsystem initialization: including interrupts, etc.? Section nesting section? 5 Kernel_init process: Start_kernel finally fork a kernel_init process, and the original execution process becomes the idle process .6 init process for user space: finalized by kernel_init process through EXECVE init7 references. The reference books given by the elp are huge .

Linux Kernel Series One: opening and Kernel launch summary

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.