source: rtems/cpukit/score/inline/rtems/score/userext.inl @ d2ac7c3

4.104.114.84.95
Last change on this file since d2ac7c3 was d2ac7c3, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 8, 2003 at 9:02:33 PM

2003-09-08 Mikec Ivica <mikici@…>

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