source: rtems/cpukit/score/src/userext.c @ 25f5730f

4.115
Last change on this file since 25f5730f was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup ScoreUserExt
5 *
6 * @brief User Extension Handler implementation.
7 */
8
9/*
10 *  COPYRIGHT (c) 1989-2008.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.org/license/LICENSE.
16 */
17
18#if HAVE_CONFIG_H
19  #include "config.h"
20#endif
21
22#include <rtems/config.h>
23#include <rtems/score/userextimpl.h>
24#include <rtems/score/wkspace.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}
50
51void _User_extensions_Handler_initialization(void)
52{
53  uint32_t number_of_initial_extensions =
54    rtems_configuration_get_number_of_initial_extensions();
55
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 };
63
64    _User_extensions_Iterate( &ctx, _User_extensions_Switch_visitor );
65  }
66}
Note: See TracBrowser for help on using the repository browser.