linux启动过程分析
linux bootup flow chart
when boot the kernel execute start_kernel(void) function in init/main.c
1. lock_kernel(); This cannot happen asynchronously,so we use spin_lock to come into agreement with other CPU.
2. setup_arch(&command_line); arch/ppc/kernel/setup.c IO base is not yet inited
pmac_feature_init(); arch/ppc/platforms/pmac_feature.c
probe_uninorth();/* Detect the UniNorth memory controller */
probe_macios();/* Probe mac-io controllers */
probe_motherboard();/* Probe machine type */
do_init_bootmem(); arch/ppc/mm/init.c Initialize the bootmem system and give it all the memory we
have available.set up the bootmem stuff with available memory ,
Be sure to change arch/ppc/Makefile to match.
3.parse_options(command_line); init/main.c
This routine also checks for options meant for the kernel.
4.trap_init(); deal with exception.
5.init_IRQ(); arch/ppc/kernel/irq.c
6.sched_init(); kernel/sched.c
7.softirq_init(); kernel/softirq.c
8.time_init();arch/ppc/kernel/time.c
9.console_init();Initialize the console device. This is called *early*, so we can't necessarily
depend on lots of kernel help here.Just do some early initializations, and do the complex setup later.
10.mem_init();arch/ppc/mm/init.c
11.kmem_cache_sizes_init();Initialisation - setup remaining internal and general caches.Called after
the gfp() functions have been enabled, and before smp_init().
12.pgtable_cache_init();include/asm-ppc/pgtable.h
13. fork_init(num_mappedpages);kernel/fork.c
14.proc_caches_init();kernel/fork.c
15.vfs_caches_init(num_physpages);fs/dcache.c
16.buffer_init(num_physpages);fs/buffer.c
17.page_cache_init(num_physpages);mm/filemap.c
18. ipc_init();ipc/util.c
19.check_bugs();arch/ppc/kernel/syscalls.c
20.rest_init();init/main.c
ok,thus we can call a kernel thread to begin init.(the call realize in rest_init function).
now in init() function.
1.lock_kernel();
2.do_basic_setup();
3.prepare_namespace();init/main.c
Ok, the machine is now initialized. None of the devices have been touched yet,
but the CPU subsystem is up and running, and memory and process management works.
Now we can finally start doing some real work..
sock_init();
start_context_thread();
do_initcalls();
4.free_initmem();
5.unlock_kernel();
6.run_init_process("/sbin/init"
;
7.run_init_process("/etc/init"
;
8.run_init_process("/bin/init"
;
9.run_init_process("/bin/sh"
;