Am335x u-boot 代码大概流程(转) Am335x u-boot 代码大概流程

Am335x u-boot 代码大概流程

 

在_面之前的流程和u-boot-spl一样,区别在于_main中。

对于u-boot 2016.03来说

复制代码
ENTRY(_main)

/*
 * Set up initial C runtime environment and call board_init_f(0).
 */


    ldr    sp, =(CONFIG_SYS_INIT_SP_ADDR)

    bic    sp, sp, #7    /* 8-byte alignment for ABI compliance */
#endif
    mov    r0, sp
    bl    board_init_f_alloc_reserve
    mov    sp, r0
    /* set up gd here, outside any C code */
    mov    r9, r0
    bl    board_init_f_init_reserve

    mov    r0, #0
    bl    board_init_f

    ldr    sp, [r9, #GD_START_ADDR_SP]    /* sp = gd->start_addr_sp */
    bic    sp, sp, #7    /* 8-byte alignment for ABI compliance */
#endif
    ldr    r9, [r9, #GD_BD]        /* r9 = gd->bd */
    sub    r9, r9, #GD_SIZE        /* new GD is below bd */

    adr    lr, here
    ldr    r0, [r9, #GD_RELOC_OFF]        /* r0 = gd->reloc_off */
    add    lr, lr, r0
    ldr    r0, [r9, #GD_RELOCADDR]        /* r0 = gd->relocaddr */
    b    relocate_code
here:
/*
 * now relocate vectors
 */

    bl    relocate_vectors

/* Set up final (full) environment */

    bl    c_runtime_cpu_setup    /* we still call old routine here */

    ldr    r0, =__bss_start    /* this is auto-relocated! */

    ldr    r3, =__bss_end        /* this is auto-relocated! */
    mov    r1, #0x00000000        /* prepare zero to clear BSS */

    subs    r2, r3, r0        /* r2 = memset len */
    bl    memset
    /* call board_init_r(gd_t *id, ulong dest_addr) */
    mov     r0, r9                  /* gd_t */
    ldr    r1, [r9, #GD_RELOCADDR]    /* dest_addr */
    /* call board_init_r */

    ldr    pc, =board_init_r    /* this is auto-relocated! */
    /* we should not return here. */
#endif

ENDPROC(_main)
复制代码

对于函数board_init_f  (u-boot-2016.03/common/board_f.c)

复制代码
1 、计算u-boot镜像的长度
2、内存池的设置
3、控制台log缓存
4、CPU的特殊初始化
5、初始化定时器 ..../arch/arm/cpu/armv7/omap-common/timer.c
6、环境变量初始化
7、a、波特路初始化
     b、串口初始化  .../driver/serival/serival-unclass.c
     c、控制台初始化 // 可放在板级初始化board_init_f(spl)内,方便调试用
8、打印相关选择项
9、打印CPU信息---speed
10、 a、说明要初始化的dram ../arch/arm/cpu/armv7/am33xx/emif4.c
        b、对relcoate 区域规划
        c、relcoate 之后 gd成员设置
11、define选择,如果定义了硬件
       I2C、SPI,对其进行初始化  u-boot-2016.03/common/board_f.c
复制代码

对于函数board_init_f  (u-boot-2016.03/common/board_r.c)

具体参看此博文

http://www.cnblogs.com/leaven/p/6296428.html

在_面之前的流程和u-boot-spl一样,区别在于_main中。

对于u-boot 2016.03来说

复制代码
ENTRY(_main)

/*
 * Set up initial C runtime environment and call board_init_f(0).
 */


    ldr    sp, =(CONFIG_SYS_INIT_SP_ADDR)

    bic    sp, sp, #7    /* 8-byte alignment for ABI compliance */
#endif
    mov    r0, sp
    bl    board_init_f_alloc_reserve
    mov    sp, r0
    /* set up gd here, outside any C code */
    mov    r9, r0
    bl    board_init_f_init_reserve

    mov    r0, #0
    bl    board_init_f

    ldr    sp, [r9, #GD_START_ADDR_SP]    /* sp = gd->start_addr_sp */
    bic    sp, sp, #7    /* 8-byte alignment for ABI compliance */
#endif
    ldr    r9, [r9, #GD_BD]        /* r9 = gd->bd */
    sub    r9, r9, #GD_SIZE        /* new GD is below bd */

    adr    lr, here
    ldr    r0, [r9, #GD_RELOC_OFF]        /* r0 = gd->reloc_off */
    add    lr, lr, r0
    ldr    r0, [r9, #GD_RELOCADDR]        /* r0 = gd->relocaddr */
    b    relocate_code
here:
/*
 * now relocate vectors
 */

    bl    relocate_vectors

/* Set up final (full) environment */

    bl    c_runtime_cpu_setup    /* we still call old routine here */

    ldr    r0, =__bss_start    /* this is auto-relocated! */

    ldr    r3, =__bss_end        /* this is auto-relocated! */
    mov    r1, #0x00000000        /* prepare zero to clear BSS */

    subs    r2, r3, r0        /* r2 = memset len */
    bl    memset
    /* call board_init_r(gd_t *id, ulong dest_addr) */
    mov     r0, r9                  /* gd_t */
    ldr    r1, [r9, #GD_RELOCADDR]    /* dest_addr */
    /* call board_init_r */

    ldr    pc, =board_init_r    /* this is auto-relocated! */
    /* we should not return here. */
#endif

ENDPROC(_main)
复制代码

对于函数board_init_f  (u-boot-2016.03/common/board_f.c)

复制代码
1 、计算u-boot镜像的长度
2、内存池的设置
3、控制台log缓存
4、CPU的特殊初始化
5、初始化定时器 ..../arch/arm/cpu/armv7/omap-common/timer.c
6、环境变量初始化
7、a、波特路初始化
     b、串口初始化  .../driver/serival/serival-unclass.c
     c、控制台初始化 // 可放在板级初始化board_init_f(spl)内,方便调试用
8、打印相关选择项
9、打印CPU信息---speed
10、 a、说明要初始化的dram ../arch/arm/cpu/armv7/am33xx/emif4.c
        b、对relcoate 区域规划
        c、relcoate 之后 gd成员设置
11、define选择,如果定义了硬件
       I2C、SPI,对其进行初始化  u-boot-2016.03/common/board_f.c
复制代码

对于函数board_init_f  (u-boot-2016.03/common/board_r.c)

具体参看此博文

http://www.cnblogs.com/leaven/p/6296428.html

猜你喜欢

转载自www.cnblogs.com/lh03061238/p/10181145.html