This article introduces the second part of the ARM Linux boot, written in C, mainly on the creation of Start_kernel to 1th process. Mainly about the process, and then the sub-function to explain.
First, Start_kernel
Start_kernel is located in Init/main.c, which mainly completes initialization of some Linux subsystems.
1) smp_setup_processor_id () Single CPU bit is empty.
2) Lock_kernel () lock Cpu,linux is a preemption-enabled, multi-CPU Call this function prevents other CPU preemption.
3) Tick_init () time-related initialization
4) Boot_cpu_init () determines how many CPUs are available. This is now described as a single CPU.
5) Page_address_init () Initializes high-end memory. Linux kernel space is 1G, corresponding to the maximum supported physical memory is also 1G. In order to support more than 1G of memory, use high-end memory (128M) for mapping processing.
6) Setup_arch (&command_line), located in arch/arm/kernel/setup.c This function is more important.
I setup_processor initialize the CPU architecture, Setup_machine initialize the platform data structure
II INIT_MM Initialize the task_struct of process # 1th
III Parse_cmdline (Cmdline_p, from) gets the default startup parameter and obtains the relevant startup command information.
IV Paging_init (&meminfo, Mdesc); Create a formal page table
V request_standard_resources (&meminfo, Mdesc); Request IO Resources
VI Related global variable assignment INIT_ARCH_IRQ = mdesc->init_irq;
System_timer = mdesc->timer;
Init_machine = mdesc->init_machine;
7) Mm_init_owner Initialize init memory, ARM system is empty
8) Setup_command_line (command_line) get the Bootargs parameter in Uboot, get the relevant start command information
9) Setup_nr_cpu_ids (); Setup_per_cpu_areas (); Smp_prepare_boot_cpu () Multi-CPU functions
Build_all_zonelists () Initializes a list of all memory management nodes for subsequent memory management initialization.
One) Page_alloc_init () Physical memory allocation initialization.
Parse_early_param () Gets the parameters of the first execution part of the command line early.
Vfs_caches_init_early () VFS Cache subsystem Initialization
Mm_init () memory management initialization
Sched_init () Scheduling management initialization
() Rcu_init () initialize the lock mechanism of direct read copy update
() INIT_IRQ Interrupt initialization
Timer initialization, high-precision time initialization
19) Soft Interrupt Initialization
(local_irq_enable) Open interrupt
Console_init Initialize the console, after the initialization of the Prink can be output, before the output to the buffer inside.
22) page Table cache initialization
) Thread Cache initialization
) IPC Initialization
25) asynchronous signal initialization
26) There are some other multi-CPU related initializations.
Rest_init Create process No. 1th.
Second, Rest_init
1) kernel_thread (Kernel_init, NULL, CLONE_FS | Clone_sighand); Create 1th Process Init
2) Create the Kthreadd thread, which is the parent of the kernel thread, manages scheduling other kernel threads, and the list of kernel threads is managed by the Kthread_create_list global chain.
3) Create idle thread consumes empty CPU time.
Next, the third part of the Kernel_init run, that is, process 1th.
Arm Linux boot two: Start_kernel to create process # 1th