asmlinkage void __init start_kernel(void)
{
char * command_line;
extern const struct kernel_param __start___param[], __stop___param[];
/*这两个变量为地址指针,指向内核启动参数处理相关结构体段在内存中的位置(虚拟地址)。
声明传入参数的外部参数对于ARM平台,位于 include\asm-generic\vmlinux.lds.h*/
/*
* Need to run as early as possible, to initialize the
* lockdep hash:
lockdep是一个内核调试模块,用来检查内核互斥机制(尤其是自旋锁)潜在的死锁问题。
*/
/*
* Set up the the initial canary ASAP:
初始化栈canary值
canary值的是用于防止栈溢出攻击的堆栈的保护字 。
*/
boot_init_stack_canary();
/*1.cgroup: 它的全称为control group.即一组进程的行为控制.
2.该函数主要是做数据结构和其中链表的初始化
3.参考资料: Linux cgroup机制分析之框架分析
*/
/*
* These use large bootmem allocations and must precede
* kmem_cache_init()
*/
setup_log_buf(0);
/*初始化hash表,以便于从进程的PID获得对应的进程描述指针,按照开发办上的物理内存初始化pid hash表
*/
pidhash_init();
vfs_caches_init_early();//建立节点哈希表和数据缓冲哈希表
sort_main_extable();//对异常处理函数进行排序
trap_init();//初始化硬件中断
mm_init();// Set up kernel memory allocators 建立了内核的内存分配器
/*
* Set up the scheduler prior starting any interrupts (such as the
* timer interrupt). Full topology setup happens at smp_init()
* time - but meanwhile we still have a functioning scheduler.
*/
sched_init();//核心进程调度器初始化
/*
* Disable preemption - early bootup scheduling is extremely
* fragile until we cpu_idle() for the first time.
*/
preempt_disable();//禁止调度
// 先检查中断是否已经打开,若打开,输出信息后则关闭中断。
if (WARN(!irqs_disabled(), "Interrupts were enabled *very* early, fixing it\n"))
local_irq_disable();
idr_init_cache();//创建idr缓冲区
rcu_init();//互斥访问机制
tick_nohz_init();
context_tracking_init();
radix_tree_init();
/* init some links before init_ISA_irqs() */
early_irq_init();
init_IRQ();//使用alpha_mv结构和entry.S入口初始化系统IRQ
tick_init();
init_timers();//定时器初始化
hrtimers_init();//高精度时钟初始化
softirq_init();//软中断初始化
timekeeping_init();// 初始化资源和普通计时器
time_init();//时间、定时器初始化(包括读取CMOS时钟、估测主频、初始化定时器中断等)
sched_clock_postinit();
perf_event_init();
profile_init();// 对内核的一个性能测试工具profile进行初始化。
call_function_init();
WARN(!irqs_disabled(), "Interrupts were enabled early\n");
early_boot_irqs_disabled = false;
local_irq_enable();//使能中断
/*
* HACK ALERT! This is early. We‘re enabling the console before
* we‘ve done PCI setups etc, and console_init() must be aware of
* this. But we do want output early, in case something goes wrong.
*/
console_init();//初始化控制台以显示printk的内容
if (panic_later)
panic("Too many boot %s vars at `%s‘", panic_later,
panic_param);