Changeset d0c39838 in rtems for cpukit/sapi


Ignore:
Timestamp:
Sep 22, 2015, 2:21:12 PM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
df55d07f
Parents:
d19d1c23
git-author:
Sebastian Huber <sebastian.huber@…> (09/22/15 14:21:12)
git-committer:
Sebastian Huber <sebastian.huber@…> (12/11/15 07:17:16)
Message:

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_setSysinit_begin
0201a2d0 D _Linker_set
Sysinit_bsp_work_area_initialize
0201a2d4 D _Linker_setSysinit_bsp_start
0201a2d8 D _Linker_set
Sysinit_rtems_initialize_data_structures
0201a2dc D _Linker_setSysinit_bsp_libc_init
0201a2e0 D _Linker_set
Sysinit_rtems_initialize_before_drivers
0201a2e4 D _Linker_setSysinit_bsp_predriver_hook
0201a2e8 D _Linker_set
Sysinit_rtems_initialize_device_drivers
0201a2ec D _Linker_setSysinit_bsp_postdriver_hook
0201a2f0 D _Linker_set
Sysinit_end

Add test sptests/spsysinit01.

Update #2408.

Location:
cpukit/sapi
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/sapi/include/rtems/init.h

    rd19d1c23 rd0c39838  
    4747
    4848/**
    49  * @brief RTEMS data structures initialization.
     49 * @brief Initializes the system and starts multitasking.
    5050 *
    51  * This routine implements the portion of the RTEMS initializatin process
    52  * that involves initializing data structures to a state that scheduling
    53  * can occur in a consistent manner.
    54  */
    55 void rtems_initialize_data_structures(void);
    56 
    57 /**
    58  * @brief RTEMS initialization before the device drivers are initialized.
     51 * Iterates through the system initialization linker set and invokes the
     52 * registered handlers.  The final step is to start multitasking.
    5953 *
    60  * This routine implements the portion of RTEMS initialization that
    61  * is done immediately before device drivers are initialized.
    62  */
    63 void rtems_initialize_before_drivers(void);
    64 
    65 /**
    66  * @brief RTEMS initialization that initializes all device drivers.
    67  *
    68  * This routine implements the portion of RTEMS initialization that
    69  * initializes all device drivers.
    70  */
    71 void rtems_initialize_device_drivers(void);
    72 
    73 /**
    74  * @brief Starts the multitasking.
    75  *
    76  * This directive initiates multitasking and performs a context switch to the
    77  * first user application task and may enable interrupts as a side-effect of
    78  * that context switch.  The context switch saves the executing context.  The
    79  * application runs now.  The directive rtems_shutdown_executive() will return
    80  * to the saved context.  The exit() function will use this directive.
    81  *
    82  * After a return to the saved context a fatal system state is reached.  The
    83  * fatal source is RTEMS_FATAL_SOURCE_EXIT with a fatal code set to the value
    84  * passed to rtems_shutdown_executive().
     54 * This directive should be called by boot_card() only.
    8555 *
    8656 * This directive does not return.
    8757 */
    88 void rtems_initialize_start_multitasking(void)
     58void rtems_initialize_executive(void)
    8959  RTEMS_NO_RETURN;
    9060
     
    9464 * This routine implements the rtems_shutdown_executive directive.  The
    9565 * invocation of this directive results in the RTEMS environment being
    96  * shutdown and multitasking halted.  From the application's perspective,
    97  * invocation of this directive results in the rtems_initialize_executive
    98  * directive exitting to the startup code which invoked it.
     66 * shutdown and multitasking halted.  The system is terminated with a fatal
     67 * source of RTEMS_FATAL_SOURCE_EXIT and the specified result code.
    9968 */
    10069void rtems_shutdown_executive(
  • cpukit/sapi/src/exinit.c

    rd19d1c23 rd0c39838  
    3232#include <rtems/extensionimpl.h>
    3333#include <rtems/init.h>
     34#include <rtems/sysinit.h>
    3435#include <rtems/score/sysstate.h>
    3536
     
    6364Objects_Information *_Internal_Objects[ OBJECTS_INTERNAL_CLASSES_LAST + 1 ];
    6465
    65 void rtems_initialize_data_structures(void)
     66static void rtems_initialize_data_structures(void)
    6667{
    6768  /*
     
    153154}
    154155
    155 void rtems_initialize_before_drivers(void)
     156static void rtems_initialize_before_drivers(void)
    156157{
    157158  #ifdef RTEMS_DRVMGR_STARTUP
     
    164165}
    165166
    166 void rtems_initialize_device_drivers(void)
     167static void rtems_initialize_device_drivers(void)
    167168{
    168169  /*
     
    247248}
    248249
    249 void rtems_initialize_start_multitasking(void)
    250 {
     250RTEMS_LINKER_ROSET( _Sysinit, rtems_sysinit_item );
     251
     252RTEMS_SYSINIT_ITEM(
     253  rtems_initialize_data_structures,
     254  RTEMS_SYSINIT_DATA_STRUCTURES,
     255  RTEMS_SYSINIT_ORDER_MIDDLE
     256);
     257
     258RTEMS_SYSINIT_ITEM(
     259  rtems_initialize_before_drivers,
     260  RTEMS_SYSINIT_BEFORE_DRIVERS,
     261  RTEMS_SYSINIT_ORDER_MIDDLE
     262);
     263
     264RTEMS_SYSINIT_ITEM(
     265  rtems_initialize_device_drivers,
     266  RTEMS_SYSINIT_DEVICE_DRIVERS,
     267  RTEMS_SYSINIT_ORDER_MIDDLE
     268);
     269
     270void rtems_initialize_executive(void)
     271{
     272  const volatile rtems_sysinit_item *cur = RTEMS_LINKER_SET_BEGIN(_Sysinit );
     273  const volatile rtems_sysinit_item *end = RTEMS_LINKER_SET_END( _Sysinit );
     274
     275  /* Invoke the registered system initialization handlers */
     276  while ( cur != end ) {
     277    ( *cur->handler )();
     278    ++cur;
     279  }
     280
    251281  _System_state_Set( SYSTEM_STATE_UP );
    252282
Note: See TracChangeset for help on using the changeset viewer.