From d0c39838146c6a186ddda3d95dac71c3fa90f11e Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 22 Sep 2015 16:21:12 +0200 Subject: 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 . 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. --- cpukit/sapi/src/exinit.c | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) (limited to 'cpukit/sapi/src/exinit.c') diff --git a/cpukit/sapi/src/exinit.c b/cpukit/sapi/src/exinit.c index 6a684d320c..1f482f0ce4 100644 --- a/cpukit/sapi/src/exinit.c +++ b/cpukit/sapi/src/exinit.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -62,7 +63,7 @@ Objects_Information *_Internal_Objects[ OBJECTS_INTERNAL_CLASSES_LAST + 1 ]; -void rtems_initialize_data_structures(void) +static void rtems_initialize_data_structures(void) { /* * Dispatching and interrupts are disabled until the end of the @@ -152,7 +153,7 @@ void rtems_initialize_data_structures(void) */ } -void rtems_initialize_before_drivers(void) +static void rtems_initialize_before_drivers(void) { #ifdef RTEMS_DRVMGR_STARTUP _DRV_Manager_initialization(); @@ -163,7 +164,7 @@ void rtems_initialize_before_drivers(void) #endif } -void rtems_initialize_device_drivers(void) +static void rtems_initialize_device_drivers(void) { /* * Initialize all the device drivers and initialize the MPCI layer. @@ -246,8 +247,37 @@ void rtems_initialize_device_drivers(void) _API_extensions_Run_postdriver(); } -void rtems_initialize_start_multitasking(void) +RTEMS_LINKER_ROSET( _Sysinit, rtems_sysinit_item ); + +RTEMS_SYSINIT_ITEM( + rtems_initialize_data_structures, + RTEMS_SYSINIT_DATA_STRUCTURES, + RTEMS_SYSINIT_ORDER_MIDDLE +); + +RTEMS_SYSINIT_ITEM( + rtems_initialize_before_drivers, + RTEMS_SYSINIT_BEFORE_DRIVERS, + RTEMS_SYSINIT_ORDER_MIDDLE +); + +RTEMS_SYSINIT_ITEM( + rtems_initialize_device_drivers, + RTEMS_SYSINIT_DEVICE_DRIVERS, + RTEMS_SYSINIT_ORDER_MIDDLE +); + +void rtems_initialize_executive(void) { + const volatile rtems_sysinit_item *cur = RTEMS_LINKER_SET_BEGIN(_Sysinit ); + const volatile rtems_sysinit_item *end = RTEMS_LINKER_SET_END( _Sysinit ); + + /* Invoke the registered system initialization handlers */ + while ( cur != end ) { + ( *cur->handler )(); + ++cur; + } + _System_state_Set( SYSTEM_STATE_UP ); _SMP_Request_start_multitasking(); -- cgit v1.2.3