Chinaunix首页 | 论坛 | 博客
  • 博客访问: 210744
  • 博文数量: 59
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 424
  • 用 户 组: 普通用户
  • 注册时间: 2012-04-25 12:57
文章分类

全部博文(59)

文章存档

2016年(23)

2015年(30)

2014年(6)

我的朋友

分类: LINUX

2016-10-16 15:33:13

1.有MMU的设备的启动过程
arch/arm/kernel/head.S
    .section ".text.head", "ax"
ENTRY(stext)
    msr    cpsr_c, #PSR_F_BIT | PSR_I_BIT | SVC_MODE @ ensure svc mode
                        @ and irqs disabled
    mrc    p15, 0, r9, c0, c0        @ get processor id
    bl    __lookup_processor_type        @ r5=procinfo r9=cpuid
    movs    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    __vet_atags
    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
                        @ mmu has been enabled
    adr    lr, __enable_mmu        @ return (PIC) address
    add    pc, r10, #PROCINFO_INITFUNC
ENDPROC(stext)
执行流程
1.__lookup_processor_type:确定内核是否支持该构架
2.__lookup_machine_type:确定内核是否支持此平台
3.__create_page_tables:建立一级页表
4.__enable_mmu:使能mmu
5.__switch_data
arch/arm/kernel/head-common.S
__switch_data    -->    __mmap_switched    -->    start_kernel


2.无MMU的设备的启动过程
    .section ".text.head", "ax"
    .type    stext, %function
ENTRY(stext)
    ldr    r1, =machine_arch_type        @ find the machine type
    msr    cpsr_c, #PSR_F_BIT | PSR_I_BIT | SVC_MODE @ ensure svc mode
                        @ and irqs disabled
#ifndef CONFIG_CPU_CP15
    ldr    r9, =CONFIG_PROCESSOR_ID
#else
    mrc    p15, 0, r9, c0, c0        @ get processor id
#endif
    bl    __lookup_processor_type        @ r5=procinfo r9=cpuid
    movs    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'

    ldr    r13, __switch_data        @ address to jump to after
                        @ the initialization is done
    adr    lr, __after_proc_init        @ return (PIC) address
    add    pc, r10, #PROCINFO_INITFUNC
其启动流程和上面基本相同


例子分享:
我现在移植的一个板子,是不带mmu的,刚开始怎么都启动不起来,打印出“done, booting the kernel",然后就无声无息了。后来在Kernel startup entry point开始处的ENTRY(stext)下添加了句代码:
”ldr    r1, =machine_arch_type“就很顺利得起来了.后来分析知道,添加这句代码后就不会进行平台的匹配了!但是启动以后也是正常的!不知道此处平台匹配的真正意义是什么,还需要与有经验的朋友共同探讨。

                                                                   xin.jin
阅读(5373) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~