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 specific analysis. The main development Board of S3C2440 is a hardware entity. It probably contains such things as the following:

1 bootloader analysis, to Uboot-based, combined with detailed development of the board. My goal is to explain clearly how uboot works (to be honest, the analysis does not want to be kidnapped by hardware, but it needs to be a practical example

To do the analysis)

2 kernel Part, this is a lot of content. It is intended 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, 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 to run is bootloader, which is similar to the BIOS on the PC. After the BL loads the kernel, the controller is handed over toLK2 What is the first statement that LK runs? Vmlinux is the core representation of the monomer. Based on the above-mentioned kernel compilation connection knowledge, the first statement is head. s in (historical reason, MD, there are very many files calledhead. S)once again, we need to analyze the composition of the kernel (here is zimage), (the method is very easy, to study make's running process, through make v=1 zimage to get nearly all the information)
    • 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 includes the image in the Include bin mode. Piggy means carrying and shouldering. Very graphic, 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? Really very 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 very interesting to set up a section, and there is 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. can also be called Second stage boot. 4 Bootloadre and BootstraploaderWhat is the difference between BL and BSL?
    • BL simply initializes the hardware, does not rely on Linux, and does not process Linux
    • BSL is executed after BL, relying on Linux, due to unzip Linux. Another important point is that BSL needs to build the environment for Linux execution
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 of general, such as the arm of the CPU initialization is done. But how to initialize the detailed board (such as cpu+ other hardware)? This is done by the initialization function in the Mach folder. So, kernel initialization is divided into: Generic CPU initialization + detailed board initialization. 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 do, just the code is generally included in the more general Head_common. S Mediumafter you want to do kernel analysis, start from Main. What did Start_kernel do?
    • Just now initialized CPU-related, and detailed and board-related run by Start_arch
3 Kernel parameter analysis: Kernel command line. Note that this parameter is passed to kernel by BL, but who is the participant set? Where does it exist? This line is placed in a global place,In addition, how does kernel deal with these parameters? There is a better way, __SET_UP macros, to have some of the parameters and corresponding function pointers in a special section, and then loop through the functions in this section. (very 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 another flags analogy early, indicating whether the processing phase is done in early-stage. The memory that marks the section of __init that is finally occupied will be discarded .4 subsystem initialization: include interrupts, etc.? Section nesting section? 5 Kernel_init process: Start_kernel finally fork a kernel_init process, and the original running process becomes the idle process .6 init process for user space: by kernel_init process finally through EXECVE init complete7 references. ELP This book gives the reference documents are very strong.

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.