http://elmurod.net/en/index.php/archives/625
Execution in Assembly
Entry point for Kernel uncompressed – arch/arm/kernel/head.S
- Read processor ID in coprocessor and obtain proc_info_list pointer
- Lookup machine type based on mach-id passed by bootloader (R1), get the mach_desc pointer and save mach-id
- Determine vailidity of ATAGS pointer (R2) and save
- Setup minimal pagetable to get Kernel running on virtual address, also setup one-to-one mapping for the page that turns on MMU
- Initialize TLB, caches, setup MMU to be turned on
- Turn on MMU
- Branch to start_kernel
Execution in C
C entry point –
start_kernel() init/main.c
- Disable IRQ local_irq_disable()
- Print Linux banner
- Arch specific setup setup_arch() (arch/arm/kernel/setup.c)
- Using mach-id, get pointer to machine_desc (defined in board file)
- Using ATAG physical pointer, obtain virtual address
- Invoke machine specific fixup
- Save & parse ATAGS parse_atags() (arch/arm/kernel/setup.c)
- Parse early params parse_early_params
- arm_memblock_init (arch/arm/mm/init.c)
- Invoke machine specific reserve
- Setup pagetables paging_init (arch/arm/mm/mmu.c)
- prepare_pagetable
- Map memory banks
- Map machine vectors devicemaps_init
- Invoke machine specific map_io
- Allocate zero page
- bootmem_init (arch/arm/mm/init.c)
- Install vectors early_trap_init (arch/arm/kernel/traps.c)
- Invoke machine specific init_early
- Build memory zone list build_all_zonelists() (mm/pagealloc.c)
- Print Kernel command line
- Parse early params
- Parse commandline args parse_args (kernel/params.c)
- pid hashtable initialization
- Setup Kernel memory allocators mm_init
- Mark free areas in memory & print memory details
- Initialize page cache
- Initialize vmalloc
- Initialize scheduler sched_init
- Disable preemption
- Initialize RCU, radix tree
- early_irq_init (kernel/irq/irqdesc.c)
- Invoke machine specific init_irq
- Initialize software timers, soft irq init_timers (kernel/timer.c), softirq_init (kernel/softirq.c)
- Initialize clocksource & common timekeeping values timekeeping_init (kernel/time/timekeeping.c)
- time_init (arch/arm/kernel/time.c)
- Get machine specific timer
- Invoke machine specific timer->init
- sched_clock post init
- Enable IRQ
- Initialize console device (if console_initcall) console_init (drivers/tty/tty_io.c)
- kmem_leak_init (mm/kmemleak.c)
- Allocate per_cpu pagesets setup_per_cpu_pageset (mm/pagealloc.c)
- Initialize NUMA policy numa_policy_init (mm/mempolicy.c)
- calibrate_delay (init/calibrate.c)
- Initialize pid map pidmap_init (kernel/pid.c)
- Initialize anonymous vma anon_vma_init (mm/rmap.c)
- Initialize init process structure fork_init (kernel/fork.c)
- Initialize security framework security_init (security/security.c)
- Initialize kdb kdb_init (kernel/debug/kdb/kdb_main.c)
- Initialize caches for VFS vfs_caches_init (fs/dcache.c)
- Initialize proc FS proc_root_init (fs/proc/root.c)
- Initialize ftrace ftrace_init (kernel/trace/ftrace.c)
- rest_init (in non-init section)
- Spawn init process
- Spawn kthreadd
- Wait till kthreadd is setup
- Enable preemption
- schedule schedule (kernel/sched.c)
- Disable preemption
- cpu_idle (arch/arm/kernel/process.c)
process – 1 (init process) kernel_init (init/main.c)
- Wait till kthreadd is setup
- do_basic_setup
- Create usermode helper wq usermodehelper_init (kernel/kmod.c)
- Initialize tmpfs init_tmpfs (mm/shmem.c)
- Initialize driver model driver_init (drivers/base/init)
- Call initcalls as per the order (machine specific init_machine would get called due to this) do_initcalls
- prepare_namespace (init/do_mounts.c)
- Load initrd initrd_load (init/do_mounts_initrd.c)
- Identify decompressor method identify_ramdisk_image (init/do_mounts_initrd.c)
- Create memory for uncompressed FS
- Decompress FS and copy crd_load (init/do_mounts_rd)
- Mount root FS mount_root (init/do_mounts.c)
- Load initrd initrd_load (init/do_mounts_initrd.c)
- init_post (in non-init section)
- Free memory in init section free_initmem (arch/arm/mm/init.c)
- Replace process – 1 (a kernel thread) with userspace init process, by exec in kernel run_init_process
Credit : Suresh Thiagarajan