上一篇中说道 这个地方是入口,再向上追溯,可以找到在cpukit/libcsupport/include/rtems/libio.h中
定义了这个函数指针类型,typedef void (*rtems_libio_helper)(void);
然后下面定义了一个该类型的函数指针。 rtems_fs_init_helper
const rtems_libio_helper rtems_fs_init_helper =
#ifdef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
rtems_libio_helper_null;
#else
rtems_filesystem_initialize; //这个地方是入口
#endif
那么这个函数指针在哪里调用呢?cpukit/libcsupport/src/libio_init.c
在函数 rtems_libio_init的最后调用
/*
* Initialize the base file system infrastructure.
*/
(* rtems_fs_init_helper)(); //函数指针调用
而rtems_libio_init也在cpukit/sapi/include/confdefs.h 中有定义,如下所示
const rtems_libio_helper rtems_libio_init_helper =
#ifdef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
rtems_libio_helper_null;
#else
rtems_libio_init;
#endif
套路是一样的。也是函数指针。所以函数指针rtems_libio_init_helper 在哪里被调用呢?
在c/src/lib/libbsp/shared/bsplibc.c中的函数bsp_libc_init中调用。
而函数bsp_libc_init就在c/src/lib/libbsp/shared/bootcard.c中的boot_card函数调用
而boot_card在start.s中调用,这就是上电后
c/src/lib/libbsp/arm/shared/start/start.S
start.s中一开始程序会进入到_start:
/* Start entry */
_start: 后面省略
那么_start:是从下面跳转过去的,所以系统一上电复位以后,会进入复位的中断处理函数。
handler_addr_reset:
#ifdef BSP_START_RESET_VECTOR //这个宏没有定义
.word BSP_START_RESET_VECTOR
#else
.word _start
#endif
上面说的那个宏定义定义需要查询bspopts.h 这个文件是生成特定的bsp的时候才有,源码中没有,源码中只有一些配置的选择。所以,会跳转到_start