zoukankan      html  css  js  c++  java
  • [uboot] (第三章)uboot流程——uboot-spl代码流程 后续2018版本分析

    board_init_f在/u-boot-2018.07-fmxx/arch/arm/mach-fmxx/spl.c中定义

    board_init_f
    之后,和转载的部分有出入:

    u-boot-2018.07-fmxx/arch/arm/lib/crt0.S

    来仔细分析如下代码:

    #if ! defined(CONFIG_SPL_BUILD) //不执行

    /*
     * Set up intermediate environment (new sp and gd) and call
     * relocate_code(addr_moni). Trick here is that we'll return
     * 'here' but relocated.
     */

        ldr    r0, [r9, #GD_START_ADDR_SP]    /* sp = gd->start_addr_sp */
        bic    r0, r0, #7    /* 8-byte alignment for ABI compliance */
        mov    sp, r0
        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
    #if defined(CONFIG_CPU_V7M)
        orr    lr, #1                /* As required by Thumb-only */
    #endif
        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 */
    #endif //#if ! defined(CONFIG_SPL_BUILD) 因为定义了CONFIG_SPL_BUILD 所以不包含上述段落

    #if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_FRAMEWORK) //!defined(CONFIG_SPL_BUILD)为假 defined(CONFIG_SPL_FRAMEWORK) 为真 下面代码执行
    # ifdef CONFIG_SPL_BUILD //执行
        /* Use a DRAM stack for the rest of SPL, if requested */
        bl    spl_relocate_stack_gd //common/spl/spl.c中定义
        cmp    r0, #0
        movne    sp, r0
        movne    r9, r0
    # endif
        ldr    r0, =__bss_start    /* this is auto-relocated! */

    #ifdef CONFIG_USE_ARCH_MEMSET //执行
        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
    #else //不执行
        ldr    r1, =__bss_end        /* this is auto-relocated! */
        mov    r2, #0x00000000        /* prepare zero to clear BSS */

    clbss_l:cmp    r0, r1            /* while not at end of BSS */
    #if defined(CONFIG_CPU_V7M) //不执行
        itt    lo
    #endif
        strlo    r2, [r0]        /* clear 32-bit BSS word */
        addlo    r0, r0, #4        /* move to next */
        blo    clbss_l
    #endif // CONFIG_USE_ARCH_MEMSET

    #if ! defined(CONFIG_SPL_BUILD) //不执行
        bl coloured_LED_init
        bl red_led_on
    #endif
        /* 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 */
    #if CONFIG_IS_ENABLED(SYS_THUMB_BUILD)
        ldr    lr, =board_init_r    /* this is auto-relocated! */
        bx    lr
    #else //执行
        ldr    pc, =board_init_r    /* this is auto-relocated! */
    #endif //CONFIG_IS_ENABLED(SYS_THUMB_BUILD)
        /* we should not return here. */
    #endif

    ENDPROC(_main)

    大概流程是
    bl    spl_relocate_stack_gd
    bl    memset  //bss清零

    ldr    pc, =board_init_r //跳转到board_init_r


    一般SPL会定义CONFIG_SPL,
    在common/spl/Kconfig中
    config SPL_FRAMEWORK
        bool "Support SPL based upon the common SPL framework"
        depends on SPL
        default y
    默认选中SPL_FRAMEWORK

    到底使用那个函数,要看Makefile和config的值


    board_init_rcommon/spl/spl.c中定义 该函数中有些调用
    比如spl_board_init 在/u-boot-2018.07-fmxx/arch/arm/mach-fmxx/spl.c中定义
    而spl_board_init又调用了preloader_console_init在common/spl/spl.c中定义




    https://blog.csdn.net/voice_shen/article/details/17373671

    https://www.cnblogs.com/maxpak/p/5593019.html

  • 相关阅读:
    NX二次开发-UFUN指定原点和轴旋转视图UF_VIEW_rotate_view_abs_csys
    NX二次开发-将草图直线约束到基准轴上SketchConstraintBuilder
    NX二次开发-UFUN检验两条直线几何上是否不同UF_CURVE_LINE_ARC__is_line_equal
    C++封装DLL文件并且调用
    NX二次开发-C# NXOPEN方式多选对话框theUI.SelectionManager.SelectTaggedObjects
    NX二次开发-NXOPEN C# Part.GetPreviewImage读取prt文件预览图
    PythonOCC开发-如何搭建开发环境和一个创建圆台例子
    NX二次开发-C# NXOPEN方式单选对话框UI.GetUI().SelectionManager.SelectTaggedObject
    羊城通薅羊毛6折公交算法
    Windows DOS命令微信多开
  • 原文地址:https://www.cnblogs.com/idyllcheung/p/11997274.html
Copyright © 2011-2022 走看看