Changeset 466cf31 in rtems


Ignore:
Timestamp:
Nov 7, 2012, 12:59:19 PM (7 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
ecf9858
Parents:
e5ae7c92
git-author:
Sebastian Huber <sebastian.huber@…> (11/07/12 12:59:19)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/13/12 08:20:57)
Message:

score: Statically initialize user extensions

The initial extensions remain now in a read-only table and will not be
copied to work space memory. The extension chains are statically
initialized. This makes it possible to call _User_extensions_Iterate()
independent of the system state. It is now guaranteed that the fatal
callout of the initial extensions will be called provided the stack
pointer, the read-only data, and code memory are valid.

Location:
cpukit
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • cpukit/sapi/include/confdefs.h

    re5ae7c92 r466cf31  
    20912091 */
    20922092#define CONFIGURE_MEMORY_FOR_STATIC_EXTENSIONS \
    2093      ((CONFIGURE_NEWLIB_EXTENSION * \
    2094         _Configure_From_workspace( sizeof(User_extensions_Control))) + \
    2095       (CONFIGURE_STACK_CHECKER_EXTENSION * \
    2096         _Configure_From_workspace( sizeof(User_extensions_Control))) \
    2097      )
     2093  (CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS == 0 ? 0 : \
     2094    _Configure_From_workspace( \
     2095      CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS \
     2096        * sizeof(User_extensions_Switch_control) \
     2097    ))
    20982098
    20992099/**
  • cpukit/score/include/rtems/score/userext.h

    re5ae7c92 r466cf31  
    235235 * @brief List of active extensions.
    236236 */
    237 SCORE_EXTERN Chain_Control _User_extensions_List;
     237extern Chain_Control _User_extensions_List;
    238238
    239239/**
    240240 * @brief List of active task switch extensions.
    241241 */
    242 SCORE_EXTERN Chain_Control _User_extensions_Switches_list;
     242extern Chain_Control _User_extensions_Switches_list;
    243243
    244244/**
  • cpukit/score/src/userext.c

    re5ae7c92 r466cf31  
    1717
    1818#if HAVE_CONFIG_H
    19 #include "config.h"
     19  #include "config.h"
    2020#endif
    2121
    22 #include <rtems/system.h>
    2322#include <rtems/config.h>
    2423#include <rtems/score/userext.h>
    2524#include <rtems/score/wkspace.h>
    26 #include <string.h>
     25
     26CHAIN_DEFINE_EMPTY( _User_extensions_Switches_list );
     27
     28typedef struct {
     29  User_extensions_Switch_control *switch_control;
     30} User_extensions_Switch_context;
     31
     32static void _User_extensions_Switch_visitor(
     33  Thread_Control              *executing,
     34  void                        *arg,
     35  const User_extensions_Table *callouts
     36)
     37{
     38  User_extensions_thread_switch_extension callout = callouts->thread_switch;
     39
     40  if ( callout != NULL ) {
     41    User_extensions_Switch_context *ctx = arg;
     42    User_extensions_Switch_control *ctrl = ctx->switch_control;
     43
     44    _Chain_Append_unprotected( &_User_extensions_Switches_list, &ctrl->Node );
     45    ctrl->thread_switch = callout;
     46
     47    ctx->switch_control = ctrl + 1;
     48  }
     49}
    2750
    2851void _User_extensions_Handler_initialization(void)
    2952{
    30   User_extensions_Control     *extension;
    31   uint32_t                     i;
    32   uint32_t                     number_of_extensions;
    33   const User_extensions_Table *initial_extensions;
     53  uint32_t number_of_initial_extensions =
     54    rtems_configuration_get_number_of_initial_extensions();
    3455
    35   number_of_extensions = rtems_configuration_get_number_of_initial_extensions();
    36   initial_extensions   = rtems_configuration_get_user_extension_table();
     56  if ( number_of_initial_extensions > 0 ) {
     57    User_extensions_Switch_control *initial_extension_switch_controls =
     58      _Workspace_Allocate_or_fatal_error(
     59        number_of_initial_extensions
     60          * sizeof( *initial_extension_switch_controls )
     61      );
     62    User_extensions_Switch_context ctx = { initial_extension_switch_controls };
    3763
    38   _Chain_Initialize_empty( &_User_extensions_List );
    39   _Chain_Initialize_empty( &_User_extensions_Switches_list );
    40 
    41   if ( initial_extensions ) {
    42     extension = (User_extensions_Control *)
    43       _Workspace_Allocate_or_fatal_error(
    44         number_of_extensions * sizeof( User_extensions_Control )
    45       );
    46 
    47     memset (
    48       extension,
    49       0,
    50       number_of_extensions * sizeof( User_extensions_Control )
    51     );
    52 
    53     for ( i = 0 ; i < number_of_extensions ; i++ ) {
    54       _User_extensions_Add_set_with_table (extension, &initial_extensions[i]);
    55       extension++;
    56     }
     64    _User_extensions_Iterate( &ctx, _User_extensions_Switch_visitor );
    5765  }
    5866}
    59 
  • cpukit/score/src/userextiterate.c

    re5ae7c92 r466cf31  
    1717#endif
    1818
     19#include <rtems/config.h>
    1920#include <rtems/score/userext.h>
     21
     22CHAIN_DEFINE_EMPTY( _User_extensions_List );
    2023
    2124void _User_extensions_Thread_create_visitor(
     
    119122)
    120123{
    121   const Chain_Node *node = _Chain_Immutable_first( &_User_extensions_List );
    122   const Chain_Node *tail = _Chain_Immutable_tail( &_User_extensions_List );
    123124  Thread_Control   *executing = _Thread_Executing;
     125  const User_extensions_Table *callouts_current =
     126    rtems_configuration_get_user_extension_table();
     127  const User_extensions_Table *callouts_end =
     128    callouts_current + rtems_configuration_get_number_of_initial_extensions();
     129  const Chain_Node *node;
     130  const Chain_Node *tail;
    124131
     132  while ( callouts_current != callouts_end ) {
     133    (*visitor)( executing, arg, callouts_current );
     134
     135    ++callouts_current;
     136  }
     137
     138  node = _Chain_Immutable_first( &_User_extensions_List );
     139  tail = _Chain_Immutable_tail( &_User_extensions_List );
    125140  while ( node != tail ) {
    126141    const User_extensions_Control *extension =
Note: See TracChangeset for help on using the changeset viewer.