Kernel Startup Process

Source: Internet
Author: User

We are now using a zookeeper zimage with 64-byte header information, which is changed to a uimage. Therefore, the front part of the kernel is self-resolved and used as a token, after that, the system will jump to the real kernel slave line to replace the slave. Therefore, we jumped from uboot to arch/ARM/boot/compressed/head. in S, this section has not been studied, but the main process is from arch/ARM/boot/compressed/vmlinux. LDS can know that the first flight line's replacement is start:

The row 131 indicates that rows 132 and lines 8 are the magic number of Linux kernel, which will be used when the uboot kernel checks the kernel. If you forget it, you can go back to uboot and check it:

The following figure shows the number of self-resolving functions that are redirected from row 3 to arch/ARM/boot/compressed/Misc. C:

Then the second row jumps:

The second line of the second line jumps to the real kernel generation of the second line in arch/ARM/kernel/head. S.

In ARCH/ARM/kernel/vmlinux. LDS:

We can see that the lable is the entrance of the kernel, which is in arch/ARM/kernel/head. S:

The first statement first gets the processor ID with the processor, and then uses the _ lookup_processor_type function to find whether the front core supports this handler in the head-common.S:

Simply put, the physical address of _ proc_info_begin Row 3 after row 3 is complete is _ proc_info_begin. After Row 3 is complete, R5 = _ proc_info_begin
R6 =__ proc_info_end, R7 = zookeeper address of the 196 line generation, the difference between zookeeper and physical address calculated in row 164, and the physical address of R5 = _ proc_info_begin after row 165, the physical address of R6 =__ proc_info_end after the first row. Let's talk about the things between address _ proc_info_begin and address _ proc_info_end. In the ARCH/ARM/mm mesh, the arm cpu architecture supported by the kernel is defined. Our s5pv210 architecture is located in the V7 architecture, and we can see the following aspects:

This defines a proc_info_list structure, which is prototype in procinfo. h, from row 327, we can see that this generation of zookeeper was placed in .proc.info. init segment, .proc.info. init is connected to kernel ARCH/ARM/kernel/vmlinux. definition in lDs:

The Rows 381 show that the address _ proc_info_begin and address _ proc_info_end are placed in the proc_info_list structure.

Back in the head-common.S, the 167 line comparison to see if the combined proc_info_list is found, we have only one proc_info_list here, we can certainly find it, for example, if the number of rows is 170, it will jump to 175 and return the result. If the number of rows cannot be found, the number of rows will jump to the next proc_info_list, if proc_info_list still exists in Row 3, skip to row 3 Comparative comparison. Otherwise, the R5 mark of Row 3 is unknown processor, and then return.

Return to arch/ARM/kernel/head. in S: whether the processor ID obtained by the 80 rows is consistent with the processor ID obtained by the slave node. If the 81 rows are disconnected, the CPU crashes. If yes, the 82 rows are deleted, __lookup_machine_type is also set in arch/ARM/kernel/head-common.S:

It is similar to the previous _ proc_info_begin. You can find the architecture from the address _ arch_info_begin and address _ arch_info_end,

.Arch.info. init puts the final structure machine_desc. Our s5pv210 component definition is in machine. C,

Machine_start and machine_end are a macro. You can see the macro definition of machine_end. In arch. h:

Looking at the 53 rows of this macro, we can see that the structure was stored in .arch.info. init segment, others do not want to say more, so how does Nr = mach_type_pdc2 refer to host serial 5001 after this is expanded, check the Three audio files in arch/ARM/tools. First, check the makefile:

How does it generate an Include/generated/mach-types.h head file (not originally? Run the awk command to run the scripts in the Gen-Mach-types file to parse the files generated by the Mach-types file, interesting to be able to study awk's large text processing tool, here we know it will generate a mach-types.h, so look at its content:

Go back to the ARCH/ARM/kernel/head-common.S, and the second line finds and returns the same as R1. What is R1 putting? That is, the first kernel data produced by Thekernel in uboot. Do you remember what it is? It is the machine ID defined in uboot, with a value of and a rare return to the ubootdeskprocess. ppt

Let's just look at the 2952 rows, and not much else.
Return to arch/ARM/kernel/head. in S, the next step is to enable MMU and so on. This is some crazy code generation. If you are interested, you can study it. In the end, there will be 97 rows:

_ Switch_data in the arch/ARM/kernel/head-common.S, extract the last half of the function:

The last 64 lines will jump to the C-generation pipeline, which is in init/Main. C:

Check the row number in arch/ARM/kernel/setup. C:

Line 2, machine_arch_type said before, in the include/generated/mach-types.h, we will find in machine. in C, define the machine_desc component. In line 3, get the value of boot_params. Here we are 0x689, which is exactly the historical data address of uboot servers, this is the agreement between uboot and kernel. If you don't understand it, check the value of uboot kernel.

Lines 695-698 are the final components compatible with the latest version. We do not have lines here, But line 701. The meminfo structure is a global change, this component will be used in many places in the future. Row 3 removes the atag_mem mark, which means that the memery memory generated by uboot kernel is not required because the kernel has its own settings; at the beginning of the second line, parse the tag numbers and go to the analysis to see:

For the first row, only T-> HDR is required. if the size is not 0, parse the records. The mark of the tag end in our uboot is the HDR of the structure of the tags. the value of size is 0, and the value of 637 rows:

Where is. taglist. init? To ARCH/arminclude/ASM/setup. h:

All the tagtable components defined by macro _ tagtable will be placed in the address starting with _ tagtable_begin and return to setup. in C, let's see which tagtable components are defined:

There are a lot of types in uboot, and there will be some types in it. Well, there will be only 622 rows after zookeeper returns to the queue. Which of the following statements can be used for analysis, such as tag = atag_cmdline, both uboot and kernel have definitions. Therefore, Row 3 is valid, and row 3 contains parse_tag_tagline numbers:

The author's self-analysis, I believe you will not fall behind. However, pay attention to the definition of the tagtable structure in arch/ARM/init. C. For example, ramdisk analysis is to go down in this file:

Line 752-754, numeric value and number of letters in machine. c elsewhere. Return to main. in C, Initialization is a lot of work along the way. Generally, there is no problem or need to be changed, problems may occur during the last rollback ramdisk period, for example, when the rollback operation fails. To use ramdisk, choose [*] initial Ram filesystem and RAM disk (initramfs/initrd) support in menuconfig-> General setup --->, ramdisk solution zookeeper is in init/initramfs. c:

You can see from the definition that this is the number of letters that initialize the root file system of zookeeper. You can analyze the content yourself in main. the last value of start_kernel in C: rest_init-> kernel_thread-> kernel_init:

Row 3 initializes all the operation and configuration changes such as the primary node and the primary node, and the primary node ramdisk is still running here. Row 3 opens the control plane, after 920,921 rows of rows are written, the labels are marked and exported to the console. This is the serial port number of Alibaba Cloud; row 3: Check whether/init exists. Here, ramdisk is stored, so if ramdisk does not exist, the prepare_namespace of the row 935 will be deleted and the root file system will be added to this function; the following lines of init_post:

After the first row is merged, the kernel does not return the result and enters the INIT program of framewrok.

Let's look back and see if there is any memory for ramdisk, that is, the number of the prepare_namespace function in row 935 of the original row:

Row 3 waits for initialization of all the settings to complete, and row 3 is the bootargs metric data that our uboot servers have imported:

Check the mount_initrd value of row 112:

It means that there is ramdisk In the silence. If noinitrd is set in the bootargs of your uboot plugin, it will be 0. Return to the prepare_namespace function, row 3:

Row 3 is set to Floppy. It is not specified. Row 3 is mount_block_root:

Row 3: obtain the first address of the file system type supported by the core. The supported types include ext2 ext3 ext4 cramfs vfat msdos sysv V7 romfs yaffs yaffs2; upload all file systems in 248 rows and then upload them again. If none of the operations are successful, go to 279 rows and print the partition information, prompting you that you cannot upload the file system, in this case, the system crashes. Check the log information:

Let's talk about the _ setup and early_param Macros in the kernel:

We can see from rows 136 and 144 that these two macro values will be written in. init. in the setup section, check whether the kernel is connected to the kernel ARCH/ARM/kernel/vmlinux. LDS:

Find in the kernel token, in init/Main. C:

In uboot, PASS Parameters such as initrd = 0x31000000 40 m, 0x3000000 indicates the starting position of ramdisk, and 40 m indicates the size of ramdisk. Then, the kernel is parsed in init. C:

Search phys_initrd_start in init. C, and then you will find:

The value is also assigned here, so you can use a single parameter here. For example, pv210 does not pass the initrd parameter.

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.