u-boot启动流程(一)

arch/arm/cpu/armv7/start.S       //这里要看你用的是什么样的cpu,我用的contex A5,所以在armv7目录下

/* Set stackpointer in internal RAM to call board_init_f */
call_board_init_f:
    ldr sp, =(CONFIG_SYS_INIT_SP_ADDR) 
    bic sp, sp, #7 /* 8-byte alignment for ABI compliance */
#ifndef CONFIG_NAND_SPL
    ldr r0,=0x00000000        
    bl  board_init_f          
#else  
    ldr r0, =(CONFIG_SYS_INIT_SP_ADDR) 
    ldr r1, =0x00000000       
    ldr r2, =(CONFIG_SYS_TEXT_BASE)
    bl relocate_code          
#endif                 
在这里会跳转到board_init_f()函数     arch/arm/lib/board.c

void board_init_f (ulong bootflag)
{
    bd_t *bd;
    init_fnc_t **init_fnc_ptr;
    gd_t *id;
    ulong addr, addr_sp;

    /* Pointer is writable since we allocated a register for it */
    gd = (gd_t *) ((CONFIG_SYS_INIT_SP_ADDR) & ~0x07);
    /* compiler optimization barrier needed for GCC >= 3.4 */
    __asm__ __volatile__("": : :"memory");

    memset ((void*)gd, 0, sizeof (gd_t));

    gd->mon_len = _bss_end_ofs;

    for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
        if ((*init_fnc_ptr)() != 0) {
            hang (); 
        }   
    }   

    debug ("monitor len: %08lX\n", gd->mon_len);
    /*  
     * Ram is setup, size stored in gd !!
     */
    debug ("ramsize: %08lX\n", gd->ram_size);
这里会调用init_sequence[ ]里的函数,该数组在该文件中定义,内容如下:

init_fnc_t *init_sequence[] = {
#if defined(CONFIG_ARCH_CPU_INIT)  
    arch_cpu_init,      /* basic arch cpu dependent setup */                                                                                                                     
#endif 
#if defined(CONFIG_BOARD_EARLY_INIT_F)
    board_early_init_f,       
#endif 
    timer_init,     /* initialize timer */
#ifdef CONFIG_FSL_ESDHC
    get_clocks,
#endif 
    env_init,       /* initialize environment */
    init_baudrate,      /* initialze baudrate settings */
    serial_init,        /* serial communications setup */
    console_init_f,     /* stage 1 init of console */  
    display_banner,     /* say that we are here */
#if defined(CONFIG_DISPLAY_CPUINFO)
    print_cpuinfo,      /* display cpu info (and speed) */                                                                                                                       
#endif 
#if defined(CONFIG_DISPLAY_BOARDINFO)
    checkboard,     /* display board info */                                                                                                                                     
#endif 
#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)                                                                                                                         
    init_func_i2c,
#endif 
    dram_init,      /* configure available RAM banks */
#if defined(CONFIG_CMD_PCI) || defined (CONFIG_PCI)                                                                                                                              
    arm_pci_init,
#endif 
    NULL,
};


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值