Arm linux 2: start_kernel to process 1, armstart_kernel

Source: Internet
Author: User

Arm linux 2: start_kernel to process 1, armstart_kernel

This article introduces the second part of arm linux Startup, which is written in C language. It mainly describes the creation of start_kernel to process 1. This section describes the general process and describes subfunctions later.

1. start_kernel

Start_kernel is located in init/main. c and mainly initializes some subsystems in linux.

1) smp_setup_processor_id () single CPU bit is empty.

2) lock_kernel () locks the CPU. linux supports preemption. This function is called when multiple CPUs are used to prevent other CPUs from preemption.
3) tick_init () time-related Initialization
4) boot_cpu_init () determines how many CPUs are available. It is described as a single CPU.
5) page_address_init () initializes high-end memory. The Linux kernel space is 1 GB, and the maximum supported physical memory is 1 GB. To support over 1 GB of memory, high-end memory (128 MB) is used for ing.

6) setup_arch (& command_line), which is located in arch/arm/kernel/setup. c. This function is important.

I setup_processor initializes the CPU architecture, and setup_machine initializes the platform data structure.

Ii init_mm initialize task_struct of process 1

Iii parse_cmdline (cmdline_p, from) to obtain the default startup parameter and related startup command information.

Iv paging_init (& meminfo, mdesc); create a formal page table

V request_standard_resources (& meminfo, mdesc); apply for IO Resources

Assign values to the global variables related to vi: init_arch_irq = mdesc-> init_irq;
System_timer = mdesc-> timer;
Init_machine = mdesc-> init_machine;

7) mm_init_owner initializes the init memory. The arm system is empty.

8) setup_command_line (command_line) obtains the bootargs parameter in uboot and the relevant startup command information.

9) setup_nr_cpu_ids (); setup_per_cpu_areas (); smp_prepare_boot_cpu () multiple CPU Functions

10) build_all_zonelists () initializes the list of all memory management nodes for memory management initialization later.

11) page_alloc_init () physical memory allocation initialization.

12) parse_early_param () gets the parameter of the earliest execution part of the command line early.

13) vfs_caches_init_early () vfs cache subsystem Initialization

14) mm_init () memory management Initialization

15) sched_init () scheduling management Initialization

16) rcu_init () initializes the lock mechanism for Directly Reading and copying updates

17) init_IRQ interrupt Initialization

18) timer initialization, high-precision time Initialization

19) Soft Interrupt Initialization

20) local_irq_enable

21) lele_init initializes the console. After initialization, prink can output the data, which is previously output to the buffer.

22) page table cache Initialization

23) thread cache Initialization

24) IPC Initialization

25) asynchronous signal Initialization

26) there are some other multi-CPU-related initialization tasks.

27) rest_init creates process 1.

Ii. rest_init

1) kernel_thread (kernel_init, NULL, CLONE_FS | CLONE_SIGHAND); create process 1 init

2) create a kthreadd thread. It is the father of the kernel thread and manages and Schedules other kernel threads. The list of kernel threads is managed by the kthread_create_list global linked list.

3) Creating an idle thread consumes no CPU time.

Next, run the kernel_init in the third part, that is, process 1.


Whether to load the driver or mount the file system during the startup of arm linux

Because Linux kernels generally run in RAM, bootloader must
Set and initialize RAM,
After power-on or reset, read bootloader from flash, initialize RAM through bootloader, initialize the serial port, detect the processor type, set the Linux Startup parameters, and call the Linux kernel image.
After bootloader copies the Linux kernel image to RAM, you can use the following code to start the Linux kernel:
Call_linux (0, machine_type, kernel_params_base ). Machine_tpye is the detected Processor type, and kernel_params_base is the address of the startup parameter in RAM.

Linux Startup of arm

Well, there will be problems. Generally, uboot is used, so there is a machine code between uboot and kernel that corresponds

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.