source: rtems/cpukit/score/src/userext.c @ a853c851

5
Last change on this file since a853c851 was a853c851, checked in by Sebastian Huber <sebastian.huber@…>, on Dec 10, 2015 at 2:44:02 PM

Optional Initial Extensions initialization

Update #2408.

  • Property mode set to 100644
File size: 1.5 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
26typedef struct {
27  User_extensions_Switch_control *switch_control;
28} User_extensions_Switch_context;
29
30static void _User_extensions_Switch_visitor(
31  Thread_Control              *executing,
32  void                        *arg,
33  const User_extensions_Table *callouts
34)
35{
36  User_extensions_thread_switch_extension callout = callouts->thread_switch;
37
38  if ( callout != NULL ) {
39    User_extensions_Switch_context *ctx = arg;
40    User_extensions_Switch_control *ctrl = ctx->switch_control;
41
42    _Chain_Append_unprotected( &_User_extensions_Switches_list, &ctrl->Node );
43    ctrl->thread_switch = callout;
44
45    ctx->switch_control = ctrl + 1;
46  }
47}
48
49void _User_extensions_Handler_initialization(void)
50{
51  User_extensions_Switch_control *initial_extension_switch_controls =
52    _Workspace_Allocate_or_fatal_error(
53      rtems_configuration_get_number_of_initial_extensions()
54        * sizeof( *initial_extension_switch_controls )
55    );
56  User_extensions_Switch_context ctx = { initial_extension_switch_controls };
57
58  _User_extensions_Iterate( &ctx, _User_extensions_Switch_visitor );
59}
Note: See TracBrowser for help on using the repository browser.