zoukankan      html  css  js  c++  java
  • RTT中的组建初始化

    /* board init routines will be called in board_init() function */
    #define INIT_BOARD_EXPORT(fn)           INIT_EXPORT(fn, "1")
    
    /* pre/device/component/env/app init routines will be called in init_thread */
    /* components pre-initialization (pure software initilization) */
    #define INIT_PREV_EXPORT(fn)            INIT_EXPORT(fn, "2")
    /* device initialization */
    #define INIT_DEVICE_EXPORT(fn)          INIT_EXPORT(fn, "3")
    /* components initialization (dfs, lwip, ...) */
    #define INIT_COMPONENT_EXPORT(fn)       INIT_EXPORT(fn, "4")
    /* environment initialization (mount disk, ...) */
    #define INIT_ENV_EXPORT(fn)             INIT_EXPORT(fn, "5")
    /* appliation initialization (rtgui application etc ...) */
    #define INIT_APP_EXPORT(fn)             INIT_EXPORT(fn, "6")
    #define INIT_EXPORT(fn, level)  RT_USED const init_fn_t __rt_init_##fn SECTION(".rti_fn."level) = fn
    /*
     * Components Initialization will initialize some driver and components as following
     * order:
     * rti_start         --> 0
     * BOARD_EXPORT      --> 1
     * rti_board_end     --> 1.end
     *
     * DEVICE_EXPORT     --> 2
     * COMPONENT_EXPORT  --> 3
     * FS_EXPORT         --> 4
     * ENV_EXPORT        --> 5
     * APP_EXPORT        --> 6
     *
     * rti_end           --> 6.end
     *
     * These automatically initialization, the driver or component initial function must
     * be defined with:
     * INIT_BOARD_EXPORT(fn);
     * INIT_DEVICE_EXPORT(fn);
     * ...
     * INIT_APP_EXPORT(fn);
     * etc.
     */
    static int rti_start(void)
    {
        return 0;
    }
    INIT_EXPORT(rti_start, "0");
    
    static int rti_board_start(void)
    {
        return 0;
    }
    INIT_EXPORT(rti_board_start, "0.end");
    
    static int rti_board_end(void)
    {
        return 0;
    }
    INIT_EXPORT(rti_board_end, "1.end");
    
    static int rti_end(void)
    {
        return 0;
    }
    INIT_EXPORT(rti_end, "6.end")
    //摘自ld文件
    SECTIONS
    {
        .text :
        {
            ...
            /* section information for initial. */
            . = ALIGN(4);
            __rt_init_start = .;
            KEEP(*(SORT(.rti_fn*)))
            __rt_init_end = .;
           ....
        } > CODE = 0
    //摘自map文件
      *(SORT(.rti_fn*))
     .rti_fn.0      0x0806a968        0x4 buildkernelsrccomponents.o
                    0x0806a968                __rt_init_rti_start
     .rti_fn.0.end  0x0806a96c        0x4 buildkernelsrccomponents.o
                    0x0806a96c                __rt_init_rti_board_start
     .rti_fn.1      0x0806a970        0x4 builddriversdrv_sdram.o
                    0x0806a970                __rt_init_stm32_hw_0_sdram_init
     .rti_fn.1      0x0806a974        0x4 builddriversusart.o
                    0x0806a974                __rt_init_stm32_hw_usart_init
     .rti_fn.1.end  0x0806a978        0x4 buildkernelsrccomponents.o
                    0x0806a978                __rt_init_rti_board_end
     .rti_fn.4      0x0806a97c        0x4 buildpackagesSystemView-v2.52aSystemView_SrcConfigSEGGER_SYSVIEW_RTThread.o
                    0x0806a97c                __rt_init_rt_trace_init
     .rti_fn.4      0x0806a980        0x4 buildkernelcomponentslibccompilers
    ewliblibc.o
                    0x0806a980                __rt_init_libc_system_init
     .rti_fn.6      0x0806a984        0x4 builddriversdrv_lcd.o
                    0x0806a984                __rt_init_stm32_hw_lcd_init
     .rti_fn.6      0x0806a988        0x4 buildkernelcomponentsfinshshell.o
                    0x0806a988                __rt_init_finsh_system_init
     .rti_fn.6      0x0806a98c        0x4 buildpackagesLittlevGL2RTT-v0.0.1examplelittlevgl2rtt_demo.o
                    0x0806a98c                __rt_init_rt_lvgl_demo_init
     .rti_fn.6.end  0x0806a990        0x4 buildkernelsrccomponents.o
                    0x0806a990                __rt_init_rti_end
                    0x0806a994                __rt_init_end = .
                    0x0806a994                . = ALIGN (0x4)
                    0x0806a994                . = ALIGN (0x4)
                    0x0806a994                _etext = .
                    0x0806a994                __exidx_start = .
    void rt_components_board_init(void)//INIT_BOARD_EXPORT在此初始化
    {
        const init_fn_t *fn_ptr;
    
        for (fn_ptr = &__rt_init_rti_board_start; fn_ptr < &__rt_init_rti_board_end; fn_ptr++)
        {
            (*fn_ptr)();
        }
    }
    
    /**
     * RT-Thread Components Initialization
     */
    void rt_components_init(void) //除INIT_BOARD_EXPORT以外的在此初始化
    {
        const init_fn_t *fn_ptr;
    
        for (fn_ptr = &__rt_init_rti_board_end; fn_ptr < &__rt_init_rti_end; fn_ptr ++)
        {
            (*fn_ptr)();
        }
    }
    懒惰不会让你一下子跌到 但会在不知不觉中减少你的收获; 勤奋也不会让你一夜成功 但会在不知不觉中积累你的成果 越努力,越幸运。
  • 相关阅读:
    佛教-著作:《般若泼若密心经》
    学科-几何:分形几何学
    战国-散文:《生于忧患,死于安乐》
    北宋-词:《临江仙·送王缄》
    音乐:《河西走廊之梦》
    影视-纪录片:《河西走廊》
    汉语-汉字:黾
    动物-昆虫:水螳螂
    动物-昆虫:水黾
    主程的晋升攻略(3):IP、DNS和CDN
  • 原文地址:https://www.cnblogs.com/Rainingday/p/10081179.html
Copyright © 2011-2022 走看看