source: rtems/cpukit/score/inline/rtems/score/userext.inl @ 61d330f5

4.104.114.84.95
Last change on this file since 61d330f5 was 61d330f5, checked in by Ralf Corsepius <ralf.corsepius@…>, on 02/21/05 at 07:53:52

New header guards.

  • Property mode set to 100644
File size: 3.8 KB
Line 
1/**
2 *  @file  rtems/score/userext.inl
3 *
4 *  This file contains the macro implementation of the inlined routines
5 *  from the User Extension Handler
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2004.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 *
16 *  $Id$
17 */
18
19#ifndef _RTEMS_SCORE_USEREXT_INL
20#define _RTEMS_SCORE_USEREXT_INL
21
22#include <rtems/score/wkspace.h>
23
24#include <string.h> /* memset */
25
26/**
27 *  @addtogroup ScoreUserExt
28 *  @{
29 */
30
31/**
32 *  This routine is used to add a user extension set to the active list.
33 *
34 *  @note Must be before _User_extensions_Handler_initialization to
35 *        ensure proper inlining.
36 */
37
38RTEMS_INLINE_ROUTINE void _User_extensions_Add_set (
39  User_extensions_Control *the_extension,
40  User_extensions_Table   *extension_table
41)
42{
43  the_extension->Callouts = *extension_table;
44
45  _Chain_Append( &_User_extensions_List, &the_extension->Node );
46
47  /*
48   * If a switch handler is present, append it to the switch chain.
49   */
50
51  if ( extension_table->thread_switch != NULL ) {
52    the_extension->Switch.thread_switch = extension_table->thread_switch;
53    _Chain_Append( &_User_extensions_Switches_list, &the_extension->Switch.Node );
54  }
55}
56
57/**
58 *  This routine performs the initialization necessary for this handler.
59 */
60
61RTEMS_INLINE_ROUTINE void _User_extensions_Handler_initialization (
62    uint32_t                number_of_extensions,
63    User_extensions_Table  *initial_extensions
64)
65{
66  User_extensions_Control *extension;
67  uint32_t                 i;
68
69  _Chain_Initialize_empty( &_User_extensions_List );
70  _Chain_Initialize_empty( &_User_extensions_Switches_list );
71
72  if ( initial_extensions ) {
73    extension = (User_extensions_Control *)
74      _Workspace_Allocate_or_fatal_error(
75        number_of_extensions * sizeof( User_extensions_Control )
76      );
77 
78    memset (
79      extension,
80      0,
81      number_of_extensions * sizeof( User_extensions_Control )
82    );
83 
84    for ( i = 0 ; i < number_of_extensions ; i++ ) {
85      _User_extensions_Add_set (extension, &initial_extensions[i]);
86      extension++;
87    }
88  }
89}
90
91/**
92 *  This routine is used to add an API extension set to the active list.
93 */
94 
95RTEMS_INLINE_ROUTINE void _User_extensions_Add_API_set (
96  User_extensions_Control *the_extension
97)
98{
99  _Chain_Append( &_User_extensions_List, &the_extension->Node );
100
101  /*
102   *  If a switch handler is present, append it to the switch chain.
103   */
104
105  if ( the_extension->Callouts.thread_switch != NULL ) {
106    the_extension->Switch.thread_switch = the_extension->Callouts.thread_switch;
107    _Chain_Append(
108      &_User_extensions_Switches_list, &the_extension->Switch.Node );
109  }
110}
111
112/**
113 *  This routine is used to remove a user extension set from the active list.
114 */
115
116RTEMS_INLINE_ROUTINE void _User_extensions_Remove_set (
117  User_extensions_Control  *the_extension
118)
119{
120  _Chain_Extract( &the_extension->Node );
121 
122  /*
123   * If a switch handler is present, remove it.
124   */
125
126  if ( the_extension->Callouts.thread_switch != NULL )
127    _Chain_Extract( &the_extension->Switch.Node );
128}
129
130/**
131 *  This routine is used to invoke the user extension which
132 *  is invoked when a context switch occurs.
133 */
134
135RTEMS_INLINE_ROUTINE void _User_extensions_Thread_switch (
136  Thread_Control *executing,
137  Thread_Control *heir
138)
139{
140  Chain_Node                     *the_node;
141  User_extensions_Switch_control *the_extension_switch;
142 
143  for ( the_node = _User_extensions_Switches_list.first ;
144        !_Chain_Is_tail( &_User_extensions_Switches_list, the_node ) ;
145        the_node = the_node->next ) {
146
147    the_extension_switch = (User_extensions_Switch_control *) the_node;
148
149    (*the_extension_switch->thread_switch)( executing, heir );
150  }
151}
152
153/**@}*/
154
155#endif
156/* end of include file */
Note: See TracBrowser for help on using the repository browser.