diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-09-22 16:21:12 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-12-11 08:17:16 +0100 |
commit | d0c39838146c6a186ddda3d95dac71c3fa90f11e (patch) | |
tree | 1f96df0fd4b6e5ee9658060529b69bea1a46de4a /c/src | |
parent | m32r/configure.ac: Looked for m32rsim to exist and now is gone (diff) | |
download | rtems-d0c39838146c6a186ddda3d95dac71c3fa90f11e.tar.bz2 |
Use linker set for system initialization
Make rtems_initialize_data_structures(),
rtems_initialize_before_drivers() and rtems_initialize_device_drivers()
static. Rename rtems_initialize_start_multitasking() to
rtems_initialize_executive() and call the registered system
initialization handlers in this function. Add system initialization API
available via #include <rtems/sysinit.h>. Update the documentation
accordingly.
This is no functional change, only the method to call the existing
initialization routines changes. Instead of direct function calls a
table of function pointers contained in the new RTEMS system
initialization linker set is used. This table looks like this (the
actual addresses depend on the target).
nm *.exe | grep _Linker | sort
0201a2d0 D _Linker_set__Sysinit_begin
0201a2d0 D _Linker_set__Sysinit_bsp_work_area_initialize
0201a2d4 D _Linker_set__Sysinit_bsp_start
0201a2d8 D _Linker_set__Sysinit_rtems_initialize_data_structures
0201a2dc D _Linker_set__Sysinit_bsp_libc_init
0201a2e0 D _Linker_set__Sysinit_rtems_initialize_before_drivers
0201a2e4 D _Linker_set__Sysinit_bsp_predriver_hook
0201a2e8 D _Linker_set__Sysinit_rtems_initialize_device_drivers
0201a2ec D _Linker_set__Sysinit_bsp_postdriver_hook
0201a2f0 D _Linker_set__Sysinit_end
Add test sptests/spsysinit01.
Update #2408.
Diffstat (limited to 'c/src')
-rw-r--r-- | c/src/lib/libbsp/shared/bootcard.c | 106 | ||||
-rw-r--r-- | c/src/lib/libbsp/shared/include/bootcard.h | 22 |
2 files changed, 36 insertions, 92 deletions
diff --git a/c/src/lib/libbsp/shared/bootcard.c b/c/src/lib/libbsp/shared/bootcard.c index 7d51e9f089..8b37a52258 100644 --- a/c/src/lib/libbsp/shared/bootcard.c +++ b/c/src/lib/libbsp/shared/bootcard.c @@ -8,25 +8,8 @@ * This is the C entry point for ALL RTEMS BSPs. It is invoked * from the assembly language initialization file usually called * start.S. It provides the framework for the BSP initialization - * sequence. The basic flow of initialization is: - * - * + start.S: basic CPU setup (stack, zero BSS) - * + boot_card - * + bspstart.c: bsp_start - more advanced initialization - * + obtain information on BSP memory and allocate RTEMS Workspace - * + rtems_initialize_data_structures - * + allocate memory to C Program Heap - * + initialize C Library and C Program Heap - * + rtems_initialize_before_drivers - * + bsp_predriver_hook - * + rtems_initialize_device_drivers - * - all device drivers - * + bsp_postdriver_hook - * + rtems_initialize_start_multitasking - * - 1st task executes C++ global constructors - * .... appplication runs ... - * - exit - * + will not return to here + * sequence. For the basic flow of initialization see RTEMS C User's Guide, + * Initialization Manager. * * This style of initialization ensures that the C++ global * constructors are executed after RTEMS is initialized. @@ -46,6 +29,7 @@ #include <bsp/bootcard.h> #include <rtems.h> +#include <rtems/sysinit.h> /* * At most a single pointer to the cmdline for those target @@ -53,6 +37,36 @@ */ const char *bsp_boot_cmdline; +RTEMS_SYSINIT_ITEM( + bsp_work_area_initialize, + RTEMS_SYSINIT_BSP_WORK_AREAS, + RTEMS_SYSINIT_ORDER_MIDDLE +); + +RTEMS_SYSINIT_ITEM( + bsp_start, + RTEMS_SYSINIT_BSP_START, + RTEMS_SYSINIT_ORDER_MIDDLE +); + +RTEMS_SYSINIT_ITEM( + bsp_libc_init, + RTEMS_SYSINIT_BSP_LIBC, + RTEMS_SYSINIT_ORDER_MIDDLE +); + +RTEMS_SYSINIT_ITEM( + bsp_predriver_hook, + RTEMS_SYSINIT_BSP_PRE_DRIVERS, + RTEMS_SYSINIT_ORDER_MIDDLE +); + +RTEMS_SYSINIT_ITEM( + bsp_postdriver_hook, + RTEMS_SYSINIT_BSP_POST_DRIVERS, + RTEMS_SYSINIT_ORDER_MIDDLE +); + /* * This is the initialization framework routine that weaves together * calls to RTEMS and the BSP in the proper sequence to initialize @@ -73,59 +87,7 @@ void boot_card( bsp_boot_cmdline = cmdline; - /* - * Initialize the RTEMS Workspace and the C Program Heap. - */ - bsp_work_area_initialize(); - - /* - * Invoke Board Support Package initialization routine written in C. - */ - bsp_start(); - - /* - * Initialize RTEMS data structures - */ - rtems_initialize_data_structures(); - - /* - * Initialize the C library for those BSPs using the shared - * framework. - */ - bsp_libc_init(); - - /* - * Let RTEMS perform initialization it requires before drivers - * are allowed to be initialized. - */ - rtems_initialize_before_drivers(); - - /* - * Execute BSP specific pre-driver hook. Drivers haven't gotten - * to initialize yet so this is a good chance to initialize - * buses, spurious interrupt handlers, etc.. - * - * NOTE: Many BSPs do not require this handler and use the - * shared stub. - */ - bsp_predriver_hook(); - - /* - * Initialize all device drivers. - */ - rtems_initialize_device_drivers(); - - /* - * Invoke the postdriver hook. This normally opens /dev/console - * for use as stdin, stdout, and stderr. - */ - bsp_postdriver_hook(); - - /* - * Complete initialization of RTEMS and switch to the first task. - * Global C++ constructors will be executed in the context of that task. - */ - rtems_initialize_start_multitasking(); + rtems_initialize_executive(); /*************************************************************** *************************************************************** diff --git a/c/src/lib/libbsp/shared/include/bootcard.h b/c/src/lib/libbsp/shared/include/bootcard.h index a0d0993e8e..8559b218d7 100644 --- a/c/src/lib/libbsp/shared/include/bootcard.h +++ b/c/src/lib/libbsp/shared/include/bootcard.h @@ -71,26 +71,8 @@ void bsp_reset(void); * assembly language initialization file usually called @c start.S which does * the basic CPU setup (stack, C runtime environment, zero BSS, load other * sections) and calls afterwards boot_card(). The boot card function provides - * the framework for the BSP initialization sequence. The basic flow of - * initialization is: - * - * - disable interrupts, interrupts will be enabled during the first context - * switch - * - bsp_work_area_initialize() - initialize the RTEMS Workspace and the C - * Program Heap - * - bsp_start() - more advanced initialization - * - rtems_initialize_data_structures() - * - initialize C Library - * - rtems_initialize_before_drivers() - * - bsp_predriver_hook() - * - rtems_initialize_device_drivers() - * - initialization of all device drivers - * - bsp_postdriver_hook() - * - rtems_initialize_start_multitasking() - * - 1st task executes C++ global constructors - * - .... application runs ... - * - exit - * - will not return to here + * the framework for the BSP initialization sequence. For the basic flow of + * initialization see RTEMS C User's Guide, Initialization Manager. * * This style of initialization ensures that the C++ global constructors are * executed after RTEMS is initialized. |