内核启动过程

来源:互联网 发布:怎么查淘宝宝贝降权 编辑:程序博客网 时间:2024/06/09 17:48

内核启动的第一阶段:

这个阶段主要是处理uboot传入的参数

我们从分析第一个 arch/arm/kernel/head.S 汇编程序开始:
msr    cpsr_c, #PSR_F_BIT | PSR_I_BIT | SVC_MODE @ ensure svc mode                                 @ and irqs disabledmrc    p15, 0, r9, c0, c0        @ get processor idbl    __lookup_processor_type    @ r5=procinfo r9=cpuid    //判断是否支持cpumovs    r10, r5                  @ invalid processor (r5=0)?beq    __error_p                 @ yes, error 'p'bl    __lookup_machine_type      @ r5=machinfo            //判断是否支持这个单板movs    r8, r5                   @ invalid machine (r5=0)?beq    __error_a                 @ yes, error 'a'    bl    __create_page_tables       @ 建立页表,使虚拟地址转换为实际地址/* * The following calls CPU specific code in a position independent * manner.  See arch/arm/mm/proc-*.S for details.  r10 = base of * xxx_proc_info structure selected by __lookup_machine_type * above.  On return, the CPU will be ready for the MMU to be * turned on, and r0 will hold the CPU control register value. */ldr    r13, __switch_data        @ address to jump to after//跳到第一个c函数                                 @ mmu has been enabledadr    lr, __enable_mmu          @ return (PIC) address    //使能mmuadd    pc, r10, #PROCINFO_INITFUNC

第一个阶段主要是汇编代码,第二阶段开始进入c语言。

内核启动的第二阶段:

这个阶段主要是初始化程序,挂接根文件系统,最终启动应用程序

start_kernel    setup_arch(&command_line);           //解析uboot启动参数    setup_command_line(command_line);    //解析uboot启动参数    rest_init                            //启动init过程        kernel_init            prepare_namespace                mount_root               //挂接根文件系统            init_post                                             //执行应用程序    


原创粉丝点击