Changeset c3db01d0 in rtems


Ignore:
Timestamp:
May 9, 2007, 6:27:26 PM (13 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
ded1977
Parents:
d81d057
Message:

2007-05-09 Joel Sherrill <joel.sherrill@…>

  • libcsupport/include/rtems/libcsupport.h, libcsupport/src/newlibc.c, sapi/Makefile.am, sapi/include/confdefs.h, sapi/src/exinit.c, score/Makefile.am, score/preinstall.am, score/include/rtems/score/userext.h, score/src/chain.c, score/src/userext.c: Switch to newlib reentrancy extension being installed in the initial set instead of using rtems_extension_create. While implementing this, noticed that user extensions and chain code had multiple functions in a single file which is not desirable in the SuperCore? and API portions of RTEMS, so split these into multiple files with one function per file. Also noticed that some of user extension code was inlined for no particular reason so moved that to C bodies. Split executive shutdown from initialization since not every application shuts down. Moved fini call to executive shutdown to be more symmetrical with where it is called at startup.
  • sapi/src/exshutdown.c, score/src/chainappend.c, score/src/chainextract.c, score/src/chainget.c, score/src/chaininsert.c, score/src/userextaddapiset.c, score/src/userextaddset.c, score/src/userextremoveset.c, score/src/userextthreadbegin.c, score/src/userextthreadcreate.c, score/src/userextthreaddelete.c, score/src/userextthreadrestart.c, score/src/userextthreadstart.c, score/src/userextthreadswitch.c: New files.
  • score/inline/rtems/score/userext.inl: Removed.
Location:
cpukit
Files:
14 added
1 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    rd81d057 rc3db01d0  
     12007-05-09      Joel Sherrill <joel.sherrill@OARcorp.com>
     2
     3        * libcsupport/include/rtems/libcsupport.h, libcsupport/src/newlibc.c,
     4        sapi/Makefile.am, sapi/include/confdefs.h, sapi/src/exinit.c,
     5        score/Makefile.am, score/preinstall.am,
     6        score/include/rtems/score/userext.h, score/src/chain.c,
     7        score/src/userext.c: Switch to newlib reentrancy extension being
     8        installed in the initial set instead of using rtems_extension_create.
     9        While implementing this, noticed that user extensions and chain code
     10        had multiple functions in a single file which is not desirable in the
     11        SuperCore and API portions of RTEMS, so split these into multiple
     12        files with one function per file. Also noticed that some of user
     13        extension code was inlined for no particular reason so moved that to
     14        C bodies.  Split executive shutdown from initialization since not
     15        every application shuts down.  Moved __fini call to executive shutdown
     16        to be more symmetrical with where it is called at startup.
     17        * sapi/src/exshutdown.c, score/src/chainappend.c,
     18        score/src/chainextract.c, score/src/chainget.c,
     19        score/src/chaininsert.c, score/src/userextaddapiset.c,
     20        score/src/userextaddset.c, score/src/userextremoveset.c,
     21        score/src/userextthreadbegin.c, score/src/userextthreadcreate.c,
     22        score/src/userextthreaddelete.c, score/src/userextthreadrestart.c,
     23        score/src/userextthreadstart.c, score/src/userextthreadswitch.c: New
     24        files.
     25        * score/inline/rtems/score/userext.inl: Removed.
     26
    1272007-05-09      Joel Sherrill <joel.sherrill@OARcorp.com>
    228
  • cpukit/libcsupport/include/rtems/libcsupport.h

    rd81d057 rc3db01d0  
    4040extern size_t malloc_free_space();
    4141
     42/*
     43 *  Prototypes required to install newlib reentrancy user extension
     44 */
     45rtems_boolean libc_create_hook(
     46  rtems_tcb *current_task,
     47  rtems_tcb *creating_task
     48);
     49
     50#if defined(RTEMS_UNIX) && !defined(hpux)
     51  rtems_extension libc_begin_hook(rtems_tcb *current_task);
     52  #define __RTEMS_NEWLIB_BEGIN libc_begin_hook
     53#else
     54  #define __RTEMS_NEWLIB_BEGIN 0
     55#endif
     56
     57rtems_extension libc_delete_hook(
     58  rtems_tcb *current_task,
     59  rtems_tcb *deleted_task
     60);
     61
     62#define RTEMS_NEWLIB_EXTENSION \
     63{ \
     64  libc_create_hook,                            /* rtems_task_create  */ \
     65  0,                                           /* rtems_task_start   */ \
     66  0,                                           /* rtems_task_restart */ \
     67  libc_delete_hook,                            /* rtems_task_delete  */ \
     68  0,                                           /* task_switch  */ \
     69  __RTEMS_NEWLIB_BEGIN,                        /* task_begin   */ \
     70  0,                                           /* task_exitted */ \
     71  0                                            /* fatal        */ \
     72}
     73
    4274#ifdef __cplusplus
    4375}
  • cpukit/libcsupport/src/newlibc.c

    rd81d057 rc3db01d0  
    5151int _fwalk(struct _reent *ptr, int (*function) (FILE *) );
    5252
    53 int              libc_reentrant;        /* do we think we are reentrant? */
    54 struct _reent    libc_global_reent __ATTRIBUTE_IMPURE_PTR__ = _REENT_INIT(libc_global_reent);
     53struct _reent    libc_global_reent
     54    __ATTRIBUTE_IMPURE_PTR__ = _REENT_INIT(libc_global_reent);
    5555
    5656/*
     
    7272   */
    7373
    74 #define REENT_MALLOCED 0
    75 #if REENT_MALLOCED
    76   ptr = (struct _reent *) calloc(1, sizeof(struct _reent));
    77 #else
    78   /* It is OK to allocate from the workspace because these
    79    * hooks run with thread dispatching disabled.
    80    */
    81   ptr = (struct _reent *) _Workspace_Allocate(sizeof(struct _reent));
    82 #endif
     74  #define REENT_MALLOCED 0
     75  #if REENT_MALLOCED
     76    ptr = (struct _reent *) calloc(1, sizeof(struct _reent));
     77  #else
     78    /* It is OK to allocate from the workspace because these
     79     * hooks run with thread dispatching disabled.
     80     */
     81    ptr = (struct _reent *) _Workspace_Allocate(sizeof(struct _reent));
     82  #endif
    8383
    84   if (ptr)
    85   {
     84  if (ptr) {
    8685
    87 #ifdef __GNUC__
    88       /* GCC extension: structure constants */
    89       _REENT_INIT_PTR((ptr));
    90 #else
    91       /*
    92        *  WARNING: THIS IS VERY DEPENDENT ON NEWLIB!!!
    93        *           Last visual check was against newlib 1.8.2 but last known
    94        *           use was against 1.7.0.  This is basically an exansion of
    95        *           REENT_INIT() in <sys/reent.h>.
    96        */
    97       memset(ptr, 0, sizeof(*ptr));
    98       ptr->_stdin = &ptr->__sf[0];
    99       ptr->_stdout = &ptr->__sf[1];
    100       ptr->_stderr = &ptr->__sf[2];
    101       ptr->_current_locale = "C";
    102       ptr->_new._reent._rand_next = 1;
    103 #endif
    104 
     86      _REENT_INIT_PTR((ptr)); /* GCC extension: structure constants */
    10587      creating_task->libc_reent = ptr;
    10688      return TRUE;
    10789  }
    10890  else
    109       return FALSE;
    110 
    111 }
    112 
    113 /*
    114  * Called for all user TASKS (system tasks are MPCI Receive Server and IDLE)
    115  */
    116 
    117 rtems_extension libc_start_hook(
    118   rtems_tcb *current_task,
    119   rtems_tcb *starting_task
    120 )
    121 {
     91    return FALSE;
    12292}
    12393
     
    134104
    135105/*
    136  *  Function:   libc_delete_hook
    137  *  Created:    94/12/10
    138  *
    139  *  Description:
    140  *      Called when a task is deleted.
    141  *      Must restore the new lib reentrancy state for the new current
    142  *      task.
    143  *
    144  *  Parameters:
    145  *
    146  *
    147  *  Returns:
    148  *
    149  *
    150  *  Side Effects:
    151  *
    152  *  Notes:
    153  *
    154  *
    155  *  Deficiencies/ToDo:
    156  *
     106 *  Called when a task is deleted.
     107 *  Must restore the new lib reentrancy state for the new current
     108 *  task.
    157109 *
    158110 */
     
    223175
    224176/*
    225  *  Function:   libc_init
    226  *  Created:    94/12/10
     177 *  Init libc for CYGNUS newlib
     178 *
     179 *  Set up _REENT to use our global libc_global_reent.
     180 *  (newlib provides a global of its own, but we prefer our own name for it)
    227181 *
    228  *  Description:
    229  *      Init libc for CYGNUS newlib
    230  *      Set up _REENT to use our global libc_global_reent.
    231  *      (newlib provides a global of its own, but we prefer our
    232  *      own name for it)
    233  *
    234  *      If reentrancy is desired (which it should be), then
    235  *      we install the task extension hooks to maintain the
    236  *      newlib reentrancy global variable _REENT on task
    237  *      create, delete, switch, exit, etc.
    238  *
    239  *  Parameters:
    240  *      reentrant               non-zero if reentrant library desired.
    241  *
    242  *  Returns:
    243  *
    244  *  Side Effects:
    245  *      installs libc extensions if reentrant.
    246  *
    247  *  Notes:
    248  *
    249  *
    250  *  Deficiencies/ToDo:
     182 *  If reentrancy is desired (which it should be), then
     183 *  we install the task extension hooks to maintain the
     184 *  newlib reentrancy global variable _REENT on task
     185 *  create, delete, switch, exit, etc.
    251186 *
    252187 */
     188
    253189
    254190void
    255191libc_init(int reentrant)
    256192{
    257   rtems_extensions_table  libc_extension;
    258   rtems_status_code       rc;
    259   rtems_id                extension_id;
    260 
    261 /*  libc_global_reent = _REENT_INIT(libc_global_reent); */
    262193  _REENT = &libc_global_reent;
    263194
    264   if (reentrant) {
    265     memset(&libc_extension, 0, sizeof(libc_extension));
    266 
    267     libc_extension.thread_create  = libc_create_hook;
    268     libc_extension.thread_start   = libc_start_hook;
    269 #ifdef NEED_SETVBUF
    270     libc_extension.thread_begin   = libc_begin_hook;
    271 #endif
    272     libc_extension.thread_delete  = libc_delete_hook;
    273 
    274     _Thread_Set_libc_reent (&_REENT);
    275 
    276     rc = rtems_extension_create(rtems_build_name('L', 'I', 'B', 'C'),
    277                           &libc_extension, &extension_id);
    278     if (rc != RTEMS_SUCCESSFUL)
    279       rtems_fatal_error_occurred( rc );
    280 
    281     libc_reentrant = reentrant;
    282   }
     195  _Thread_Set_libc_reent (&_REENT);
    283196}
    284197
  • cpukit/sapi/Makefile.am

    rd81d057 rc3db01d0  
    2323libsapi_a_SOURCES = src/debug.c src/extension.c src/extensioncreate.c \
    2424    src/extensiondelete.c src/extensionident.c src/fatal.c src/exinit.c \
    25     src/io.c src/itronapi.c src/posixapi.c src/rtemsapi.c
     25    src/exshutdown.c src/io.c src/itronapi.c src/posixapi.c src/rtemsapi.c
    2626libsapi_a_CPPFLAGS = $(AM_CPPFLAGS)
    2727
  • cpukit/sapi/include/confdefs.h

    rd81d057 rc3db01d0  
    6565 */
    6666
    67 #ifdef RTEMS_NEWLIB
    68 #define CONFIGURE_NEWLIB_EXTENSION 1
    69 #else
    70 #define CONFIGURE_NEWLIB_EXTENSION 0
     67#if (defined(RTEMS_NEWLIB) && defined(CONFIGURE_DISABLE_NEWLIB_REENTRANCY))
     68  #define CONFIGURE_NEWLIB_EXTENSION 1
     69#else
     70  #define CONFIGURE_NEWLIB_EXTENSION 0
    7171#endif
    7272
     
    131131
    132132#ifdef CONFIGURE_INIT
    133 #ifndef CONFIGURE_HAS_OWN_MOUNT_TABLE
    134 rtems_filesystem_mount_table_t configuration_mount_table = {
    135 #ifdef CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
    136   &IMFS_ops,
    137 #else  /* using miniIMFS as base filesystem */
    138   &miniIMFS_ops,
    139 #endif
    140   RTEMS_FILESYSTEM_READ_WRITE,
    141   NULL,
    142   NULL
    143 };
    144 
    145 rtems_filesystem_mount_table_t
    146     *rtems_filesystem_mount_table = &configuration_mount_table;
    147 int rtems_filesystem_mount_table_size = 1;
    148 #endif
    149 
    150 #endif
    151 
     133  #ifndef CONFIGURE_HAS_OWN_MOUNT_TABLE
     134    rtems_filesystem_mount_table_t configuration_mount_table = {
     135      #ifdef CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
     136        &IMFS_ops,
     137      #else  /* using miniIMFS as base filesystem */
     138        &miniIMFS_ops,
     139      #endif
     140      RTEMS_FILESYSTEM_READ_WRITE,
     141      NULL,
     142      NULL
     143    };
     144
     145    rtems_filesystem_mount_table_t
     146        *rtems_filesystem_mount_table = &configuration_mount_table;
     147    int rtems_filesystem_mount_table_size = 1;
     148  #endif
     149#endif
    152150
    153151/*
     
    511509#include <rtems/stackchk.h>
    512510#endif
     511#include <rtems/libcsupport.h>
    513512
    514513#if defined(CONFIGURE_INITIAL_EXTENSIONS) || \
    515     defined(STACK_CHECKER_ON)
    516 rtems_extensions_table Configuration_Initial_Extensions[] = {
    517 #ifdef CONFIGURE_INITIAL_EXTENSIONS
    518     CONFIGURE_INITIAL_EXTENSIONS,
    519 #endif
    520 #ifdef STACK_CHECKER_ON
    521     RTEMS_STACK_CHECKER_EXTENSION,
    522 #endif
    523 };
    524 
    525 #define CONFIGURE_INITIAL_EXTENSION_TABLE Configuration_Initial_Extensions
    526 #define CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS \
    527   ((sizeof(Configuration_Initial_Extensions) / \
    528     sizeof(rtems_extensions_table)))
    529 #else
    530 #define CONFIGURE_INITIAL_EXTENSION_TABLE NULL
    531 #define CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS 0
     514    defined(STACK_CHECKER_ON) || \
     515    (defined(RTEMS_NEWLIB) && !defined(CONFIGURE_DISABLE_NEWLIB_REENTRANCY))
     516  rtems_extensions_table Configuration_Initial_Extensions[] = {
     517    #if !defined(CONFIGURE_DISABLE_NEWLIB_REENTRANCY)
     518      RTEMS_NEWLIB_EXTENSION,
     519    #endif
     520    #if defined(STACK_CHECKER_ON)
     521      RTEMS_STACK_CHECKER_EXTENSION,
     522    #endif
     523    #if defined(CONFIGURE_INITIAL_EXTENSIONS)
     524      CONFIGURE_INITIAL_EXTENSIONS,
     525    #endif
     526  };
     527
     528  #define CONFIGURE_INITIAL_EXTENSION_TABLE Configuration_Initial_Extensions
     529  #define CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS \
     530    ((sizeof(Configuration_Initial_Extensions) / \
     531      sizeof(rtems_extensions_table)))
     532#else
     533  #define CONFIGURE_INITIAL_EXTENSION_TABLE NULL
     534  #define CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS 0
    532535#endif
    533536
  • cpukit/sapi/src/exinit.c

    rd81d057 rc3db01d0  
    106106
    107107  _Configuration_Table    = configuration_table;
     108#if defined(RTEMS_MULTIPROCESSING)
    108109  _Configuration_MP_table = multiprocessing_table;
     110#endif
    109111
    110112  /*
     
    278280  _ISR_Enable( bsp_level );
    279281}
    280 
    281 /*PAGE
    282  *
    283  *  rtems_shutdown_executive
    284  *
    285  *  This kernel routine shutdowns the executive.  It halts multitasking
    286  *  and returns control to the application execution "thread" which
    287  *  initialially invoked the rtems_initialize_executive directive.
    288  *
    289  *  Input parameters:   NONE
    290  *
    291  *  Output parameters:  NONE
    292  */
    293 
    294 void rtems_shutdown_executive(
    295    uint32_t   result
    296 )
    297 {
    298   if ( _System_state_Current != SYSTEM_STATE_SHUTDOWN ) {
    299     _System_state_Set( SYSTEM_STATE_SHUTDOWN );
    300     _Thread_Stop_multitasking();
    301   }
    302 }
  • cpukit/score/Makefile.am

    rd81d057 rc3db01d0  
    5252    inline/rtems/score/sysstate.inl inline/rtems/score/thread.inl \
    5353    inline/rtems/score/threadq.inl inline/rtems/score/tod.inl \
    54     inline/rtems/score/tqdata.inl inline/rtems/score/userext.inl \
     54    inline/rtems/score/tqdata.inl \
    5555    inline/rtems/score/watchdog.inl inline/rtems/score/wkspace.inl
    5656
     
    159159    src/watchdoginsert.c src/watchdogremove.c src/watchdogtickle.c
    160160
     161## USEREXT_C_FILES
     162libscore_a_SOURCES += src/userextaddapiset.c src/userextaddset.c \
     163    src/userext.c src/userextremoveset.c src/userextthreadbegin.c \
     164    src/userextthreadcreate.c src/userextthreaddelete.c \
     165    src/userextthreadrestart.c src/userextthreadstart.c \
     166    src/userextthreadswitch.c
     167
    161168## STD_C_FILES
    162 libscore_a_SOURCES += src/apiext.c src/chain.c \
    163     src/interr.c src/isr.c src/userext.c src/wkspace.c
     169libscore_a_SOURCES += src/apiext.c src/chain.c src/chainappend.c \
     170    src/chainextract.c src/chainget.c src/chaininsert.c \
     171    src/interr.c src/isr.c src/wkspace.c
    164172
    165173EXTRA_DIST = src/Unlimited.txt
  • cpukit/score/include/rtems/score/userext.h

    rd81d057 rc3db01d0  
    203203/*@{*/
    204204
     205/** @brief User extensions Handler Initialization
     206 *
     207 *  This routine performs the initialization necessary for this handler.
     208 *
     209 *  @param[in] number_of_extensions is the number of extensions
     210 *  @param[in] initial_extensions is the initial extension set
     211 */
     212void _User_extensions_Handler_initialization (
     213  uint32_t                number_of_extensions,
     214  User_extensions_Table  *initial_extensions
     215);
     216
     217/** @brief User extensions Add to API extension set
     218 *
     219 *  This routine is used to add an API extension set to the active list.
     220 *
     221 *  @param[in] the_extension is the extension set to add
     222 */
     223void _User_extensions_Add_API_set (
     224  User_extensions_Control *the_extension
     225);
     226
     227/** @brief User extensions Add extension set
     228 *
     229 *  This routine is used to add a user extension set to the active list.
     230 *
     231 *  @param[in] the_extension is the extension set to add
     232 *  @param[in] extension_table is the user's extension set
     233 */
     234void _User_extensions_Add_set (
     235  User_extensions_Control *the_extension,
     236  User_extensions_Table   *extension_table
     237);
     238
     239/**
     240 *  This routine is used to remove a user extension set from the active list.
     241 */
     242void _User_extensions_Remove_set (
     243  User_extensions_Control  *the_extension
     244);
     245
    205246/** @brief  User extensions Thread create
    206247 *
     
    259300void _User_extensions_Thread_begin (
    260301  Thread_Control *executing
     302);
     303
     304
     305/** @brief  User extensions Thread switch
     306 *
     307 *  This routine is used to invoke the user extension which
     308 *  is invoked when a context switch occurs.
     309 *
     310 *  @param[in] executing is the thread currently executing.
     311 *  @param[in] heir is the thread which will execute.
     312 */
     313void _User_extensions_Thread_switch (
     314  Thread_Control *executing,
     315  Thread_Control *heir
    261316);
    262317
     
    287342);
    288343
    289 #ifndef __RTEMS_APPLICATION__
    290 #include <rtems/score/userext.inl>
    291 #endif
    292 
    293344#ifdef __cplusplus
    294345}
  • cpukit/score/preinstall.am

    rd81d057 rc3db01d0  
    253253PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/tqdata.inl
    254254
    255 $(PROJECT_INCLUDE)/rtems/score/userext.inl: inline/rtems/score/userext.inl $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
    256         $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/userext.inl
    257 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/userext.inl
    258 
    259255$(PROJECT_INCLUDE)/rtems/score/watchdog.inl: inline/rtems/score/watchdog.inl $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
    260256        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/watchdog.inl
  • cpukit/score/src/chain.c

    rd81d057 rc3db01d0  
    11/*
    2  *  Chain Handler
    3  *
    4  *  NOTE:
    5  *
    6  *  The order of this file is to allow proper compilation due to the
    7  *  order of inlining required by the compiler.
    8  *
    9  *  COPYRIGHT (c) 1989-1999.
     2 *  COPYRIGHT (c) 1989-2007.
    103 *  On-Line Applications Research Corporation (OAR).
    114 *
     
    6659  the_chain->last  = current;
    6760}
    68 
    69 /*PAGE
    70  *
    71  *  _Chain_Get
    72  *
    73  *  This kernel routine returns a pointer to a node taken from the
    74  *  given chain.
    75  *
    76  *  Input parameters:
    77  *    the_chain - pointer to chain header
    78  *
    79  *  Output parameters:
    80  *    return_node - pointer to node in chain allocated
    81  *    CHAIN_END   - if no nodes available
    82  *
    83  *  INTERRUPT LATENCY:
    84  *    only case
    85  */
    86 
    87 Chain_Node *_Chain_Get(
    88   Chain_Control *the_chain
    89 )
    90 {
    91   ISR_Level          level;
    92   Chain_Node *return_node;
    93 
    94   return_node = NULL;
    95   _ISR_Disable( level );
    96     if ( !_Chain_Is_empty( the_chain ) )
    97       return_node = _Chain_Get_first_unprotected( the_chain );
    98   _ISR_Enable( level );
    99   return return_node;
    100 }
    101 
    102 /*PAGE
    103  *
    104  *  _Chain_Append
    105  *
    106  *  This kernel routine puts a node on the end of the specified chain.
    107  *
    108  *  Input parameters:
    109  *    the_chain - pointer to chain header
    110  *    node      - address of node to put at rear of chain
    111  *
    112  *  Output parameters:  NONE
    113  *
    114  *  INTERRUPT LATENCY:
    115  *    only case
    116  */
    117 
    118 void _Chain_Append(
    119   Chain_Control *the_chain,
    120   Chain_Node    *node
    121 )
    122 {
    123   ISR_Level level;
    124 
    125   _ISR_Disable( level );
    126     _Chain_Append_unprotected( the_chain, node );
    127   _ISR_Enable( level );
    128 }
    129 
    130 /*PAGE
    131  *
    132  *  _Chain_Extract
    133  *
    134  *  This kernel routine deletes the given node from a chain.
    135  *
    136  *  Input parameters:
    137  *    node - pointer to node in chain to be deleted
    138  *
    139  *  Output parameters:  NONE
    140  *
    141  *  INTERRUPT LATENCY:
    142  *    only case
    143  */
    144 
    145 void _Chain_Extract(
    146   Chain_Node *node
    147 )
    148 {
    149   ISR_Level level;
    150 
    151   _ISR_Disable( level );
    152     _Chain_Extract_unprotected( node );
    153   _ISR_Enable( level );
    154 }
    155 
    156 /*PAGE
    157  *
    158  *  _Chain_Insert
    159  *
    160  *  This kernel routine inserts a given node after a specified node
    161  *  a requested chain.
    162  *
    163  *  Input parameters:
    164  *    after_node - pointer to node in chain to be inserted after
    165  *    node       - pointer to node to be inserted
    166  *
    167  *  Output parameters:  NONE
    168  *
    169  *  INTERRUPT LATENCY:
    170  *    only case
    171  */
    172 
    173 void _Chain_Insert(
    174   Chain_Node *after_node,
    175   Chain_Node *node
    176 )
    177 {
    178   ISR_Level level;
    179 
    180   _ISR_Disable( level );
    181     _Chain_Insert_unprotected( after_node, node );
    182   _ISR_Enable( level );
    183 }
  • cpukit/score/src/userext.c

    rd81d057 rc3db01d0  
    11/*
    2  *  User Extension Handler
    3  *
    4  *  NOTE: XXX
    5  *
    6  *  COPYRIGHT (c) 1989-1999.
     2 *  COPYRIGHT (c) 1989-2007.
    73 *  On-Line Applications Research Corporation (OAR).
    84 *
     
    2016#include <rtems/system.h>
    2117#include <rtems/score/userext.h>
     18#include <rtems/score/wkspace.h>
     19#include <string.h>
    2220
    23 /*PAGE
    24  *
    25  *  _User_extensions_Thread_create
     21/**
     22 *  This routine performs the initialization necessary for this handler.
    2623 */
    2724
    28 boolean _User_extensions_Thread_create (
    29   Thread_Control *the_thread
     25void _User_extensions_Handler_initialization (
     26  uint32_t                number_of_extensions,
     27  User_extensions_Table  *initial_extensions
    3028)
    3129{
    32   Chain_Node              *the_node;
    33   User_extensions_Control *the_extension;
    34   boolean                  status;
     30  User_extensions_Control *extension;
     31  uint32_t                 i;
    3532
    36   for ( the_node = _User_extensions_List.first ;
    37         !_Chain_Is_tail( &_User_extensions_List, the_node ) ;
    38         the_node = the_node->next ) {
     33  _Chain_Initialize_empty( &_User_extensions_List );
     34  _Chain_Initialize_empty( &_User_extensions_Switches_list );
    3935
    40     the_extension = (User_extensions_Control *) the_node;
    41 
    42     if ( the_extension->Callouts.thread_create != NULL ) {
    43       status = (*the_extension->Callouts.thread_create)(
    44         _Thread_Executing,
    45         the_thread
     36  if ( initial_extensions ) {
     37    extension = (User_extensions_Control *)
     38      _Workspace_Allocate_or_fatal_error(
     39        number_of_extensions * sizeof( User_extensions_Control )
    4640      );
    47       if ( !status )
    48         return FALSE;
     41 
     42    memset (
     43      extension,
     44      0,
     45      number_of_extensions * sizeof( User_extensions_Control )
     46    );
     47 
     48    for ( i = 0 ; i < number_of_extensions ; i++ ) {
     49      _User_extensions_Add_set (extension, &initial_extensions[i]);
     50      extension++;
    4951    }
    50   }
    51 
    52   return TRUE;
    53 }
    54 
    55 /*PAGE
    56  *
    57  *  _User_extensions_Thread_delete
    58  */
    59 
    60 void _User_extensions_Thread_delete (
    61   Thread_Control *the_thread
    62 )
    63 {
    64   Chain_Node              *the_node;
    65   User_extensions_Control *the_extension;
    66 
    67   for ( the_node = _User_extensions_List.last ;
    68         !_Chain_Is_head( &_User_extensions_List, the_node ) ;
    69         the_node = the_node->previous ) {
    70 
    71     the_extension = (User_extensions_Control *) the_node;
    72 
    73     if ( the_extension->Callouts.thread_delete != NULL )
    74       (*the_extension->Callouts.thread_delete)(
    75         _Thread_Executing,
    76         the_thread
    77       );
    7852  }
    7953}
    8054
    81 /*PAGE
    82  *
    83  *  _User_extensions_Thread_start
    84  *
    85  */
    86 
    87 void _User_extensions_Thread_start (
    88   Thread_Control *the_thread
    89 )
    90 {
    91   Chain_Node              *the_node;
    92   User_extensions_Control *the_extension;
    93 
    94   for ( the_node = _User_extensions_List.first ;
    95         !_Chain_Is_tail( &_User_extensions_List, the_node ) ;
    96         the_node = the_node->next ) {
    97 
    98     the_extension = (User_extensions_Control *) the_node;
    99 
    100     if ( the_extension->Callouts.thread_start != NULL )
    101       (*the_extension->Callouts.thread_start)(
    102         _Thread_Executing,
    103         the_thread
    104       );
    105   }
    106 }
    107 
    108 /*PAGE
    109  *
    110  *  _User_extensions_Thread_restart
    111  *
    112  */
    113 
    114 void _User_extensions_Thread_restart (
    115   Thread_Control *the_thread
    116 )
    117 {
    118   Chain_Node              *the_node;
    119   User_extensions_Control *the_extension;
    120 
    121   for ( the_node = _User_extensions_List.first ;
    122         !_Chain_Is_tail( &_User_extensions_List, the_node ) ;
    123         the_node = the_node->next ) {
    124 
    125     the_extension = (User_extensions_Control *) the_node;
    126 
    127     if ( the_extension->Callouts.thread_restart != NULL )
    128       (*the_extension->Callouts.thread_restart)(
    129         _Thread_Executing,
    130         the_thread
    131       );
    132   }
    133 }
    134 
    135 /*PAGE
    136  *
    137  *  _User_extensions_Thread_begin
    138  *
    139  */
    140 
    141 void _User_extensions_Thread_begin (
    142   Thread_Control *executing
    143 )
    144 {
    145   Chain_Node              *the_node;
    146   User_extensions_Control *the_extension;
    147 
    148   for ( the_node = _User_extensions_List.first ;
    149         !_Chain_Is_tail( &_User_extensions_List, the_node ) ;
    150         the_node = the_node->next ) {
    151 
    152     the_extension = (User_extensions_Control *) the_node;
    153 
    154     if ( the_extension->Callouts.thread_begin != NULL )
    155       (*the_extension->Callouts.thread_begin)( executing );
    156   }
    157 }
    158 
    159 /*PAGE
    160  *
    161  *  _User_extensions_Thread_exitted
    162  */
    163 
    164 void _User_extensions_Thread_exitted (
    165   Thread_Control *executing
    166 )
    167 {
    168   Chain_Node              *the_node;
    169   User_extensions_Control *the_extension;
    170 
    171   for ( the_node = _User_extensions_List.last ;
    172         !_Chain_Is_head( &_User_extensions_List, the_node ) ;
    173         the_node = the_node->previous ) {
    174 
    175     the_extension = (User_extensions_Control *) the_node;
    176 
    177     if ( the_extension->Callouts.thread_exitted != NULL )
    178       (*the_extension->Callouts.thread_exitted)( executing );
    179   }
    180 }
    181 
    182 /*PAGE
    183  *
    184  *  _User_extensions_Fatal
    185  */
    186 
    187 void _User_extensions_Fatal (
    188   Internal_errors_Source  the_source,
    189   boolean                 is_internal,
    190   uint32_t                the_error
    191 )
    192 {
    193   Chain_Node              *the_node;
    194   User_extensions_Control *the_extension;
    195 
    196   for ( the_node = _User_extensions_List.last ;
    197         !_Chain_Is_head( &_User_extensions_List, the_node ) ;
    198         the_node = the_node->previous ) {
    199 
    200     the_extension = (User_extensions_Control *) the_node;
    201 
    202     if ( the_extension->Callouts.fatal != NULL )
    203       (*the_extension->Callouts.fatal)( the_source, is_internal, the_error );
    204   }
    205 }
Note: See TracChangeset for help on using the changeset viewer.